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