一個文本文件中像這樣的查詢文件:字符串匹配的搜索
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