perl 多fasta文件匹配,并提取匹配文件第一条序列
目标如题,有多个fasta文件和一个文件名列表,将文件名列表中包含的文件匹配出来并提取第一条序列合并成一个fa文件。
这个采用perl实现,用法和代码如下:
#!/usr/bin/perl -w use strict; sub usage{ die "usage:perl $0 <fa.list> <Fasta_Dir> <merged.fa>\n",unless(@ARGV==3); } usage(); open LIST,"$ARGV[0]"; open F,"$ARGV[1]"; open OU,">$ARGV[2]"; my @listName=<LIST>; my @files=glob("$ARGV[1]/*.faa"); my $matchNum=0; foreach my $k(@files){ my $fileName=(split /\//,$k)[-1]; if(grep /^$fileName$/,@listName){ $matchNum+=1; open EACH,"$ARGV[1]/$fileName"; $/=">"; <EACH>; while(<EACH>){ chomp; my @info=split /\n/,$_; my $seqID=shift @info; my $seq=join "",@info; print OU ">$seqID\n$seq\n"; last; } $/="\n"; } } print "match: $matchNum files,and merge completed!\n"; close LIST; close F;
相关推荐
边城客栈学无止境 2020-07-05
Walter的学习笔记 2020-07-04
A宇 2020-06-14
边城客栈学无止境 2020-06-10
邓博学习笔记 2020-06-03
davidliu00 2020-05-26
ShiShuo 2020-05-16
Aggressivesnail 2020-05-10
ShiShuo 2020-04-26
hanxingwang00 2020-04-22
davidliu00 2020-03-06
ShiShuo 2020-03-06
ShiShuo 2020-03-05
Aggressivesnail 2020-02-28
aaLiweipeng 2020-02-01
amberom 2020-01-16
Walter的学习笔记 2020-01-06