あなたのコードに基づいて構築します: (停止コドンと開始コドンを見やすくするためにヌクレオチド配列を変更しましたが、あなたの配列でもまったく同じように機能します...) また、一致した配列を次のように、配列のハッシュ内の配列:
#!/usr/bin/perl
use warnings;
use strict;
use Data::Dumper;
my @file = qw(ATGcgcgcgcgcgcgTAAATGatatatatataTAG ATGcccccccccTAAgggggggggATGtttttttttttTAG atATGaggggaTAGaaaatttttttctttct);
my (@match, %hash, @sequence, $line);
my $line_number = 0;
foreach (@file){
push @match, /(ATG\w+?TA[AG])/g;
push @sequence, @file for 0 .. $#match;
}
push @ { $hash{$sequence[$_]}}, [$match[$_] ] for 0 .. $#match; # Hasho of arrays
for my $key (sort keys %hash){
for my $orf (@ { $hash{$key}}){
my ($match) = @$orf;
print "Sequence:$key contains ORFs: $match\n";
}
}
出力:
Sequence:ATGcccccccccTAAgggggggggATGtttttttttttTAG contains ORFs: ATGatatatatataTAG
Sequence:ATGcccccccccTAAgggggggggATGtttttttttttTAG contains ORFs: ATGaggggaTAG
Sequence:ATGcgcgcgcgcgcgTAAATGatatatatataTAG contains ORFs: ATGcgcgcgcgcgcgTAA
Sequence:ATGcgcgcgcgcgcgTAAATGatatatatataTAG contains ORFs: ATGtttttttttttTAG
Sequence:atATGaggggaTAGaaaatttttttctttct contains ORFs: ATGcccccccccTAA