Il seguente script è per trovare un motivo nella sequenza di proteine.Come posso trovare più motivi (sottostringa) in una sequenza di proteine (stringa)?
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;
}
Non sono sicuro come estendere questo per trovare molteplici motivi (in un ordine fisso cioè motif1, motif2, motif3) in un dato file contenente una sequenza proteica.
Il codice sembra avere qualche problema. Nella riga 19, si dichiara $ line, ma non viene mai utilizzato. Nella riga 20, $ motif è sempre '', poiché questo non è mai cambiato dalla sua dichiarazione. Nella linea 43, si concatenano alcuni elsifs, ma ciò che si vuole veramente è 'if ($ line = ~/^ \ s * $/o $ line = ~/^ \ s * #/o $ line = ~/^ > /) {successivo; } else {$ sequence. = $ line; }; ', o meglio:' if ($ line = ~ /^\s*(#.*)?|^>/) {next; } else {$ sequence. = $ line; }; '. Non so cosa dovrebbero fare le parentesi in 'sub (match_positions) ...'. – Svante