一个文本文件中像这样的查询文件:字符串匹配的搜索
fooLONGcite
GetmoreDATA
stringMATCH
GOODthing
另一个文本文件中像这样的主题文件:
sometingfooLONGcite
anyotherfooLONGcite
matchGetmoreDATA
GETGOODthing
brotherGETDATA
CITEMORETHING
TOOLONGSTUFFETC
预期的结果将是摆脱主题文件匹配的字符串然后打印出来。所以,输出应该是:
sometingfooLONGcite
anyotherfooLONGcite
matchGetmoreDATA
GETGOODthing
这是我的Perl脚本。但它不起作用。你能帮我找出问题在哪里吗?谢谢。
#!/usr/bin/perl
use strict;
# to check the command line option
if($#ARGV<0){
printf("Usage: \n <tag> <seq> <outfile>\n");
exit 1;
}
# to open the given infile file
open(tag, $ARGV[0]) or die "Cannot open the file $ARGV[0]";
open(seq, $ARGV[1]) or die "Cannot open the file $ARGV[1]";
my %seqhash =();
my $tag_id;
my $tag_seq;
my $seq_id;
my $seq_seq;
my $seq;
my $i = 0;
print "Processing cds seq\n";
#check the seq file
while(<seq>){
my @line = split;
if($i != 0){
$seqhash{$seq_seq} = $seq;
$seq = "";
print "$seq_seq\n";
}
$seq_seq = $line[0];
$i++;
}
while(<tag>){
my @tagline = split;
$tag_seq = $tagline[0];
$seq = $seqhash{$seq_seq};
#print "$tag_seq\n";
print "$seq\n";
#print output ">$id\n$seq\n";
}
#print "Ending of Processing gff\n";
close(tag);
close(seq);
[什么都有你试过?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – 2012-02-01 21:24:24
我加了我的脚本。 – Jianguo 2012-02-01 21:28:26