in reply to finding open reading frames

Ok, so it looks like the rules are: Here's a one-pass solution:
my @start = ([],[],[]); my $sequence = 'ATGATGAATGAATAGTAGATAG'; for my $i (0 .. length($sequence)-3) { my $triplet = substr($sequence, $i, 3); if ($triplet eq 'ATG') { push @{$start[$i%3]}, $i; } elsif ($triplet eq 'TAG' || $triplet eq 'TAA' || $triplet eq 'TGA') + { for my $j (@{$start[$i%3]}) { print $j, '..', $i+2, "\n"; } @{$start[$i%3]} = (); } }
Output:
0..14 3..14 7..21
Explanation of the output:
ATGATGAATGAATAGTAGATAG STA123123123END STA123123END STA123123123END