Entering edit mode
8.7 years ago
ksi216
▴
80
Hello,
I've created a hash, of codons and amino acids. My program should allow a user to input a DNA codon and then output the appropriate single letter code for the amino acid corresponding to that codon. If the input does not correspond to an amino acid, then the output should say so. I'm stuck. Here is all my code
my %codon= ();
while(<DATA>){ # while loop to read line by line was is in __DATA__
chomp; #remove newline characters
my ($key, $lettercode)= split; #we split the key value pairs on each line
$codon{$key} = $lettercode; # we assign the key value pairs to %codon in scalar fasion
}
#print out all pairs
while (my($k,$l)= each(%codon)){print"$k =>$l\n";
#print to see that hash was created with data sucessfully
# input output command to generate letter code if (exists()
}
__DATA__
TTT F
CTT L
ATT I
GTT V
TTC F
CTC L
ATC I
GTC V
TTA L
CTA L
ATA I
GTA V
TTG L
CTG L
ATG M
GTG V
TCT S
CCT P
ACT T
GCT A
TCC S
CCC P
ACC T
GCC A
TCA S
CCA P
ACA T
GCA A
TCG S
CCG P
ACG T
GCG A
TAT Y
CAT H
AAT N
GAT D
TAC Y
CAC H
AAC N
GAC D
TAA Stop
CAA Q
AAA K
GAA E
TAG Stop
CAG Q
AAG K
GAG E
TGT C
CGT R
AGT S
GGT G
TGC C
CGC R
AGC S
GGC G
TGA Stop
CGA R
AGA R
GGA G
TGG W
CGG R
AGG R
GGG G
Format your code to make it more readable and enclose it within code tags,
Check this program and try to find where your mistake is.
Please review the content before sharing links to sites like this. That code is awful (it won't even compile with a recent Perl, and doesn't answer the question) and the site is pretty sketchy. We can use github/gist for sharing code, that way you can embed the code in your post.