Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Hash Data 2

Status
Not open for further replies.

torstens

Technical User
Oct 9, 2006
26
US
Sorry bout posting this in another post, but replying didn't work. I fixed the first problem, but now I don't know how to access the hashes within hashes. How could I get a list for each amino acid that goes like...

and this is for research, but not the programing part

Thanks for any help that any of you can offer

Name
Number of codons (I've got these parts so far)
Codon A: number of occurrences
Codon B: number of occurrences
Codon C: number of occurrences (if these exist)

I don't know how to extract that information.

Thanks for any help


use Data::Dumper;


##########################################
# Load Sequence
##########################################

my $DNA;

$DNA = "ATGACCCCAATACGCAAAACTAACCCCCTAATAAAATTAATTAACCACTCATTCATCGACCTCCCCACCCCATCCAACATCTCCGCATGATGAAACTTCGGCTCACTCCTTGGCGCCTGCCTGATCCTCCAAATCACCACAGGACTATTCCTAGCCATGCACTACTCACCAGACGCCTCAACCGCCTTTTCATCAATCGCCCACATCACTCGAGACGTAAATTATGGCTGAATCATCCGCTACCTTCACGCCAATGGCGCCTCAATATTCTTTATCTGCCTCTTCCTACACATCGGGCGAGGCCTATATTACGGATCATTTCTCTACTCAGAAACCTGAAACATCGGCATTATCCTCCTGCTTGCAACTATAGCAACAGCCTTCATAGGCTATGTCCTCCCGTGAGGCCAAATATCATTCTGAGGGGCCACAGTAATTACAAACTTACTATCCGCCATCCCATACATTGGGACAGACCTAGTTCAATGAATCTGAGGAGGCTACTCAGTAGACAGTCCCACCCTCACACGATTCTTTACCTTTCACTTCATCTTGCCCTTCATTATTGCAGCCCTAGCAACACTCCACCTCCTATTCTTGCACGAAACGGGATCAAACAACCCCCTAGGAATCACCTCCCATTCCGATAAAATCACCTTCCACCCTTACTACACAATCAAAGACGCCCTCGGCTTACTTCTCTTCCTTCTCTCCTTAATGACATTAACACTATTCTCACCAGACCTCCTAGGCGACCCAGACAATTATACCCTAGCCAACCCCTTAAACACCCCTCCCCACATCAAGCCCGAATGATATTTCCTATTCGCCTACACAATTCTCCGATCCGTCCCTAACAAACTAGGAGGCGTCCTTGCCCTATTACTATCCATCCTCATCCTAGCAATAATCCCCATCCTCCATATATCCAAACAACAAAGCATAATATTTCGCCCACTAAGCCAATCACTTTATTGACTCCTAGCCGCAGACCTCCTCATTCTAACCTGAATCGGAGGACAACCAGTAAGCTACCCTTTTACCATCATTGGACAAGTAGCATCCGTACTATACTTCACAACAATCCTAATCCTAATACCAACTATCTCCCTAATTGAAAACAAAATACTCAAATAATAAT";



##########################################
# Populate Data Set
##########################################

my %MasterHash = ();
my $AA_Count = 0;
my $CD_Occurences = 0;


for(my $i=0; $i < (length($DNA) - 2) ; $i += 3) {

my $Codon = substr($DNA,$i,3);

my $AA = codon2aa( $Codon );

print "\nAmino Acid: $AA";
print "\nCodon: $Codon\n";


### Setting up AA count

if ($MasterHash{$AA}) { #tests whether AA key has already been created

$MasterHash{$AA}{Count}++; #if so, add to AA count

} else { #if not...

$MasterHash{$AA}{Symbol} = $AA; #set up symbol
$MasterHash{$AA}{Name} = nameAA($AA); #set up name
$MasterHash{$AA}{Count} = 1; #set up AA count

}

print "Amino Acid Count: $MasterHash{$AA}{Count}\n";


### Settin up Codon Count

if ($MasterHash{$AA}{Codons}{$Codon}) { #tests whether codon key has already been created

$MasterHash{$AA}{Codons}{$Codon}{Count}++; #if so, add to codon count

} else { #if not...

$MasterHash{$AA}{Codons}{$Codon}{Count} = 1; #set up codon count

}

print "Codon Count: $MasterHash{$AA}{Codons}{$Codon}{Count}\n";



# %MasterHash = (
#
# $AA => {
# Symbol => $AA,
# Name => nameAA($AA),
# Count => $AA_Count,
# Codons => {
# $Codon => {
# Count => $CD_Count,
# },
# },
# },
# );

}










##########################################
# Print Data Set
##########################################


print "\n\nRESULTS...\n\n";

while( my ($var_AA, $var_unknown) = each (%MasterHash)) {
my $AA_Name = nameAA($var_AA);
print "$AA_Name\n";
print "unknown: $var_unknown\n";
print "AA Count: ";
print $MasterHash{$var_AA}->{Count};
print "\nCodons: ";
print $MasterHash{$var_AA}->{Codons};

print "\n\n";

}

#print Dumper(%MasterHash);



##########################################
# Subroutines
##########################################






sub codon2aa {
my($codon) = @_;

$codon = uc $codon;

my(%genetic_code) = (

'TCA' => 'S', # Serine
'TCC' => 'S', # Serine
'TCG' => 'S', # Serine
'TCT' => 'S', # Serine
'TTC' => 'F', # Phenylalanine
'TTT' => 'F', # Phenylalanine
'TTA' => 'L', # Leucine
'TTG' => 'L', # Leucine
'TAC' => 'Y', # Tyrosine
'TAT' => 'Y', # Tyrosine
'TAA' => '_', # Stop
'TAG' => '_', # Stop
'TGC' => 'C', # Cysteine
'TGT' => 'C', # Cysteine
'TGA' => '_', # Stop
'TGG' => 'W', # Tryptophan
'CTA' => 'L', # Leucine
'CTC' => 'L', # Leucine
'CTG' => 'L', # Leucine
'CTT' => 'L', # Leucine
'CCA' => 'P', # Proline
'CCC' => 'P', # Proline
'CCG' => 'P', # Proline
'CCT' => 'P', # Proline
'CAC' => 'H', # Histidine
'CAT' => 'H', # Histidine
'CAA' => 'Q', # Glutamine
'CAG' => 'Q', # Glutamine
'CGA' => 'R', # Arginine
'CGC' => 'R', # Arginine
'CGG' => 'R', # Arginine
'CGT' => 'R', # Arginine
'ATA' => 'I', # Isoleucine
'ATC' => 'I', # Isoleucine
'ATT' => 'I', # Isoleucine
'ATG' => 'M', # Methionine
'ACA' => 'T', # Threonine
'ACC' => 'T', # Threonine
'ACG' => 'T', # Threonine
'ACT' => 'T', # Threonine
'AAC' => 'N', # Asparagine
'AAT' => 'N', # Asparagine
'AAA' => 'K', # Lysine
'AAG' => 'K', # Lysine
'AGC' => 'S', # Serine
'AGT' => 'S', # Serine
'AGA' => 'R', # Arginine
'AGG' => 'R', # Arginine
'GTA' => 'V', # Valine
'GTC' => 'V', # Valine
'GTG' => 'V', # Valine
'GTT' => 'V', # Valine
'GCA' => 'A', # Alanine
'GCC' => 'A', # Alanine
'GCG' => 'A', # Alanine
'GCT' => 'A', # Alanine
'GAC' => 'D', # Aspartic Acid
'GAT' => 'D', # Aspartic Acid
'GAA' => 'E', # Glutamic Acid
'GAG' => 'E', # Glutamic Acid
'GGA' => 'G', # Glycine
'GGC' => 'G', # Glycine
'GGG' => 'G', # Glycine
'GGT' => 'G', # Glycine
);

if(exists $genetic_code{$codon}) {
return $genetic_code{$codon};
}else{

print STDERR "Bad codon \"$codon\"!!\n";
#exit;
}
}



sub nameAA {
my($AA_single) = @_;

$AA_single = uc $AA_single;

my(%AA_Name_code) = (

'S' => 'Serine',
'F' => 'Phenylalanine',
'L' => 'Leucine',
'Y' => 'Tyrosine',
'_' => 'Stop',
'C' => 'Cysteine',
'W' => 'Tryptophan',
'P' => 'Proline',
'H' => 'Histidine',
'Q' => 'Glutamine',
'R' => 'Arginine',
'I' => 'Isoleucine',
'M' => 'Methionine',
'T' => 'Threonine',
'N' => 'Asparagine',
'K' => 'Lysine',
'V' => 'Valine',
'A' => 'Alanine',
'D' => 'Aspartic Acid',
'E' => 'Glutamic Acid',
'G' => 'Glycine',

);

if(exists $AA_Name_code{$AA_single}) {
return $AA_Name_code{$AA_single};
}else{
print STDERR "Bad codon \"$codon\"!!\n";
#exit;
}
}





 
please answer if this is school/course work.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
It is not for coursework. Also, I've found a way to do it (sort of), but now it prints out my data four times, and I don't see where the bug is.

Again, any help is greatly appreciated.





use Data::Dumper;


##########################################
# Load Sequence
##########################################

my $DNA;

$DNA = "ATGACCCCAATACGCAAAACTAACCCCCTAATAAAATTAATTAACCACTCATTCATCGACCTCCCCACCCCATCCAACATCTCCGCATGATGAAACTTCGGCTCACTCCTTGGCGCCTGCCTGATCCTCCAAATCACCACAGGACTATTCCTAGCCATGCACTACTCACCAGACGCCTCAACCGCCTTTTCATCAATCGCCCACATCACTCGAGACGTAAATTATGGCTGAATCATCCGCTACCTTCACGCCAATGGCGCCTCAATATTCTTTATCTGCCTCTTCCTACACATCGGGCGAGGCCTATATTACGGATCATTTCTCTACTCAGAAACCTGAAACATCGGCATTATCCTCCTGCTTGCAACTATAGCAACAGCCTTCATAGGCTATGTCCTCCCGTGAGGCCAAATATCATTCTGAGGGGCCACAGTAATTACAAACTTACTATCCGCCATCCCATACATTGGGACAGACCTAGTTCAATGAATCTGAGGAGGCTACTCAGTAGACAGTCCCACCCTCACACGATTCTTTACCTTTCACTTCATCTTGCCCTTCATTATTGCAGCCCTAGCAACACTCCACCTCCTATTCTTGCACGAAACGGGATCAAACAACCCCCTAGGAATCACCTCCCATTCCGATAAAATCACCTTCCACCCTTACTACACAATCAAAGACGCCCTCGGCTTACTTCTCTTCCTTCTCTCCTTAATGACATTAACACTATTCTCACCAGACCTCCTAGGCGACCCAGACAATTATACCCTAGCCAACCCCTTAAACACCCCTCCCCACATCAAGCCCGAATGATATTTCCTATTCGCCTACACAATTCTCCGATCCGTCCCTAACAAACTAGGAGGCGTCCTTGCCCTATTACTATCCATCCTCATCCTAGCAATAATCCCCATCCTCCATATATCCAAACAACAAAGCATAATATTTCGCCCACTAAGCCAATCACTTTATTGACTCCTAGCCGCAGACCTCCTCATTCTAACCTGAATCGGAGGACAACCAGTAAGCTACCCTTTTACCATCATTGGACAAGTAGCATCCGTACTATACTTCACAACAATCCTAATCCTAATACCAACTATCTCCCTAATTGAAAACAAAATACTCAAATAATAAT";



##########################################
# Populate Data Set
##########################################

my %MasterHash = ();
my $AA_Count = 0;
my $CD_Occurences = 0;


for(my $i=0; $i < (length($DNA) - 2) ; $i += 3) {

my $Codon = substr($DNA,$i,3);

my $AA = codon2aa( $Codon );

print "\nAmino Acid: $AA";
print "\nCodon: $Codon\n";


### Setting up AA count

if ($MasterHash{$AA}) { #tests whether AA key has already been created

$MasterHash{$AA}{Count}++; #if so, add to AA count

} else { #if not...

$MasterHash{$AA}{Symbol} = $AA; #set up symbol
$MasterHash{$AA}{Name} = nameAA($AA); #set up name
$MasterHash{$AA}{Count} = 1; #set up AA count

}

print "Amino Acid Count: $MasterHash{$AA}{Count}\n";


### Settin up Codon Count

if ($MasterHash{$AA}{Codons}{$Codon}) { #tests whether codon key has already been created

$MasterHash{$AA}{Codons}{$Codon}{Count}++; #if so, add to codon count

} else { #if not...

$MasterHash{$AA}{Codons}{$Codon}{Count} = 1; #set up codon count

}

print "Codon Count: $MasterHash{$AA}{Codons}{$Codon}{Count}\n";



# %MasterHash = (
#
# $AA => {
# Symbol => $AA,
# Name => nameAA($AA),
# Count => $AA_Count,
# Codons => {
# $Codon => {
# Count => $CD_Count,
# },
# },
# },
# );

}










##########################################
# Print Data Set
##########################################


print "\n\nRESULTS...\n\n";



foreach $AA_Cod_Shizzle ( keys %MasterHash ) {



my $ProName = nameAA($AA_Cod_Shizzle);

print "\n\n---------------------------------------------------------------------------------";
print "\n$ProName:\n\n";



for $Codon_Var_Shizzle ( keys %{ $MasterHash{$AA_Cod_Shizzle} } ) {

#print "$Codon_Var_Shizzle=$MasterHash{$AA_Cod_Shizzle}{$Codon_Var_Shizzle} ";

for $Codon_Sp (keys %{ $MasterHash{$AA_Cod_Shizzle}{Codons} }) {

print "$Codon_Sp = $MasterHash{$AA_Cod_Shizzle}{Codons}{$Codon_Sp}{Count}\n";

}

}
print "\n";
}




##########################################
# Subroutines
##########################################






sub codon2aa {
my($codon) = @_;

$codon = uc $codon;

my(%genetic_code) = (

'TCA' => 'S', # Serine
'TCC' => 'S', # Serine
'TCG' => 'S', # Serine
'TCT' => 'S', # Serine
'TTC' => 'F', # Phenylalanine
'TTT' => 'F', # Phenylalanine
'TTA' => 'L', # Leucine
'TTG' => 'L', # Leucine
'TAC' => 'Y', # Tyrosine
'TAT' => 'Y', # Tyrosine
'TAA' => '_', # Stop
'TAG' => '_', # Stop
'TGC' => 'C', # Cysteine
'TGT' => 'C', # Cysteine
'TGA' => '_', # Stop
'TGG' => 'W', # Tryptophan
'CTA' => 'L', # Leucine
'CTC' => 'L', # Leucine
'CTG' => 'L', # Leucine
'CTT' => 'L', # Leucine
'CCA' => 'P', # Proline
'CCC' => 'P', # Proline
'CCG' => 'P', # Proline
'CCT' => 'P', # Proline
'CAC' => 'H', # Histidine
'CAT' => 'H', # Histidine
'CAA' => 'Q', # Glutamine
'CAG' => 'Q', # Glutamine
'CGA' => 'R', # Arginine
'CGC' => 'R', # Arginine
'CGG' => 'R', # Arginine
'CGT' => 'R', # Arginine
'ATA' => 'I', # Isoleucine
'ATC' => 'I', # Isoleucine
'ATT' => 'I', # Isoleucine
'ATG' => 'M', # Methionine
'ACA' => 'T', # Threonine
'ACC' => 'T', # Threonine
'ACG' => 'T', # Threonine
'ACT' => 'T', # Threonine
'AAC' => 'N', # Asparagine
'AAT' => 'N', # Asparagine
'AAA' => 'K', # Lysine
'AAG' => 'K', # Lysine
'AGC' => 'S', # Serine
'AGT' => 'S', # Serine
'AGA' => 'R', # Arginine
'AGG' => 'R', # Arginine
'GTA' => 'V', # Valine
'GTC' => 'V', # Valine
'GTG' => 'V', # Valine
'GTT' => 'V', # Valine
'GCA' => 'A', # Alanine
'GCC' => 'A', # Alanine
'GCG' => 'A', # Alanine
'GCT' => 'A', # Alanine
'GAC' => 'D', # Aspartic Acid
'GAT' => 'D', # Aspartic Acid
'GAA' => 'E', # Glutamic Acid
'GAG' => 'E', # Glutamic Acid
'GGA' => 'G', # Glycine
'GGC' => 'G', # Glycine
'GGG' => 'G', # Glycine
'GGT' => 'G', # Glycine
);

if(exists $genetic_code{$codon}) {
return $genetic_code{$codon};
}else{

print STDERR "Bad codon \"$codon\"!!\n";
#exit;
}
}



sub nameAA {
my($AA_single) = @_;

$AA_single = uc $AA_single;

my(%AA_Name_code) = (

'S' => 'Serine',
'F' => 'Phenylalanine',
'L' => 'Leucine',
'Y' => 'Tyrosine',
'_' => 'Stop',
'C' => 'Cysteine',
'W' => 'Tryptophan',
'P' => 'Proline',
'H' => 'Histidine',
'Q' => 'Glutamine',
'R' => 'Arginine',
'I' => 'Isoleucine',
'M' => 'Methionine',
'T' => 'Threonine',
'N' => 'Asparagine',
'K' => 'Lysine',
'V' => 'Valine',
'A' => 'Alanine',
'D' => 'Aspartic Acid',
'E' => 'Glutamic Acid',
'G' => 'Glycine',

);

if(exists $AA_Name_code{$AA_single}) {
return $AA_Name_code{$AA_single};
}else{
print STDERR "Bad codon \"$codon\"!!\n";
#exit;
}
}



...

---------------------------------------------------------------------------------
Glycine:

GGC = 12
GGG = 3
GGA = 9
GGC = 12
GGG = 3
GGA = 9
GGC = 12
GGG = 3
GGA = 9
GGC = 12
GGG = 3
GGA = 9







 
Code:
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]

[gray][i]##########################################[/i][/gray]
[gray][i]#   Load Sequence[/i][/gray]
[gray][i]##########################################[/i][/gray]

[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$DNA[/blue] = [url=http://perldoc.perl.org/functions/join.html][black][b]join[/b][/black][/url] [red]'[/red][purple][/purple][red]'[/red], [red]qw([/red][purple][/purple]
[purple]ATGACCCCAATACGCAAAACTAACCCCCTAATAAAATTAATTAACCACTCATTCATCGACCTCCCCACCCCATCCAACAT[/purple]
[purple]CTCCGCATGATGAAACTTCGGCTCACTCCTTGGCGCCTGCCTGATCCTCCAAATCACCACAGGACTATTCCTAGCCATGC[/purple]
[purple]ACTACTCACCAGACGCCTCAACCGCCTTTTCATCAATCGCCCACATCACTCGAGACGTAAATTATGGCTGAATCATCCGC[/purple]
[purple]TACCTTCACGCCAATGGCGCCTCAATATTCTTTATCTGCCTCTTCCTACACATCGGGCGAGGCCTATATTACGGATCATT[/purple]
[purple]TCTCTACTCAGAAACCTGAAACATCGGCATTATCCTCCTGCTTGCAACTATAGCAACAGCCTTCATAGGCTATGTCCTCC[/purple]
[purple]CGTGAGGCCAAATATCATTCTGAGGGGCCACAGTAATTACAAACTTACTATCCGCCATCCCATACATTGGGACAGACCTA[/purple]
[purple]GTTCAATGAATCTGAGGAGGCTACTCAGTAGACAGTCCCACCCTCACACGATTCTTTACCTTTCACTTCATCTTGCCCTT[/purple]
[purple]CATTATTGCAGCCCTAGCAACACTCCACCTCCTATTCTTGCACGAAACGGGATCAAACAACCCCCTAGGAATCACCTCCC[/purple]
[purple]ATTCCGATAAAATCACCTTCCACCCTTACTACACAATCAAAGACGCCCTCGGCTTACTTCTCTTCCTTCTCTCCTTAATG[/purple]
[purple]ACATTAACACTATTCTCACCAGACCTCCTAGGCGACCCAGACAATTATACCCTAGCCAACCCCTTAAACACCCCTCCCCA[/purple]
[purple]CATCAAGCCCGAATGATATTTCCTATTCGCCTACACAATTCTCCGATCCGTCCCTAACAAACTAGGAGGCGTCCTTGCCC[/purple]
[purple]TATTACTATCCATCCTCATCCTAGCAATAATCCCCATCCTCCATATATCCAAACAACAAAGCATAATATTTCGCCCACTA[/purple]
[purple]AGCCAATCACTTTATTGACTCCTAGCCGCAGACCTCCTCATTCTAACCTGAATCGGAGGACAACCAGTAAGCTACCCTTT[/purple]
[purple]TACCATCATTGGACAAGTAGCATCCGTACTATACTTCACAACAATCCTAATCCTAATACCAACTATCTCCCTAATTGAAA[/purple]
[purple]ACAAAATACTCAAATAATAAT[/purple]
[purple][/purple][red])[/red][red];[/red]


[gray][i]##########################################[/i][/gray]
[gray][i]#   Populate Data Set[/i][/gray]
[gray][i]##########################################[/i][/gray]

[black][b]my[/b][/black] [blue]%MasterHash[/blue] = [red]([/red][red])[/red][red];[/red]

[olive][b]for[/b][/olive][red]([/red][black][b]my[/b][/black] [blue]$i[/blue]=[fuchsia]0[/fuchsia][red];[/red] [blue]$i[/blue] < [red]([/red][url=http://perldoc.perl.org/functions/length.html][black][b]length[/b][/black][/url][red]([/red][blue]$DNA[/blue][red])[/red] - [fuchsia]2[/fuchsia][red])[/red] [red];[/red] [blue]$i[/blue] += [fuchsia]3[/fuchsia][red])[/red] [red]{[/red]

	[black][b]my[/b][/black] [blue]$Codon[/blue] = [url=http://perldoc.perl.org/functions/substr.html][black][b]substr[/b][/black][/url][red]([/red][blue]$DNA[/blue],[blue]$i[/blue],[fuchsia]3[/fuchsia][red])[/red][red];[/red]
	[black][b]my[/b][/black] [blue]$AA[/blue] = [maroon]codon2aa[/maroon][red]([/red] [blue]$Codon[/blue] [red])[/red][red];[/red]

[gray][i]#	print "\nAmino Acid: $AA";[/i][/gray]
[gray][i]#	print "\nCodon: $Codon\n";[/i][/gray]

	[gray][i]# Setting up AA count[/i][/gray]
	[black][b]my[/b][/black] [blue]$aaHash[/blue] = [blue]$MasterHash[/blue][red]{[/red][blue]$AA[/blue][red]}[/red] ||= [red]{[/red]
		[purple]Symbol[/purple]	=> [blue]$AA[/blue],				[gray][i]#set up symbol[/i][/gray]
		[purple]Name[/purple]	=> [maroon]nameAA[/maroon][red]([/red][blue]$AA[/blue][red])[/red],		[gray][i]#set up name[/i][/gray]
		[purple]Count[/purple]	=> [fuchsia]0[/fuchsia],				[gray][i]#set up AA count[/i][/gray]
		[purple]Codons[/purple]	=> [red]{[/red][red]}[/red],
	[red]}[/red][red];[/red]
	
	[blue]$aaHash[/blue]->[red]{[/red]Count[red]}[/red]++[red];[/red] [gray][i]# add to AA count[/i][/gray]

[gray][i]#	print "Amino Acid Count: $aaHash->{Count}\n";[/i][/gray]

	[gray][i]# Settin up Codon Count[/i][/gray]
	[black][b]my[/b][/black] [blue]$codonHash[/blue] = [blue]$aaHash[/blue]->[red]{[/red]Codons[red]}[/red][red]{[/red][blue]$Codon[/blue][red]}[/red] ||= [red]{[/red]
		[purple]Count[/purple]	=> [fuchsia]0[/fuchsia],				[gray][i]#set up codon count[/i][/gray]
	[red]}[/red][red];[/red]
	
	[blue]$codonHash[/blue]->[red]{[/red]Count[red]}[/red]++[red];[/red] [gray][i]# add to codon count[/i][/gray]

[gray][i]#	print "Codon Count: $codonHash->{Count}\n";[/i][/gray]
[red]}[/red]


[gray][i]##########################################[/i][/gray]
[gray][i]#   Print Data Set[/i][/gray]
[gray][i]##########################################[/i][/gray]

[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple][purple][b]\n[/b][/purple][purple][b]\n[/b][/purple]RESULTS...[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]

[olive][b]while[/b][/olive] [red]([/red][black][b]my[/b][/black] [red]([/red][blue]$AA[/blue], [blue]$aaHash[/blue][red])[/red] = [url=http://perldoc.perl.org/functions/each.html][black][b]each[/b][/black][/url] [blue]%MasterHash[/blue][red])[/red] [red]{[/red]
	[black][b]my[/b][/black] [blue]$ProName[/blue] = [maroon]nameAA[/maroon][red]([/red][blue]$AA[/blue][red])[/red][red];[/red]

	[black][b]print[/b][/black] [red]"[/red][purple][purple][b]\n[/b][/purple][purple][b]\n[/b][/purple]---------------------------------------------------------------------------------[/purple][red]"[/red][red];[/red]
	[black][b]print[/b][/black] [red]"[/red][purple][purple][b]\n[/b][/purple][blue]$ProName[/blue]:[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]

	[olive][b]while[/b][/olive] [red]([/red][black][b]my[/b][/black] [red]([/red][blue]$codon[/blue], [blue]$codonHash[/blue][red])[/red] = [black][b]each[/b][/black] [blue]%[/blue][red]{[/red] [blue]$aaHash[/blue]->[red]{[/red]Codons[red]}[/red] [red]}[/red][red])[/red] [red]{[/red]
		[black][b]print[/b][/black] [red]"[/red][purple][blue]$codon[/blue] = [blue]$codonHash[/blue]->{Count}[purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
	[red]}[/red]
	[black][b]print[/b][/black] [red]"[/red][purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[red]}[/red]


[gray][i]##########################################[/i][/gray]
[gray][i]#   Subroutines[/i][/gray]
[gray][i]##########################################[/i][/gray]

[url=http://perldoc.perl.org/functions/sub.html][black][b]sub[/b][/black][/url] [maroon]codon2aa[/maroon] [red]{[/red]
	[black][b]my[/b][/black][red]([/red][blue]$codon[/blue][red])[/red] = [blue]@_[/blue][red];[/red]

	[blue]$codon[/blue] = [url=http://perldoc.perl.org/functions/uc.html][black][b]uc[/b][/black][/url] [blue]$codon[/blue][red];[/red]

	[black][b]my[/b][/black] [blue]%genetic_code[/blue] = [red]([/red]
		[red]'[/red][purple]TCA[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
		[red]'[/red][purple]TCC[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
		[red]'[/red][purple]TCG[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
		[red]'[/red][purple]TCT[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
		[red]'[/red][purple]TTC[/purple][red]'[/red] => [red]'[/red][purple]F[/purple][red]'[/red],    [gray][i]# Phenylalanine[/i][/gray]
		[red]'[/red][purple]TTT[/purple][red]'[/red] => [red]'[/red][purple]F[/purple][red]'[/red],    [gray][i]# Phenylalanine[/i][/gray]
		[red]'[/red][purple]TTA[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
		[red]'[/red][purple]TTG[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
		[red]'[/red][purple]TAC[/purple][red]'[/red] => [red]'[/red][purple]Y[/purple][red]'[/red],    [gray][i]# Tyrosine[/i][/gray]
		[red]'[/red][purple]TAT[/purple][red]'[/red] => [red]'[/red][purple]Y[/purple][red]'[/red],    [gray][i]# Tyrosine[/i][/gray]
		[red]'[/red][purple]TAA[/purple][red]'[/red] => [red]'[/red][purple]_[/purple][red]'[/red],    [gray][i]# Stop[/i][/gray]
		[red]'[/red][purple]TAG[/purple][red]'[/red] => [red]'[/red][purple]_[/purple][red]'[/red],    [gray][i]# Stop[/i][/gray]
		[red]'[/red][purple]TGC[/purple][red]'[/red] => [red]'[/red][purple]C[/purple][red]'[/red],    [gray][i]# Cysteine[/i][/gray]
		[red]'[/red][purple]TGT[/purple][red]'[/red] => [red]'[/red][purple]C[/purple][red]'[/red],    [gray][i]# Cysteine[/i][/gray]
		[red]'[/red][purple]TGA[/purple][red]'[/red] => [red]'[/red][purple]_[/purple][red]'[/red],    [gray][i]# Stop[/i][/gray]
		[red]'[/red][purple]TGG[/purple][red]'[/red] => [red]'[/red][purple]W[/purple][red]'[/red],    [gray][i]# Tryptophan[/i][/gray]
		[red]'[/red][purple]CTA[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
		[red]'[/red][purple]CTC[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
		[red]'[/red][purple]CTG[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
		[red]'[/red][purple]CTT[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
		[red]'[/red][purple]CCA[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
		[red]'[/red][purple]CCC[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
		[red]'[/red][purple]CCG[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
		[red]'[/red][purple]CCT[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
		[red]'[/red][purple]CAC[/purple][red]'[/red] => [red]'[/red][purple]H[/purple][red]'[/red],    [gray][i]# Histidine[/i][/gray]
		[red]'[/red][purple]CAT[/purple][red]'[/red] => [red]'[/red][purple]H[/purple][red]'[/red],    [gray][i]# Histidine[/i][/gray]
		[red]'[/red][purple]CAA[/purple][red]'[/red] => [red]'[/red][purple]Q[/purple][red]'[/red],    [gray][i]# Glutamine[/i][/gray]
		[red]'[/red][purple]CAG[/purple][red]'[/red] => [red]'[/red][purple]Q[/purple][red]'[/red],    [gray][i]# Glutamine[/i][/gray]
		[red]'[/red][purple]CGA[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
		[red]'[/red][purple]CGC[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
		[red]'[/red][purple]CGG[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
		[red]'[/red][purple]CGT[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
		[red]'[/red][purple]ATA[/purple][red]'[/red] => [red]'[/red][purple]I[/purple][red]'[/red],    [gray][i]# Isoleucine[/i][/gray]
		[red]'[/red][purple]ATC[/purple][red]'[/red] => [red]'[/red][purple]I[/purple][red]'[/red],    [gray][i]# Isoleucine[/i][/gray]
		[red]'[/red][purple]ATT[/purple][red]'[/red] => [red]'[/red][purple]I[/purple][red]'[/red],    [gray][i]# Isoleucine[/i][/gray]
		[red]'[/red][purple]ATG[/purple][red]'[/red] => [red]'[/red][purple]M[/purple][red]'[/red],    [gray][i]# Methionine[/i][/gray]
		[red]'[/red][purple]ACA[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
		[red]'[/red][purple]ACC[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
		[red]'[/red][purple]ACG[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
		[red]'[/red][purple]ACT[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
		[red]'[/red][purple]AAC[/purple][red]'[/red] => [red]'[/red][purple]N[/purple][red]'[/red],    [gray][i]# Asparagine[/i][/gray]
		[red]'[/red][purple]AAT[/purple][red]'[/red] => [red]'[/red][purple]N[/purple][red]'[/red],    [gray][i]# Asparagine[/i][/gray]
		[red]'[/red][purple]AAA[/purple][red]'[/red] => [red]'[/red][purple]K[/purple][red]'[/red],    [gray][i]# Lysine[/i][/gray]
		[red]'[/red][purple]AAG[/purple][red]'[/red] => [red]'[/red][purple]K[/purple][red]'[/red],    [gray][i]# Lysine[/i][/gray]
		[red]'[/red][purple]AGC[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
		[red]'[/red][purple]AGT[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
		[red]'[/red][purple]AGA[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
		[red]'[/red][purple]AGG[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
		[red]'[/red][purple]GTA[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
		[red]'[/red][purple]GTC[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
		[red]'[/red][purple]GTG[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
		[red]'[/red][purple]GTT[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
		[red]'[/red][purple]GCA[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
		[red]'[/red][purple]GCC[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
		[red]'[/red][purple]GCG[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
		[red]'[/red][purple]GCT[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
		[red]'[/red][purple]GAC[/purple][red]'[/red] => [red]'[/red][purple]D[/purple][red]'[/red],    [gray][i]# Aspartic Acid[/i][/gray]
		[red]'[/red][purple]GAT[/purple][red]'[/red] => [red]'[/red][purple]D[/purple][red]'[/red],    [gray][i]# Aspartic Acid[/i][/gray]
		[red]'[/red][purple]GAA[/purple][red]'[/red] => [red]'[/red][purple]E[/purple][red]'[/red],    [gray][i]# Glutamic Acid[/i][/gray]
		[red]'[/red][purple]GAG[/purple][red]'[/red] => [red]'[/red][purple]E[/purple][red]'[/red],    [gray][i]# Glutamic Acid[/i][/gray]
		[red]'[/red][purple]GGA[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
		[red]'[/red][purple]GGC[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
		[red]'[/red][purple]GGG[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
		[red]'[/red][purple]GGT[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
	[red])[/red][red];[/red]

	[olive][b]if[/b][/olive] [red]([/red][url=http://perldoc.perl.org/functions/exists.html][black][b]exists[/b][/black][/url] [blue]$genetic_code[/blue][red]{[/red][blue]$codon[/blue][red]}[/red][red])[/red] [red]{[/red]
		[url=http://perldoc.perl.org/functions/return.html][black][b]return[/b][/black][/url] [blue]$genetic_code[/blue][red]{[/red][blue]$codon[/blue][red]}[/red][red];[/red]
	[red]}[/red] [olive][b]else[/b][/olive] [red]{[/red]
		[black][b]print[/b][/black] STDERR [red]"[/red][purple]Bad codon [purple][b]\"[/b][/purple][blue]$codon[/blue][purple][b]\"[/b][/purple]!![purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
		[gray][i]#exit;[/i][/gray]
	[red]}[/red]
[red]}[/red]

[black][b]sub[/b][/black] [maroon]nameAA[/maroon] [red]{[/red]
	[black][b]my[/b][/black] [red]([/red][blue]$AA_single[/blue][red])[/red] = [blue]@_[/blue][red];[/red]

	[blue]$AA_single[/blue] = [black][b]uc[/b][/black] [blue]$AA_single[/blue][red];[/red]

	[black][b]my[/b][/black] [blue]%AA_Name_code[/blue] = [red]([/red]
		[red]'[/red][purple]S[/purple][red]'[/red] => [red]'[/red][purple]Serine[/purple][red]'[/red],
		[red]'[/red][purple]F[/purple][red]'[/red] => [red]'[/red][purple]Phenylalanine[/purple][red]'[/red],
		[red]'[/red][purple]L[/purple][red]'[/red] => [red]'[/red][purple]Leucine[/purple][red]'[/red],
		[red]'[/red][purple]Y[/purple][red]'[/red] => [red]'[/red][purple]Tyrosine[/purple][red]'[/red],
		[red]'[/red][purple]_[/purple][red]'[/red] => [red]'[/red][purple]Stop[/purple][red]'[/red],
		[red]'[/red][purple]C[/purple][red]'[/red] => [red]'[/red][purple]Cysteine[/purple][red]'[/red],
		[red]'[/red][purple]W[/purple][red]'[/red] => [red]'[/red][purple]Tryptophan[/purple][red]'[/red],
		[red]'[/red][purple]P[/purple][red]'[/red] => [red]'[/red][purple]Proline[/purple][red]'[/red],
		[red]'[/red][purple]H[/purple][red]'[/red] => [red]'[/red][purple]Histidine[/purple][red]'[/red],
		[red]'[/red][purple]Q[/purple][red]'[/red] => [red]'[/red][purple]Glutamine[/purple][red]'[/red],
		[red]'[/red][purple]R[/purple][red]'[/red] => [red]'[/red][purple]Arginine[/purple][red]'[/red],
		[red]'[/red][purple]I[/purple][red]'[/red] => [red]'[/red][purple]Isoleucine[/purple][red]'[/red],
		[red]'[/red][purple]M[/purple][red]'[/red] => [red]'[/red][purple]Methionine[/purple][red]'[/red],
		[red]'[/red][purple]T[/purple][red]'[/red] => [red]'[/red][purple]Threonine[/purple][red]'[/red],
		[red]'[/red][purple]N[/purple][red]'[/red] => [red]'[/red][purple]Asparagine[/purple][red]'[/red],
		[red]'[/red][purple]K[/purple][red]'[/red] => [red]'[/red][purple]Lysine[/purple][red]'[/red],
		[red]'[/red][purple]V[/purple][red]'[/red] => [red]'[/red][purple]Valine[/purple][red]'[/red],
		[red]'[/red][purple]A[/purple][red]'[/red] => [red]'[/red][purple]Alanine[/purple][red]'[/red],
		[red]'[/red][purple]D[/purple][red]'[/red] => [red]'[/red][purple]Aspartic Acid[/purple][red]'[/red],
		[red]'[/red][purple]E[/purple][red]'[/red] => [red]'[/red][purple]Glutamic Acid[/purple][red]'[/red],
		[red]'[/red][purple]G[/purple][red]'[/red] => [red]'[/red][purple]Glycine[/purple][red]'[/red],
	[red])[/red][red];[/red]

	[olive][b]if[/b][/olive] [red]([/red][black][b]exists[/b][/black] [blue]$AA_Name_code[/blue][red]{[/red][blue]$AA_single[/blue][red]}[/red][red])[/red] [red]{[/red]
		[black][b]return[/b][/black] [blue]$AA_Name_code[/blue][red]{[/red][blue]$AA_single[/blue][red]}[/red][red];[/red]
	[red]}[/red] [olive][b]else[/b][/olive] [red]{[/red]
		[black][b]print[/b][/black] STDERR [red]"[/red][purple]Bad Amino Acid [purple][b]\"[/b][/purple][blue]$AA_single[/blue][purple][b]\"[/b][/purple]!![purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
		[gray][i]#exit;[/i][/gray]
	[red]}[/red]
[red]}[/red]

[fuchsia]1[/fuchsia][red];[/red]

[teal]__END__[/teal]
[tt]------------------------------------------------------------
Pragmas (perl 5.8.8) used :
[ul]
[li]strict - Perl pragma to restrict unsafe constructs[/li]
[/ul]
[/tt]

- Miller
 
I also worked on the code but went a bit further by getting rid of the unnecessary subroutines.

Code:
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]
[black][b]use[/b][/black] [green]warnings[/green][red];[/red]
[gray][i]#use Data::Dumper;[/i][/gray]


[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]%genetic_code[/blue] = [red]([/red]
    
    [red]'[/red][purple]TCA[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
    [red]'[/red][purple]TCC[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
    [red]'[/red][purple]TCG[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
    [red]'[/red][purple]TCT[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
    [red]'[/red][purple]TTC[/purple][red]'[/red] => [red]'[/red][purple]F[/purple][red]'[/red],    [gray][i]# Phenylalanine[/i][/gray]
    [red]'[/red][purple]TTT[/purple][red]'[/red] => [red]'[/red][purple]F[/purple][red]'[/red],    [gray][i]# Phenylalanine[/i][/gray]
    [red]'[/red][purple]TTA[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
    [red]'[/red][purple]TTG[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
    [red]'[/red][purple]TAC[/purple][red]'[/red] => [red]'[/red][purple]Y[/purple][red]'[/red],    [gray][i]# Tyrosine[/i][/gray]
    [red]'[/red][purple]TAT[/purple][red]'[/red] => [red]'[/red][purple]Y[/purple][red]'[/red],    [gray][i]# Tyrosine[/i][/gray]
    [red]'[/red][purple]TAA[/purple][red]'[/red] => [red]'[/red][purple]_[/purple][red]'[/red],    [gray][i]# Stop[/i][/gray]
    [red]'[/red][purple]TAG[/purple][red]'[/red] => [red]'[/red][purple]_[/purple][red]'[/red],    [gray][i]# Stop[/i][/gray]
    [red]'[/red][purple]TGC[/purple][red]'[/red] => [red]'[/red][purple]C[/purple][red]'[/red],    [gray][i]# Cysteine[/i][/gray]
    [red]'[/red][purple]TGT[/purple][red]'[/red] => [red]'[/red][purple]C[/purple][red]'[/red],    [gray][i]# Cysteine[/i][/gray]
    [red]'[/red][purple]TGA[/purple][red]'[/red] => [red]'[/red][purple]_[/purple][red]'[/red],    [gray][i]# Stop[/i][/gray]
    [red]'[/red][purple]TGG[/purple][red]'[/red] => [red]'[/red][purple]W[/purple][red]'[/red],    [gray][i]# Tryptophan[/i][/gray]
    [red]'[/red][purple]CTA[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
    [red]'[/red][purple]CTC[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
    [red]'[/red][purple]CTG[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
    [red]'[/red][purple]CTT[/purple][red]'[/red] => [red]'[/red][purple]L[/purple][red]'[/red],    [gray][i]# Leucine[/i][/gray]
    [red]'[/red][purple]CCA[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
    [red]'[/red][purple]CCC[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
    [red]'[/red][purple]CCG[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
    [red]'[/red][purple]CCT[/purple][red]'[/red] => [red]'[/red][purple]P[/purple][red]'[/red],    [gray][i]# Proline[/i][/gray]
    [red]'[/red][purple]CAC[/purple][red]'[/red] => [red]'[/red][purple]H[/purple][red]'[/red],    [gray][i]# Histidine[/i][/gray]
    [red]'[/red][purple]CAT[/purple][red]'[/red] => [red]'[/red][purple]H[/purple][red]'[/red],    [gray][i]# Histidine[/i][/gray]
    [red]'[/red][purple]CAA[/purple][red]'[/red] => [red]'[/red][purple]Q[/purple][red]'[/red],    [gray][i]# Glutamine[/i][/gray]
    [red]'[/red][purple]CAG[/purple][red]'[/red] => [red]'[/red][purple]Q[/purple][red]'[/red],    [gray][i]# Glutamine[/i][/gray]
    [red]'[/red][purple]CGA[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
    [red]'[/red][purple]CGC[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
    [red]'[/red][purple]CGG[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
    [red]'[/red][purple]CGT[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
    [red]'[/red][purple]ATA[/purple][red]'[/red] => [red]'[/red][purple]I[/purple][red]'[/red],    [gray][i]# Isoleucine[/i][/gray]
    [red]'[/red][purple]ATC[/purple][red]'[/red] => [red]'[/red][purple]I[/purple][red]'[/red],    [gray][i]# Isoleucine[/i][/gray]
    [red]'[/red][purple]ATT[/purple][red]'[/red] => [red]'[/red][purple]I[/purple][red]'[/red],    [gray][i]# Isoleucine[/i][/gray]
    [red]'[/red][purple]ATG[/purple][red]'[/red] => [red]'[/red][purple]M[/purple][red]'[/red],    [gray][i]# Methionine[/i][/gray]
    [red]'[/red][purple]ACA[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
    [red]'[/red][purple]ACC[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
    [red]'[/red][purple]ACG[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
    [red]'[/red][purple]ACT[/purple][red]'[/red] => [red]'[/red][purple]T[/purple][red]'[/red],    [gray][i]# Threonine[/i][/gray]
    [red]'[/red][purple]AAC[/purple][red]'[/red] => [red]'[/red][purple]N[/purple][red]'[/red],    [gray][i]# Asparagine[/i][/gray]
    [red]'[/red][purple]AAT[/purple][red]'[/red] => [red]'[/red][purple]N[/purple][red]'[/red],    [gray][i]# Asparagine[/i][/gray]
    [red]'[/red][purple]AAA[/purple][red]'[/red] => [red]'[/red][purple]K[/purple][red]'[/red],    [gray][i]# Lysine[/i][/gray]
    [red]'[/red][purple]AAG[/purple][red]'[/red] => [red]'[/red][purple]K[/purple][red]'[/red],    [gray][i]# Lysine[/i][/gray]
    [red]'[/red][purple]AGC[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
    [red]'[/red][purple]AGT[/purple][red]'[/red] => [red]'[/red][purple]S[/purple][red]'[/red],    [gray][i]# Serine[/i][/gray]
    [red]'[/red][purple]AGA[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
    [red]'[/red][purple]AGG[/purple][red]'[/red] => [red]'[/red][purple]R[/purple][red]'[/red],    [gray][i]# Arginine[/i][/gray]
    [red]'[/red][purple]GTA[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
    [red]'[/red][purple]GTC[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
    [red]'[/red][purple]GTG[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
    [red]'[/red][purple]GTT[/purple][red]'[/red] => [red]'[/red][purple]V[/purple][red]'[/red],    [gray][i]# Valine[/i][/gray]
    [red]'[/red][purple]GCA[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
    [red]'[/red][purple]GCC[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
    [red]'[/red][purple]GCG[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
    [red]'[/red][purple]GCT[/purple][red]'[/red] => [red]'[/red][purple]A[/purple][red]'[/red],    [gray][i]# Alanine[/i][/gray]
    [red]'[/red][purple]GAC[/purple][red]'[/red] => [red]'[/red][purple]D[/purple][red]'[/red],    [gray][i]# Aspartic Acid[/i][/gray]
    [red]'[/red][purple]GAT[/purple][red]'[/red] => [red]'[/red][purple]D[/purple][red]'[/red],    [gray][i]# Aspartic Acid[/i][/gray]
    [red]'[/red][purple]GAA[/purple][red]'[/red] => [red]'[/red][purple]E[/purple][red]'[/red],    [gray][i]# Glutamic Acid[/i][/gray]
    [red]'[/red][purple]GAG[/purple][red]'[/red] => [red]'[/red][purple]E[/purple][red]'[/red],    [gray][i]# Glutamic Acid[/i][/gray]
    [red]'[/red][purple]GGA[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
    [red]'[/red][purple]GGC[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
    [red]'[/red][purple]GGG[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
    [red]'[/red][purple]GGT[/purple][red]'[/red] => [red]'[/red][purple]G[/purple][red]'[/red],    [gray][i]# Glycine[/i][/gray]
[red])[/red][red];[/red]

[black][b]my[/b][/black] [blue]%AA_Name_code[/blue] = [red]([/red]
    
    [red]'[/red][purple]S[/purple][red]'[/red] => [red]'[/red][purple]Serine[/purple][red]'[/red],
    [red]'[/red][purple]F[/purple][red]'[/red] => [red]'[/red][purple]Phenylalanine[/purple][red]'[/red],
    [red]'[/red][purple]L[/purple][red]'[/red] => [red]'[/red][purple]Leucine[/purple][red]'[/red],
    [red]'[/red][purple]Y[/purple][red]'[/red] => [red]'[/red][purple]Tyrosine[/purple][red]'[/red],
    [red]'[/red][purple]_[/purple][red]'[/red] => [red]'[/red][purple]Stop[/purple][red]'[/red],
    [red]'[/red][purple]C[/purple][red]'[/red] => [red]'[/red][purple]Cysteine[/purple][red]'[/red],
    [red]'[/red][purple]W[/purple][red]'[/red] => [red]'[/red][purple]Tryptophan[/purple][red]'[/red],
    [red]'[/red][purple]P[/purple][red]'[/red] => [red]'[/red][purple]Proline[/purple][red]'[/red],
    [red]'[/red][purple]H[/purple][red]'[/red] => [red]'[/red][purple]Histidine[/purple][red]'[/red],
    [red]'[/red][purple]Q[/purple][red]'[/red] => [red]'[/red][purple]Glutamine[/purple][red]'[/red],
    [red]'[/red][purple]R[/purple][red]'[/red] => [red]'[/red][purple]Arginine[/purple][red]'[/red],
    [red]'[/red][purple]I[/purple][red]'[/red] => [red]'[/red][purple]Isoleucine[/purple][red]'[/red],
    [red]'[/red][purple]M[/purple][red]'[/red] => [red]'[/red][purple]Methionine[/purple][red]'[/red],
    [red]'[/red][purple]T[/purple][red]'[/red] => [red]'[/red][purple]Threonine[/purple][red]'[/red],
    [red]'[/red][purple]N[/purple][red]'[/red] => [red]'[/red][purple]Asparagine[/purple][red]'[/red],
    [red]'[/red][purple]K[/purple][red]'[/red] => [red]'[/red][purple]Lysine[/purple][red]'[/red],
    [red]'[/red][purple]V[/purple][red]'[/red] => [red]'[/red][purple]Valine[/purple][red]'[/red],
    [red]'[/red][purple]A[/purple][red]'[/red] => [red]'[/red][purple]Alanine[/purple][red]'[/red],
    [red]'[/red][purple]D[/purple][red]'[/red] => [red]'[/red][purple]Aspartic Acid[/purple][red]'[/red],
    [red]'[/red][purple]E[/purple][red]'[/red] => [red]'[/red][purple]Glutamic Acid[/purple][red]'[/red],
    [red]'[/red][purple]G[/purple][red]'[/red] => [red]'[/red][purple]Glycine[/purple][red]'[/red],
[red])[/red][red];[/red]



[gray][i]##########################################[/i][/gray]
[gray][i]#   Load Sequence[/i][/gray]
[gray][i]##########################################[/i][/gray]

[black][b]my[/b][/black] [blue]$DNA[/blue] = [red]"[/red][purple]ATGACCCCACCAATACGCAAAACTAACCCCCTAATAAAATTAATTAACCACTCATTCATCGACCTCCCCACCCCATCCAACATCTCCGCATGATGAAACTTCGGCTCACTCCTTGGCGCCTGCCTGATCCTCCAAATCACCACAGGACTATTCCTAGCCATGCACTACTCACCAGACGCCTCAACCGCCTTTTCATCAATCGCCCACATCACTCGAGACGTAAATTATGGCTGAATCATCCGCTACCTTCACGCCAATGGCGCCTCAATATTCTTTATCTGCCTCTTCCTACACATCGGGCGAGGCCTATATTACGGATCATTTCTCTACTCAGAAACCTGAAACATCGGCATTATCCTCCTGCTTGCAACTATAGCAACAGCCTTCATAGGCTATGTCCTCCCGTGAGGCCAAATATCATTCTGAGGGGCCACAGTAATTACAAACTTACTATCCGCCATCCCATACATTGGGACAGACCTAGTTCAATGAATCTGAGGAGGCTACTCAGTAGACAGTCCCACCCTCACACGATTCTTTACCTTTCACTTCATCTTGCCCTTCATTATTGCAGCCCTAGCAACACTCCACCTCCTATTCTTGCACGAAACGGGATCAAACAACCCCCTAGGAATCACCTCCCATTCCGATAAAATCACCTTCCACCCTTACTACACAATCAAAGACGCCCTCGGCTTACTTCTCTTCCTTCTCTCCTTAATGACATTAACACTATTCTCACCAGACCTCCTAGGCGACCCAGACAATTATACCCTAGCCAACCCCTTAAACACCCCTCCCCACATCAAGCCCGAATGATATTTCCTATTCGCCTACACAATTCTCCGATCCGTCCCTAACAAACTAGGAGGCGTCCTTGCCCTATTACTATCCATCCTCATCCTAGCAATAATCCCCATCCTCCATATATCCAAACAACAAAGCATAATATTTCGCCCACTAAGCCAATCACTTTATTGACTCCTAGCCGCAGACCTCCTCATTCTAACCTGAATCGGAGGACAACCAGTAAGCTACCCTTTTACCATCATTGGACAAGTAGCATCCGTACTATACTTCACAACAATCCTAATCCTAATACCAACTATCTCCCTAATTGAAAACAAAATACTCAAATAATAAT[/purple][red]"[/red][red];[/red]



[gray][i]##########################################[/i][/gray]
[gray][i]#   Populate Data Set[/i][/gray]
[gray][i]##########################################[/i][/gray]

[black][b]my[/b][/black] [blue]%MasterHash[/blue] = [red]([/red][red])[/red][red];[/red]

[olive][b]for[/b][/olive] [red]([/red][black][b]my[/b][/black] [blue]$i[/blue]=[fuchsia]0[/fuchsia][red];[/red] [blue]$i[/blue] < [red]([/red][url=http://perldoc.perl.org/functions/length.html][black][b]length[/b][/black][/url][red]([/red][blue]$DNA[/blue][red])[/red] - [fuchsia]2[/fuchsia][red])[/red] [red];[/red] [blue]$i[/blue] += [fuchsia]3[/fuchsia][red])[/red] [red]{[/red]

    [black][b]my[/b][/black] [blue]$Codon[/blue] = [url=http://perldoc.perl.org/functions/uc.html][black][b]uc[/b][/black][/url][red]([/red][url=http://perldoc.perl.org/functions/substr.html][black][b]substr[/b][/black][/url][red]([/red][blue]$DNA[/blue],[blue]$i[/blue],[fuchsia]3[/fuchsia][red])[/red][red])[/red][red];[/red]
    
    [black][b]my[/b][/black] [blue]$AA[/blue] = [url=http://perldoc.perl.org/functions/exists.html][black][b]exists[/b][/black][/url] [blue]$genetic_code[/blue][red]{[/red][blue]$Codon[/blue][red]}[/red] ?  [blue]$genetic_code[/blue][red]{[/red][blue]$Codon[/blue][red]}[/red] : [red]qq~[/red][purple]Bad codon "$Codon"!!\n[/purple][red]~[/red][red];[/red]

    [blue]$MasterHash[/blue][red]{[/red][blue]$AA[/blue][red]}[/red][red]{[/red]Symbol[red]}[/red] = [blue]$AA[/blue]    [gray][i]#set up symbol[/i][/gray]
    [blue]$MasterHash[/blue][red]{[/red][blue]$AA[/blue][red]}[/red][red]{[/red]Name[red]}[/red] = [black][b]exists[/b][/black] [blue]$AA_Name_code[/blue][red]{[/red][blue]$AA[/blue][red]}[/red] ? [blue]$AA_Name_code[/blue][red]{[/red][blue]$AA[/blue][red]}[/red] : [red]qq~[/red][purple]Bad codon "$Codon"!!\n[/purple][red]~[/red][red];[/red]    [gray][i]#set up name[/i][/gray]
    [blue]$MasterHash[/blue][red]{[/red][blue]$AA[/blue][red]}[/red][red]{[/red]Count[red]}[/red]++[red];[/red]    [gray][i]#set up AA count[/i][/gray]
    [blue]$MasterHash[/blue][red]{[/red][blue]$AA[/blue][red]}[/red][red]{[/red]Codons[red]}[/red][red]{[/red][blue]$Codon[/blue][red]}[/red][red]{[/red]Count[red]}[/red]++[red];[/red]    [gray][i]#set up codon count[/i][/gray]
[red]}[/red]
[gray][i]##########################################[/i][/gray]
[gray][i]#   Print Data Set[/i][/gray]
[gray][i]##########################################[/i][/gray]


[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple][purple][b]\n[/b][/purple][purple][b]\n[/b][/purple]RESULTS...[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]

[olive][b]foreach[/b][/olive] [black][b]my[/b][/black] [blue]$var_AA[/blue] [red]([/red][url=http://perldoc.perl.org/functions/keys.html][black][b]keys[/b][/black][/url] [blue]%MasterHash[/blue][red])[/red] [red]{[/red]
    [black][b]print[/b][/black] [red]qq~[/red][purple]$MasterHash{$var_AA}{Name}\n\tSymbol: $MasterHash{$var_AA}{Symbol}\n\tCount: $MasterHash{$var_AA}{Count}\n[/purple][red]~[/red][red];[/red]
    [olive][b]foreach[/b][/olive] [black][b]my[/b][/black] [blue]$c[/blue] [red]([/red][black][b]keys[/b][/black] [blue]%[/blue][red]{[/red][blue]$MasterHash[/blue][red]{[/red][blue]$var_AA[/blue][red]}[/red][red]{[/red]Codons[red]}[/red][red]}[/red][red])[/red] [red]{[/red]
       [black][b]print[/b][/black] [red]qq~[/red][purple]\t\t$c ($MasterHash{$var_AA}{Codons}{$c}{Count})\n[/purple][red]~[/red][red];[/red]
        
    [red]}[/red]
    [black][b]print[/b][/black] [red]"[/red][purple][purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[red]}[/red]

[gray][i]#print Dumper \%MasterHash;[/i][/gray]



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
missing the semi-colon in this line in my code:

$MasterHash{$AA}{Symbol} = $AA #set up symbol

should be:

$MasterHash{$AA}{Symbol} = $AA; #set up symbol

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top