1
2
3
4
5
6
7 """Miscellaneous functions for dealing with sequences (DEPRECATED).
8
9 This module is deprecated, and is expected to be removed in the next release.
10 If you use this module, please contact the Biopython developers via the
11 mailing lists.
12 """
13
14 import warnings
15 import Bio
16 warnings.warn("Bio.utils has been deprecated, and we intend to remove it in "
17 "the next release of Biopython.", Bio.BiopythonDeprecationWarning)
18
19 import Seq
20 import Alphabet
21
22 from Bio.Alphabet import _verify_alphabet as verify_alphabet
23
24 from PropertyManager import default_manager
25
27 """given a sequence with gap encoding, return the ungapped sequence"""
28
29
30 warnings.warn("Bio.utils has been deprecated, and we intend to remove it "
31 "in the next release of Biopython. Instead of function "
32 "Bio.utils.ungap please use the ungap method of the Seq "
33 "object (added in Biopython 1.53).",
34 Bio.BiopythonDeprecationWarning)
35 gap = seq.gap_char
36 letters = []
37 for c in seq:
38 if c != gap:
39 letters.append(c)
40 return Seq.Seq("".join(letters), seq.alphabet.alphabet)
41
47
49 dict2 = {}
50 seq_len = len(seq)
51 dict = count_monomers(seq)
52 for m in dict:
53 dict2[m] = dict[m] * 100. / seq_len
54 return dict2
55
56 -def sum(seq, table, zero = 0.0):
57 total = zero
58 for c in getattr(seq, "data", seq):
59 total = total + table[c]
60 return total
61
62
63 -def sum_2ple(seq, table, zero = (0.0, 0.0)):
64 x, y = zero
65 data = getattr(seq, "data", seq)
66 for c in data:
67 x2, y2 = table[c]
68 x = x + x2
69 y = y + y2
70 return (x, y)
71
76
81
83 """ given an amino-acid sequence, return it in reduced alphabet form based
84 on the letter-translation table passed. Some "standard" tables are in
85 Alphabet.Reduced.
86 seq: a Seq.Seq type sequence
87 reduction_table: a dictionary whose keys are the "from" alphabet, and values
88 are the "to" alphabet"""
89 if new_alphabet is None:
90 new_alphabet = Alphabet.single_letter_alphabet
91 new_alphabet.letters = ''
92 for letter in reduction_table:
93 new_alphabet.letters += letter
94 new_alphabet.size = len(new_alphabet.letters)
95 new_seq = Seq.Seq('',new_alphabet)
96 for letter in seq:
97 new_seq += reduction_table[letter]
98 return new_seq
99