次のスクリプトは、タンパク質配列中に1つのモチーフを見つけるためのスクリプトです。タンパク質配列(文字列)内で複数のモチーフ(部分文字列)を見つけるにはどうすればよいですか?
use strict;
use warnings;
my @file_data=();
my $protein_seq='';
my $h= '[VLIM]';
my $s= '[AG]';
my $x= '[ARNDCEQGHILKMFPSTWYV]';
my $regexp = "($h){4}D($x){4}D"; #motif to be searched is hhhhDxxxxD
my @locations=();
@file_data= get_file_data("seq.txt");
$protein_seq= extract_sequence(@file_data);
#searching for a motif hhhhDxxxxD in each protein sequence in the give file
foreach my $line(@file_data){
if ($motif=~ /$regexp/){
print "found motif \n\n";
} else {
print "not found \n\n";
}
}
#recording the location/position of motif to be outputed
@locations= match_position($regexp,$seq);
if (@locations){
print "Searching for motifs $regexp \n";
print "Catalytic site is at location:\n";
} else {
print "motif not found \n\n";
}
exit;
sub get_file_data{
my ($filename)[email protected]_;
use strict;
use warnings;
my $sequence='';
foreach my $line(@fasta_file_data){
if ($line=~ /^\s*(#.*)?|^>/{
next;
}
else {
$sequence.=$line;
}
}
$sequence=~ s/\s//g;
return $sequence;
}
sub(match_positions) {
my ($regexp, $sequence)[email protected]_;
use strict;
my @position=();
while ($sequence=~ /$regexp/ig){
push (@position, $-[0]);
}
return @position;
}
Iは、タンパク質配列を含む指定したファイルに(すなわちmotif1、motif2、motif3一定の順序で)複数のモチーフを見つけるためにこれを拡張する方法ではないと確信しています。
あなたのコードでは、いくつかの問題を持っているようです。 19行目で$ lineを宣言しますが、使用されることはありません。 20行目では、$ motifは常に宣言以来変更されていないので、常に ''です。 43行目ではいくつかのelsifを連鎖させていますが、本当に必要なのは 'if($ line =〜/^\ s * $ /または$ line =〜/^\ s *#/または$ line =〜/ > /){next; } else {$ sequence。= $ line; }; '、またはさらに良い:' if($ line =〜/^\s*(#.*)?|^>/){next; } else {$ sequence。= $ line; }; '。私はかっこが 'sub(match_positions)... 'で何をするべきかわからない。 – Svante