my $seq = shift;
my $amino_acid;
for (my $i=0; $i<=length($seq)-3; $i=$i+3) {
my $codon = substr($seq,$i,3);
$amino_acid .= $genetic_code{$codon};
}
return $amino_acid;
####
print OneFrameTranslation('ATGCCCGTAC'),"\n";
print OneFrameTranslation('GCTTCCCAGCGC'),"\n";
__END__
MPV
ASQR
##
##
my $amino_acid;
while ($seq=~/\G(...)/sg) {
$amino_acid .= $genetic_code{$1};
}
return $amino_acid;
##
##
# build the regex, this only needs to be done once
my ($genetic_regex) = map qr/$_/, join '|', keys %genetic_code;
# apply the regex
(my $amino_acid = $seq) =~ s/($genetic_regex)/$genetic_code{$1}/g;
return $amino_acid;