biotite 0.41.2__cp310-cp310-macosx_11_0_arm64.whl → 1.0.0__cp310-cp310-macosx_11_0_arm64.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 +1 -1
  3. biotite/application/application.py +20 -10
  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 +3 -3
  52. biotite/sequence/align/__init__.py +2 -2
  53. biotite/sequence/align/alignment.py +99 -90
  54. biotite/sequence/align/banded.cpython-310-darwin.so +0 -0
  55. biotite/sequence/align/buckets.py +12 -10
  56. biotite/sequence/align/cigar.py +43 -52
  57. biotite/sequence/align/kmeralphabet.cpython-310-darwin.so +0 -0
  58. biotite/sequence/align/kmeralphabet.pyx +55 -51
  59. biotite/sequence/align/kmersimilarity.cpython-310-darwin.so +0 -0
  60. biotite/sequence/align/kmertable.cpython-310-darwin.so +0 -0
  61. biotite/sequence/align/kmertable.pyx +3 -2
  62. biotite/sequence/align/localgapped.cpython-310-darwin.so +0 -0
  63. biotite/sequence/align/localungapped.cpython-310-darwin.so +0 -0
  64. biotite/sequence/align/matrix.py +81 -82
  65. biotite/sequence/align/multiple.cpython-310-darwin.so +0 -0
  66. biotite/sequence/align/multiple.pyx +1 -1
  67. biotite/sequence/align/pairwise.cpython-310-darwin.so +0 -0
  68. biotite/sequence/align/permutation.cpython-310-darwin.so +0 -0
  69. biotite/sequence/align/permutation.pyx +12 -4
  70. biotite/sequence/align/selector.cpython-310-darwin.so +0 -0
  71. biotite/sequence/align/selector.pyx +52 -54
  72. biotite/sequence/align/statistics.py +32 -33
  73. biotite/sequence/align/tracetable.cpython-310-darwin.so +0 -0
  74. biotite/sequence/alphabet.py +51 -65
  75. biotite/sequence/annotation.py +78 -77
  76. biotite/sequence/codec.cpython-310-darwin.so +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.cpython-310-darwin.so +0 -0
  102. biotite/sequence/phylo/tree.cpython-310-darwin.so +0 -0
  103. biotite/sequence/phylo/upgma.cpython-310-darwin.so +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 +15 -17
  108. biotite/structure/__init__.py +3 -3
  109. biotite/structure/atoms.py +221 -235
  110. biotite/structure/basepairs.py +260 -271
  111. biotite/structure/bonds.cpython-310-darwin.so +0 -0
  112. biotite/structure/bonds.pyx +29 -32
  113. biotite/structure/box.py +67 -71
  114. biotite/structure/celllist.cpython-310-darwin.so +0 -0
  115. biotite/structure/chains.py +55 -39
  116. biotite/structure/charges.cpython-310-darwin.so +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 +4 -5
  130. biotite/structure/info/groups.py +1 -3
  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.cpython-310-darwin.so +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 -44
  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.cpython-310-darwin.so +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.cpython-310-darwin.so +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.2.dist-info → biotite-1.0.0.dist-info}/METADATA +5 -5
  184. biotite-1.0.0.dist-info/RECORD +322 -0
  185. biotite/structure/io/ctab.py +0 -72
  186. biotite/structure/io/mmtf/__init__.py +0 -21
  187. biotite/structure/io/mmtf/assembly.py +0 -214
  188. biotite/structure/io/mmtf/convertarray.cpython-310-darwin.so +0 -0
  189. biotite/structure/io/mmtf/convertarray.pyx +0 -341
  190. biotite/structure/io/mmtf/convertfile.cpython-310-darwin.so +0 -0
  191. biotite/structure/io/mmtf/convertfile.pyx +0 -501
  192. biotite/structure/io/mmtf/decode.cpython-310-darwin.so +0 -0
  193. biotite/structure/io/mmtf/decode.pyx +0 -152
  194. biotite/structure/io/mmtf/encode.cpython-310-darwin.so +0 -0
  195. biotite/structure/io/mmtf/encode.pyx +0 -183
  196. biotite/structure/io/mmtf/file.py +0 -233
  197. biotite/structure/io/npz/__init__.py +0 -20
  198. biotite/structure/io/npz/file.py +0 -152
  199. biotite/structure/io/pdbx/legacy.py +0 -267
  200. biotite/structure/io/tng/__init__.py +0 -13
  201. biotite/structure/io/tng/file.py +0 -46
  202. biotite/temp.py +0 -86
  203. biotite-0.41.2.dist-info/RECORD +0 -340
  204. {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/WHEEL +0 -0
  205. {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/licenses/LICENSE.rst +0 -0
@@ -6,9 +6,9 @@ __name__ = "biotite.structure.info"
6
6
  __author__ = "Patrick Kunzmann"
7
7
  __all__ = ["vdw_radius_protor", "vdw_radius_single"]
8
8
 
9
- from .bonds import bonds_in_residue
10
-
9
+ from biotite.structure.info.bonds import bonds_in_residue
11
10
 
11
+ # fmt: off
12
12
  # Contains tuples for the different ProtOr groups:
13
13
  # Tuple contains: element, valency, H count
14
14
  _PROTOR_RADII = {
@@ -35,28 +35,29 @@ _PROTOR_RADII = {
35
35
  _SINGLE_RADII = {
36
36
  "H": 1.20,
37
37
  "HE": 1.40,
38
-
38
+
39
39
  "C": 1.70,
40
40
  "N": 1.55,
41
41
  "O": 1.52,
42
42
  "F": 1.47,
43
43
  "NE": 1.54,
44
-
44
+
45
45
  "SI": 2.10,
46
46
  "P": 1.80,
47
47
  "S": 1.80,
48
48
  "CL": 1.75,
49
49
  "AR": 1.88,
50
-
50
+
51
51
  "AS": 1.85,
52
52
  "SE": 1.90,
53
53
  "BR": 1.85,
54
54
  "KR": 2.02,
55
-
55
+
56
56
  "TE": 2.06,
57
57
  "I": 1.98,
58
58
  "XE": 2.16,
59
59
  }
60
+ # fmt: on
60
61
 
61
62
  # A dictionary that caches radii for each residue
62
63
  _protor_radii = {}
@@ -82,7 +83,7 @@ def vdw_radius_protor(res_name, atom_name):
82
83
  to.
83
84
  atom_name : str
84
85
  The name of the non-hydrogen atom.
85
-
86
+
86
87
  Returns
87
88
  -------
88
89
  The Van-der-Waals radius of the given atom.
@@ -91,12 +92,12 @@ def vdw_radius_protor(res_name, atom_name):
91
92
  See also
92
93
  --------
93
94
  vdw_radius_single
94
-
95
+
95
96
  References
96
97
  ----------
97
-
98
+
98
99
  .. footbibliography::
99
-
100
+
100
101
  Examples
101
102
  --------
102
103
 
@@ -113,8 +114,7 @@ def vdw_radius_protor(res_name, atom_name):
113
114
  # Use cached radii for the residue, if already calculated
114
115
  if atom_name not in _protor_radii[res_name]:
115
116
  raise KeyError(
116
- f"Residue '{res_name}' does not contain an atom named "
117
- f"'{atom_name}'"
117
+ f"Residue '{res_name}' does not contain an atom named " f"'{atom_name}'"
118
118
  )
119
119
  return _protor_radii[res_name].get(atom_name)
120
120
  else:
@@ -124,6 +124,7 @@ def vdw_radius_protor(res_name, atom_name):
124
124
  # are cached
125
125
  return vdw_radius_protor(res_name, atom_name)
126
126
 
127
+
127
128
  def _calculate_protor_radii(res_name):
128
129
  """
129
130
  Calculate the ProtOr VdW radii for all atoms (atom names) in
@@ -159,8 +160,7 @@ def _calculate_protor_radii(res_name):
159
160
  group[2] += 1
160
161
  groups[main_atom] = group
161
162
  # Get radii based on ProtOr groups
162
- radii = {atom : _PROTOR_RADII.get(tuple(group))
163
- for atom, group in groups.items()}
163
+ radii = {atom: _PROTOR_RADII.get(tuple(group)) for atom, group in groups.items()}
164
164
  return radii
165
165
 
166
166
 
@@ -173,25 +173,25 @@ def vdw_radius_single(element):
173
173
  ----------
174
174
  element : str
175
175
  The chemical element of the atoms.
176
-
176
+
177
177
  Returns
178
178
  -------
179
179
  The Van-der-Waals radius of the atom.
180
180
  If the radius is unknown for the element, `None` is returned.
181
-
181
+
182
182
  See also
183
183
  --------
184
184
  vdw_radius_protor
185
-
185
+
186
186
  References
187
187
  ----------
188
-
188
+
189
189
  .. footbibliography::
190
-
190
+
191
191
  Examples
192
192
  --------
193
193
 
194
194
  >>> print(vdw_radius_single("C"))
195
195
  1.7
196
196
  """
197
- return _SINGLE_RADII.get(element.upper())
197
+ return _SINGLE_RADII.get(element.upper())
@@ -8,9 +8,9 @@ __all__ = ["standardize_order"]
8
8
 
9
9
  import warnings
10
10
  import numpy as np
11
- from .ccd import get_from_ccd
12
- from ..residues import get_residue_starts
13
- from ..error import BadStructureError
11
+ from biotite.structure.error import BadStructureError
12
+ from biotite.structure.info.ccd import get_from_ccd
13
+ from biotite.structure.residues import get_residue_starts
14
14
 
15
15
 
16
16
  def standardize_order(atoms):
@@ -116,26 +116,24 @@ def standardize_order(atoms):
116
116
  reordered_indices = np.zeros(atoms.array_length(), dtype=int)
117
117
 
118
118
  starts = get_residue_starts(atoms, add_exclusive_stop=True)
119
- for i in range(len(starts)-1):
119
+ for i in range(len(starts) - 1):
120
120
  start = starts[i]
121
- stop = starts[i+1]
121
+ stop = starts[i + 1]
122
122
 
123
123
  res_name = atoms.res_name[start]
124
- standard_atom_names = get_from_ccd(
125
- "chem_comp_atom", res_name, "atom_id"
126
- )
124
+ standard_atom_names = get_from_ccd("chem_comp_atom", res_name, "atom_id")
127
125
  if standard_atom_names is None:
128
126
  # If the residue is not in the CCD, keep the current order
129
127
  warnings.warn(
130
128
  f"Residue '{res_name}' is not in the CCD, "
131
129
  f"keeping current atom order"
132
130
  )
133
- reordered_indices[start : stop] = np.arange(start, stop)
131
+ reordered_indices[start:stop] = np.arange(start, stop)
134
132
  continue
135
133
 
136
- reordered_indices[start : stop] = _reorder(
137
- atoms.atom_name[start : stop], standard_atom_names
138
- ) + start
134
+ reordered_indices[start:stop] = (
135
+ _reorder(atoms.atom_name[start:stop], standard_atom_names) + start
136
+ )
139
137
 
140
138
  return reordered_indices
141
139
 
@@ -164,17 +162,13 @@ def _reorder(origin, target):
164
162
  Indices for `origin` that that changes the order of `origin`
165
163
  to the order of `target`.
166
164
  """
167
- target_hits, origin_hits = np.where(
168
- target[:, np.newaxis] == origin[np.newaxis, :]
169
- )
165
+ target_hits, origin_hits = np.where(target[:, np.newaxis] == origin[np.newaxis, :])
170
166
 
171
167
  counts = np.bincount(target_hits, minlength=len(target))
172
168
  if (counts > 1).any():
173
169
  counts = np.bincount(target_hits, minlength=len(target))
174
170
  # Identify which atom is duplicate
175
- duplicate_i = np.where(
176
- counts > 1
177
- )[0][0]
171
+ duplicate_i = np.where(counts > 1)[0][0]
178
172
  duplicate_name = target[duplicate_i]
179
173
  raise BadStructureError(
180
174
  f"Input structure has duplicate atom '{duplicate_name}'"
@@ -185,12 +179,7 @@ def _reorder(origin, target):
185
179
  # to the target structure
186
180
  # -> Identify which atoms are missing in the target structure
187
181
  # and append these to the end of the residue
188
- missing_atom_mask = np.bincount(
189
- origin_hits, minlength=len(origin)
190
- ).astype(bool)
191
- return np.concatenate([
192
- origin_hits,
193
- np.where(~missing_atom_mask)[0]
194
- ])
182
+ missing_atom_mask = np.bincount(origin_hits, minlength=len(origin)).astype(bool)
183
+ return np.concatenate([origin_hits, np.where(~missing_atom_mask)[0]])
195
184
  else:
196
- return origin_hits
185
+ return origin_hits
@@ -9,53 +9,29 @@ errors in the structure.
9
9
 
10
10
  __name__ = "biotite.structure"
11
11
  __author__ = "Patrick Kunzmann, Daniel Bauer"
12
- __all__ = ["check_id_continuity", "check_atom_id_continuity",
13
- "check_res_id_continuity", "check_backbone_continuity",
14
- "check_duplicate_atoms", "check_bond_continuity",
15
- "check_linear_continuity"]
12
+ __all__ = [
13
+ "check_atom_id_continuity",
14
+ "check_res_id_continuity",
15
+ "check_backbone_continuity",
16
+ "check_duplicate_atoms",
17
+ "check_linear_continuity",
18
+ ]
16
19
 
17
20
  import numpy as np
18
- import warnings
19
- from .atoms import AtomArray, AtomArrayStack
20
- from .filter import (
21
- filter_peptide_backbone, filter_phosphate_backbone, filter_linear_bond_continuity)
22
- from .box import coord_to_fraction
21
+ from biotite.structure.box import coord_to_fraction
22
+ from biotite.structure.filter import (
23
+ filter_linear_bond_continuity,
24
+ filter_peptide_backbone,
25
+ filter_phosphate_backbone,
26
+ )
23
27
 
24
28
 
25
29
  def _check_continuity(array):
26
30
  diff = np.diff(array)
27
- discontinuity = np.where( ((diff != 0) & (diff != 1)) )
31
+ discontinuity = np.where(((diff != 0) & (diff != 1)))
28
32
  return discontinuity[0] + 1
29
33
 
30
34
 
31
- def check_id_continuity(array):
32
- """
33
- Check if the residue IDs are incremented by more than 1 or
34
- decremented, from one atom to the next one.
35
-
36
- An increment by more than 1 is as strong clue for missing residues,
37
- a decrement means probably a start of a new chain.
38
-
39
- DEPRECATED: Use :func:`check_res_id_continuity()` instead.
40
-
41
- Parameters
42
- ----------
43
- array : AtomArray or AtomArrayStack
44
- The array to be checked.
45
-
46
- Returns
47
- -------
48
- discontinuity : ndarray, dtype=int
49
- Contains the indices of atoms after a discontinuity
50
- """
51
- warnings.warn(
52
- "'check_id_continuity()' is deprecated, "
53
- "use 'check_res_id_continuity()' instead",
54
- DeprecationWarning
55
- )
56
- return check_res_id_continuity(array)
57
-
58
-
59
35
  def check_atom_id_continuity(array):
60
36
  """
61
37
  Check if the atom IDs are incremented by more than 1 or
@@ -99,36 +75,6 @@ def check_res_id_continuity(array):
99
75
  return _check_continuity(ids)
100
76
 
101
77
 
102
- def check_bond_continuity(array, min_len=1.2, max_len=1.8):
103
- """
104
- Check if the peptide or phosphate backbone atoms have a
105
- non-reasonable distance to the next residue.
106
-
107
- A large or very small distance is a very strong clue, that there is
108
- no bond between those atoms, therefore the chain is discontinued.
109
-
110
- DEPRECATED: Please use :func:`check_backbone_continuity` for the same functionality.
111
-
112
- Parameters
113
- ----------
114
- array : AtomArray
115
- The array to be checked.
116
- min_len, max_len : float, optional
117
- The interval in which the atom-atom distance is evaluated as
118
- bond.
119
-
120
- Returns
121
- -------
122
- discontinuity : ndarray, dtype=int
123
- Contains the indices of atoms after a discontinuity.
124
- """
125
- warnings.warn(
126
- "Reimplemented into `check_backbone_continuity()`",
127
- DeprecationWarning
128
- )
129
- return check_backbone_continuity(array, min_len, max_len)
130
-
131
-
132
78
  def check_linear_continuity(array, min_len=1.2, max_len=1.8):
133
79
  """
134
80
  Check linear (consecutive) bond continuity of atoms in atom array.
@@ -223,8 +169,9 @@ def check_duplicate_atoms(array):
223
169
  The first occurence of an atom is not counted as duplicate.
224
170
  """
225
171
  duplicates = []
226
- annots = [array.get_annotation(category) for category
227
- in array.get_annotation_categories()]
172
+ annots = [
173
+ array.get_annotation(category) for category in array.get_annotation_categories()
174
+ ]
228
175
  for i in range(1, array.array_length()):
229
176
  # Start with assumption that all atoms in the array
230
177
  # until index i are duplicates of the atom at index i
@@ -233,7 +180,7 @@ def check_duplicate_atoms(array):
233
180
  # For each annotation array filter out the atoms until
234
181
  # index i that have an unequal annotation
235
182
  # to the atom at index i
236
- is_duplicate &= (annot[:i] == annot[i])
183
+ is_duplicate &= annot[:i] == annot[i]
237
184
  # After checking all annotation arrays,
238
185
  # if there still is any duplicate to the atom at index i,
239
186
  # add i the the list of duplicate atom indices
@@ -18,13 +18,12 @@ structure file.
18
18
  The recommended format for reading structure files is *BinaryCIF*.
19
19
  It has by far the shortest parsing time and file size.
20
20
 
21
- Besides the mentioned structure formats, Gromacs trajectory files can be
22
- loaded, if `mdtraj` is installed.
21
+ Besides the mentioned structure formats, common trajectory formats can be
22
+ loaded as well.
23
23
  """
24
24
 
25
25
  __name__ = "biotite.structure.io"
26
26
  __author__ = "Patrick Kunzmann"
27
27
 
28
- from .ctab import *
29
28
  from .general import *
30
- from .trajfile import *
29
+ from .trajfile import *
@@ -10,4 +10,4 @@ CDC format used by software like *CHARMM*, *OpenMM* and *NAMD*.
10
10
  __name__ = "biotite.structure.io.dcd"
11
11
  __author__ = "Patrick Kunzmann"
12
12
 
13
- from .file import *
13
+ from .file import *
@@ -6,21 +6,21 @@ __name__ = "biotite.structure.io.dcd"
6
6
  __author__ = "Patrick Kunzmann"
7
7
  __all__ = ["DCDFile"]
8
8
 
9
+ import biotraj
9
10
  import numpy as np
10
- from ..trajfile import TrajectoryFile
11
- from ...box import vectors_from_unitcell, unitcell_from_vectors
11
+ from biotite.structure.box import unitcell_from_vectors, vectors_from_unitcell
12
+ from biotite.structure.io.trajfile import TrajectoryFile
12
13
 
13
14
 
14
15
  class DCDFile(TrajectoryFile):
15
16
  """
16
17
  This file class represents a DCD trajectory file.
17
18
  """
18
-
19
+
19
20
  @classmethod
20
21
  def traj_type(cls):
21
- import mdtraj.formats as traj
22
- return traj.DCDTrajectoryFile
23
-
22
+ return biotraj.DCDTrajectoryFile
23
+
24
24
  @classmethod
25
25
  def process_read_values(cls, read_values):
26
26
  # .netcdf files use Angstrom
@@ -28,38 +28,40 @@ class DCDFile(TrajectoryFile):
28
28
  cell_lengths = read_values[1]
29
29
  cell_angles = read_values[2]
30
30
  if cell_lengths is None or cell_angles is None:
31
- box = None
31
+ box = None
32
32
  else:
33
33
  box = np.stack(
34
- [vectors_from_unitcell(a, b, c, alpha, beta, gamma)
35
- for (a, b, c), (alpha, beta, gamma)
36
- in zip(cell_lengths, np.deg2rad(cell_angles))],
37
- axis=0
34
+ [
35
+ vectors_from_unitcell(a, b, c, alpha, beta, gamma)
36
+ for (a, b, c), (alpha, beta, gamma) in zip(
37
+ cell_lengths, np.deg2rad(cell_angles)
38
+ )
39
+ ],
40
+ axis=0,
38
41
  )
39
42
  return coord, box, None
40
-
43
+
41
44
  @classmethod
42
45
  def prepare_write_values(cls, coord, box, time):
43
- xyz = coord.astype(np.float32, copy=False) \
44
- if coord is not None else None
46
+ xyz = coord.astype(np.float32, copy=False) if coord is not None else None
45
47
  if box is None:
46
48
  cell_lengths = None
47
- cell_angles = None
49
+ cell_angles = None
48
50
  else:
49
51
  cell_lengths = np.zeros((len(box), 3), dtype=np.float32)
50
- cell_angles = np.zeros((len(box), 3), dtype=np.float32)
52
+ cell_angles = np.zeros((len(box), 3), dtype=np.float32)
51
53
  for i, model_box in enumerate(box):
52
54
  a, b, c, alpha, beta, gamma = unitcell_from_vectors(model_box)
53
55
  cell_lengths[i] = np.array((a, b, c))
54
56
  cell_angles[i] = np.rad2deg((alpha, beta, gamma))
55
57
  return {
56
- "xyz" : xyz,
57
- "cell_lengths" : cell_lengths,
58
- "cell_angles" : cell_angles,
58
+ "xyz": xyz,
59
+ "cell_lengths": cell_lengths,
60
+ "cell_angles": cell_angles,
59
61
  }
60
62
 
61
63
  def set_time(self, time):
62
64
  if time is not None:
63
65
  raise NotImplementedError(
64
66
  "This trajectory file does not support writing simulation time"
65
- )
67
+ )
@@ -12,9 +12,9 @@ __author__ = "Patrick Kunzmann"
12
12
  __all__ = ["load_structure", "save_structure"]
13
13
 
14
14
  import datetime
15
- import os.path
16
15
  import io
17
- from ..atoms import AtomArrayStack
16
+ import os.path
17
+ from biotite.structure.atoms import AtomArrayStack
18
18
 
19
19
 
20
20
  def load_structure(file_path, template=None, **kwargs):
@@ -64,73 +64,63 @@ def load_structure(file_path, template=None, **kwargs):
64
64
  _, suffix = os.path.splitext(file_path)
65
65
  match suffix:
66
66
  case ".pdb":
67
- from .pdb import PDBFile
67
+ from biotite.structure.io.pdb import PDBFile
68
+
68
69
  file = PDBFile.read(file_path)
69
70
  array = file.get_structure(**kwargs)
70
71
  return _as_single_model_if_possible(array)
71
72
  case ".pdbqt":
72
- from .pdbqt import PDBQTFile
73
+ from biotite.structure.io.pdbqt import PDBQTFile
74
+
73
75
  file = PDBQTFile.read(file_path)
74
76
  array = file.get_structure(**kwargs)
75
77
  return _as_single_model_if_possible(array)
76
78
  case ".cif" | ".pdbx":
77
- from .pdbx import CIFFile, get_structure
79
+ from biotite.structure.io.pdbx import CIFFile, get_structure
80
+
78
81
  file = CIFFile.read(file_path)
79
82
  array = get_structure(file, **kwargs)
80
83
  return _as_single_model_if_possible(array)
81
84
  case ".bcif":
82
- from .pdbx import BinaryCIFFile, get_structure
85
+ from biotite.structure.io.pdbx import BinaryCIFFile, get_structure
86
+
83
87
  file = BinaryCIFFile.read(file_path)
84
88
  array = get_structure(file, **kwargs)
85
89
  return _as_single_model_if_possible(array)
86
90
  case ".gro":
87
- from .gro import GROFile
91
+ from biotite.structure.io.gro import GROFile
92
+
88
93
  file = GROFile.read(file_path)
89
94
  array = file.get_structure(**kwargs)
90
95
  return _as_single_model_if_possible(array)
91
- case ".mmtf":
92
- from .mmtf import MMTFFile, get_structure
93
- file = MMTFFile.read(file_path)
94
- array = get_structure(file, **kwargs)
95
- return _as_single_model_if_possible(array)
96
- case ".npz":
97
- from .npz import NpzFile
98
- file = NpzFile.read(file_path)
99
- array = file.get_structure(**kwargs)
100
- return _as_single_model_if_possible(array)
101
96
  case ".mol":
102
- from .mol import MOLFile
97
+ from biotite.structure.io.mol import MOLFile
98
+
103
99
  file = MOLFile.read(file_path)
104
100
  array = file.get_structure(**kwargs)
105
101
  # MOL and SDF files only contain a single model
106
102
  return array
107
103
  case ".sdf" | ".sd":
108
- from .mol import SDFile, get_structure
104
+ from biotite.structure.io.mol import SDFile, get_structure
105
+
109
106
  file = SDFile.read(file_path)
110
107
  array = get_structure(file, **kwargs)
111
108
  return array
112
- case ".trr" | ".xtc" | ".tng" | ".dcd" | ".netcdf":
109
+ case ".trr" | ".xtc" | ".dcd" | ".netcdf":
113
110
  if template is None:
114
- raise TypeError(
115
- "Template must be specified for trajectory files"
116
- )
111
+ raise TypeError("Template must be specified for trajectory files")
117
112
  # Filter template for atom ids, if an unfiltered template
118
- if (
119
- "atom_i" in kwargs
120
- and template.shape[-1] != len(kwargs["atom_i"])
121
- ):
113
+ if "atom_i" in kwargs and template.shape[-1] != len(kwargs["atom_i"]):
122
114
  template = template[..., kwargs["atom_i"]]
123
- from .trr import TRRFile
124
- from .xtc import XTCFile
125
- from .tng import TNGFile
126
- from .dcd import DCDFile
127
- from .netcdf import NetCDFFile
115
+ from biotite.structure.io.dcd import DCDFile
116
+ from biotite.structure.io.netcdf import NetCDFFile
117
+ from biotite.structure.io.trr import TRRFile
118
+ from biotite.structure.io.xtc import XTCFile
119
+
128
120
  if suffix == ".trr":
129
121
  traj_file_cls = TRRFile
130
122
  if suffix == ".xtc":
131
123
  traj_file_cls = XTCFile
132
- if suffix == ".tng":
133
- traj_file_cls = TNGFile
134
124
  if suffix == ".dcd":
135
125
  traj_file_cls = DCDFile
136
126
  if suffix == ".netcdf":
@@ -169,65 +159,60 @@ def save_structure(file_path, array, **kwargs):
169
159
  _, suffix = os.path.splitext(file_path)
170
160
  match suffix:
171
161
  case ".pdb":
172
- from .pdb import PDBFile
162
+ from biotite.structure.io.pdb import PDBFile
163
+
173
164
  file = PDBFile()
174
165
  file.set_structure(array, **kwargs)
175
166
  file.write(file_path)
176
167
  case ".pdbqt":
177
- from .pdbqt import PDBQTFile
168
+ from biotite.structure.io.pdbqt import PDBQTFile
169
+
178
170
  file = PDBQTFile()
179
171
  file.set_structure(array, **kwargs)
180
172
  file.write(file_path)
181
173
  case ".cif" | ".pdbx":
182
- from .pdbx import CIFFile, set_structure
174
+ from biotite.structure.io.pdbx import CIFFile, set_structure
175
+
183
176
  file = CIFFile()
184
177
  set_structure(file, array, **kwargs)
185
178
  file.write(file_path)
186
179
  case ".bcif":
187
- from .pdbx import BinaryCIFFile, set_structure
180
+ from biotite.structure.io.pdbx import BinaryCIFFile, set_structure
181
+
188
182
  file = BinaryCIFFile()
189
183
  set_structure(file, array, **kwargs)
190
184
  file.write(file_path)
191
185
  case ".gro":
192
- from .gro import GROFile
186
+ from biotite.structure.io.gro import GROFile
187
+
193
188
  file = GROFile()
194
189
  file.set_structure(array, **kwargs)
195
190
  file.write(file_path)
196
- case ".mmtf":
197
- from .mmtf import MMTFFile, set_structure
198
- file = MMTFFile()
199
- set_structure(file, array, **kwargs)
200
- file.write(file_path)
201
- case ".npz":
202
- from .npz import NpzFile
203
- file = NpzFile()
204
- file.set_structure(array, **kwargs)
205
- file.write(file_path)
206
191
  case ".mol":
207
- from .mol import MOLFile
192
+ from biotite.structure.io.mol import MOLFile
193
+
208
194
  file = MOLFile()
209
195
  file.set_structure(array, **kwargs)
210
196
  file.header = _mol_header()
211
197
  file.write(file_path)
212
198
  case ".sdf" | ".sd":
213
- from .mol import SDFile, SDRecord, set_structure
199
+ from biotite.structure.io.mol import SDFile, SDRecord, set_structure
200
+
214
201
  record = SDRecord()
215
202
  record.set_structure(array, **kwargs)
216
203
  record.header = _mol_header()
217
204
  file = SDFile({"Molecule": record})
218
205
  file.write(file_path)
219
- case ".trr" | ".xtc" | ".tng" | ".dcd" | ".netcdf":
220
- from .trr import TRRFile
221
- from .xtc import XTCFile
222
- from .tng import TNGFile
223
- from .dcd import DCDFile
224
- from .netcdf import NetCDFFile
206
+ case ".trr" | ".xtc" | ".dcd" | ".netcdf":
207
+ from biotite.structure.io.dcd import DCDFile
208
+ from biotite.structure.io.netcdf import NetCDFFile
209
+ from biotite.structure.io.trr import TRRFile
210
+ from biotite.structure.io.xtc import XTCFile
211
+
225
212
  if suffix == ".trr":
226
213
  traj_file_cls = TRRFile
227
214
  if suffix == ".xtc":
228
215
  traj_file_cls = XTCFile
229
- if suffix == ".tng":
230
- traj_file_cls = TNGFile
231
216
  if suffix == ".dcd":
232
217
  traj_file_cls = DCDFile
233
218
  if suffix == ".netcdf":
@@ -248,10 +233,11 @@ def _as_single_model_if_possible(atoms):
248
233
 
249
234
 
250
235
  def _mol_header():
251
- from .mol import Header
236
+ from biotite.structure.io.mol import Header
237
+
252
238
  return Header(
253
239
  mol_name="Molecule",
254
240
  program="Biotite",
255
241
  time=datetime.datetime.now(),
256
242
  dimensions="3D",
257
- )
243
+ )
@@ -11,4 +11,4 @@ software package.
11
11
  __name__ = "biotite.structure.io.gro"
12
12
  __author__ = "Daniel Bauer"
13
13
 
14
- from .file import *
14
+ from .file import *