forked from packetzero/code1920
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genetic_code.go
49 lines (44 loc) · 2.21 KB
/
genetic_code.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package microbio
// WaitForTRNAAndGetAttachedAminoAcid emulates tRNA machine
// RNA codon to deliver matching amino acids.
// tRNA have an RNA matching codon (3 nucleotides) on one end
// and an AminoAcid on the other
func WaitForTRNAAndGetAttachedAminoAcid(codon *NucleotideStrand) *AminoAcid {
return lookupAminoForCodon(codon.String())
}
func lookupAminoForCodon(codonStr string) *AminoAcid {
return codonToAminoMap[codonStr]
}
// codonToAminoMap maps 3-nucleotide codon strings to the corresponding
// amino acid or stop signal(nil).
// TODO: The amino acids are defined for you in amino_acid.go file.
// It's important that you follow the UCAG pattern as demonstrated below,
// as the Unit Test depends on exact order.
// One line for each of the second letter U,C,A,G and each line
// has a mapping where the third letter changes from U,C,A,G.
// https://www.thoughtco.com/genetic-code-373449
var codonToAminoMap = map[string]*AminoAcid{
// UUU through UGG
"UUU": &Phenylalanine, "UUC": &Phenylalanine, "UUA": &Leucine, "UUG": &Leucine,
"UCU": &Serine, "UCC": &Serine, "UCA": &Serine, "UCG": &Serine,
"UAU": &Tyrosine, "UAC": &Tyrosine, "UAA": nil, "UAG": nil,
"UGU": &Cysteine, "UGC": &Cysteine, "UGA": nil, "UGG": &Tryptophan,
// CUU through CGG
// TODO: Add 16 entries
"CUU": &Leucine, "CUC": &Leucine, "CUA": &Leucine, "CUG": &Leucine,
"CCU": &Proline, "CCC": &Proline, "CCA": &Proline, "CCG": &Proline,
"CAU": &Histidine, "CAC": &Histidine, "CAA": &Glutamine, "CAG": &Glutamine,
"CGU": &Arginine, "CGC": &Arginine, "CGA": &Arginine, "CGG": &Arginine,
// AUU through AGG
// TODO: Add 16 entries
"AUU": &Isoleucine, "AUC": &Isoleucine, "AUA": &Isoleucine, "AUG": &Methionine,
"ACU": &Threonine, "ACC": &Threonine, "ACA": &Threonine, "ACG": &Threonine,
"AAU": &Asparagine, "AAC": &Asparagine, "AAA": &Lysine, "AAG": &Lysine,
"AGU": &Serine, "AGC": &Serine, "AGA": &Arginine, "AGG": &Arginine,
// GUU through GGG
// TODO: Add 16 entries
"GUU": &Valine, "GUC": &Valine, "GUA": &Valine, "GUG": &Valine,
"GCU": &Alanine, "GCC": &Alanine, "GCA": &Alanine, "GCG": &Alanine,
"GAU": &AsparticAcid, "GAC": &AsparticAcid, "GAA": &GlutamicAcid, "GAG": &GlutamicAcid,
"GGU": &Glycine, "GGC": &Glycine, "GGA": &Glycine, "GGG": &Glycine,
}