biotite 0.41.1__cp310-cp310-win_amd64.whl → 1.0.0__cp310-cp310-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of biotite might be problematic. Click here for more details.

Files changed (205) hide show
  1. biotite/__init__.py +2 -3
  2. biotite/application/__init__.py +36 -10
  3. biotite/application/application.py +22 -11
  4. biotite/application/autodock/__init__.py +1 -1
  5. biotite/application/autodock/app.py +74 -79
  6. biotite/application/blast/__init__.py +1 -1
  7. biotite/application/blast/alignment.py +19 -10
  8. biotite/application/blast/webapp.py +92 -85
  9. biotite/application/clustalo/__init__.py +1 -1
  10. biotite/application/clustalo/app.py +46 -61
  11. biotite/application/dssp/__init__.py +1 -1
  12. biotite/application/dssp/app.py +8 -11
  13. biotite/application/localapp.py +62 -60
  14. biotite/application/mafft/__init__.py +1 -1
  15. biotite/application/mafft/app.py +16 -22
  16. biotite/application/msaapp.py +78 -89
  17. biotite/application/muscle/__init__.py +1 -1
  18. biotite/application/muscle/app3.py +50 -64
  19. biotite/application/muscle/app5.py +23 -31
  20. biotite/application/sra/__init__.py +1 -1
  21. biotite/application/sra/app.py +64 -68
  22. biotite/application/tantan/__init__.py +1 -1
  23. biotite/application/tantan/app.py +22 -45
  24. biotite/application/util.py +7 -9
  25. biotite/application/viennarna/rnaalifold.py +34 -28
  26. biotite/application/viennarna/rnafold.py +24 -39
  27. biotite/application/viennarna/rnaplot.py +36 -21
  28. biotite/application/viennarna/util.py +17 -12
  29. biotite/application/webapp.py +13 -14
  30. biotite/copyable.py +13 -13
  31. biotite/database/__init__.py +1 -1
  32. biotite/database/entrez/__init__.py +1 -1
  33. biotite/database/entrez/check.py +2 -3
  34. biotite/database/entrez/dbnames.py +7 -5
  35. biotite/database/entrez/download.py +55 -49
  36. biotite/database/entrez/key.py +1 -1
  37. biotite/database/entrez/query.py +62 -23
  38. biotite/database/error.py +2 -1
  39. biotite/database/pubchem/__init__.py +1 -1
  40. biotite/database/pubchem/download.py +43 -45
  41. biotite/database/pubchem/error.py +2 -2
  42. biotite/database/pubchem/query.py +34 -31
  43. biotite/database/pubchem/throttle.py +3 -4
  44. biotite/database/rcsb/__init__.py +1 -1
  45. biotite/database/rcsb/download.py +44 -52
  46. biotite/database/rcsb/query.py +85 -80
  47. biotite/database/uniprot/check.py +6 -3
  48. biotite/database/uniprot/download.py +6 -11
  49. biotite/database/uniprot/query.py +115 -31
  50. biotite/file.py +12 -31
  51. biotite/sequence/__init__.py +16 -5
  52. biotite/sequence/align/__init__.py +160 -6
  53. biotite/sequence/align/alignment.py +99 -90
  54. biotite/sequence/align/banded.cp310-win_amd64.pyd +0 -0
  55. biotite/sequence/align/buckets.py +12 -10
  56. biotite/sequence/align/cigar.py +43 -52
  57. biotite/sequence/align/kmeralphabet.cp310-win_amd64.pyd +0 -0
  58. biotite/sequence/align/kmeralphabet.pyx +55 -51
  59. biotite/sequence/align/kmersimilarity.cp310-win_amd64.pyd +0 -0
  60. biotite/sequence/align/kmertable.cp310-win_amd64.pyd +0 -0
  61. biotite/sequence/align/kmertable.pyx +3 -2
  62. biotite/sequence/align/localgapped.cp310-win_amd64.pyd +0 -0
  63. biotite/sequence/align/localungapped.cp310-win_amd64.pyd +0 -0
  64. biotite/sequence/align/matrix.py +81 -82
  65. biotite/sequence/align/multiple.cp310-win_amd64.pyd +0 -0
  66. biotite/sequence/align/multiple.pyx +35 -35
  67. biotite/sequence/align/pairwise.cp310-win_amd64.pyd +0 -0
  68. biotite/sequence/align/permutation.cp310-win_amd64.pyd +0 -0
  69. biotite/sequence/align/permutation.pyx +12 -4
  70. biotite/sequence/align/selector.cp310-win_amd64.pyd +0 -0
  71. biotite/sequence/align/selector.pyx +52 -54
  72. biotite/sequence/align/statistics.py +32 -33
  73. biotite/sequence/align/tracetable.cp310-win_amd64.pyd +0 -0
  74. biotite/sequence/alphabet.py +112 -126
  75. biotite/sequence/annotation.py +78 -77
  76. biotite/sequence/codec.cp310-win_amd64.pyd +0 -0
  77. biotite/sequence/codon.py +90 -79
  78. biotite/sequence/graphics/__init__.py +1 -1
  79. biotite/sequence/graphics/alignment.py +184 -103
  80. biotite/sequence/graphics/colorschemes.py +10 -12
  81. biotite/sequence/graphics/dendrogram.py +79 -34
  82. biotite/sequence/graphics/features.py +133 -99
  83. biotite/sequence/graphics/logo.py +22 -28
  84. biotite/sequence/graphics/plasmid.py +229 -178
  85. biotite/sequence/io/fasta/__init__.py +1 -1
  86. biotite/sequence/io/fasta/convert.py +44 -33
  87. biotite/sequence/io/fasta/file.py +42 -55
  88. biotite/sequence/io/fastq/__init__.py +1 -1
  89. biotite/sequence/io/fastq/convert.py +11 -14
  90. biotite/sequence/io/fastq/file.py +68 -112
  91. biotite/sequence/io/genbank/__init__.py +2 -2
  92. biotite/sequence/io/genbank/annotation.py +12 -20
  93. biotite/sequence/io/genbank/file.py +74 -76
  94. biotite/sequence/io/genbank/metadata.py +74 -62
  95. biotite/sequence/io/genbank/sequence.py +13 -14
  96. biotite/sequence/io/general.py +39 -30
  97. biotite/sequence/io/gff/__init__.py +2 -2
  98. biotite/sequence/io/gff/convert.py +10 -15
  99. biotite/sequence/io/gff/file.py +81 -65
  100. biotite/sequence/phylo/__init__.py +1 -1
  101. biotite/sequence/phylo/nj.cp310-win_amd64.pyd +0 -0
  102. biotite/sequence/phylo/tree.cp310-win_amd64.pyd +0 -0
  103. biotite/sequence/phylo/upgma.cp310-win_amd64.pyd +0 -0
  104. biotite/sequence/profile.py +57 -28
  105. biotite/sequence/search.py +17 -15
  106. biotite/sequence/seqtypes.py +200 -164
  107. biotite/sequence/sequence.py +64 -64
  108. biotite/structure/__init__.py +3 -3
  109. biotite/structure/atoms.py +226 -240
  110. biotite/structure/basepairs.py +260 -271
  111. biotite/structure/bonds.cp310-win_amd64.pyd +0 -0
  112. biotite/structure/bonds.pyx +88 -100
  113. biotite/structure/box.py +67 -71
  114. biotite/structure/celllist.cp310-win_amd64.pyd +0 -0
  115. biotite/structure/chains.py +55 -39
  116. biotite/structure/charges.cp310-win_amd64.pyd +0 -0
  117. biotite/structure/compare.py +32 -32
  118. biotite/structure/density.py +13 -18
  119. biotite/structure/dotbracket.py +20 -22
  120. biotite/structure/error.py +10 -2
  121. biotite/structure/filter.py +82 -77
  122. biotite/structure/geometry.py +130 -119
  123. biotite/structure/graphics/atoms.py +60 -43
  124. biotite/structure/graphics/rna.py +81 -68
  125. biotite/structure/hbond.py +112 -93
  126. biotite/structure/info/__init__.py +0 -2
  127. biotite/structure/info/atoms.py +10 -11
  128. biotite/structure/info/bonds.py +41 -43
  129. biotite/structure/info/ccd.py +21 -7
  130. biotite/structure/info/groups.py +10 -15
  131. biotite/structure/info/masses.py +5 -10
  132. biotite/structure/info/misc.py +1 -1
  133. biotite/structure/info/radii.py +20 -20
  134. biotite/structure/info/standardize.py +15 -26
  135. biotite/structure/integrity.py +18 -71
  136. biotite/structure/io/__init__.py +3 -4
  137. biotite/structure/io/dcd/__init__.py +1 -1
  138. biotite/structure/io/dcd/file.py +22 -20
  139. biotite/structure/io/general.py +47 -61
  140. biotite/structure/io/gro/__init__.py +1 -1
  141. biotite/structure/io/gro/file.py +73 -72
  142. biotite/structure/io/mol/__init__.py +1 -1
  143. biotite/structure/io/mol/convert.py +8 -11
  144. biotite/structure/io/mol/ctab.py +37 -36
  145. biotite/structure/io/mol/header.py +14 -10
  146. biotite/structure/io/mol/mol.py +9 -53
  147. biotite/structure/io/mol/sdf.py +47 -50
  148. biotite/structure/io/netcdf/__init__.py +1 -1
  149. biotite/structure/io/netcdf/file.py +24 -23
  150. biotite/structure/io/pdb/__init__.py +1 -1
  151. biotite/structure/io/pdb/convert.py +32 -20
  152. biotite/structure/io/pdb/file.py +151 -172
  153. biotite/structure/io/pdb/hybrid36.cp310-win_amd64.pyd +0 -0
  154. biotite/structure/io/pdbqt/__init__.py +1 -1
  155. biotite/structure/io/pdbqt/convert.py +17 -11
  156. biotite/structure/io/pdbqt/file.py +128 -80
  157. biotite/structure/io/pdbx/__init__.py +1 -2
  158. biotite/structure/io/pdbx/bcif.py +36 -52
  159. biotite/structure/io/pdbx/cif.py +64 -62
  160. biotite/structure/io/pdbx/component.py +10 -16
  161. biotite/structure/io/pdbx/convert.py +235 -246
  162. biotite/structure/io/pdbx/encoding.cp310-win_amd64.pyd +0 -0
  163. biotite/structure/io/trajfile.py +76 -93
  164. biotite/structure/io/trr/__init__.py +1 -1
  165. biotite/structure/io/trr/file.py +12 -15
  166. biotite/structure/io/xtc/__init__.py +1 -1
  167. biotite/structure/io/xtc/file.py +11 -14
  168. biotite/structure/mechanics.py +9 -11
  169. biotite/structure/molecules.py +3 -4
  170. biotite/structure/pseudoknots.py +53 -67
  171. biotite/structure/rdf.py +23 -21
  172. biotite/structure/repair.py +137 -86
  173. biotite/structure/residues.py +26 -16
  174. biotite/structure/sasa.cp310-win_amd64.pyd +0 -0
  175. biotite/structure/{resutil.py → segments.py} +24 -23
  176. biotite/structure/sequence.py +10 -11
  177. biotite/structure/sse.py +100 -119
  178. biotite/structure/superimpose.py +39 -77
  179. biotite/structure/transform.py +97 -71
  180. biotite/structure/util.py +11 -13
  181. biotite/version.py +2 -2
  182. biotite/visualize.py +69 -55
  183. {biotite-0.41.1.dist-info → biotite-1.0.0.dist-info}/METADATA +6 -6
  184. biotite-1.0.0.dist-info/RECORD +322 -0
  185. {biotite-0.41.1.dist-info → biotite-1.0.0.dist-info}/WHEEL +1 -1
  186. biotite/structure/io/ctab.py +0 -72
  187. biotite/structure/io/mmtf/__init__.py +0 -21
  188. biotite/structure/io/mmtf/assembly.py +0 -214
  189. biotite/structure/io/mmtf/convertarray.cp310-win_amd64.pyd +0 -0
  190. biotite/structure/io/mmtf/convertarray.pyx +0 -341
  191. biotite/structure/io/mmtf/convertfile.cp310-win_amd64.pyd +0 -0
  192. biotite/structure/io/mmtf/convertfile.pyx +0 -501
  193. biotite/structure/io/mmtf/decode.cp310-win_amd64.pyd +0 -0
  194. biotite/structure/io/mmtf/decode.pyx +0 -152
  195. biotite/structure/io/mmtf/encode.cp310-win_amd64.pyd +0 -0
  196. biotite/structure/io/mmtf/encode.pyx +0 -183
  197. biotite/structure/io/mmtf/file.py +0 -233
  198. biotite/structure/io/npz/__init__.py +0 -20
  199. biotite/structure/io/npz/file.py +0 -152
  200. biotite/structure/io/pdbx/legacy.py +0 -267
  201. biotite/structure/io/tng/__init__.py +0 -13
  202. biotite/structure/io/tng/file.py +0 -46
  203. biotite/temp.py +0 -86
  204. biotite-0.41.1.dist-info/RECORD +0 -340
  205. {biotite-0.41.1.dist-info → biotite-1.0.0.dist-info}/licenses/LICENSE.rst +0 -0
biotite/sequence/codon.py CHANGED
@@ -7,11 +7,10 @@ __author__ = "Patrick Kunzmann"
7
7
  __all__ = ["CodonTable"]
8
8
 
9
9
  import copy
10
- from os.path import join, dirname, realpath
11
- import numpy as np
12
10
  from numbers import Integral
13
- from .seqtypes import NucleotideSequence, ProteinSequence
14
-
11
+ from os.path import dirname, join, realpath
12
+ import numpy as np
13
+ from biotite.sequence.seqtypes import NucleotideSequence, ProteinSequence
15
14
 
16
15
  # Abbreviations
17
16
  _NUC_ALPH = NucleotideSequence.alphabet_unamb
@@ -20,7 +19,7 @@ _PROT_ALPH = ProteinSequence.alphabet
20
19
  # Multiplier array that converts a codon in code representation
21
20
  # into a unique integer
22
21
  _radix = len(_NUC_ALPH)
23
- _radix_multiplier = np.array([_radix**n for n in (2,1,0)], dtype=int)
22
+ _radix_multiplier = np.array([_radix**n for n in (2, 1, 0)], dtype=int)
24
23
 
25
24
 
26
25
  class CodonTable(object):
@@ -29,14 +28,14 @@ class CodonTable(object):
29
28
  amino acid.
30
29
  It also defines start codons. A :class:`CodonTable`
31
30
  takes/outputs either the symbols or code of the codon/amino acid.
32
-
31
+
33
32
  Furthermore, this class is able to give a list of codons that
34
33
  corresponds to a given amino acid.
35
-
34
+
36
35
  The :func:`load()` method allows loading of NCBI codon tables.
37
-
36
+
38
37
  Objects of this class are immutable.
39
-
38
+
40
39
  Parameters
41
40
  ----------
42
41
  codon_dict : dict of (str -> str)
@@ -47,27 +46,27 @@ class CodonTable(object):
47
46
  starts : iterable object of str
48
47
  The start codons. Each entry must be a string of length 3
49
48
  (all upper case).
50
-
49
+
51
50
  Examples
52
51
  --------
53
-
52
+
54
53
  Get the amino acid coded by a given codon (symbol and code):
55
-
54
+
56
55
  >>> table = CodonTable.default_table()
57
56
  >>> print(table["ATG"])
58
57
  M
59
58
  >>> print(table[(1,2,3)])
60
59
  14
61
-
60
+
62
61
  Get the codons coding for a given amino acid (symbol and code):
63
-
62
+
64
63
  >>> table = CodonTable.default_table()
65
64
  >>> print(table["M"])
66
65
  ('ATG',)
67
66
  >>> print(table[14])
68
67
  ((0, 2, 0), (0, 2, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2), (1, 2, 3))
69
68
  """
70
-
69
+
71
70
  # For efficient mapping of codon codes to amino acid codes,
72
71
  # especially in in the 'map_codon_codes()' function, the class
73
72
  # maps each possible codon into a unique number using a radix based
@@ -77,7 +76,7 @@ class CodonTable(object):
77
76
 
78
77
  # file for builtin codon tables from NCBI
79
78
  _table_file = join(dirname(realpath(__file__)), "codon_tables.txt")
80
-
79
+
81
80
  def __init__(self, codon_dict, starts):
82
81
  # Check if 'starts' is iterable object of length 3 string
83
82
  for start in starts:
@@ -100,12 +99,10 @@ class CodonTable(object):
100
99
  if (self._codons == -1).any():
101
100
  # Find the missing codon
102
101
  missing_index = np.where(self._codons == -1)[0][0]
103
- codon_code = CodonTable._to_codon(missing_index)
102
+ codon_code = CodonTable._to_codon(missing_index)
104
103
  codon = _NUC_ALPH.decode_multiple(codon_code)
105
104
  codon_str = "".join(codon)
106
- raise ValueError(
107
- f"Codon dictionary does not contain codon '{codon_str}'"
108
- )
105
+ raise ValueError(f"Codon dictionary does not contain codon '{codon_str}'")
109
106
 
110
107
  def __repr__(self):
111
108
  """Represent CodonTable as a string for debugging."""
@@ -131,8 +128,10 @@ class CodonTable(object):
131
128
  codon_numbers = np.where(self._codons == aa_code)[0]
132
129
  codon_codes = CodonTable._to_codon(codon_numbers)
133
130
  codons = tuple(
134
- ["".join(_NUC_ALPH.decode_multiple(codon_code))
135
- for codon_code in codon_codes]
131
+ [
132
+ "".join(_NUC_ALPH.decode_multiple(codon_code))
133
+ for codon_code in codon_codes
134
+ ]
136
135
  )
137
136
  return codons
138
137
  elif len(item) == 3:
@@ -147,37 +146,36 @@ class CodonTable(object):
147
146
  elif isinstance(item, int):
148
147
  # Code for amino acid -> return possible codon codes
149
148
  codon_numbers = np.where(self._codons == item)[0]
150
- codon_codes = tuple(CodonTable._to_codon(codon_numbers))
151
- codon_codes = tuple([tuple(code) for code in codon_codes])
149
+ codon_codes = tuple(
150
+ [tuple(code.tolist()) for code in CodonTable._to_codon(codon_numbers)]
151
+ )
152
152
  return codon_codes
153
153
  else:
154
154
  # Code for codon as any iterable object
155
155
  # Code for codon -> return corresponding amino acid codes
156
156
  if len(item) != 3:
157
- raise ValueError(
158
- f"{item} is an invalid sequence code for a codon"
159
- )
157
+ raise ValueError(f"{item} is an invalid sequence code for a codon")
160
158
  codon_number = CodonTable._to_number(item)
161
159
  aa_code = self._codons[codon_number]
162
160
  return aa_code
163
-
161
+
164
162
  def map_codon_codes(self, codon_codes):
165
163
  """
166
164
  Efficiently map multiple codons to the corresponding amino
167
165
  acids.
168
-
166
+
169
167
  Parameters
170
168
  ----------
171
169
  codon_codes : ndarray, dtype=int, shape=(n,3)
172
170
  The codons to be translated into amino acids.
173
171
  The codons are given as symbol codes.
174
172
  *n* is the amount of codons.
175
-
173
+
176
174
  Returns
177
175
  -------
178
176
  aa_codes : ndarray, dtype=int, shape=(n,)
179
177
  The amino acids as symbol codes.
180
-
178
+
181
179
  Examples
182
180
  --------
183
181
  >>> dna = NucleotideSequence("ATGGTTTAA")
@@ -208,46 +206,50 @@ class CodonTable(object):
208
206
  codon_numbers = CodonTable._to_number(codon_codes)
209
207
  aa_codes = self._codons[codon_numbers]
210
208
  return aa_codes
211
-
209
+
212
210
  def codon_dict(self, code=False):
213
211
  """
214
212
  Get the codon to amino acid mappings dictionary.
215
-
213
+
216
214
  Parameters
217
215
  ----------
218
216
  code : bool
219
217
  If true, the dictionary contains keys and values as code.
220
218
  Otherwise, the dictionary contains strings for codons and
221
219
  amino acid. (Default: False)
222
-
220
+
223
221
  Returns
224
222
  -------
225
223
  codon_dict : dict
226
224
  The dictionary mapping codons to amino acids.
227
225
  """
228
226
  if code:
229
- return {tuple(CodonTable._to_codon(codon_number)): aa_code
230
- for codon_number, aa_code in enumerate(self._codons)}
227
+ return {
228
+ tuple(CodonTable._to_codon(codon_number)): aa_code
229
+ for codon_number, aa_code in enumerate(self._codons)
230
+ }
231
231
  else:
232
- return {"".join(_NUC_ALPH.decode_multiple(codon_code)):
233
- _PROT_ALPH.decode(aa_code)
234
- for codon_code, aa_code
235
- in self.codon_dict(code=True).items()}
236
-
232
+ return {
233
+ "".join(_NUC_ALPH.decode_multiple(codon_code)): _PROT_ALPH.decode(
234
+ aa_code
235
+ )
236
+ for codon_code, aa_code in self.codon_dict(code=True).items()
237
+ }
238
+
237
239
  def is_start_codon(self, codon_codes):
238
240
  codon_numbers = CodonTable._to_number(codon_codes)
239
241
  return np.isin(codon_numbers, self._starts)
240
-
242
+
241
243
  def start_codons(self, code=False):
242
244
  """
243
245
  Get the start codons of the codon table.
244
-
246
+
245
247
  Parameters
246
248
  ----------
247
249
  code : bool
248
250
  If true, the code will be returned instead of strings.
249
251
  (Default: False)
250
-
252
+
251
253
  Returns
252
254
  -------
253
255
  start_codons : tuple
@@ -256,25 +258,29 @@ class CodonTable(object):
256
258
  """
257
259
  if code:
258
260
  return tuple(
259
- [tuple(CodonTable._to_codon(codon_number))
260
- for codon_number in self._starts]
261
+ [
262
+ tuple(CodonTable._to_codon(codon_number))
263
+ for codon_number in self._starts
264
+ ]
261
265
  )
262
266
  else:
263
267
  return tuple(
264
- ["".join(_NUC_ALPH.decode_multiple(codon_code))
265
- for codon_code in self.start_codons(code=True)]
268
+ [
269
+ "".join(_NUC_ALPH.decode_multiple(codon_code))
270
+ for codon_code in self.start_codons(code=True)
271
+ ]
266
272
  )
267
-
273
+
268
274
  def with_start_codons(self, starts):
269
275
  """
270
276
  Create an new :class:`CodonTable` with the same codon mappings,
271
277
  but changed start codons.
272
-
278
+
273
279
  Parameters
274
280
  ----------
275
281
  starts : iterable object of str
276
282
  The new start codons.
277
-
283
+
278
284
  Returns
279
285
  -------
280
286
  new_table : CodonTable
@@ -287,17 +293,17 @@ class CodonTable(object):
287
293
  )
288
294
  new_table._starts = CodonTable._to_number(start_codon_codes)
289
295
  return new_table
290
-
296
+
291
297
  def with_codon_mappings(self, codon_dict):
292
298
  """
293
299
  Create an new :class:`CodonTable` with partially changed codon
294
300
  mappings.
295
-
301
+
296
302
  Parameters
297
303
  ----------
298
304
  codon_dict : dict of (str -> str)
299
305
  The changed codon mappings.
300
-
306
+
301
307
  Returns
302
308
  -------
303
309
  new_table : CodonTable
@@ -328,9 +334,9 @@ class CodonTable(object):
328
334
  else:
329
335
  string += " "
330
336
  # Add space for next codon
331
- string += " "*3
337
+ string += " " * 3
332
338
  # Remove terminal space
333
- string = string [:-6]
339
+ string = string[:-6]
334
340
  # Jump to next line
335
341
  string += "\n"
336
342
  # Add empty line
@@ -353,10 +359,10 @@ class CodonTable(object):
353
359
  if not isinstance(numbers, np.ndarray):
354
360
  numbers = np.array(list(numbers), dtype=int)
355
361
  codons = np.zeros(numbers.shape + (3,), dtype=int)
356
- for n in (2,1,0):
362
+ for n in (2, 1, 0):
357
363
  val = _radix**n
358
364
  digit = numbers // val
359
- codons[..., -(n+1)] = digit
365
+ codons[..., -(n + 1)] = digit
360
366
  numbers = numbers - digit * val
361
367
  return codons
362
368
 
@@ -364,14 +370,14 @@ class CodonTable(object):
364
370
  def load(table_name):
365
371
  """
366
372
  Load a NCBI codon table.
367
-
373
+
368
374
  Parameters
369
375
  ----------
370
376
  table_name : str or int
371
377
  If a string is given, it is interpreted as official NCBI
372
378
  codon table name (e.g. "Vertebrate Mitochondrial").
373
379
  An integer is interpreted as NCBI codon table ID.
374
-
380
+
375
381
  Returns
376
382
  -------
377
383
  table : CodonTable
@@ -380,7 +386,7 @@ class CodonTable(object):
380
386
  # Loads codon tables from codon_tables.txt
381
387
  with open(CodonTable._table_file, "r") as f:
382
388
  lines = f.read().split("\n")
383
-
389
+
384
390
  # Extract data for codon table from file
385
391
  table_found = False
386
392
  aa = None
@@ -391,11 +397,11 @@ class CodonTable(object):
391
397
  for line in lines:
392
398
  if not line:
393
399
  table_found = False
394
- if type(table_name) == int and line.startswith("id"):
400
+ if isinstance(table_name, Integral) and line.startswith("id"):
395
401
  # remove identifier 'id'
396
402
  if table_name == int(line[2:]):
397
403
  table_found = True
398
- elif type(table_name) == str and line.startswith("name"):
404
+ elif isinstance(table_name, str) and line.startswith("name"):
399
405
  # Get list of table names from lines
400
406
  # (separated with ';')
401
407
  # remove identifier 'name'
@@ -404,7 +410,7 @@ class CodonTable(object):
404
410
  table_found = True
405
411
  if table_found:
406
412
  if line.startswith("AA"):
407
- #Remove identifier
413
+ # Remove identifier
408
414
  aa = line[5:].strip()
409
415
  elif line.startswith("Init"):
410
416
  init = line[5:].strip()
@@ -414,19 +420,24 @@ class CodonTable(object):
414
420
  base2 = line[5:].strip()
415
421
  elif line.startswith("Base3"):
416
422
  base3 = line[5:].strip()
417
-
423
+
418
424
  # Create codon table from data
419
- if aa is not None and init is not None \
420
- and base1 is not None and base2 is not None and base3 is not None:
421
- symbol_dict = {}
422
- starts = []
423
- # aa, init and baseX all have the same length
424
- for i in range(len(aa)):
425
- codon = base1[i] + base2[i] + base3[i]
426
- if init[i] == "i":
427
- starts.append(codon)
428
- symbol_dict[codon] = aa[i]
429
- return CodonTable(symbol_dict, starts)
425
+ if (
426
+ aa is not None
427
+ and init is not None
428
+ and base1 is not None
429
+ and base2 is not None
430
+ and base3 is not None
431
+ ):
432
+ symbol_dict = {}
433
+ starts = []
434
+ # aa, init and baseX all have the same length
435
+ for i in range(len(aa)):
436
+ codon = base1[i] + base2[i] + base3[i]
437
+ if init[i] == "i":
438
+ starts.append(codon)
439
+ symbol_dict[codon] = aa[i]
440
+ return CodonTable(symbol_dict, starts)
430
441
  else:
431
442
  raise ValueError(f"Codon table '{table_name}' was not found")
432
443
 
@@ -434,7 +445,7 @@ class CodonTable(object):
434
445
  def table_names():
435
446
  """
436
447
  The possible codon table names for :func:`load()`.
437
-
448
+
438
449
  Returns
439
450
  -------
440
451
  names : list of str
@@ -447,14 +458,14 @@ class CodonTable(object):
447
458
  if line.startswith("name"):
448
459
  names.extend([name.strip() for name in line[4:].split(";")])
449
460
  return names
450
-
461
+
451
462
  @staticmethod
452
463
  def default_table():
453
464
  """
454
465
  The default codon table.
455
466
  The table is equal to the NCBI "Standard" codon table,
456
467
  with the difference that only "ATG" is a start codon.
457
-
468
+
458
469
  Returns
459
470
  -------
460
471
  table : CodonTable
@@ -29,5 +29,5 @@ from .alignment import *
29
29
  from .colorschemes import *
30
30
  from .dendrogram import *
31
31
  from .features import *
32
- from .plasmid import *
33
32
  from .logo import *
33
+ from .plasmid import *