MCPcopy Create free account
hub / github.com/bebop/poly / ExampleTranslationTable_Optimize

Function ExampleTranslationTable_Optimize

synthesis/codon/example_test.go:81–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81func ExampleTranslationTable_Optimize() {
82 gfpTranslation := "MASKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTLVTTFSYGVQCFSRYPDHMKRHDFFKSAMPEGYVQERTISFKDDGNYKTRAEVKFEGDTLVNRIELKGIDFKEDGNILGHKLEYNYNSHNVYITADKQKNGIKANFKIRHNIEDGSVQLADHYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK*"
83
84 sequence, _ := genbank.Read("../../data/puc19.gbk")
85 codonTable, err := codon.NewTranslationTable(11)
86 if err != nil {
87 fmt.Printf("error running example: %s\n", err)
88 return
89 }
90
91 _ = codonTable.UpdateWeightsWithSequence(sequence)
92
93 // Here, we double check if the number of genes is equal to the number of stop codons
94 stopCodonCount := 0
95 for _, aa := range codonTable.AminoAcids {
96 if aa.Letter == "*" {
97 for _, codon := range aa.Codons {
98 stopCodonCount = stopCodonCount + codon.Weight
99 }
100 }
101 }
102
103 if stopCodonCount != codonTable.Stats.GeneCount {
104 fmt.Println("Stop codons don't equal number of genes!")
105 }
106
107 optimizedSequence, _ := codonTable.Optimize(gfpTranslation)
108 optimizedSequenceTranslation, _ := codonTable.Translate(optimizedSequence)
109
110 fmt.Println(optimizedSequenceTranslation == gfpTranslation)
111 // output: true
112}
113
114func ExampleReadCodonJSON() {
115 codontable := codon.ReadCodonJSON("../../data/bsub_codon_test.json")

Callers

nothing calls this directly

Calls 5

OptimizeMethod · 0.95
TranslateMethod · 0.95
ReadFunction · 0.92
NewTranslationTableFunction · 0.92

Tested by

no test coverage detected