如何在蛋白质序列(字符串)中找到多个基序(子串)?

shu*_*ter 6 perl bioinformatics

以下脚本用于在蛋白质序列中找到一个基序.

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)=@_;
    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)=@_;
    use strict;
    my @position=();
    while ($sequence=~ /$regexp/ig){
        push (@position, $-[0]);
    }
    return @position;
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何扩展这个以在含有蛋白质序列的给定文件中找到多个基序(以固定顺序,即motif1,motif2,motif3).

Axe*_*man 2

|您可以简单地使用序列的交替(由 分隔)。这样正则表达式引擎就可以匹配每个序列。

/($h{4}D$x{4}D|$x{1,4}A{1,2}$s{2})/
Run Code Online (Sandbox Code Playgroud)

然后您可以通过查看来测试此匹配$1