biotite 1.2.0__cp312-cp312-macosx_11_0_arm64.whl → 1.4.0__cp312-cp312-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.
- biotite/application/viennarna/rnaplot.py +7 -7
- biotite/interface/openmm/__init__.py +4 -0
- biotite/interface/pymol/__init__.py +3 -0
- biotite/interface/pymol/object.py +3 -1
- biotite/interface/rdkit/__init__.py +4 -0
- biotite/interface/rdkit/mol.py +5 -5
- biotite/interface/version.py +23 -0
- biotite/sequence/align/banded.cpython-312-darwin.so +0 -0
- biotite/sequence/align/banded.pyx +1 -1
- biotite/sequence/align/kmeralphabet.cpython-312-darwin.so +0 -0
- biotite/sequence/align/kmersimilarity.cpython-312-darwin.so +0 -0
- biotite/sequence/align/kmertable.cpython-312-darwin.so +0 -0
- biotite/sequence/align/localgapped.cpython-312-darwin.so +0 -0
- biotite/sequence/align/localungapped.cpython-312-darwin.so +0 -0
- biotite/sequence/align/multiple.cpython-312-darwin.so +0 -0
- biotite/sequence/align/multiple.pyx +1 -2
- biotite/sequence/align/pairwise.cpython-312-darwin.so +0 -0
- biotite/sequence/align/pairwise.pyx +2 -4
- biotite/sequence/align/permutation.cpython-312-darwin.so +0 -0
- biotite/sequence/align/selector.cpython-312-darwin.so +0 -0
- biotite/sequence/align/tracetable.cpython-312-darwin.so +0 -0
- biotite/sequence/codec.cpython-312-darwin.so +0 -0
- biotite/sequence/phylo/nj.cpython-312-darwin.so +0 -0
- biotite/sequence/phylo/tree.cpython-312-darwin.so +0 -0
- biotite/sequence/phylo/upgma.cpython-312-darwin.so +0 -0
- biotite/structure/basepairs.py +13 -14
- biotite/structure/bonds.cpython-312-darwin.so +0 -0
- biotite/structure/bonds.pyx +67 -6
- biotite/structure/box.py +141 -3
- biotite/structure/celllist.cpython-312-darwin.so +0 -0
- biotite/structure/celllist.pyx +0 -1
- biotite/structure/chains.py +15 -21
- biotite/structure/charges.cpython-312-darwin.so +0 -0
- biotite/structure/compare.py +2 -0
- biotite/structure/dotbracket.py +4 -4
- biotite/structure/graphics/rna.py +19 -16
- biotite/structure/hbond.py +1 -2
- biotite/structure/info/components.bcif +0 -0
- biotite/structure/io/pdb/convert.py +84 -2
- biotite/structure/io/pdb/file.py +94 -7
- biotite/structure/io/pdb/hybrid36.cpython-312-darwin.so +0 -0
- biotite/structure/io/pdbx/bcif.py +6 -3
- biotite/structure/io/pdbx/cif.py +5 -2
- biotite/structure/io/pdbx/compress.py +71 -34
- biotite/structure/io/pdbx/convert.py +226 -58
- biotite/structure/io/pdbx/encoding.cpython-312-darwin.so +0 -0
- biotite/structure/io/pdbx/encoding.pyx +39 -23
- biotite/structure/pseudoknots.py +6 -6
- biotite/structure/residues.py +10 -27
- biotite/structure/rings.py +118 -2
- biotite/structure/sasa.cpython-312-darwin.so +0 -0
- biotite/structure/sasa.pyx +28 -29
- biotite/structure/segments.py +55 -0
- biotite/structure/spacegroups.json +1567 -0
- biotite/structure/spacegroups.license +26 -0
- biotite/structure/superimpose.py +1 -191
- biotite/structure/transform.py +220 -1
- biotite/version.py +2 -2
- {biotite-1.2.0.dist-info → biotite-1.4.0.dist-info}/METADATA +4 -34
- {biotite-1.2.0.dist-info → biotite-1.4.0.dist-info}/RECORD +62 -60
- {biotite-1.2.0.dist-info → biotite-1.4.0.dist-info}/WHEEL +3 -1
- {biotite-1.2.0.dist-info → biotite-1.4.0.dist-info}/licenses/LICENSE.rst +0 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
The transformations in 'spacegroups.json' are adapted from
|
|
2
|
+
'molstar/src/mol-math/geometry/spacegroup/tables.ts' from the Mol* project
|
|
3
|
+
(https://github.com/molstar/molstar) governed by the following license:
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
The MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2017 - now, Mol* contributors
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in
|
|
18
|
+
all copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
26
|
+
THE SOFTWARE.
|
biotite/structure/superimpose.py
CHANGED
|
@@ -12,7 +12,6 @@ __all__ = [
|
|
|
12
12
|
"superimpose",
|
|
13
13
|
"superimpose_homologs",
|
|
14
14
|
"superimpose_without_outliers",
|
|
15
|
-
"AffineTransformation",
|
|
16
15
|
]
|
|
17
16
|
|
|
18
17
|
|
|
@@ -27,186 +26,7 @@ from biotite.structure.chains import chain_iter
|
|
|
27
26
|
from biotite.structure.filter import filter_amino_acids, filter_nucleotides
|
|
28
27
|
from biotite.structure.geometry import centroid, distance
|
|
29
28
|
from biotite.structure.sequence import to_sequence
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class AffineTransformation:
|
|
33
|
-
"""
|
|
34
|
-
An affine transformation, consisting of translations and a rotation.
|
|
35
|
-
|
|
36
|
-
Parameters
|
|
37
|
-
----------
|
|
38
|
-
center_translation : ndarray, shape=(3,) or shape=(m,3), dtype=float
|
|
39
|
-
The translation vector for moving the centroid into the
|
|
40
|
-
origin.
|
|
41
|
-
rotation : ndarray, shape=(3,3) or shape=(m,3,3), dtype=float
|
|
42
|
-
The rotation matrix.
|
|
43
|
-
target_translation : ndarray, shape=(m,3), dtype=float
|
|
44
|
-
The translation vector for moving the structure onto the
|
|
45
|
-
fixed one.
|
|
46
|
-
|
|
47
|
-
Attributes
|
|
48
|
-
----------
|
|
49
|
-
center_translation, rotation, target_translation : ndarray
|
|
50
|
-
Same as the parameters.
|
|
51
|
-
The dimensions are always expanded to *(m,3)* or *(m,3,3)*,
|
|
52
|
-
respectively.
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
def __init__(self, center_translation, rotation, target_translation):
|
|
56
|
-
self.center_translation = _expand_dims(center_translation, 2)
|
|
57
|
-
self.rotation = _expand_dims(rotation, 3)
|
|
58
|
-
self.target_translation = _expand_dims(target_translation, 2)
|
|
59
|
-
|
|
60
|
-
def apply(self, atoms):
|
|
61
|
-
"""
|
|
62
|
-
Apply this transformation on the given structure.
|
|
63
|
-
|
|
64
|
-
Parameters
|
|
65
|
-
----------
|
|
66
|
-
atoms : AtomArray or AtomArrayStack or ndarray, shape(n,), dtype=float or ndarray, shape(m,n), dtype=float
|
|
67
|
-
The structure to apply the transformation on.
|
|
68
|
-
|
|
69
|
-
Returns
|
|
70
|
-
-------
|
|
71
|
-
transformed : AtomArray or AtomArrayStack or ndarray, shape(n,), dtype=float or ndarray, shape(m,n), dtype=float
|
|
72
|
-
A copy of the `atoms` structure,
|
|
73
|
-
with transformations applied.
|
|
74
|
-
Only coordinates are returned, if coordinates were given in
|
|
75
|
-
`atoms`.
|
|
76
|
-
|
|
77
|
-
Examples
|
|
78
|
-
--------
|
|
79
|
-
|
|
80
|
-
>>> coord = np.arange(15).reshape(5,3)
|
|
81
|
-
>>> print(coord)
|
|
82
|
-
[[ 0 1 2]
|
|
83
|
-
[ 3 4 5]
|
|
84
|
-
[ 6 7 8]
|
|
85
|
-
[ 9 10 11]
|
|
86
|
-
[12 13 14]]
|
|
87
|
-
>>> # Rotates 90 degrees around the z-axis
|
|
88
|
-
>>> transform = AffineTransformation(
|
|
89
|
-
... center_translation=np.array([0,0,0]),
|
|
90
|
-
... rotation=np.array([
|
|
91
|
-
... [0, -1, 0],
|
|
92
|
-
... [1, 0, 0],
|
|
93
|
-
... [0, 0, 1]
|
|
94
|
-
... ]),
|
|
95
|
-
... target_translation=np.array([0,0,0])
|
|
96
|
-
... )
|
|
97
|
-
>>> print(transform.apply(coord))
|
|
98
|
-
[[ -1. 0. 2.]
|
|
99
|
-
[ -4. 3. 5.]
|
|
100
|
-
[ -7. 6. 8.]
|
|
101
|
-
[-10. 9. 11.]
|
|
102
|
-
[-13. 12. 14.]]
|
|
103
|
-
"""
|
|
104
|
-
mobile_coord = coord(atoms)
|
|
105
|
-
original_shape = mobile_coord.shape
|
|
106
|
-
mobile_coord = _reshape_to_3d(mobile_coord)
|
|
107
|
-
if mobile_coord.shape[0] != self.rotation.shape[0]:
|
|
108
|
-
raise IndexError(
|
|
109
|
-
f"Number of transformations is {self.rotation.shape[0]}, "
|
|
110
|
-
f"but number of structure models is {mobile_coord.shape[0]}"
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
superimposed_coord = mobile_coord.copy()
|
|
114
|
-
superimposed_coord += self.center_translation[:, np.newaxis, :]
|
|
115
|
-
superimposed_coord = _multi_matmul(self.rotation, superimposed_coord)
|
|
116
|
-
superimposed_coord += self.target_translation[:, np.newaxis, :]
|
|
117
|
-
|
|
118
|
-
superimposed_coord = superimposed_coord.reshape(original_shape)
|
|
119
|
-
if isinstance(atoms, np.ndarray):
|
|
120
|
-
return superimposed_coord
|
|
121
|
-
else:
|
|
122
|
-
superimposed = atoms.copy()
|
|
123
|
-
superimposed.coord = superimposed_coord
|
|
124
|
-
return superimposed
|
|
125
|
-
|
|
126
|
-
def as_matrix(self):
|
|
127
|
-
"""
|
|
128
|
-
Get the translations and rotation as a combined 4x4
|
|
129
|
-
transformation matrix.
|
|
130
|
-
|
|
131
|
-
Multiplying this matrix with coordinates in the form
|
|
132
|
-
*(x, y, z, 1)* will apply the same transformation as
|
|
133
|
-
:meth:`apply()` to coordinates in the form *(x, y, z)*.
|
|
134
|
-
|
|
135
|
-
Returns
|
|
136
|
-
-------
|
|
137
|
-
transformation_matrix : ndarray, shape=(m,4,4), dtype=float
|
|
138
|
-
The transformation matrix.
|
|
139
|
-
*m* is the number of models in the transformation.
|
|
140
|
-
|
|
141
|
-
Examples
|
|
142
|
-
--------
|
|
143
|
-
|
|
144
|
-
>>> coord = np.arange(15).reshape(5,3)
|
|
145
|
-
>>> print(coord)
|
|
146
|
-
[[ 0 1 2]
|
|
147
|
-
[ 3 4 5]
|
|
148
|
-
[ 6 7 8]
|
|
149
|
-
[ 9 10 11]
|
|
150
|
-
[12 13 14]]
|
|
151
|
-
>>> # Rotates 90 degrees around the z-axis
|
|
152
|
-
>>> transform = AffineTransformation(
|
|
153
|
-
... center_translation=np.array([0,0,0]),
|
|
154
|
-
... rotation=np.array([
|
|
155
|
-
... [0, -1, 0],
|
|
156
|
-
... [1, 0, 0],
|
|
157
|
-
... [0, 0, 1]
|
|
158
|
-
... ]),
|
|
159
|
-
... target_translation=np.array([0,0,0])
|
|
160
|
-
... )
|
|
161
|
-
>>> print(transform.apply(coord))
|
|
162
|
-
[[ -1. 0. 2.]
|
|
163
|
-
[ -4. 3. 5.]
|
|
164
|
-
[ -7. 6. 8.]
|
|
165
|
-
[-10. 9. 11.]
|
|
166
|
-
[-13. 12. 14.]]
|
|
167
|
-
>>> # Use a 4x4 matrix for transformation as alternative
|
|
168
|
-
>>> coord_4 = np.concatenate([coord, np.ones((len(coord), 1))], axis=-1)
|
|
169
|
-
>>> print(coord_4)
|
|
170
|
-
[[ 0. 1. 2. 1.]
|
|
171
|
-
[ 3. 4. 5. 1.]
|
|
172
|
-
[ 6. 7. 8. 1.]
|
|
173
|
-
[ 9. 10. 11. 1.]
|
|
174
|
-
[12. 13. 14. 1.]]
|
|
175
|
-
>>> print((transform.as_matrix()[0] @ coord_4.T).T)
|
|
176
|
-
[[ -1. 0. 2. 1.]
|
|
177
|
-
[ -4. 3. 5. 1.]
|
|
178
|
-
[ -7. 6. 8. 1.]
|
|
179
|
-
[-10. 9. 11. 1.]
|
|
180
|
-
[-13. 12. 14. 1.]]
|
|
181
|
-
"""
|
|
182
|
-
n_models = self.rotation.shape[0]
|
|
183
|
-
rotation_mat = _3d_identity(n_models, 4)
|
|
184
|
-
rotation_mat[:, :3, :3] = self.rotation
|
|
185
|
-
center_translation_mat = _3d_identity(n_models, 4)
|
|
186
|
-
center_translation_mat[:, :3, 3] = self.center_translation
|
|
187
|
-
target_translation_mat = _3d_identity(n_models, 4)
|
|
188
|
-
target_translation_mat[:, :3, 3] = self.target_translation
|
|
189
|
-
return target_translation_mat @ rotation_mat @ center_translation_mat
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
def _expand_dims(array, n_dims):
|
|
193
|
-
"""
|
|
194
|
-
Expand the dimensions of an `ndarray` to a certain number of
|
|
195
|
-
dimensions.
|
|
196
|
-
"""
|
|
197
|
-
while array.ndim < n_dims:
|
|
198
|
-
array = array[np.newaxis, ...]
|
|
199
|
-
return array
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
def _3d_identity(m, n):
|
|
203
|
-
"""
|
|
204
|
-
Create an array of *m* identity matrices of shape *(n, n)*
|
|
205
|
-
"""
|
|
206
|
-
matrices = np.zeros((m, n, n), dtype=float)
|
|
207
|
-
indices = np.arange(n)
|
|
208
|
-
matrices[:, indices, indices] = 1
|
|
209
|
-
return matrices
|
|
29
|
+
from biotite.structure.transform import AffineTransformation
|
|
210
30
|
|
|
211
31
|
|
|
212
32
|
def superimpose(fixed, mobile, atom_mask=None):
|
|
@@ -624,16 +444,6 @@ def _get_rotation_matrices(fixed, mobile):
|
|
|
624
444
|
return matrices
|
|
625
445
|
|
|
626
446
|
|
|
627
|
-
def _multi_matmul(matrices, vectors):
|
|
628
|
-
"""
|
|
629
|
-
Calculate the matrix multiplication of m matrices
|
|
630
|
-
with m x n vectors.
|
|
631
|
-
"""
|
|
632
|
-
return np.transpose(
|
|
633
|
-
np.matmul(matrices, np.transpose(vectors, axes=(0, 2, 1))), axes=(0, 2, 1)
|
|
634
|
-
)
|
|
635
|
-
|
|
636
|
-
|
|
637
447
|
def _get_backbone_anchor_indices(atoms):
|
|
638
448
|
"""
|
|
639
449
|
Select one representative anchor atom for each amino acid and
|
biotite/structure/transform.py
CHANGED
|
@@ -10,6 +10,7 @@ that can be applied on structures.
|
|
|
10
10
|
__name__ = "biotite.structure"
|
|
11
11
|
__author__ = "Patrick Kunzmann", "Claude J. Rogers"
|
|
12
12
|
__all__ = [
|
|
13
|
+
"AffineTransformation",
|
|
13
14
|
"translate",
|
|
14
15
|
"rotate",
|
|
15
16
|
"rotate_centered",
|
|
@@ -20,10 +21,215 @@ __all__ = [
|
|
|
20
21
|
|
|
21
22
|
import numpy as np
|
|
22
23
|
from biotite.structure.atoms import Atom, AtomArray, AtomArrayStack, coord
|
|
23
|
-
from biotite.structure.geometry import centroid
|
|
24
24
|
from biotite.structure.util import matrix_rotate, norm_vector, vector_dot
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
class AffineTransformation:
|
|
28
|
+
"""
|
|
29
|
+
An affine transformation, consisting of translations and a rotation.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
center_translation : ndarray, shape=(3,) or shape=(m,3), dtype=float
|
|
34
|
+
The translation vector for moving the centroid into the
|
|
35
|
+
origin.
|
|
36
|
+
rotation : ndarray, shape=(3,3) or shape=(m,3,3), dtype=float
|
|
37
|
+
The rotation matrix.
|
|
38
|
+
target_translation : ndarray, shape=(m,3), dtype=float
|
|
39
|
+
The translation vector for moving the structure onto the
|
|
40
|
+
fixed one.
|
|
41
|
+
|
|
42
|
+
Attributes
|
|
43
|
+
----------
|
|
44
|
+
center_translation, rotation, target_translation : ndarray
|
|
45
|
+
Same as the parameters.
|
|
46
|
+
The dimensions are always expanded to *(m,3)* or *(m,3,3)*,
|
|
47
|
+
respectively.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
def __init__(self, center_translation, rotation, target_translation):
|
|
51
|
+
self.center_translation = _expand_dims(center_translation, 2)
|
|
52
|
+
self.rotation = _expand_dims(rotation, 3)
|
|
53
|
+
self.target_translation = _expand_dims(target_translation, 2)
|
|
54
|
+
|
|
55
|
+
def apply(self, atoms):
|
|
56
|
+
"""
|
|
57
|
+
Apply this transformation on the given structure.
|
|
58
|
+
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
atoms : AtomArray or AtomArrayStack or ndarray, shape(n,), dtype=float or ndarray, shape(m,n), dtype=float
|
|
62
|
+
The structure to apply the transformation on.
|
|
63
|
+
|
|
64
|
+
Returns
|
|
65
|
+
-------
|
|
66
|
+
transformed : AtomArray or AtomArrayStack or ndarray, shape(n,), dtype=float or ndarray, shape(m,n), dtype=float
|
|
67
|
+
A copy of the `atoms` structure, with transformations applied.
|
|
68
|
+
Only coordinates are returned, if coordinates were given in `atoms`.
|
|
69
|
+
|
|
70
|
+
Examples
|
|
71
|
+
--------
|
|
72
|
+
|
|
73
|
+
>>> coord = np.arange(15).reshape(5,3)
|
|
74
|
+
>>> print(coord)
|
|
75
|
+
[[ 0 1 2]
|
|
76
|
+
[ 3 4 5]
|
|
77
|
+
[ 6 7 8]
|
|
78
|
+
[ 9 10 11]
|
|
79
|
+
[12 13 14]]
|
|
80
|
+
>>> # Rotates 90 degrees around the z-axis
|
|
81
|
+
>>> transform = AffineTransformation(
|
|
82
|
+
... center_translation=np.array([0,0,0]),
|
|
83
|
+
... rotation=np.array([
|
|
84
|
+
... [0, -1, 0],
|
|
85
|
+
... [1, 0, 0],
|
|
86
|
+
... [0, 0, 1]
|
|
87
|
+
... ]),
|
|
88
|
+
... target_translation=np.array([0,0,0])
|
|
89
|
+
... )
|
|
90
|
+
>>> print(transform.apply(coord))
|
|
91
|
+
[[ -1. 0. 2.]
|
|
92
|
+
[ -4. 3. 5.]
|
|
93
|
+
[ -7. 6. 8.]
|
|
94
|
+
[-10. 9. 11.]
|
|
95
|
+
[-13. 12. 14.]]
|
|
96
|
+
"""
|
|
97
|
+
mobile_coord = coord(atoms)
|
|
98
|
+
original_shape = mobile_coord.shape
|
|
99
|
+
mobile_coord = _reshape_to_3d(mobile_coord)
|
|
100
|
+
if (
|
|
101
|
+
self.rotation.shape[0] != 1
|
|
102
|
+
and mobile_coord.shape[0] != self.rotation.shape[0]
|
|
103
|
+
):
|
|
104
|
+
raise IndexError(
|
|
105
|
+
f"Number of transformations is {self.rotation.shape[0]}, "
|
|
106
|
+
f"but number of structure models is {mobile_coord.shape[0]}"
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
superimposed_coord = mobile_coord.copy()
|
|
110
|
+
superimposed_coord += self.center_translation[:, np.newaxis, :]
|
|
111
|
+
superimposed_coord = _multi_matmul(self.rotation, superimposed_coord)
|
|
112
|
+
superimposed_coord += self.target_translation[:, np.newaxis, :]
|
|
113
|
+
|
|
114
|
+
superimposed_coord = superimposed_coord.reshape(original_shape)
|
|
115
|
+
if isinstance(atoms, np.ndarray):
|
|
116
|
+
return superimposed_coord
|
|
117
|
+
else:
|
|
118
|
+
superimposed = atoms.copy()
|
|
119
|
+
superimposed.coord = superimposed_coord
|
|
120
|
+
return superimposed
|
|
121
|
+
|
|
122
|
+
def as_matrix(self):
|
|
123
|
+
"""
|
|
124
|
+
Get the translations and rotation as a combined 4x4
|
|
125
|
+
transformation matrix.
|
|
126
|
+
|
|
127
|
+
Multiplying this matrix with coordinates in the form
|
|
128
|
+
*(x, y, z, 1)* will apply the same transformation as
|
|
129
|
+
:meth:`apply()` to coordinates in the form *(x, y, z)*.
|
|
130
|
+
|
|
131
|
+
Returns
|
|
132
|
+
-------
|
|
133
|
+
transformation_matrix : ndarray, shape=(m,4,4), dtype=float
|
|
134
|
+
The transformation matrix.
|
|
135
|
+
*m* is the number of models in the transformation.
|
|
136
|
+
|
|
137
|
+
Examples
|
|
138
|
+
--------
|
|
139
|
+
|
|
140
|
+
>>> coord = np.arange(15).reshape(5,3)
|
|
141
|
+
>>> print(coord)
|
|
142
|
+
[[ 0 1 2]
|
|
143
|
+
[ 3 4 5]
|
|
144
|
+
[ 6 7 8]
|
|
145
|
+
[ 9 10 11]
|
|
146
|
+
[12 13 14]]
|
|
147
|
+
>>> # Rotates 90 degrees around the z-axis
|
|
148
|
+
>>> transform = AffineTransformation(
|
|
149
|
+
... center_translation=np.array([0,0,0]),
|
|
150
|
+
... rotation=np.array([
|
|
151
|
+
... [0, -1, 0],
|
|
152
|
+
... [1, 0, 0],
|
|
153
|
+
... [0, 0, 1]
|
|
154
|
+
... ]),
|
|
155
|
+
... target_translation=np.array([0,0,0])
|
|
156
|
+
... )
|
|
157
|
+
>>> print(transform.apply(coord))
|
|
158
|
+
[[ -1. 0. 2.]
|
|
159
|
+
[ -4. 3. 5.]
|
|
160
|
+
[ -7. 6. 8.]
|
|
161
|
+
[-10. 9. 11.]
|
|
162
|
+
[-13. 12. 14.]]
|
|
163
|
+
>>> # Use a 4x4 matrix for transformation as alternative
|
|
164
|
+
>>> coord_4 = np.concatenate([coord, np.ones((len(coord), 1))], axis=-1)
|
|
165
|
+
>>> print(coord_4)
|
|
166
|
+
[[ 0. 1. 2. 1.]
|
|
167
|
+
[ 3. 4. 5. 1.]
|
|
168
|
+
[ 6. 7. 8. 1.]
|
|
169
|
+
[ 9. 10. 11. 1.]
|
|
170
|
+
[12. 13. 14. 1.]]
|
|
171
|
+
>>> print((transform.as_matrix()[0] @ coord_4.T).T)
|
|
172
|
+
[[ -1. 0. 2. 1.]
|
|
173
|
+
[ -4. 3. 5. 1.]
|
|
174
|
+
[ -7. 6. 8. 1.]
|
|
175
|
+
[-10. 9. 11. 1.]
|
|
176
|
+
[-13. 12. 14. 1.]]
|
|
177
|
+
"""
|
|
178
|
+
n_models = self.rotation.shape[0]
|
|
179
|
+
rotation_mat = _3d_identity(n_models, 4)
|
|
180
|
+
rotation_mat[:, :3, :3] = self.rotation
|
|
181
|
+
center_translation_mat = _3d_identity(n_models, 4)
|
|
182
|
+
center_translation_mat[:, :3, 3] = self.center_translation
|
|
183
|
+
target_translation_mat = _3d_identity(n_models, 4)
|
|
184
|
+
target_translation_mat[:, :3, 3] = self.target_translation
|
|
185
|
+
return target_translation_mat @ rotation_mat @ center_translation_mat
|
|
186
|
+
|
|
187
|
+
def __eq__(self, other):
|
|
188
|
+
if not isinstance(other, AffineTransformation):
|
|
189
|
+
return False
|
|
190
|
+
if not np.array_equal(self.center_translation, other.center_translation):
|
|
191
|
+
return False
|
|
192
|
+
if not np.array_equal(self.rotation, other.rotation):
|
|
193
|
+
return False
|
|
194
|
+
if not np.array_equal(self.target_translation, other.target_translation):
|
|
195
|
+
return False
|
|
196
|
+
return True
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _expand_dims(array, n_dims):
|
|
200
|
+
"""
|
|
201
|
+
Expand the dimensions of an `ndarray` to a certain number of
|
|
202
|
+
dimensions.
|
|
203
|
+
"""
|
|
204
|
+
while array.ndim < n_dims:
|
|
205
|
+
array = array[np.newaxis, ...]
|
|
206
|
+
return array
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def _3d_identity(m, n):
|
|
210
|
+
"""
|
|
211
|
+
Create an array of *m* identity matrices of shape *(n, n)*
|
|
212
|
+
"""
|
|
213
|
+
matrices = np.zeros((m, n, n), dtype=float)
|
|
214
|
+
indices = np.arange(n)
|
|
215
|
+
matrices[:, indices, indices] = 1
|
|
216
|
+
return matrices
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def _reshape_to_3d(coord):
|
|
220
|
+
"""
|
|
221
|
+
Reshape the coordinate array to 3D, if it is 2D.
|
|
222
|
+
"""
|
|
223
|
+
if coord.ndim < 2:
|
|
224
|
+
raise ValueError("Coordinates must be at least two-dimensional")
|
|
225
|
+
if coord.ndim == 2:
|
|
226
|
+
return coord[np.newaxis, ...]
|
|
227
|
+
elif coord.ndim == 3:
|
|
228
|
+
return coord
|
|
229
|
+
else:
|
|
230
|
+
raise ValueError("Coordinates must be at most three-dimensional")
|
|
231
|
+
|
|
232
|
+
|
|
27
233
|
def translate(atoms, vector):
|
|
28
234
|
"""
|
|
29
235
|
Translate the given atoms or coordinates by a given vector.
|
|
@@ -150,6 +356,9 @@ def rotate_centered(atoms, angles):
|
|
|
150
356
|
rotate : Rotate atoms about the origin.
|
|
151
357
|
rotate_about_axis : Rotate atoms about a given axis.
|
|
152
358
|
"""
|
|
359
|
+
# Avoid circular import
|
|
360
|
+
from biotite.structure.geometry import centroid
|
|
361
|
+
|
|
153
362
|
if len(coord(atoms).shape) == 1:
|
|
154
363
|
# Single value -> centered rotation does not change coordinates
|
|
155
364
|
return atoms.copy()
|
|
@@ -515,3 +724,13 @@ def _put_back(input_atoms, transformed):
|
|
|
515
724
|
return moved_atoms
|
|
516
725
|
else:
|
|
517
726
|
return transformed
|
|
727
|
+
|
|
728
|
+
|
|
729
|
+
def _multi_matmul(matrices, vectors):
|
|
730
|
+
"""
|
|
731
|
+
Calculate the matrix multiplication of m matrices
|
|
732
|
+
with m x n vectors.
|
|
733
|
+
"""
|
|
734
|
+
return np.transpose(
|
|
735
|
+
np.matmul(matrices, np.transpose(vectors, axes=(0, 2, 1))), axes=(0, 2, 1)
|
|
736
|
+
)
|
biotite/version.py
CHANGED
|
@@ -1,46 +1,16 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: biotite
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A comprehensive library for computational molecular biology
|
|
5
5
|
Project-URL: homepage, https://www.biotite-python.org
|
|
6
6
|
Project-URL: repository, https://github.com/biotite-dev/biotite
|
|
7
7
|
Project-URL: documentation, https://www.biotite-python.org
|
|
8
8
|
Author: The Biotite contributors
|
|
9
|
-
License: BSD
|
|
10
|
-
--------------------
|
|
11
|
-
|
|
12
|
-
Copyright 2017, The Biotite contributors
|
|
13
|
-
All rights reserved.
|
|
14
|
-
|
|
15
|
-
Redistribution and use in source and binary forms, with or without modification,
|
|
16
|
-
are permitted provided that the following conditions are met:
|
|
17
|
-
|
|
18
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
19
|
-
list of conditions and the following disclaimer.
|
|
20
|
-
|
|
21
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
22
|
-
this list of conditions and the following disclaimer in the documentation and/or
|
|
23
|
-
other materials provided with the distribution.
|
|
24
|
-
|
|
25
|
-
3. Neither the name of the copyright holder nor the names of its contributors
|
|
26
|
-
may be used to endorse or promote products derived from this software without
|
|
27
|
-
specific prior written permission.
|
|
28
|
-
|
|
29
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
30
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
31
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
32
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
33
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
34
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
35
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
36
|
-
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
37
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
38
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
9
|
+
License-Expression: BSD-3-Clause
|
|
39
10
|
License-File: LICENSE.rst
|
|
40
11
|
Classifier: Development Status :: 5 - Production/Stable
|
|
41
12
|
Classifier: Intended Audience :: Developers
|
|
42
13
|
Classifier: Intended Audience :: Science/Research
|
|
43
|
-
Classifier: License :: OSI Approved :: BSD License
|
|
44
14
|
Classifier: Natural Language :: English
|
|
45
15
|
Classifier: Operating System :: MacOS
|
|
46
16
|
Classifier: Operating System :: Microsoft :: Windows
|
|
@@ -48,7 +18,7 @@ Classifier: Operating System :: POSIX :: Linux
|
|
|
48
18
|
Classifier: Programming Language :: Python :: 3
|
|
49
19
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
50
20
|
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
51
|
-
Requires-Python: >=3.
|
|
21
|
+
Requires-Python: >=3.11
|
|
52
22
|
Requires-Dist: biotraj<2.0,>=1.0
|
|
53
23
|
Requires-Dist: msgpack>=0.5.6
|
|
54
24
|
Requires-Dist: networkx>=2.0
|