Copy returns a deep copy of the translation table. This is to prevent an unintended update of data used in another process.
()
| 119 | // Copy returns a deep copy of the translation table. This is to prevent an unintended update of data used in another |
| 120 | // process. |
| 121 | func (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 |
| 163 | func (table *TranslationTable) GetWeightedAminoAcids() []AminoAcid { |