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

Method Copy

synthesis/codon/codon.go:121–160  ·  view source on GitHub ↗

Copy returns a deep copy of the translation table. This is to prevent an unintended update of data used in another process.

()

Source from the content-addressed store, hash-verified

119// Copy returns a deep copy of the translation table. This is to prevent an unintended update of data used in another
120// process.
121func (table *TranslationTable) Copy() (*TranslationTable, error) {
122 newTranslationMap := map[string]string{}
123 newStartCodonTable := map[string]string{}
124
125 for k, v := range table.TranslationMap {
126 newTranslationMap[k] = v
127 }
128
129 for k, v := range table.StartCodonTable {
130 newStartCodonTable[k] = v
131 }
132
133 newAAs := []AminoAcid{}
134 for _, v := range table.AminoAcids {
135 newAAs = append(newAAs, AminoAcid{
136 Letter: "",
137 Codons: append([]Codon{}, v.Codons...),
138 })
139 }
140
141 newChoosers, err := newAminoAcidChoosers(newAAs)
142 if err != nil {
143 return nil, err
144 }
145
146 return &TranslationTable{
147 StartCodons: append([]string{}, table.StartCodons...),
148 StopCodons: append([]string{}, table.StopCodons...),
149 AminoAcids: append([]AminoAcid{}, table.AminoAcids...),
150
151 TranslationMap: newTranslationMap,
152 StartCodonTable: newStartCodonTable,
153 Choosers: newChoosers,
154
155 Stats: &Stats{
156 StartCodonCount: table.Stats.StartCodonCount,
157 GeneCount: table.Stats.GeneCount,
158 },
159 }, nil
160}
161
162// GetWeightedAminoAcids returns the amino acids along with their associated codon weights
163func (table *TranslationTable) GetWeightedAminoAcids() []AminoAcid {

Callers 4

TestCopyFunction · 0.95
CompromiseCodonTableFunction · 0.80
AddCodonTableFunction · 0.80
TestPrintLFDebugFunction · 0.80

Calls 1

newAminoAcidChoosersFunction · 0.85

Tested by 2

TestCopyFunction · 0.76
TestPrintLFDebugFunction · 0.64