in reply to Translation Substring Error
This is not addressing the problem you were having, rather it is a suggestion for a simpler way of initialising your %genetic_code hash that would save some typing. The glob function can be used to generate combinations of letters. Your hash contains 64 keys which are all possible 3-character combinations of A, C, G and T. These can be generated using glob like this ...
johngg@shiraz:~/perl/Monks > perl -E 'say for glob q{{A,C,G,T}} x 3' AAA AAC AAG AAT ACA ACC ACG ACT ... TGA TGC TGG TGT TTA TTC TTG TTT
Arranging the corresponding amino acid letters in an array allows us to map keys (genetic codes) and values (amino acids) shift'ed from the array together to create the hash lookup.
my %genetic_code = do { my @amino_acids = qw{ K N K N T T T T R S R S I I M I Q H Q H P P P P R R R R L L L L E D E D A A A A G G G G V V V V * Y * Y S S S S * C W C L F L F }; map { $_ => shift @amino_acids } glob q{{A,C,G,T}} x 3; };
I hope this is of interest.
Cheers,
JohnGG
|
|---|