1
2
3
4
5
6
7 """Miscellaneous functions for dealing with sequences (obsolete?)."""
8
9 import string
10 import Seq
11 import Alphabet
12
13 from PropertyManager import default_manager
14
16 """Translate a sequence (DEPRECATED)."""
17 import warnings
18 warnings.warn("Bio.utils.translate() has been deprecated, and we" \
19 +" intend to remove it in a future release of Biopython."\
20 +" Please use the translate method or function in Bio.Seq"\
21 +" instead, as described in the Tutorial.",
22 DeprecationWarning)
23 if id is None:
24 s = "translator"
25 else:
26 s = "translator.id.%d" % id
27 translator = default_manager.resolve(seq.alphabet, s)
28 return translator.translate(seq)
29
31 """Translate a sequence up to the first in frame stop codon (DEPRECATED)."""
32 import warnings
33 warnings.warn("Bio.utils.translate_to_stop() has been deprecated, and we" \
34 +" intend to remove it in a future release of Biopython."\
35 +" Please use the translate method or function in Bio.Seq"\
36 +" instead, as described in the Tutorial.",
37 DeprecationWarning)
38 if id is None:
39 s = "translator"
40 else:
41 s = "translator.id.%d" % id
42 translator = default_manager.resolve(seq.alphabet, s)
43 return translator.translate_to_stop(seq)
44
46 """Back-translate a sequence (DEPRECATED)."""
47 import warnings
48 warnings.warn("Bio.utils.back_translate() has been deprecated, and we" \
49 +" intend to remove it in a future release of Biopython."\
50 +" If you use it, please tell us on the mailing list.",
51 DeprecationWarning)
52 if id is None:
53 s = "translator"
54 else:
55 s = "translator.id.%d" % id
56 translator = default_manager.resolve(seq.alphabet, s)
57 return translator.back_translate(seq)
58
59
61 """Transcribe a sequence (DEPRECATED)."""
62 import warnings
63 warnings.warn("Bio.utils.transcribe() has been deprecated, and we" \
64 +" intend to remove it in a future release of Biopython."\
65 +" Please use the transcribe method or function in"\
66 +" Bio.Seq instead, as described in the Tutorial.",
67 DeprecationWarning)
68 transcriber = default_manager.resolve(seq.alphabet, "transcriber")
69 return transcriber.transcribe(seq)
70
72 """Back-transcribe a sequence (DEPRECATED)."""
73 import warnings
74 warnings.warn("Bio.utils.back_transcribe() has been deprecated, and we" \
75 +" intend to remove it in a future release of Biopython."\
76 +" Please use the back_transcribe method or function in"\
77 +" Bio.Seq instead, as described in the Tutorial.",
78 DeprecationWarning)
79 transcriber = default_manager.resolve(seq.alphabet, "transcriber")
80 return transcriber.back_transcribe(seq)
81
92
103
111
113 dict2 = {}
114 seq_len = len(seq)
115 dict = count_monomers(seq)
116 for m in dict:
117 dict2[m] = dict[m] * 100. / seq_len
118 return dict2
119
120 -def sum(seq, table, zero = 0.0):
121 total = zero
122 for c in getattr(seq, "data", seq):
123 total = total + table[c]
124 return total
125
126
127 -def sum_2ple(seq, table, zero = (0.0, 0.0)):
128 x, y = zero
129 data = getattr(seq, "data", seq)
130 for c in data:
131 x2, y2 = table[c]
132 x = x + x2
133 y = y + y2
134 return (x, y)
135
140
145
147 """ given an amino-acid sequence, return it in reduced alphabet form based
148 on the letter-translation table passed. Some "standard" tables are in
149 Alphabet.Reduced.
150 seq: a Seq.Seq type sequence
151 reduction_table: a dictionary whose keys are the "from" alphabet, and values
152 are the "to" alphabet"""
153 if new_alphabet is None:
154 new_alphabet = Alphabet.single_letter_alphabet
155 new_alphabet.letters = ''
156 for letter in reduction_table:
157 new_alphabet.letters += letter
158 new_alphabet.size = len(new_alphabet.letters)
159 new_seq = Seq.Seq('',new_alphabet)
160 for letter in seq:
161 new_seq += reduction_table[letter]
162 return new_seq
163