biotite 0.41.2__cp310-cp310-win_amd64.whl → 1.0.1__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 +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.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 +1 -1
  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 +51 -65
  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 +15 -17
  108. biotite/structure/__init__.py +3 -3
  109. biotite/structure/atoms.py +246 -236
  110. biotite/structure/basepairs.py +260 -271
  111. biotite/structure/bonds.cp310-win_amd64.pyd +0 -0
  112. biotite/structure/bonds.pyx +29 -32
  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 +83 -78
  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.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 -44
  159. biotite/structure/io/pdbx/cif.py +140 -110
  160. biotite/structure/io/pdbx/component.py +10 -16
  161. biotite/structure/io/pdbx/convert.py +260 -258
  162. biotite/structure/io/pdbx/encoding.cp310-win_amd64.pyd +0 -0
  163. biotite/structure/io/trajfile.py +90 -107
  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.2.dist-info → biotite-1.0.1.dist-info}/METADATA +6 -5
  184. biotite-1.0.1.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.cp310-win_amd64.pyd +0 -0
  189. biotite/structure/io/mmtf/convertarray.pyx +0 -341
  190. biotite/structure/io/mmtf/convertfile.cp310-win_amd64.pyd +0 -0
  191. biotite/structure/io/mmtf/convertfile.pyx +0 -501
  192. biotite/structure/io/mmtf/decode.cp310-win_amd64.pyd +0 -0
  193. biotite/structure/io/mmtf/decode.pyx +0 -152
  194. biotite/structure/io/mmtf/encode.cp310-win_amd64.pyd +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.1.dist-info}/WHEEL +0 -0
  205. {biotite-0.41.2.dist-info → biotite-1.0.1.dist-info}/licenses/LICENSE.rst +0 -0
@@ -9,25 +9,33 @@ in a structure, mainly lenghts and angles.
9
9
 
10
10
  __name__ = "biotite.structure"
11
11
  __author__ = "Patrick Kunzmann"
12
- __all__ = ["displacement", "index_displacement", "distance", "index_distance",
13
- "angle", "index_angle", "dihedral", "index_dihedral",
14
- "dihedral_backbone", "centroid"]
12
+ __all__ = [
13
+ "displacement",
14
+ "index_displacement",
15
+ "distance",
16
+ "index_distance",
17
+ "angle",
18
+ "index_angle",
19
+ "dihedral",
20
+ "index_dihedral",
21
+ "dihedral_backbone",
22
+ "centroid",
23
+ ]
15
24
 
16
25
  import numpy as np
17
- from .atoms import Atom, AtomArray, AtomArrayStack, coord
18
- from .util import vector_dot, norm_vector
19
- from .filter import filter_peptide_backbone
20
- from .chains import chain_iter
21
- from .box import (coord_to_fraction, fraction_to_coord,
22
- move_inside_box, is_orthogonal)
23
- from .error import BadStructureError
26
+ from biotite.structure.atoms import AtomArray, AtomArrayStack, coord
27
+ from biotite.structure.box import coord_to_fraction, fraction_to_coord, is_orthogonal
28
+ from biotite.structure.chains import chain_iter
29
+ from biotite.structure.error import BadStructureError
30
+ from biotite.structure.filter import filter_peptide_backbone
31
+ from biotite.structure.util import norm_vector, vector_dot
24
32
 
25
33
 
26
34
  def displacement(atoms1, atoms2, box=None):
27
35
  """
28
36
  Measure the displacement vector, i.e. the vector difference, from
29
37
  one array of atom coordinates to another array of coordinates.
30
-
38
+
31
39
  Parameters
32
40
  ----------
33
41
  atoms1, atoms2 : ndarray, shape=(m,n,3) or ndarray, shape=(n,3) or ndarray, shape=(3,) or Atom or AtomArray or AtomArrayStack
@@ -43,13 +51,13 @@ def displacement(atoms1, atoms2, box=None):
43
51
  the box vectors given with this parameter.
44
52
  The shape *(m,3,3)* is only allowed, when the input coordinates
45
53
  comprise multiple models.
46
-
54
+
47
55
  Returns
48
56
  -------
49
57
  disp : ndarray, shape=(m,n,3) or ndarray, shape=(n,3) or ndarray, shape=(3,)
50
58
  The displacement vector(s). The shape is equal to the shape of
51
59
  the input `atoms` with the highest dimensionality.
52
-
60
+
53
61
  See also
54
62
  --------
55
63
  index_displacement
@@ -62,7 +70,7 @@ def displacement(atoms1, atoms2, box=None):
62
70
  diff = v2 - v1
63
71
  else:
64
72
  diff = -(v1 - v2)
65
-
73
+
66
74
  # Use minimum-image convention if box is given
67
75
  if box is not None:
68
76
  # Transform difference vector
@@ -81,28 +89,24 @@ def displacement(atoms1, atoms2, box=None):
81
89
  fractions = fractions[np.newaxis, :]
82
90
  disp = disp[np.newaxis, :]
83
91
  if orthogonality:
84
- _displacement_orthogonal_box(
85
- fractions, box, disp
86
- )
92
+ _displacement_orthogonal_box(fractions, box, disp)
87
93
  else:
88
94
  _displacement_triclinic_box(
89
95
  fractions.astype(diff.dtype, copy=False),
90
96
  box.astype(diff.dtype, copy=False),
91
- disp
97
+ disp,
92
98
  )
93
99
  # Transform back
94
100
  disp = disp[0]
95
101
  if fractions.ndim == 2:
96
102
  # Single model
97
103
  if orthogonality:
98
- _displacement_orthogonal_box(
99
- fractions, box, disp
100
- )
104
+ _displacement_orthogonal_box(fractions, box, disp)
101
105
  else:
102
106
  _displacement_triclinic_box(
103
107
  fractions.astype(diff.dtype, copy=False),
104
108
  box.astype(diff.dtype, copy=False),
105
- disp
109
+ disp,
106
110
  )
107
111
  elif fractions.ndim == 3:
108
112
  # Multiple models
@@ -117,21 +121,17 @@ def displacement(atoms1, atoms2, box=None):
117
121
  else:
118
122
  raise ValueError(f"{box.ndim} are to many box dimensions")
119
123
  if orthogonality_for_model:
120
- _displacement_orthogonal_box(
121
- fractions[i], box_for_model, disp[i]
122
- )
124
+ _displacement_orthogonal_box(fractions[i], box_for_model, disp[i])
123
125
  else:
124
126
  _displacement_triclinic_box(
125
127
  fractions[i].astype(diff.dtype, copy=False),
126
128
  box_for_model.astype(diff.dtype, copy=False),
127
- disp[i]
129
+ disp[i],
128
130
  )
129
131
  else:
130
- raise ValueError(
131
- f"{diff.shape} is an invalid shape for atom coordinates"
132
- )
132
+ raise ValueError(f"{diff.shape} is an invalid shape for atom coordinates")
133
133
  return disp
134
-
134
+
135
135
  else:
136
136
  return diff
137
137
 
@@ -139,7 +139,7 @@ def displacement(atoms1, atoms2, box=None):
139
139
  def index_displacement(*args, **kwargs):
140
140
  """
141
141
  index_displacement(atoms, indices, periodic=False, box=None)
142
-
142
+
143
143
  Measure the displacement, i.e. the vector difference, between pairs
144
144
  of atoms.
145
145
 
@@ -159,7 +159,7 @@ def index_displacement(*args, **kwargs):
159
159
  :class:`ndarray`.
160
160
  indices : ndarray, shape=(k,2)
161
161
  Pairs of indices that point to `atoms`.
162
- The displacement is measured from ``indices[x,0]`` to
162
+ The displacement is measured from ``indices[x,0]`` to
163
163
  ``indices[x,1]``.
164
164
  periodic : bool, optional
165
165
  If set to true, periodic boundary conditions are taken into
@@ -171,14 +171,14 @@ def index_displacement(*args, **kwargs):
171
171
  box : ndarray, shape=(3,3) or shape=(m,3,3), optional
172
172
  If this parameter is set, the given box is used instead of the
173
173
  `box` attribute of `atoms`.
174
-
174
+
175
175
  Returns
176
176
  -------
177
177
  disp : ndarray, shape=(k,) or shape=(m,k)
178
178
  The pairwise displacements.
179
179
  If `atoms` is an atom array stack, The distances are
180
180
  calculated for each model.
181
-
181
+
182
182
  Warnings
183
183
  --------
184
184
  In case `periodic` is set to true and if the box is not orthorhombic
@@ -199,7 +199,7 @@ def index_displacement(*args, **kwargs):
199
199
  def distance(atoms1, atoms2, box=None):
200
200
  """
201
201
  Measure the euclidian distance between atoms.
202
-
202
+
203
203
  Parameters
204
204
  ----------
205
205
  atoms1, atoms2 : ndarray or Atom or AtomArray or AtomArrayStack
@@ -214,14 +214,14 @@ def distance(atoms1, atoms2, box=None):
214
214
  the box vectors given with this parameter.
215
215
  The shape *(m,3,3)* is only allowed, when the input coordinates
216
216
  comprise multiple models.
217
-
217
+
218
218
  Returns
219
219
  -------
220
220
  dist : float or ndarray
221
221
  The atom distances.
222
222
  The shape is equal to the shape of the input `atoms` with the
223
223
  highest dimensionality minus the last axis.
224
-
224
+
225
225
  See also
226
226
  --------
227
227
  index_distance
@@ -233,7 +233,7 @@ def distance(atoms1, atoms2, box=None):
233
233
  def index_distance(*args, **kwargs):
234
234
  """
235
235
  index_distance(atoms, indices, periodic=False, box=None)
236
-
236
+
237
237
  Measure the euclidian distance between pairs of atoms.
238
238
 
239
239
  The pairs refer to indices of a given atom array, whose pairwise
@@ -262,14 +262,14 @@ def index_distance(*args, **kwargs):
262
262
  box : ndarray, shape=(3,3) or shape=(m,3,3), optional
263
263
  If this parameter is set, the given box is used instead of the
264
264
  `box` attribute of `atoms`.
265
-
265
+
266
266
  Returns
267
267
  -------
268
268
  dist : ndarray, shape=(k,) or shape=(m,k)
269
269
  The pairwise distances.
270
270
  If `atoms` is an atom array stack, The distances are
271
271
  calculated for each model.
272
-
272
+
273
273
  Warnings
274
274
  --------
275
275
  In case `periodic` is set to true and if the box is not orthorhombic
@@ -290,7 +290,7 @@ def index_distance(*args, **kwargs):
290
290
  def angle(atoms1, atoms2, atoms3, box=None):
291
291
  """
292
292
  Measure the angle between 3 atoms.
293
-
293
+
294
294
  Parameters
295
295
  ----------
296
296
  atoms1, atoms2, atoms3 : ndarray or Atom or AtomArray or AtomArrayStack
@@ -302,14 +302,14 @@ def angle(atoms1, atoms2, atoms3, box=None):
302
302
  the box vectors given with this parameter.
303
303
  The shape *(m,3,3)* is only allowed, when the input coordinates
304
304
  comprise multiple models.
305
-
305
+
306
306
  Returns
307
307
  -------
308
308
  angle : float or ndarray
309
309
  The angle(s) between the atoms. The shape is equal to the shape
310
310
  of the input `atoms` with the highest dimensionality minus the
311
311
  last axis.
312
-
312
+
313
313
  See also
314
314
  --------
315
315
  index_angle
@@ -318,13 +318,13 @@ def angle(atoms1, atoms2, atoms3, box=None):
318
318
  v2 = displacement(atoms3, atoms2, box)
319
319
  norm_vector(v1)
320
320
  norm_vector(v2)
321
- return np.arccos(vector_dot(v1,v2))
321
+ return np.arccos(vector_dot(v1, v2))
322
322
 
323
323
 
324
324
  def index_angle(*args, **kwargs):
325
325
  """
326
326
  index_angle(atoms, indices, periodic=False, box=None)
327
-
327
+
328
328
  Measure the angle between triples of atoms.
329
329
 
330
330
  The triples refer to indices of a given atom array, whose triplewise
@@ -351,14 +351,14 @@ def index_angle(*args, **kwargs):
351
351
  box : ndarray, shape=(3,3) or shape=(m,3,3), optional
352
352
  If this parameter is set, the given box is used instead of the
353
353
  `box` attribute of `atoms`.
354
-
354
+
355
355
  Returns
356
356
  -------
357
357
  angle : ndarray, shape=(k,) or shape=(m,k)
358
358
  The triplewise angles.
359
359
  If `atoms` is an atom array stack, The distances are
360
360
  calculated for each model.
361
-
361
+
362
362
  Warnings
363
363
  --------
364
364
  In case `periodic` is set to true and if the box is not orthorhombic
@@ -379,7 +379,7 @@ def index_angle(*args, **kwargs):
379
379
  def dihedral(atoms1, atoms2, atoms3, atoms4, box=None):
380
380
  """
381
381
  Measure the dihedral angle between 4 atoms.
382
-
382
+
383
383
  Parameters
384
384
  ----------
385
385
  atoms1, atoms2, atoms3, atoms4 : ndarray or Atom or AtomArray or AtomArrayStack
@@ -392,14 +392,14 @@ def dihedral(atoms1, atoms2, atoms3, atoms4, box=None):
392
392
  the box vectors given with this parameter.
393
393
  The shape *(m,3,3)* is only allowed, when the input coordinates
394
394
  comprise multiple models.
395
-
395
+
396
396
  Returns
397
397
  -------
398
398
  dihed : float or ndarray
399
399
  The dihedral angle(s) between the atoms. The shape is equal to
400
400
  the shape of the input `atoms` with the highest dimensionality
401
401
  minus the last axis.
402
-
402
+
403
403
  See Also
404
404
  --------
405
405
  index_dihedral
@@ -411,20 +411,20 @@ def dihedral(atoms1, atoms2, atoms3, atoms4, box=None):
411
411
  norm_vector(v1)
412
412
  norm_vector(v2)
413
413
  norm_vector(v3)
414
-
414
+
415
415
  n1 = np.cross(v1, v2)
416
416
  n2 = np.cross(v2, v3)
417
-
418
- # Calculation using atan2, to ensure the correct sign of the angle
419
- x = vector_dot(n1,n2)
420
- y = vector_dot(np.cross(n1,n2), v2)
421
- return np.arctan2(y,x)
417
+
418
+ # Calculation using atan2, to ensure the correct sign of the angle
419
+ x = vector_dot(n1, n2)
420
+ y = vector_dot(np.cross(n1, n2), v2)
421
+ return np.arctan2(y, x)
422
422
 
423
423
 
424
424
  def index_dihedral(*args, **kwargs):
425
425
  """
426
426
  index_dihedral(atoms, indices, periodic=False, box=None)
427
-
427
+
428
428
  Measure the dihedral angle between quadruples of atoms.
429
429
 
430
430
  The triples refer to indices of a given atom array, whose
@@ -452,14 +452,14 @@ def index_dihedral(*args, **kwargs):
452
452
  box : ndarray, shape=(3,3) or shape=(m,3,3), optional
453
453
  If this parameter is set, the given box is used instead of the
454
454
  `box` attribute of `atoms`.
455
-
455
+
456
456
  Returns
457
457
  -------
458
458
  dihedral : ndarray, shape=(k,) or shape=(m,k)
459
459
  The quadruplewise dihedral angles.
460
460
  If `atoms` is an atom array stack, The distances are
461
461
  calculated for each model.
462
-
462
+
463
463
  Warnings
464
464
  --------
465
465
  In case `periodic` is set to true and if the box is not orthorhombic
@@ -482,7 +482,7 @@ def dihedral_backbone(atom_array):
482
482
  """
483
483
  Measure the characteristic backbone dihedral angles of a protein
484
484
  structure.
485
-
485
+
486
486
  Parameters
487
487
  ----------
488
488
  atom_array: AtomArray or AtomArrayStack
@@ -492,7 +492,7 @@ def dihedral_backbone(atom_array):
492
492
  `NaN`.
493
493
  The order of the backbone atoms for each residue must be
494
494
  (N, CA, C).
495
-
495
+
496
496
  Returns
497
497
  -------
498
498
  phi, psi, omega : ndarray
@@ -502,20 +502,20 @@ def dihedral_backbone(atom_array):
502
502
  have *NaN* values. If an :class:`AtomArrayStack` is given, the
503
503
  output angles are 2-dimensional, the first dimension corresponds
504
504
  to the model number.
505
-
505
+
506
506
  Raises
507
507
  ------
508
508
  BadStructureError
509
509
  If the amount of backbone atoms is not equal to amount of
510
510
  residues times 3 (for N, CA and C).
511
-
511
+
512
512
  See Also
513
513
  --------
514
514
  dihedral
515
-
515
+
516
516
  Examples
517
517
  --------
518
-
518
+
519
519
  >>> phi, psi, omega = dihedral_backbone(atom_array)
520
520
  >>> print(np.stack([np.rad2deg(phi), np.rad2deg(psi)]).T)
521
521
  [[ nan -56.145]
@@ -541,15 +541,17 @@ def dihedral_backbone(atom_array):
541
541
  """
542
542
  bb_filter = filter_peptide_backbone(atom_array)
543
543
  backbone = atom_array[..., bb_filter]
544
-
545
- if backbone.array_length() % 3 != 0 \
546
- or (backbone.atom_name[0::3] != "N" ).any() \
547
- or (backbone.atom_name[1::3] != "CA").any() \
548
- or (backbone.atom_name[2::3] != "C" ).any():
549
- raise BadStructureError(
550
- "The backbone is invalid, must be repeats of (N, CA, C), "
551
- "maybe a backbone atom is missing"
552
- )
544
+
545
+ if (
546
+ backbone.array_length() % 3 != 0
547
+ or (backbone.atom_name[0::3] != "N").any()
548
+ or (backbone.atom_name[1::3] != "CA").any()
549
+ or (backbone.atom_name[2::3] != "C").any()
550
+ ):
551
+ raise BadStructureError(
552
+ "The backbone is invalid, must be repeats of (N, CA, C), "
553
+ "maybe a backbone atom is missing"
554
+ )
553
555
  phis = []
554
556
  psis = []
555
557
  omegas = []
@@ -558,9 +560,11 @@ def dihedral_backbone(atom_array):
558
560
  phis.append(phi)
559
561
  psis.append(psi)
560
562
  omegas.append(omega)
561
- return np.concatenate(phis, axis=-1), np.concatenate(psis, axis=-1), \
562
- np.concatenate(omegas, axis=-1)
563
-
563
+ return (
564
+ np.concatenate(phis, axis=-1),
565
+ np.concatenate(psis, axis=-1),
566
+ np.concatenate(omegas, axis=-1),
567
+ )
564
568
 
565
569
 
566
570
  def _dihedral_backbone(chain_bb):
@@ -571,49 +575,57 @@ def _dihedral_backbone(chain_bb):
571
575
  # Dim 2: X, Y, Z coordinates
572
576
  # Dim 3: Atoms involved in dihedral angle
573
577
  if isinstance(chain_bb, AtomArray):
574
- angle_coord_shape = (len(bb_coord)//3, 3, 4)
578
+ angle_coord_shape = (len(bb_coord) // 3, 3, 4)
575
579
  elif isinstance(chain_bb, AtomArrayStack):
576
- angle_coord_shape = (bb_coord.shape[0], bb_coord.shape[1]//3, 3, 4)
577
- phi_coord = np.full(angle_coord_shape, np.nan)
578
- psi_coord = np.full(angle_coord_shape, np.nan)
580
+ angle_coord_shape = (bb_coord.shape[0], bb_coord.shape[1] // 3, 3, 4)
581
+ phi_coord = np.full(angle_coord_shape, np.nan)
582
+ psi_coord = np.full(angle_coord_shape, np.nan)
579
583
  omega_coord = np.full(angle_coord_shape, np.nan)
580
-
581
- # Indices for coordinates of CA atoms
582
- ca_i = np.arange(bb_coord.shape[-2]//3) * 3 + 1
583
- phi_coord [..., 1: , :, 0] = bb_coord[..., ca_i[1: ]-2 ,:]
584
- phi_coord [..., 1: , :, 1] = bb_coord[..., ca_i[1: ]-1 ,:]
585
- phi_coord [..., 1: , :, 2] = bb_coord[..., ca_i[1: ] ,:]
586
- phi_coord [..., 1: , :, 3] = bb_coord[..., ca_i[1: ]+1 ,:]
587
- psi_coord [..., :-1, :, 0] = bb_coord[..., ca_i[:-1]-1 ,:]
588
- psi_coord [..., :-1, :, 1] = bb_coord[..., ca_i[:-1] ,:]
589
- psi_coord [..., :-1, :, 2] = bb_coord[..., ca_i[:-1]+1 ,:]
590
- psi_coord [..., :-1, :, 3] = bb_coord[..., ca_i[:-1]+2 ,:]
591
- omega_coord[..., :-1, :, 0] = bb_coord[..., ca_i[:-1] ,:]
592
- omega_coord[..., :-1, :, 1] = bb_coord[..., ca_i[:-1]+1 ,:]
593
- omega_coord[..., :-1, :, 2] = bb_coord[..., ca_i[:-1]+2 ,:]
594
- omega_coord[..., :-1, :, 3] = bb_coord[..., ca_i[:-1]+3 ,:]
595
-
596
- phi = dihedral(phi_coord[...,0], phi_coord[...,1],
597
- phi_coord[...,2], phi_coord[...,3])
598
- psi = dihedral(psi_coord[...,0], psi_coord[...,1],
599
- psi_coord[...,2], psi_coord[...,3])
600
- omega = dihedral(omega_coord[...,0], omega_coord[...,1],
601
- omega_coord[...,2], omega_coord[...,3])
602
-
584
+
585
+ # Indices for coordinates of CA atoms
586
+ ca_i = np.arange(bb_coord.shape[-2] // 3) * 3 + 1
587
+ # fmt: off
588
+ phi_coord [..., 1:, :, 0] = bb_coord[..., ca_i[1: ]-2, :]
589
+ phi_coord [..., 1:, :, 1] = bb_coord[..., ca_i[1: ]-1, :]
590
+ phi_coord [..., 1:, :, 2] = bb_coord[..., ca_i[1: ], :]
591
+ phi_coord [..., 1:, :, 3] = bb_coord[..., ca_i[1: ]+1, :]
592
+ psi_coord [..., :-1, :, 0] = bb_coord[..., ca_i[:-1]-1, :]
593
+ psi_coord [..., :-1, :, 1] = bb_coord[..., ca_i[:-1], :]
594
+ psi_coord [..., :-1, :, 2] = bb_coord[..., ca_i[:-1]+1, :]
595
+ psi_coord [..., :-1, :, 3] = bb_coord[..., ca_i[:-1]+2, :]
596
+ omega_coord[..., :-1, :, 0] = bb_coord[..., ca_i[:-1], :]
597
+ omega_coord[..., :-1, :, 1] = bb_coord[..., ca_i[:-1]+1, :]
598
+ omega_coord[..., :-1, :, 2] = bb_coord[..., ca_i[:-1]+2, :]
599
+ omega_coord[..., :-1, :, 3] = bb_coord[..., ca_i[:-1]+3, :]
600
+ # fmt: on
601
+
602
+ phi = dihedral(
603
+ phi_coord[..., 0], phi_coord[..., 1], phi_coord[..., 2], phi_coord[..., 3]
604
+ )
605
+ psi = dihedral(
606
+ psi_coord[..., 0], psi_coord[..., 1], psi_coord[..., 2], psi_coord[..., 3]
607
+ )
608
+ omega = dihedral(
609
+ omega_coord[..., 0],
610
+ omega_coord[..., 1],
611
+ omega_coord[..., 2],
612
+ omega_coord[..., 3],
613
+ )
614
+
603
615
  return phi, psi, omega
604
616
 
605
617
 
606
618
  def centroid(atoms):
607
619
  """
608
620
  Measure the centroid of a structure.
609
-
621
+
610
622
  Parameters
611
623
  ----------
612
624
  atoms: ndarray or AtomArray or AtomArrayStack
613
625
  The structures to determine the centroid from.
614
626
  Alternatively an ndarray containing the coordinates can be
615
627
  provided.
616
-
628
+
617
629
  Returns
618
630
  -------
619
631
  centroid : float or ndarray
@@ -623,8 +635,9 @@ def centroid(atoms):
623
635
  return np.mean(coord(atoms), axis=-2)
624
636
 
625
637
 
626
- def _call_non_index_function(function, expected_amount,
627
- atoms, indices, periodic=False, box=None):
638
+ def _call_non_index_function(
639
+ function, expected_amount, atoms, indices, periodic=False, box=None
640
+ ):
628
641
  """
629
642
  Call an `xxx()` function based on the parameters given to a
630
643
  `index_xxx()` function.
@@ -636,15 +649,14 @@ def _call_non_index_function(function, expected_amount,
636
649
  )
637
650
  coord_list = []
638
651
  for i in range(expected_amount):
639
- coord_list.append(coord(atoms)[..., indices[:,i], :])
652
+ coord_list.append(coord(atoms)[..., indices[:, i], :])
640
653
  if periodic:
641
654
  if box is None:
642
655
  if isinstance(atoms, (AtomArray, AtomArrayStack)):
643
656
  box = atoms.box
644
657
  else:
645
658
  raise ValueError(
646
- "If `atoms` are coordinates, "
647
- "the box must be set explicitly"
659
+ "If `atoms` are coordinates, " "the box must be set explicitly"
648
660
  )
649
661
  else:
650
662
  box = None
@@ -656,7 +668,7 @@ def _displacement_orthogonal_box(fractions, box, disp):
656
668
  Fill in the PBC-aware displacement vector for non-PBC-aware
657
669
  displacements given as fractions of given box vectors.
658
670
  """
659
- # Fraction components are guaranteed to be positive
671
+ # Fraction components are guaranteed to be positive
660
672
  # Use fraction vector components with lower absolute
661
673
  # -> new_vec[i] = vec[i] - 1 if vec[i] > 0.5 else vec[i]
662
674
  fractions[fractions > 0.5] -= 1
@@ -669,7 +681,7 @@ def _displacement_triclinic_box(fractions, box, disp):
669
681
  displacements given as fractions of given box vectors.
670
682
  """
671
683
  diffs = fraction_to_coord(fractions, box)
672
- # Fraction components are guaranteed to be positive
684
+ # Fraction components are guaranteed to be positive
673
685
  # Test all 3 fraction vector components
674
686
  # with positive and negative sign
675
687
  # (i,j,k in {-1, 0})
@@ -678,10 +690,10 @@ def _displacement_triclinic_box(fractions, box, disp):
678
690
  for i in range(-1, 1):
679
691
  for j in range(-1, 1):
680
692
  for k in range(-1, 1):
681
- x = i*box[0,0] + j*box[1,0] + k*box[2,0]
682
- y = i*box[0,1] + j*box[1,1] + k*box[2,1]
683
- z = i*box[0,2] + j*box[1,2] + k*box[2,2]
684
- periodic_shift.append([x,y,z])
693
+ x = i * box[0, 0] + j * box[1, 0] + k * box[2, 0]
694
+ y = i * box[0, 1] + j * box[1, 1] + k * box[2, 1]
695
+ z = i * box[0, 2] + j * box[1, 2] + k * box[2, 2]
696
+ periodic_shift.append([x, y, z])
685
697
  periodic_shift = np.array(periodic_shift, dtype=disp.dtype)
686
698
  # Create 8 periodically shifted variants for each atom
687
699
  shifted_diffs = diffs[:, np.newaxis, :] + periodic_shift[np.newaxis, :, :]
@@ -692,6 +704,5 @@ def _displacement_triclinic_box(fractions, box, disp):
692
704
  # for each given non-PBC-aware displacement find the PBC-aware
693
705
  # displacement with the lowest distance
694
706
  disp[:] = shifted_diffs[
695
- np.arange(len(shifted_diffs)),
696
- np.argmin(sq_distance, axis=1)
707
+ np.arange(len(shifted_diffs)), np.argmin(sq_distance, axis=1)
697
708
  ]