하나 개의 텍스트 파일을문자열 일치 검색
fooLONGcite
GetmoreDATA
stringMATCH
GOODthing
이 같은 대상 파일과 같은 다른 텍스트 파일 :
sometingfooLONGcite
anyotherfooLONGcite
matchGetmoreDATA
GETGOODthing
brotherGETDATA
CITEMORETHING
TOOLONGSTUFFETC
예상됩니다 할 대상 파일에서 일치하는 문자열을 얻을 그런 다음 인쇄하십시오. 출력은 다음과 같아야합니다.
sometingfooLONGcite
anyotherfooLONGcite
matchGetmoreDATA
GETGOODthing
여기 내 필용 스크립트입니다. 그러나 그것은 작동하지 않습니다. 문제가있는 곳을 찾도록 도와 줄 수 있습니까? 감사.
#!/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/) –
내 스크립트를 추가했습니다. – Jianguo