biotite 0.41.2__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.
- biotite/__init__.py +2 -3
- biotite/application/__init__.py +1 -1
- biotite/application/application.py +20 -10
- biotite/application/autodock/__init__.py +1 -1
- biotite/application/autodock/app.py +74 -79
- biotite/application/blast/__init__.py +1 -1
- biotite/application/blast/alignment.py +19 -10
- biotite/application/blast/webapp.py +92 -85
- biotite/application/clustalo/__init__.py +1 -1
- biotite/application/clustalo/app.py +46 -61
- biotite/application/dssp/__init__.py +1 -1
- biotite/application/dssp/app.py +8 -11
- biotite/application/localapp.py +62 -60
- biotite/application/mafft/__init__.py +1 -1
- biotite/application/mafft/app.py +16 -22
- biotite/application/msaapp.py +78 -89
- biotite/application/muscle/__init__.py +1 -1
- biotite/application/muscle/app3.py +50 -64
- biotite/application/muscle/app5.py +23 -31
- biotite/application/sra/__init__.py +1 -1
- biotite/application/sra/app.py +64 -68
- biotite/application/tantan/__init__.py +1 -1
- biotite/application/tantan/app.py +22 -45
- biotite/application/util.py +7 -9
- biotite/application/viennarna/rnaalifold.py +34 -28
- biotite/application/viennarna/rnafold.py +24 -39
- biotite/application/viennarna/rnaplot.py +36 -21
- biotite/application/viennarna/util.py +17 -12
- biotite/application/webapp.py +13 -14
- biotite/copyable.py +13 -13
- biotite/database/__init__.py +1 -1
- biotite/database/entrez/__init__.py +1 -1
- biotite/database/entrez/check.py +2 -3
- biotite/database/entrez/dbnames.py +7 -5
- biotite/database/entrez/download.py +55 -49
- biotite/database/entrez/key.py +1 -1
- biotite/database/entrez/query.py +62 -23
- biotite/database/error.py +2 -1
- biotite/database/pubchem/__init__.py +1 -1
- biotite/database/pubchem/download.py +43 -45
- biotite/database/pubchem/error.py +2 -2
- biotite/database/pubchem/query.py +34 -31
- biotite/database/pubchem/throttle.py +3 -4
- biotite/database/rcsb/__init__.py +1 -1
- biotite/database/rcsb/download.py +44 -52
- biotite/database/rcsb/query.py +85 -80
- biotite/database/uniprot/check.py +6 -3
- biotite/database/uniprot/download.py +6 -11
- biotite/database/uniprot/query.py +115 -31
- biotite/file.py +12 -31
- biotite/sequence/__init__.py +3 -3
- biotite/sequence/align/__init__.py +2 -2
- biotite/sequence/align/alignment.py +99 -90
- biotite/sequence/align/banded.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/buckets.py +12 -10
- biotite/sequence/align/cigar.py +43 -52
- biotite/sequence/align/kmeralphabet.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/kmeralphabet.pyx +55 -51
- biotite/sequence/align/kmersimilarity.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.pyx +3 -2
- biotite/sequence/align/localgapped.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/localungapped.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/matrix.py +81 -82
- biotite/sequence/align/multiple.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/multiple.pyx +1 -1
- biotite/sequence/align/pairwise.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/permutation.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/permutation.pyx +12 -4
- biotite/sequence/align/selector.cp310-win_amd64.pyd +0 -0
- biotite/sequence/align/selector.pyx +52 -54
- biotite/sequence/align/statistics.py +32 -33
- biotite/sequence/align/tracetable.cp310-win_amd64.pyd +0 -0
- biotite/sequence/alphabet.py +51 -65
- biotite/sequence/annotation.py +78 -77
- biotite/sequence/codec.cp310-win_amd64.pyd +0 -0
- biotite/sequence/codon.py +90 -79
- biotite/sequence/graphics/__init__.py +1 -1
- biotite/sequence/graphics/alignment.py +184 -103
- biotite/sequence/graphics/colorschemes.py +10 -12
- biotite/sequence/graphics/dendrogram.py +79 -34
- biotite/sequence/graphics/features.py +133 -99
- biotite/sequence/graphics/logo.py +22 -28
- biotite/sequence/graphics/plasmid.py +229 -178
- biotite/sequence/io/fasta/__init__.py +1 -1
- biotite/sequence/io/fasta/convert.py +44 -33
- biotite/sequence/io/fasta/file.py +42 -55
- biotite/sequence/io/fastq/__init__.py +1 -1
- biotite/sequence/io/fastq/convert.py +11 -14
- biotite/sequence/io/fastq/file.py +68 -112
- biotite/sequence/io/genbank/__init__.py +2 -2
- biotite/sequence/io/genbank/annotation.py +12 -20
- biotite/sequence/io/genbank/file.py +74 -76
- biotite/sequence/io/genbank/metadata.py +74 -62
- biotite/sequence/io/genbank/sequence.py +13 -14
- biotite/sequence/io/general.py +39 -30
- biotite/sequence/io/gff/__init__.py +2 -2
- biotite/sequence/io/gff/convert.py +10 -15
- biotite/sequence/io/gff/file.py +81 -65
- biotite/sequence/phylo/__init__.py +1 -1
- biotite/sequence/phylo/nj.cp310-win_amd64.pyd +0 -0
- biotite/sequence/phylo/tree.cp310-win_amd64.pyd +0 -0
- biotite/sequence/phylo/upgma.cp310-win_amd64.pyd +0 -0
- biotite/sequence/profile.py +57 -28
- biotite/sequence/search.py +17 -15
- biotite/sequence/seqtypes.py +200 -164
- biotite/sequence/sequence.py +15 -17
- biotite/structure/__init__.py +3 -3
- biotite/structure/atoms.py +221 -235
- biotite/structure/basepairs.py +260 -271
- biotite/structure/bonds.cp310-win_amd64.pyd +0 -0
- biotite/structure/bonds.pyx +29 -32
- biotite/structure/box.py +67 -71
- biotite/structure/celllist.cp310-win_amd64.pyd +0 -0
- biotite/structure/chains.py +55 -39
- biotite/structure/charges.cp310-win_amd64.pyd +0 -0
- biotite/structure/compare.py +32 -32
- biotite/structure/density.py +13 -18
- biotite/structure/dotbracket.py +20 -22
- biotite/structure/error.py +10 -2
- biotite/structure/filter.py +82 -77
- biotite/structure/geometry.py +130 -119
- biotite/structure/graphics/atoms.py +60 -43
- biotite/structure/graphics/rna.py +81 -68
- biotite/structure/hbond.py +112 -93
- biotite/structure/info/__init__.py +0 -2
- biotite/structure/info/atoms.py +10 -11
- biotite/structure/info/bonds.py +41 -43
- biotite/structure/info/ccd.py +4 -5
- biotite/structure/info/groups.py +1 -3
- biotite/structure/info/masses.py +5 -10
- biotite/structure/info/misc.py +1 -1
- biotite/structure/info/radii.py +20 -20
- biotite/structure/info/standardize.py +15 -26
- biotite/structure/integrity.py +18 -71
- biotite/structure/io/__init__.py +3 -4
- biotite/structure/io/dcd/__init__.py +1 -1
- biotite/structure/io/dcd/file.py +22 -20
- biotite/structure/io/general.py +47 -61
- biotite/structure/io/gro/__init__.py +1 -1
- biotite/structure/io/gro/file.py +73 -72
- biotite/structure/io/mol/__init__.py +1 -1
- biotite/structure/io/mol/convert.py +8 -11
- biotite/structure/io/mol/ctab.py +37 -36
- biotite/structure/io/mol/header.py +14 -10
- biotite/structure/io/mol/mol.py +9 -53
- biotite/structure/io/mol/sdf.py +47 -50
- biotite/structure/io/netcdf/__init__.py +1 -1
- biotite/structure/io/netcdf/file.py +24 -23
- biotite/structure/io/pdb/__init__.py +1 -1
- biotite/structure/io/pdb/convert.py +32 -20
- biotite/structure/io/pdb/file.py +151 -172
- biotite/structure/io/pdb/hybrid36.cp310-win_amd64.pyd +0 -0
- biotite/structure/io/pdbqt/__init__.py +1 -1
- biotite/structure/io/pdbqt/convert.py +17 -11
- biotite/structure/io/pdbqt/file.py +128 -80
- biotite/structure/io/pdbx/__init__.py +1 -2
- biotite/structure/io/pdbx/bcif.py +36 -44
- biotite/structure/io/pdbx/cif.py +64 -62
- biotite/structure/io/pdbx/component.py +10 -16
- biotite/structure/io/pdbx/convert.py +235 -246
- biotite/structure/io/pdbx/encoding.cp310-win_amd64.pyd +0 -0
- biotite/structure/io/trajfile.py +76 -93
- biotite/structure/io/trr/__init__.py +1 -1
- biotite/structure/io/trr/file.py +12 -15
- biotite/structure/io/xtc/__init__.py +1 -1
- biotite/structure/io/xtc/file.py +11 -14
- biotite/structure/mechanics.py +9 -11
- biotite/structure/molecules.py +3 -4
- biotite/structure/pseudoknots.py +53 -67
- biotite/structure/rdf.py +23 -21
- biotite/structure/repair.py +137 -86
- biotite/structure/residues.py +26 -16
- biotite/structure/sasa.cp310-win_amd64.pyd +0 -0
- biotite/structure/{resutil.py → segments.py} +24 -23
- biotite/structure/sequence.py +10 -11
- biotite/structure/sse.py +100 -119
- biotite/structure/superimpose.py +39 -77
- biotite/structure/transform.py +97 -71
- biotite/structure/util.py +11 -13
- biotite/version.py +2 -2
- biotite/visualize.py +69 -55
- {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/METADATA +5 -5
- biotite-1.0.0.dist-info/RECORD +322 -0
- biotite/structure/io/ctab.py +0 -72
- biotite/structure/io/mmtf/__init__.py +0 -21
- biotite/structure/io/mmtf/assembly.py +0 -214
- biotite/structure/io/mmtf/convertarray.cp310-win_amd64.pyd +0 -0
- biotite/structure/io/mmtf/convertarray.pyx +0 -341
- biotite/structure/io/mmtf/convertfile.cp310-win_amd64.pyd +0 -0
- biotite/structure/io/mmtf/convertfile.pyx +0 -501
- biotite/structure/io/mmtf/decode.cp310-win_amd64.pyd +0 -0
- biotite/structure/io/mmtf/decode.pyx +0 -152
- biotite/structure/io/mmtf/encode.cp310-win_amd64.pyd +0 -0
- biotite/structure/io/mmtf/encode.pyx +0 -183
- biotite/structure/io/mmtf/file.py +0 -233
- biotite/structure/io/npz/__init__.py +0 -20
- biotite/structure/io/npz/file.py +0 -152
- biotite/structure/io/pdbx/legacy.py +0 -267
- biotite/structure/io/tng/__init__.py +0 -13
- biotite/structure/io/tng/file.py +0 -46
- biotite/temp.py +0 -86
- biotite-0.41.2.dist-info/RECORD +0 -340
- {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/WHEEL +0 -0
- {biotite-0.41.2.dist-info → biotite-1.0.0.dist-info}/licenses/LICENSE.rst +0 -0
|
Binary file
|
biotite/structure/io/trajfile.py
CHANGED
|
@@ -6,25 +6,22 @@ __name__ = "biotite.structure.io"
|
|
|
6
6
|
__author__ = "Patrick Kunzmann"
|
|
7
7
|
__all__ = ["TrajectoryFile"]
|
|
8
8
|
|
|
9
|
-
import itertools
|
|
10
9
|
import abc
|
|
10
|
+
import itertools
|
|
11
11
|
import numpy as np
|
|
12
|
-
from
|
|
13
|
-
from
|
|
12
|
+
from biotite.file import File
|
|
13
|
+
from biotite.structure.atoms import AtomArray, AtomArrayStack, from_template
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
17
17
|
"""
|
|
18
18
|
This file class represents a trajectory file interfacing a
|
|
19
|
-
trajectory file class from `
|
|
20
|
-
|
|
19
|
+
trajectory file class from `biotraj`.
|
|
20
|
+
|
|
21
21
|
A trajectory file stores atom coordinates over multiple (time)
|
|
22
22
|
frames. The file formats are usually binary and involve sometimes
|
|
23
23
|
heavy compression, so that a large number of frames can be stored
|
|
24
24
|
in relatively small space.
|
|
25
|
-
Since all :class:`TrajectoryFile` subclasses interface *MDtraj*
|
|
26
|
-
trajectory file classes, `MDtraj` must be installed to use any of
|
|
27
|
-
them.
|
|
28
25
|
|
|
29
26
|
Notes
|
|
30
27
|
-----
|
|
@@ -34,27 +31,27 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
34
31
|
Therefore, it is strongly recommended to make a copy of the
|
|
35
32
|
respective array, if the array is modified.
|
|
36
33
|
"""
|
|
37
|
-
|
|
34
|
+
|
|
38
35
|
def __init__(self):
|
|
39
36
|
super().__init__()
|
|
40
37
|
self._coord = None
|
|
41
38
|
self._time = None
|
|
42
39
|
self._box = None
|
|
43
40
|
self._model_count = None
|
|
44
|
-
|
|
45
41
|
|
|
46
42
|
@classmethod
|
|
47
|
-
def read(
|
|
48
|
-
|
|
43
|
+
def read(
|
|
44
|
+
cls, file_name, start=None, stop=None, step=None, atom_i=None, chunk_size=None
|
|
45
|
+
):
|
|
49
46
|
"""
|
|
50
47
|
Read a trajectory file.
|
|
51
|
-
|
|
48
|
+
|
|
52
49
|
A trajectory file can be seen as a file representation of an
|
|
53
50
|
:class:`AtomArrayStack`.
|
|
54
51
|
Therefore, `start`, `stop` and `step` represent slice parameters
|
|
55
52
|
of the index of the first dimension and
|
|
56
53
|
`atom_i` represents an index array for the second dimension.
|
|
57
|
-
|
|
54
|
+
|
|
58
55
|
Parameters
|
|
59
56
|
----------
|
|
60
57
|
file_name : str
|
|
@@ -85,7 +82,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
85
82
|
Although lower values can decrease the memory consumption of
|
|
86
83
|
reading trajectories, they also increase the computation
|
|
87
84
|
time.
|
|
88
|
-
|
|
85
|
+
|
|
89
86
|
Returns
|
|
90
87
|
-------
|
|
91
88
|
file_object : TrajectoryFile
|
|
@@ -105,7 +102,6 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
105
102
|
|
|
106
103
|
traj_type = cls.traj_type()
|
|
107
104
|
with traj_type(file_name, "r") as f:
|
|
108
|
-
|
|
109
105
|
if start is None:
|
|
110
106
|
start = 0
|
|
111
107
|
# Discard atoms before start
|
|
@@ -116,13 +112,13 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
116
112
|
TrajectoryFile._read_chunk_wise(
|
|
117
113
|
f, start, None, atom_i, chunk_size, discard=True
|
|
118
114
|
)
|
|
119
|
-
|
|
115
|
+
|
|
120
116
|
# The upcoming frames are saved
|
|
121
117
|
# Calculate the amount of frames to be read
|
|
122
118
|
if stop is None:
|
|
123
119
|
n_frames = None
|
|
124
120
|
else:
|
|
125
|
-
n_frames = stop-start
|
|
121
|
+
n_frames = stop - start
|
|
126
122
|
if step is not None and n_frames is not None:
|
|
127
123
|
# Divide number of frames by 'step' in order to convert
|
|
128
124
|
# 'step' into 'stride'
|
|
@@ -130,7 +126,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
130
126
|
# the number of frames is decremented before division
|
|
131
127
|
# and incremented afterwards again
|
|
132
128
|
n_frames = ((n_frames - 1) // step) + 1
|
|
133
|
-
|
|
129
|
+
|
|
134
130
|
# Read frames
|
|
135
131
|
if chunk_size is None:
|
|
136
132
|
result = f.read(n_frames, stride=step, atom_indices=atom_i)
|
|
@@ -138,7 +134,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
138
134
|
result = TrajectoryFile._read_chunk_wise(
|
|
139
135
|
f, n_frames, step, atom_i, chunk_size, discard=False
|
|
140
136
|
)
|
|
141
|
-
|
|
137
|
+
|
|
142
138
|
# nm to Angstrom
|
|
143
139
|
coord, box, time = cls.process_read_values(result)
|
|
144
140
|
file.set_coord(coord)
|
|
@@ -146,15 +142,15 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
146
142
|
file.set_time(time)
|
|
147
143
|
|
|
148
144
|
return file
|
|
149
|
-
|
|
150
145
|
|
|
151
146
|
@classmethod
|
|
152
|
-
def read_iter(
|
|
153
|
-
|
|
147
|
+
def read_iter(
|
|
148
|
+
cls, file_name, start=None, stop=None, step=None, atom_i=None, stack_size=None
|
|
149
|
+
):
|
|
154
150
|
"""
|
|
155
151
|
Create an iterator over each frame of the given trajectory file
|
|
156
152
|
in the selected range.
|
|
157
|
-
|
|
153
|
+
|
|
158
154
|
Parameters
|
|
159
155
|
----------
|
|
160
156
|
file_name : str
|
|
@@ -181,7 +177,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
181
177
|
values.
|
|
182
178
|
If the number of frames is not a multiple of `stack_size`,
|
|
183
179
|
the final stack is smaller than `stack_size`.
|
|
184
|
-
|
|
180
|
+
|
|
185
181
|
Yields
|
|
186
182
|
------
|
|
187
183
|
coord : ndarray, dtype=float32, shape=(n,3) or shape=(m,n,3)
|
|
@@ -190,30 +186,29 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
190
186
|
The box vectors of the current frame or stack.
|
|
191
187
|
time : float or ndarray, dtype=float32, shape=(n,) or None
|
|
192
188
|
The simulation time of the current frame or stack in *ps*.
|
|
193
|
-
|
|
189
|
+
|
|
194
190
|
See also
|
|
195
191
|
--------
|
|
196
192
|
read_iter_structure
|
|
197
|
-
|
|
193
|
+
|
|
198
194
|
Notes
|
|
199
195
|
-----
|
|
200
196
|
The `step` parameter does currently not work for *DCD* files.
|
|
201
197
|
"""
|
|
202
198
|
traj_type = cls.traj_type()
|
|
203
199
|
with traj_type(file_name, "r") as f:
|
|
204
|
-
|
|
205
200
|
if start is None:
|
|
206
201
|
start = 0
|
|
207
202
|
# Discard atoms before start
|
|
208
203
|
if start != 0:
|
|
209
204
|
f.read(n_frames=start, stride=None, atom_indices=atom_i)
|
|
210
|
-
|
|
205
|
+
|
|
211
206
|
# The upcoming frames are read
|
|
212
207
|
# Calculate the amount of frames to be read
|
|
213
208
|
if stop is None:
|
|
214
209
|
n_frames = None
|
|
215
210
|
else:
|
|
216
|
-
n_frames = stop-start
|
|
211
|
+
n_frames = stop - start
|
|
217
212
|
if step is not None and n_frames is not None:
|
|
218
213
|
# Divide number of frames by 'step' in order to convert
|
|
219
214
|
# 'step' into 'stride'
|
|
@@ -221,7 +216,6 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
221
216
|
# the number of frames is decremented before division
|
|
222
217
|
# and incremented afterwards again
|
|
223
218
|
n_frames = ((n_frames - 1) // step) + 1
|
|
224
|
-
|
|
225
219
|
|
|
226
220
|
# Read frames
|
|
227
221
|
if stack_size is None:
|
|
@@ -242,7 +236,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
242
236
|
yield coord, box, time
|
|
243
237
|
if remaining_frames is not None:
|
|
244
238
|
remaining_frames -= 1
|
|
245
|
-
|
|
239
|
+
|
|
246
240
|
else:
|
|
247
241
|
remaining_frames = n_frames
|
|
248
242
|
while remaining_frames is None or remaining_frames > 0:
|
|
@@ -260,11 +254,18 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
260
254
|
yield coord, box, time
|
|
261
255
|
if remaining_frames is not None:
|
|
262
256
|
remaining_frames -= stack_size
|
|
263
|
-
|
|
264
257
|
|
|
265
258
|
@classmethod
|
|
266
|
-
def read_iter_structure(
|
|
267
|
-
|
|
259
|
+
def read_iter_structure(
|
|
260
|
+
cls,
|
|
261
|
+
file_name,
|
|
262
|
+
template,
|
|
263
|
+
start=None,
|
|
264
|
+
stop=None,
|
|
265
|
+
step=None,
|
|
266
|
+
atom_i=None,
|
|
267
|
+
stack_size=None,
|
|
268
|
+
):
|
|
268
269
|
"""
|
|
269
270
|
Create an iterator over each frame of the given trajectory file
|
|
270
271
|
in the selected range.
|
|
@@ -275,8 +276,8 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
275
276
|
information and no topology information, this method requires
|
|
276
277
|
a template atom array or stack. This template can be acquired
|
|
277
278
|
for example from a PDB file, which is associated with the
|
|
278
|
-
trajectory file.
|
|
279
|
-
|
|
279
|
+
trajectory file.
|
|
280
|
+
|
|
280
281
|
Parameters
|
|
281
282
|
----------
|
|
282
283
|
file_name : str
|
|
@@ -306,18 +307,18 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
306
307
|
determined by this parameter.
|
|
307
308
|
If the number of frames is not a multiple of `stack_size`,
|
|
308
309
|
the final stack is smaller than `stack_size`.
|
|
309
|
-
|
|
310
|
+
|
|
310
311
|
Yields
|
|
311
312
|
------
|
|
312
313
|
structure : AtomArray or AtomArrayStack
|
|
313
314
|
The structure of the current frame as :class:`AtomArray`.
|
|
314
315
|
If `stack_size` is set, multiple frames are returned as
|
|
315
316
|
:class:`AtomArrayStack`.
|
|
316
|
-
|
|
317
|
+
|
|
317
318
|
See also
|
|
318
319
|
--------
|
|
319
320
|
read_iter
|
|
320
|
-
|
|
321
|
+
|
|
321
322
|
Notes
|
|
322
323
|
-----
|
|
323
324
|
This iterator creates a new copy of the given template for every
|
|
@@ -335,7 +336,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
335
336
|
f"An 'AtomArray' or 'AtomArrayStack' is expected as template, "
|
|
336
337
|
f"not '{type(template).__name__}'"
|
|
337
338
|
)
|
|
338
|
-
|
|
339
|
+
|
|
339
340
|
for coord, box, _ in cls.read_iter(
|
|
340
341
|
file_name, start, stop, step, atom_i, stack_size
|
|
341
342
|
):
|
|
@@ -347,7 +348,6 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
347
348
|
else:
|
|
348
349
|
yield from_template(template, coord, box)
|
|
349
350
|
|
|
350
|
-
|
|
351
351
|
def write(self, file_name):
|
|
352
352
|
"""
|
|
353
353
|
Write the content into a trajectory file.
|
|
@@ -360,9 +360,8 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
360
360
|
"""
|
|
361
361
|
traj_type = self.traj_type()
|
|
362
362
|
param = self.prepare_write_values(self._coord, self._box, self._time)
|
|
363
|
-
with traj_type(file_name,
|
|
363
|
+
with traj_type(file_name, "w") as f:
|
|
364
364
|
f.write(**param)
|
|
365
|
-
|
|
366
365
|
|
|
367
366
|
@classmethod
|
|
368
367
|
def write_iter(cls, file_name, coord, box=None, time=None):
|
|
@@ -376,7 +375,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
376
375
|
Hence, this class method may save a large amount of memory if
|
|
377
376
|
a large file should be written, if `coord` are provided as
|
|
378
377
|
generator.
|
|
379
|
-
|
|
378
|
+
|
|
380
379
|
Parameters
|
|
381
380
|
----------
|
|
382
381
|
file_name : str
|
|
@@ -391,7 +390,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
391
390
|
|
|
392
391
|
Notes
|
|
393
392
|
-----
|
|
394
|
-
The `time` parameter has no effect for *
|
|
393
|
+
The `time` parameter has no effect for *DCD* files.
|
|
395
394
|
"""
|
|
396
395
|
if box is None:
|
|
397
396
|
box = itertools.repeat(None)
|
|
@@ -399,7 +398,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
399
398
|
time = itertools.repeat(None)
|
|
400
399
|
|
|
401
400
|
traj_type = cls.traj_type()
|
|
402
|
-
with traj_type(file_name,
|
|
401
|
+
with traj_type(file_name, "w") as f:
|
|
403
402
|
for c, b, t in zip(coord, box, time):
|
|
404
403
|
if c.ndim != 2:
|
|
405
404
|
raise IndexError(
|
|
@@ -414,24 +413,22 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
414
413
|
t = np.expand_dims(t, axis=0)
|
|
415
414
|
param = cls.prepare_write_values(c, b, t)
|
|
416
415
|
f.write(**param)
|
|
417
|
-
|
|
418
416
|
|
|
419
417
|
def get_coord(self):
|
|
420
418
|
"""
|
|
421
419
|
Extract only the atom coordinates from the trajectory file.
|
|
422
|
-
|
|
420
|
+
|
|
423
421
|
Returns
|
|
424
422
|
-------
|
|
425
423
|
coord : ndarray, dtype=float, shape=(m,n,3)
|
|
426
424
|
The coordinates stored in the trajectory file.
|
|
427
425
|
"""
|
|
428
426
|
return self._coord
|
|
429
|
-
|
|
430
427
|
|
|
431
428
|
def get_time(self):
|
|
432
429
|
"""
|
|
433
430
|
Get the simlation time in *ps* values for each frame.
|
|
434
|
-
|
|
431
|
+
|
|
435
432
|
Returns
|
|
436
433
|
-------
|
|
437
434
|
time : ndarray, dtype=float, shape=(m,)
|
|
@@ -439,12 +436,11 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
439
436
|
frames, that were read from the file.
|
|
440
437
|
"""
|
|
441
438
|
return self._time
|
|
442
|
-
|
|
443
439
|
|
|
444
440
|
def get_box(self):
|
|
445
441
|
"""
|
|
446
442
|
Get the box vectors for each frame.
|
|
447
|
-
|
|
443
|
+
|
|
448
444
|
Returns
|
|
449
445
|
-------
|
|
450
446
|
box : ndarray, dtype=float, shape=(m,3,3)
|
|
@@ -452,12 +448,11 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
452
448
|
frames, that were read from the file.
|
|
453
449
|
"""
|
|
454
450
|
return self._box
|
|
455
|
-
|
|
456
451
|
|
|
457
452
|
def set_coord(self, coord):
|
|
458
453
|
"""
|
|
459
454
|
Set the atom coordinates in the trajectory file.
|
|
460
|
-
|
|
455
|
+
|
|
461
456
|
Parameters
|
|
462
457
|
----------
|
|
463
458
|
coord : ndarray, dtype=float, shape=(m,n,3)
|
|
@@ -465,12 +460,11 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
465
460
|
"""
|
|
466
461
|
self._check_model_count(coord)
|
|
467
462
|
self._coord = coord
|
|
468
|
-
|
|
469
463
|
|
|
470
464
|
def set_time(self, time):
|
|
471
465
|
"""
|
|
472
466
|
Set the simulation time of each frame in the trajectory file.
|
|
473
|
-
|
|
467
|
+
|
|
474
468
|
Parameters
|
|
475
469
|
----------
|
|
476
470
|
time : ndarray, dtype=float, shape=(m,)
|
|
@@ -478,13 +472,12 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
478
472
|
"""
|
|
479
473
|
self._check_model_count(time)
|
|
480
474
|
self._time = time
|
|
481
|
-
|
|
482
475
|
|
|
483
476
|
def set_box(self, box):
|
|
484
477
|
"""
|
|
485
478
|
Set the periodic box vectors of each frame in the trajectory
|
|
486
479
|
file.
|
|
487
|
-
|
|
480
|
+
|
|
488
481
|
Parameters
|
|
489
482
|
----------
|
|
490
483
|
time : ndarray, dtype=float, shape=(m,3,3)
|
|
@@ -492,25 +485,24 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
492
485
|
"""
|
|
493
486
|
self._check_model_count(box)
|
|
494
487
|
self._box = box
|
|
495
|
-
|
|
496
488
|
|
|
497
489
|
def get_structure(self, template):
|
|
498
490
|
"""
|
|
499
491
|
Convert the trajectory file content into an
|
|
500
492
|
:class:`AtomArrayStack`.
|
|
501
|
-
|
|
493
|
+
|
|
502
494
|
Since trajectory files usually only contain atom coordinate
|
|
503
495
|
information and no topology information, this method requires
|
|
504
496
|
a template atom array or stack. This template can be acquired
|
|
505
497
|
for example from a PDB file, which is associated with the
|
|
506
|
-
trajectory file.
|
|
507
|
-
|
|
498
|
+
trajectory file.
|
|
499
|
+
|
|
508
500
|
Parameters
|
|
509
501
|
----------
|
|
510
502
|
template : AtomArray or AtomArrayStack
|
|
511
503
|
The template array or stack, where the atom annotation data
|
|
512
504
|
is taken from.
|
|
513
|
-
|
|
505
|
+
|
|
514
506
|
Returns
|
|
515
507
|
-------
|
|
516
508
|
array_stack : AtomArrayStack
|
|
@@ -519,15 +511,14 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
519
511
|
trajectory file.
|
|
520
512
|
"""
|
|
521
513
|
return from_template(template, self.get_coord(), self.get_box())
|
|
522
|
-
|
|
523
514
|
|
|
524
515
|
def set_structure(self, structure, time=None):
|
|
525
516
|
"""
|
|
526
517
|
Write an atom array (stack) into the trajectory file object.
|
|
527
|
-
|
|
518
|
+
|
|
528
519
|
The topology information (chain, residue, etc.) is not saved in
|
|
529
520
|
the file.
|
|
530
|
-
|
|
521
|
+
|
|
531
522
|
Parameters
|
|
532
523
|
----------
|
|
533
524
|
structure : AtomArray or AtomArrayStack
|
|
@@ -547,51 +538,47 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
547
538
|
if time is not None:
|
|
548
539
|
self.set_time(time)
|
|
549
540
|
|
|
550
|
-
|
|
551
541
|
def copy(self):
|
|
552
542
|
"""
|
|
553
543
|
This operation is not implemented for trajectory files.
|
|
554
|
-
|
|
544
|
+
|
|
555
545
|
Raises
|
|
556
546
|
------
|
|
557
547
|
NotImplementedError
|
|
558
548
|
"""
|
|
559
|
-
raise NotImplementedError("Copying is not implemented "
|
|
560
|
-
"for trajectory files")
|
|
561
|
-
|
|
549
|
+
raise NotImplementedError("Copying is not implemented " "for trajectory files")
|
|
562
550
|
|
|
563
551
|
@classmethod
|
|
564
552
|
@abc.abstractmethod
|
|
565
553
|
def traj_type(cls):
|
|
566
554
|
"""
|
|
567
|
-
The
|
|
568
|
-
|
|
555
|
+
The ``biotraj`` files class to be used.
|
|
556
|
+
|
|
569
557
|
PROTECTED: Override when inheriting.
|
|
570
|
-
|
|
558
|
+
|
|
571
559
|
Returns
|
|
572
560
|
-------
|
|
573
561
|
class
|
|
574
|
-
An
|
|
562
|
+
An ``biotraj`` subclass of :class:`TrajectoryFile`.
|
|
575
563
|
"""
|
|
576
564
|
pass
|
|
577
|
-
|
|
578
565
|
|
|
579
566
|
@classmethod
|
|
580
567
|
@abc.abstractmethod
|
|
581
568
|
def process_read_values(cls, read_values):
|
|
582
569
|
"""
|
|
583
570
|
Convert the return value of the `read()` method of the
|
|
584
|
-
respective :class:`
|
|
571
|
+
respective :class:`biotraj.TrajectoryFile` into coordinates,
|
|
585
572
|
simulation box and simulation time.
|
|
586
|
-
|
|
573
|
+
|
|
587
574
|
PROTECTED: Override when inheriting.
|
|
588
|
-
|
|
575
|
+
|
|
589
576
|
Parameters
|
|
590
577
|
----------
|
|
591
578
|
read_values : tuple
|
|
592
579
|
The return value of the respective
|
|
593
|
-
:func:`
|
|
594
|
-
|
|
580
|
+
:func:`biotraj.TrajectoryFile.read()` method.
|
|
581
|
+
|
|
595
582
|
Returns
|
|
596
583
|
-------
|
|
597
584
|
coord : ndarray, dtype=float, shape=(m,n,3)
|
|
@@ -602,7 +589,6 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
602
589
|
The simulation time in ps for each frame.
|
|
603
590
|
"""
|
|
604
591
|
pass
|
|
605
|
-
|
|
606
592
|
|
|
607
593
|
@classmethod
|
|
608
594
|
@abc.abstractmethod
|
|
@@ -610,7 +596,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
610
596
|
"""
|
|
611
597
|
Convert the `coord`, `box` and `time` attribute into a
|
|
612
598
|
dictionary that is given as *kwargs* to the respective
|
|
613
|
-
:func:`
|
|
599
|
+
:func:`biotraj.TrajectoryFile.write()` method.
|
|
614
600
|
|
|
615
601
|
PROTECTED: Override when inheriting.
|
|
616
602
|
|
|
@@ -622,16 +608,15 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
622
608
|
The box vectors in Å for each frame.
|
|
623
609
|
time : ndarray, dtype=float, shape=(m,)
|
|
624
610
|
The simulation time in ps for each frame.
|
|
625
|
-
|
|
611
|
+
|
|
626
612
|
Returns
|
|
627
613
|
-------
|
|
628
614
|
parameters : dict
|
|
629
615
|
This dictionary is given as *kwargs* parameter to the
|
|
630
|
-
respective :func:`
|
|
616
|
+
respective :func:`biotraj.TrajectoryFile.write()` method.
|
|
631
617
|
"""
|
|
632
618
|
pass
|
|
633
619
|
|
|
634
|
-
|
|
635
620
|
def _check_model_count(self, array):
|
|
636
621
|
"""
|
|
637
622
|
Check if the amount of models in the given array is equal to
|
|
@@ -650,11 +635,9 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
650
635
|
f"{len(array)} models were given, "
|
|
651
636
|
f"but the file contains {self._model_count} models"
|
|
652
637
|
)
|
|
653
|
-
|
|
654
638
|
|
|
655
639
|
@staticmethod
|
|
656
|
-
def _read_chunk_wise(file, n_frames, step, atom_i, chunk_size,
|
|
657
|
-
discard=False):
|
|
640
|
+
def _read_chunk_wise(file, n_frames, step, atom_i, chunk_size, discard=False):
|
|
658
641
|
"""
|
|
659
642
|
Similar to :func:`read()`, just for chunk-wise reading of the
|
|
660
643
|
trajectory.
|
|
@@ -674,7 +657,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
674
657
|
try:
|
|
675
658
|
chunk = file.read(n_frames=n, stride=step, atom_indices=atom_i)
|
|
676
659
|
except ValueError as e:
|
|
677
|
-
#
|
|
660
|
+
# biotraj raises exception because no coordinates can be
|
|
678
661
|
# concatenated
|
|
679
662
|
# -> all frames have been read
|
|
680
663
|
# -> stop reading chunks
|
|
@@ -691,7 +674,7 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
691
674
|
chunks.append(chunk)
|
|
692
675
|
if remaining_frames is not None:
|
|
693
676
|
remaining_frames -= n
|
|
694
|
-
|
|
677
|
+
|
|
695
678
|
if not discard:
|
|
696
679
|
# Assemble the chunks into contiguous arrays
|
|
697
680
|
# for each value (coord, box, time)
|
|
@@ -707,4 +690,4 @@ class TrajectoryFile(File, metaclass=abc.ABCMeta):
|
|
|
707
690
|
result[i] = None
|
|
708
691
|
return tuple(result)
|
|
709
692
|
else:
|
|
710
|
-
return None
|
|
693
|
+
return None
|
biotite/structure/io/trr/file.py
CHANGED
|
@@ -6,20 +6,20 @@ __name__ = "biotite.structure.io.trr"
|
|
|
6
6
|
__author__ = "Patrick Kunzmann"
|
|
7
7
|
__all__ = ["TRRFile"]
|
|
8
8
|
|
|
9
|
+
import biotraj
|
|
9
10
|
import numpy as np
|
|
10
|
-
from
|
|
11
|
+
from biotite.structure.io.trajfile import TrajectoryFile
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class TRRFile(TrajectoryFile):
|
|
14
15
|
"""
|
|
15
16
|
This file class represents a TRR trajectory file.
|
|
16
17
|
"""
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
@classmethod
|
|
19
20
|
def traj_type(cls):
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
return biotraj.TRRTrajectoryFile
|
|
22
|
+
|
|
23
23
|
@classmethod
|
|
24
24
|
def process_read_values(cls, read_values):
|
|
25
25
|
# nm to Angstrom
|
|
@@ -29,18 +29,15 @@ class TRRFile(TrajectoryFile):
|
|
|
29
29
|
box *= 10
|
|
30
30
|
time = read_values[1]
|
|
31
31
|
return coord, box, time
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
@classmethod
|
|
34
34
|
def prepare_write_values(cls, coord, box, time):
|
|
35
35
|
# Angstrom to nm
|
|
36
|
-
xyz = np.divide(coord, 10, dtype=np.float32)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if time is not None else None
|
|
40
|
-
box = np.divide(box, 10, dtype=np.float32) \
|
|
41
|
-
if box is not None else None
|
|
36
|
+
xyz = np.divide(coord, 10, dtype=np.float32) if coord is not None else None
|
|
37
|
+
time = time.astype(np.float32, copy=False) if time is not None else None
|
|
38
|
+
box = np.divide(box, 10, dtype=np.float32) if box is not None else None
|
|
42
39
|
return {
|
|
43
|
-
"xyz"
|
|
44
|
-
"box"
|
|
45
|
-
"time"
|
|
40
|
+
"xyz": xyz,
|
|
41
|
+
"box": box,
|
|
42
|
+
"time": time,
|
|
46
43
|
}
|
biotite/structure/io/xtc/file.py
CHANGED
|
@@ -6,19 +6,19 @@ __name__ = "biotite.structure.io.xtc"
|
|
|
6
6
|
__author__ = "Patrick Kunzmann"
|
|
7
7
|
__all__ = ["XTCFile"]
|
|
8
8
|
|
|
9
|
+
import biotraj
|
|
9
10
|
import numpy as np
|
|
10
|
-
from
|
|
11
|
+
from biotite.structure.io.trajfile import TrajectoryFile
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class XTCFile(TrajectoryFile):
|
|
14
15
|
"""
|
|
15
16
|
This file class represents a XTC trajectory file.
|
|
16
17
|
"""
|
|
17
|
-
|
|
18
|
+
|
|
18
19
|
@classmethod
|
|
19
20
|
def traj_type(cls):
|
|
20
|
-
|
|
21
|
-
return traj.XTCTrajectoryFile
|
|
21
|
+
return biotraj.XTCTrajectoryFile
|
|
22
22
|
|
|
23
23
|
@classmethod
|
|
24
24
|
def process_read_values(cls, read_values):
|
|
@@ -29,18 +29,15 @@ class XTCFile(TrajectoryFile):
|
|
|
29
29
|
box *= 10
|
|
30
30
|
time = read_values[1]
|
|
31
31
|
return coord, box, time
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
@classmethod
|
|
34
34
|
def prepare_write_values(cls, coord, box, time):
|
|
35
35
|
# Angstrom to nm
|
|
36
|
-
xyz = np.divide(coord, 10, dtype=np.float32)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if time is not None else None
|
|
40
|
-
box = np.divide(box, 10, dtype=np.float32) \
|
|
41
|
-
if box is not None else None
|
|
36
|
+
xyz = np.divide(coord, 10, dtype=np.float32) if coord is not None else None
|
|
37
|
+
time = time.astype(np.float32, copy=False) if time is not None else None
|
|
38
|
+
box = np.divide(box, 10, dtype=np.float32) if box is not None else None
|
|
42
39
|
return {
|
|
43
|
-
"xyz"
|
|
44
|
-
"box"
|
|
45
|
-
"time"
|
|
40
|
+
"xyz": xyz,
|
|
41
|
+
"box": box,
|
|
42
|
+
"time": time,
|
|
46
43
|
}
|