1 """Code to translate DNA or RNA into proteins (DEPRECATED).
2
3 Instead of Bio.Translate, for translation you are now encouraged to use the
4 Seq object's translate method, or the translate function in the Bio.Seq
5 module. Translate-to-stop functionality is via an optional argument.
6
7 Bio.Seq does not offer any back-translation function like the one here. It
8 was concluded that a since a simple back-translation giving a Seq or python
9 string could only capture some of the possible back translations, there were
10 no practical uses for such a method/function.
11
12 This module is now deprecated, and will be removed in a future release of
13 Biopython.
14 """
15 import warnings
16 import Bio
17 warnings.warn("Bio.Translate and Bio.Transcribe are deprecated, and will be "\
18 "removed in a future release of Biopython. Please use the "\
19 "functions or object methods defined in Bio.Seq instead "\
20 "(described in the tutorial). If you want to continue to use "\
21 "this code, please get in contact with the Biopython developers "\
22 "via the mailing lists to avoid its permanent removal from "
23 +"Biopython.", \
24 Bio.BiopythonDeprecationWarning)
25
26 from Bio import Alphabet, Seq
27 from Bio.Data import CodonTable
28
31 self.table = table
32 self._encoded = {}
33
35 return "Translator object\n" + str(self.table)
36
61
82
102
116
117 unambiguous_dna_by_name = {}
118 for key, value in CodonTable.unambiguous_dna_by_name.items():
119 unambiguous_dna_by_name[key] = Translator(value)
120 unambiguous_dna_by_id = {}
121 for key, value in CodonTable.unambiguous_dna_by_id.items():
122 unambiguous_dna_by_id[key] = Translator(value)
123
124 unambiguous_rna_by_name = {}
125 for key, value in CodonTable.unambiguous_rna_by_name.items():
126 unambiguous_rna_by_name[key] = Translator(value)
127 unambiguous_rna_by_id = {}
128 for key, value in CodonTable.unambiguous_rna_by_id.items():
129 unambiguous_rna_by_id[key] = Translator(value)
130
131
132 ambiguous_dna_by_name = {}
133 for key, value in CodonTable.ambiguous_dna_by_name.items():
134 ambiguous_dna_by_name[key] = Translator(value)
135 ambiguous_dna_by_id = {}
136 for key, value in CodonTable.ambiguous_dna_by_id.items():
137 ambiguous_dna_by_id[key] = Translator(value)
138
139 ambiguous_rna_by_name = {}
140 for key, value in CodonTable.ambiguous_rna_by_name.items():
141 ambiguous_rna_by_name[key] = Translator(value)
142 ambiguous_rna_by_id = {}
143 for key, value in CodonTable.ambiguous_rna_by_id.items():
144 ambiguous_rna_by_id[key] = Translator(value)
145