biotite 0.41.2__cp312-cp312-win_amd64.whl → 1.0.0__cp312-cp312-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.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/buckets.py +12 -10
- biotite/sequence/align/cigar.py +43 -52
- biotite/sequence/align/kmeralphabet.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/kmeralphabet.pyx +55 -51
- biotite/sequence/align/kmersimilarity.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.pyx +3 -2
- biotite/sequence/align/localgapped.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/localungapped.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/matrix.py +81 -82
- biotite/sequence/align/multiple.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/multiple.pyx +1 -1
- biotite/sequence/align/pairwise.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/permutation.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/permutation.pyx +12 -4
- biotite/sequence/align/selector.cp312-win_amd64.pyd +0 -0
- biotite/sequence/align/selector.pyx +52 -54
- biotite/sequence/align/statistics.py +32 -33
- biotite/sequence/align/tracetable.cp312-win_amd64.pyd +0 -0
- biotite/sequence/alphabet.py +51 -65
- biotite/sequence/annotation.py +78 -77
- biotite/sequence/codec.cp312-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.cp312-win_amd64.pyd +0 -0
- biotite/sequence/phylo/tree.cp312-win_amd64.pyd +0 -0
- biotite/sequence/phylo/upgma.cp312-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.cp312-win_amd64.pyd +0 -0
- biotite/structure/bonds.pyx +29 -32
- biotite/structure/box.py +67 -71
- biotite/structure/celllist.cp312-win_amd64.pyd +0 -0
- biotite/structure/chains.py +55 -39
- biotite/structure/charges.cp312-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.cp312-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.cp312-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.cp312-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.cp312-win_amd64.pyd +0 -0
- biotite/structure/io/mmtf/convertarray.pyx +0 -341
- biotite/structure/io/mmtf/convertfile.cp312-win_amd64.pyd +0 -0
- biotite/structure/io/mmtf/convertfile.pyx +0 -501
- biotite/structure/io/mmtf/decode.cp312-win_amd64.pyd +0 -0
- biotite/structure/io/mmtf/decode.pyx +0 -152
- biotite/structure/io/mmtf/encode.cp312-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
|
@@ -18,7 +18,7 @@ def get_structure(pdbqt_file, model=None):
|
|
|
18
18
|
PDBQT file.
|
|
19
19
|
|
|
20
20
|
EXPERIMENTAL: Future API changes are probable.
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
Parameters
|
|
23
23
|
----------
|
|
24
24
|
pdbqt_file : PDBQTFile
|
|
@@ -32,7 +32,7 @@ def get_structure(pdbqt_file, model=None):
|
|
|
32
32
|
If this parameter is omitted, an :class:`AtomArrayStack`
|
|
33
33
|
containing all models will be returned, even if the
|
|
34
34
|
structure contains only one model.
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
Returns
|
|
37
37
|
-------
|
|
38
38
|
array : AtomArray or AtomArrayStack
|
|
@@ -41,13 +41,20 @@ def get_structure(pdbqt_file, model=None):
|
|
|
41
41
|
return pdbqt_file.get_structure(model)
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
def set_structure(
|
|
45
|
-
|
|
44
|
+
def set_structure(
|
|
45
|
+
pdbqt_file,
|
|
46
|
+
atoms,
|
|
47
|
+
charges=None,
|
|
48
|
+
atom_types=None,
|
|
49
|
+
rotatable_bonds=None,
|
|
50
|
+
root=None,
|
|
51
|
+
include_torsdof=True,
|
|
52
|
+
):
|
|
46
53
|
"""
|
|
47
54
|
Write an :class:`AtomArray` into a PDBQT file.
|
|
48
55
|
|
|
49
56
|
EXPERIMENTAL: Future API changes are probable.
|
|
50
|
-
|
|
57
|
+
|
|
51
58
|
Parameters
|
|
52
59
|
----------
|
|
53
60
|
pdbqt_file : PDBQTFile
|
|
@@ -71,7 +78,7 @@ def set_structure(pdbqt_file, atoms, charges=None, atom_types=None,
|
|
|
71
78
|
be written.
|
|
72
79
|
- ``'rigid'`` - The molecule is handled as rigid ligand:
|
|
73
80
|
Only a ``ROOT`` line will be written.
|
|
74
|
-
- ``'all'`` - The molecule is handled as flexible
|
|
81
|
+
- ``'all'`` - The molecule is handled as flexible
|
|
75
82
|
ligand:
|
|
76
83
|
A ``ROOT`` line will be written and all rotatable
|
|
77
84
|
bonds are included using ``BRANCH`` and ``ENDBRANCH``
|
|
@@ -81,7 +88,7 @@ def set_structure(pdbqt_file, atoms, charges=None, atom_types=None,
|
|
|
81
88
|
A ``ROOT`` line will be written and all bonds in the
|
|
82
89
|
given :class:`BondList` are considered flexible via
|
|
83
90
|
``BRANCH`` and ``ENDBRANCH`` lines.
|
|
84
|
-
|
|
91
|
+
|
|
85
92
|
root : int, optional
|
|
86
93
|
Specifies the index of the atom following the ``ROOT`` line.
|
|
87
94
|
Setting the root atom is useful for specifying the *anchor*
|
|
@@ -93,7 +100,7 @@ def set_structure(pdbqt_file, atoms, charges=None, atom_types=None,
|
|
|
93
100
|
By default, a ``TORSDOF`` (torsional degrees of freedom)
|
|
94
101
|
record is written at the end of the file.
|
|
95
102
|
By setting this parameter to false, the record is omitted.
|
|
96
|
-
|
|
103
|
+
|
|
97
104
|
Returns
|
|
98
105
|
-------
|
|
99
106
|
mask : ndarray, shape=(n,), dtype=bool
|
|
@@ -102,6 +109,5 @@ def set_structure(pdbqt_file, atoms, charges=None, atom_types=None,
|
|
|
102
109
|
hydrogen.
|
|
103
110
|
"""
|
|
104
111
|
return pdbqt_file.set_structure(
|
|
105
|
-
atoms, charges, atom_types, rotatable_bonds, root,
|
|
106
|
-
|
|
107
|
-
)
|
|
112
|
+
atoms, charges, atom_types, rotatable_bonds, root, include_torsdof
|
|
113
|
+
)
|
|
@@ -8,17 +8,33 @@ __all__ = ["PDBQTFile"]
|
|
|
8
8
|
|
|
9
9
|
import warnings
|
|
10
10
|
import numpy as np
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
from biotite.file import InvalidFileError, TextFile
|
|
12
|
+
from biotite.structure.atoms import AtomArray, AtomArrayStack
|
|
13
|
+
from biotite.structure.bonds import (
|
|
14
|
+
BondList,
|
|
15
|
+
BondType,
|
|
16
|
+
find_connected,
|
|
17
|
+
find_rotatable_bonds,
|
|
18
|
+
)
|
|
19
|
+
from biotite.structure.charges import partial_charges
|
|
20
|
+
from biotite.structure.error import BadStructureError
|
|
17
21
|
|
|
18
22
|
PARAMETRIZED_ELEMENTS = [
|
|
19
|
-
"H",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
23
|
+
"H",
|
|
24
|
+
"C",
|
|
25
|
+
"N",
|
|
26
|
+
"O",
|
|
27
|
+
"P",
|
|
28
|
+
"S",
|
|
29
|
+
"F",
|
|
30
|
+
"Cl",
|
|
31
|
+
"Br",
|
|
32
|
+
"I",
|
|
33
|
+
"Mg",
|
|
34
|
+
"Ca",
|
|
35
|
+
"Mn",
|
|
36
|
+
"Fe",
|
|
37
|
+
"Zn",
|
|
22
38
|
]
|
|
23
39
|
|
|
24
40
|
|
|
@@ -116,13 +132,15 @@ class PDBQTFile(TextFile):
|
|
|
116
132
|
``'REMARKS'``.
|
|
117
133
|
"""
|
|
118
134
|
# Line indices where a new model starts
|
|
119
|
-
model_start_i = np.array(
|
|
120
|
-
|
|
121
|
-
|
|
135
|
+
model_start_i = np.array(
|
|
136
|
+
[i for i in range(len(self.lines)) if self.lines[i].startswith(("MODEL"))],
|
|
137
|
+
dtype=int,
|
|
138
|
+
)
|
|
122
139
|
# Line indices with ATOM or HETATM records
|
|
123
|
-
remark_line_i = np.array(
|
|
124
|
-
|
|
125
|
-
|
|
140
|
+
remark_line_i = np.array(
|
|
141
|
+
[i for i in range(len(self.lines)) if self.lines[i].startswith("REMARK")],
|
|
142
|
+
dtype=int,
|
|
143
|
+
)
|
|
126
144
|
# Structures containing only one model may omit MODEL record
|
|
127
145
|
# In these cases model starting index is set to 0
|
|
128
146
|
if len(model_start_i) == 0:
|
|
@@ -131,11 +149,10 @@ class PDBQTFile(TextFile):
|
|
|
131
149
|
if model is None:
|
|
132
150
|
# Add exclusive end of file
|
|
133
151
|
model_start_i = np.concatenate((model_start_i, [len(self.lines)]))
|
|
134
|
-
model_i = 0
|
|
135
152
|
remarks = []
|
|
136
153
|
for i in range(len(model_start_i) - 1):
|
|
137
154
|
start = model_start_i[i]
|
|
138
|
-
stop
|
|
155
|
+
stop = model_start_i[i + 1]
|
|
139
156
|
model_remark_line_i = remark_line_i[
|
|
140
157
|
(remark_line_i >= start) & (remark_line_i < stop)
|
|
141
158
|
]
|
|
@@ -152,10 +169,11 @@ class PDBQTFile(TextFile):
|
|
|
152
169
|
model = last_model + model + 1 if model < 0 else model
|
|
153
170
|
|
|
154
171
|
if model < last_model:
|
|
155
|
-
line_filter = (
|
|
156
|
-
|
|
172
|
+
line_filter = (remark_line_i >= model_start_i[model - 1]) & (
|
|
173
|
+
remark_line_i < model_start_i[model]
|
|
174
|
+
)
|
|
157
175
|
elif model == last_model:
|
|
158
|
-
line_filter =
|
|
176
|
+
line_filter = remark_line_i >= model_start_i[model - 1]
|
|
159
177
|
else:
|
|
160
178
|
raise ValueError(
|
|
161
179
|
f"The file has {last_model} models, "
|
|
@@ -166,7 +184,6 @@ class PDBQTFile(TextFile):
|
|
|
166
184
|
# Do not include 'REMARK ' itself -> begin from pos 8
|
|
167
185
|
return "\n".join([self.lines[i][7:] for i in remark_line_i])
|
|
168
186
|
|
|
169
|
-
|
|
170
187
|
def get_structure(self, model=None):
|
|
171
188
|
"""
|
|
172
189
|
Get an :class:`AtomArray` or :class:`AtomArrayStack` from the
|
|
@@ -190,13 +207,19 @@ class PDBQTFile(TextFile):
|
|
|
190
207
|
The return type depends on the `model` parameter.
|
|
191
208
|
"""
|
|
192
209
|
# Line indices where a new model starts
|
|
193
|
-
model_start_i = np.array(
|
|
194
|
-
|
|
195
|
-
|
|
210
|
+
model_start_i = np.array(
|
|
211
|
+
[i for i in range(len(self.lines)) if self.lines[i].startswith(("MODEL"))],
|
|
212
|
+
dtype=int,
|
|
213
|
+
)
|
|
196
214
|
# Line indices with ATOM or HETATM records
|
|
197
|
-
atom_line_i = np.array(
|
|
198
|
-
|
|
199
|
-
|
|
215
|
+
atom_line_i = np.array(
|
|
216
|
+
[
|
|
217
|
+
i
|
|
218
|
+
for i in range(len(self.lines))
|
|
219
|
+
if self.lines[i].startswith(("ATOM", "HETATM"))
|
|
220
|
+
],
|
|
221
|
+
dtype=int,
|
|
222
|
+
)
|
|
200
223
|
# Structures containing only one model may omit MODEL record
|
|
201
224
|
# In these cases model starting index is set to 0
|
|
202
225
|
if len(model_start_i) == 0:
|
|
@@ -224,10 +247,11 @@ class PDBQTFile(TextFile):
|
|
|
224
247
|
model = last_model + model + 1 if model < 0 else model
|
|
225
248
|
|
|
226
249
|
if model < last_model:
|
|
227
|
-
line_filter = (
|
|
228
|
-
|
|
250
|
+
line_filter = (atom_line_i >= model_start_i[model - 1]) & (
|
|
251
|
+
atom_line_i < model_start_i[model]
|
|
252
|
+
)
|
|
229
253
|
elif model == last_model:
|
|
230
|
-
line_filter =
|
|
254
|
+
line_filter = atom_line_i >= model_start_i[model - 1]
|
|
231
255
|
else:
|
|
232
256
|
raise ValueError(
|
|
233
257
|
f"The file has {last_model} models, "
|
|
@@ -237,16 +261,16 @@ class PDBQTFile(TextFile):
|
|
|
237
261
|
array = AtomArray(len(coord_i))
|
|
238
262
|
|
|
239
263
|
# Save atom IDs for later sorting into the original atom order
|
|
240
|
-
atom_id
|
|
264
|
+
atom_id = np.zeros(array.array_length(), int)
|
|
241
265
|
|
|
242
266
|
# Create annotation arrays
|
|
243
|
-
chain_id
|
|
244
|
-
res_id
|
|
245
|
-
ins_code
|
|
246
|
-
res_name
|
|
247
|
-
hetero
|
|
267
|
+
chain_id = np.zeros(array.array_length(), array.chain_id.dtype)
|
|
268
|
+
res_id = np.zeros(array.array_length(), array.res_id.dtype)
|
|
269
|
+
ins_code = np.zeros(array.array_length(), array.ins_code.dtype)
|
|
270
|
+
res_name = np.zeros(array.array_length(), array.res_name.dtype)
|
|
271
|
+
hetero = np.zeros(array.array_length(), array.hetero.dtype)
|
|
248
272
|
atom_name = np.zeros(array.array_length(), array.atom_name.dtype)
|
|
249
|
-
element
|
|
273
|
+
element = np.zeros(array.array_length(), array.element.dtype)
|
|
250
274
|
|
|
251
275
|
# Fill annotation array
|
|
252
276
|
# i is index in array, line_i is line index
|
|
@@ -258,7 +282,7 @@ class PDBQTFile(TextFile):
|
|
|
258
282
|
res_id[i] = int(line[22:26])
|
|
259
283
|
ins_code[i] = line[26].strip()
|
|
260
284
|
res_name[i] = line[17:20].strip()
|
|
261
|
-
hetero[i] =
|
|
285
|
+
hetero[i] = False if line[0:4] == "ATOM" else True
|
|
262
286
|
atom_name[i] = line[12:16].strip()
|
|
263
287
|
element[i] = line[76:78].strip()
|
|
264
288
|
|
|
@@ -275,21 +299,21 @@ class PDBQTFile(TextFile):
|
|
|
275
299
|
if isinstance(array, AtomArray):
|
|
276
300
|
for i, line_i in enumerate(coord_i):
|
|
277
301
|
line = self.lines[line_i]
|
|
278
|
-
array.coord[i,0] = float(line[30:38])
|
|
279
|
-
array.coord[i,1] = float(line[38:46])
|
|
280
|
-
array.coord[i,2] = float(line[46:54])
|
|
302
|
+
array.coord[i, 0] = float(line[30:38])
|
|
303
|
+
array.coord[i, 1] = float(line[38:46])
|
|
304
|
+
array.coord[i, 2] = float(line[46:54])
|
|
281
305
|
|
|
282
306
|
elif isinstance(array, AtomArrayStack):
|
|
283
307
|
m = 0
|
|
284
308
|
i = 0
|
|
285
309
|
for line_i in atom_line_i:
|
|
286
|
-
if m < len(model_start_i)-1 and line_i > model_start_i[m+1]:
|
|
310
|
+
if m < len(model_start_i) - 1 and line_i > model_start_i[m + 1]:
|
|
287
311
|
m += 1
|
|
288
312
|
i = 0
|
|
289
313
|
line = self.lines[line_i]
|
|
290
|
-
array.coord[m,i,0] = float(line[30:38])
|
|
291
|
-
array.coord[m,i,1] = float(line[38:46])
|
|
292
|
-
array.coord[m,i,2] = float(line[46:54])
|
|
314
|
+
array.coord[m, i, 0] = float(line[30:38])
|
|
315
|
+
array.coord[m, i, 1] = float(line[38:46])
|
|
316
|
+
array.coord[m, i, 2] = float(line[46:54])
|
|
293
317
|
i += 1
|
|
294
318
|
|
|
295
319
|
# Sort into the original atom order
|
|
@@ -297,9 +321,15 @@ class PDBQTFile(TextFile):
|
|
|
297
321
|
|
|
298
322
|
return array
|
|
299
323
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
324
|
+
def set_structure(
|
|
325
|
+
self,
|
|
326
|
+
atoms,
|
|
327
|
+
charges=None,
|
|
328
|
+
atom_types=None,
|
|
329
|
+
rotatable_bonds=None,
|
|
330
|
+
root=None,
|
|
331
|
+
include_torsdof=True,
|
|
332
|
+
):
|
|
303
333
|
"""
|
|
304
334
|
Write an :class:`AtomArray` into the PDBQT file.
|
|
305
335
|
|
|
@@ -394,12 +424,8 @@ class PDBQTFile(TextFile):
|
|
|
394
424
|
use_root = True
|
|
395
425
|
else:
|
|
396
426
|
if rotatable_bonds.ndim != 2 or rotatable_bonds.shape[1] != 2:
|
|
397
|
-
raise ValueError(
|
|
398
|
-
|
|
399
|
-
)
|
|
400
|
-
rotatable_bonds = BondList(
|
|
401
|
-
len(mask), np.asarray(rotatable_bonds)
|
|
402
|
-
)[mask]
|
|
427
|
+
raise ValueError("An (nx2) array is expected for rotatable bonds")
|
|
428
|
+
rotatable_bonds = BondList(len(mask), np.asarray(rotatable_bonds))[mask]
|
|
403
429
|
use_root = True
|
|
404
430
|
|
|
405
431
|
if root is None:
|
|
@@ -426,35 +452,51 @@ class PDBQTFile(TextFile):
|
|
|
426
452
|
# for simple branch determination in '_write_atoms()'
|
|
427
453
|
atoms.bonds.remove_bonds(rotatable_bonds)
|
|
428
454
|
|
|
429
|
-
hetero = ["
|
|
455
|
+
hetero = ["HETATM" if e else "ATOM" for e in atoms.hetero]
|
|
430
456
|
if "atom_id" in atoms.get_annotation_categories():
|
|
431
457
|
atom_id = atoms.atom_id
|
|
432
458
|
else:
|
|
433
|
-
atom_id = np.arange(1, atoms.array_length()+1)
|
|
459
|
+
atom_id = np.arange(1, atoms.array_length() + 1)
|
|
434
460
|
occupancy = np.ones(atoms.array_length())
|
|
435
461
|
b_factor = np.zeros(atoms.array_length())
|
|
436
462
|
|
|
437
463
|
# Convert rotatable bonds into array for easier handling
|
|
438
464
|
# The bond type is irrelevant from this point on
|
|
439
|
-
rotatable_bonds = rotatable_bonds.as_array()[
|
|
465
|
+
rotatable_bonds = rotatable_bonds.as_array()[:, :2]
|
|
440
466
|
|
|
441
467
|
self.lines = []
|
|
442
468
|
self._write_atoms(
|
|
443
|
-
atoms,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
469
|
+
atoms,
|
|
470
|
+
charges,
|
|
471
|
+
types,
|
|
472
|
+
atom_id,
|
|
473
|
+
hetero,
|
|
474
|
+
occupancy,
|
|
475
|
+
b_factor,
|
|
476
|
+
root_index,
|
|
477
|
+
rotatable_bonds,
|
|
478
|
+
np.zeros(len(rotatable_bonds), dtype=bool),
|
|
479
|
+
use_root,
|
|
447
480
|
)
|
|
448
481
|
if include_torsdof:
|
|
449
482
|
self.lines.append(f"TORSDOF {len(rotatable_bonds)}")
|
|
450
483
|
|
|
451
484
|
return mask
|
|
452
485
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
486
|
+
def _write_atoms(
|
|
487
|
+
self,
|
|
488
|
+
atoms,
|
|
489
|
+
charges,
|
|
490
|
+
types,
|
|
491
|
+
atom_id,
|
|
492
|
+
hetero,
|
|
493
|
+
occupancy,
|
|
494
|
+
b_factor,
|
|
495
|
+
root_atom,
|
|
496
|
+
rotatable_bonds,
|
|
497
|
+
visited_rotatable_bonds,
|
|
498
|
+
is_root,
|
|
499
|
+
):
|
|
458
500
|
if len(rotatable_bonds) != 0:
|
|
459
501
|
# Get the indices to atoms of this branch, i.e. a group of
|
|
460
502
|
# atoms that are connected by non-rotatable bonds
|
|
@@ -465,9 +507,7 @@ class PDBQTFile(TextFile):
|
|
|
465
507
|
# the rotatable bond should always be listed first
|
|
466
508
|
# -> Remove root atom and insert it at the beginning
|
|
467
509
|
this_branch_indices = np.insert(
|
|
468
|
-
this_branch_indices[this_branch_indices != root_atom],
|
|
469
|
-
0,
|
|
470
|
-
root_atom
|
|
510
|
+
this_branch_indices[this_branch_indices != root_atom], 0, root_atom
|
|
471
511
|
)
|
|
472
512
|
else:
|
|
473
513
|
# No rotatable bonds
|
|
@@ -525,18 +565,24 @@ class PDBQTFile(TextFile):
|
|
|
525
565
|
f"BRANCH {atom_id[this_br_i]:>3d} {atom_id[new_br_i]:>3d}"
|
|
526
566
|
)
|
|
527
567
|
self._write_atoms(
|
|
528
|
-
atoms,
|
|
529
|
-
|
|
568
|
+
atoms,
|
|
569
|
+
charges,
|
|
570
|
+
types,
|
|
571
|
+
atom_id,
|
|
572
|
+
hetero,
|
|
573
|
+
occupancy,
|
|
574
|
+
b_factor,
|
|
530
575
|
# The root atom of the branch
|
|
531
|
-
#is the other atom of the rotatable bond
|
|
532
|
-
new_br_i,
|
|
533
|
-
|
|
576
|
+
# is the other atom of the rotatable bond
|
|
577
|
+
new_br_i,
|
|
578
|
+
rotatable_bonds,
|
|
579
|
+
visited_rotatable_bonds,
|
|
580
|
+
False,
|
|
534
581
|
)
|
|
535
582
|
self.lines.append(
|
|
536
583
|
f"ENDBRANCH {atom_id[this_br_i]:>3d} {atom_id[new_br_i]:>3d}"
|
|
537
584
|
)
|
|
538
585
|
|
|
539
|
-
|
|
540
586
|
def _get_model_length(self, model_start_i, atom_line_i):
|
|
541
587
|
"""
|
|
542
588
|
Determine length of models and check that all models
|
|
@@ -546,8 +592,11 @@ class PDBQTFile(TextFile):
|
|
|
546
592
|
length = None
|
|
547
593
|
for model_i in range(len(model_start_i)):
|
|
548
594
|
model_start = model_start_i[model_i]
|
|
549
|
-
model_stop =
|
|
550
|
-
|
|
595
|
+
model_stop = (
|
|
596
|
+
model_start_i[model_i + 1]
|
|
597
|
+
if model_i + 1 < n_models
|
|
598
|
+
else len(self.lines)
|
|
599
|
+
)
|
|
551
600
|
model_length = np.count_nonzero(
|
|
552
601
|
(atom_line_i >= model_start) & (atom_line_i < model_stop)
|
|
553
602
|
)
|
|
@@ -613,8 +662,7 @@ def convert_atoms(atoms, charges):
|
|
|
613
662
|
)
|
|
614
663
|
elif element == "C":
|
|
615
664
|
if np.isin(
|
|
616
|
-
all_bond_types[i],
|
|
617
|
-
[BondType.AROMATIC_SINGLE, BondType.AROMATIC_DOUBLE]
|
|
665
|
+
all_bond_types[i], [BondType.AROMATIC_SINGLE, BondType.AROMATIC_DOUBLE]
|
|
618
666
|
).any():
|
|
619
667
|
# Aromatic carbon
|
|
620
668
|
atom_types[i] = "A"
|
|
@@ -637,4 +685,4 @@ def convert_atoms(atoms, charges):
|
|
|
637
685
|
atom_types[i] = "H"
|
|
638
686
|
|
|
639
687
|
mask = ~hydrogen_removal_mask
|
|
640
|
-
return atoms[mask], charges[mask], atom_types[mask], mask
|
|
688
|
+
return atoms[mask], charges[mask], atom_types[mask], mask
|
|
@@ -15,9 +15,8 @@ from/to these files.
|
|
|
15
15
|
__name__ = "biotite.structure.io.pdbx"
|
|
16
16
|
__author__ = "Patrick Kunzmann"
|
|
17
17
|
|
|
18
|
-
from .convert import *
|
|
19
18
|
from .bcif import *
|
|
20
19
|
from .cif import *
|
|
21
20
|
from .component import *
|
|
21
|
+
from .convert import *
|
|
22
22
|
from .encoding import *
|
|
23
|
-
from .legacy import *
|
|
@@ -4,16 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
__name__ = "biotite.structure.io.pdbx"
|
|
6
6
|
__author__ = "Patrick Kunzmann"
|
|
7
|
-
__all__ = [
|
|
8
|
-
|
|
7
|
+
__all__ = [
|
|
8
|
+
"BinaryCIFFile",
|
|
9
|
+
"BinaryCIFBlock",
|
|
10
|
+
"BinaryCIFCategory",
|
|
11
|
+
"BinaryCIFColumn",
|
|
12
|
+
"BinaryCIFData",
|
|
13
|
+
]
|
|
9
14
|
|
|
10
15
|
from collections.abc import Sequence
|
|
11
|
-
import numpy as np
|
|
12
16
|
import msgpack
|
|
13
|
-
|
|
14
|
-
from .
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
import numpy as np
|
|
18
|
+
from biotite.file import File, SerializationError, is_binary, is_open_compatible
|
|
19
|
+
from biotite.structure.io.pdbx.component import (
|
|
20
|
+
MaskValue,
|
|
21
|
+
_Component,
|
|
22
|
+
_HierarchicalContainer,
|
|
23
|
+
)
|
|
24
|
+
from biotite.structure.io.pdbx.encoding import (
|
|
25
|
+
create_uncompressed_encoding,
|
|
26
|
+
decode_stepwise,
|
|
27
|
+
deserialize_encoding,
|
|
28
|
+
encode_stepwise,
|
|
29
|
+
)
|
|
17
30
|
|
|
18
31
|
|
|
19
32
|
class BinaryCIFData(_Component):
|
|
@@ -74,10 +87,7 @@ class BinaryCIFData(_Component):
|
|
|
74
87
|
"""
|
|
75
88
|
|
|
76
89
|
def __init__(self, array, encoding=None):
|
|
77
|
-
if (
|
|
78
|
-
not isinstance(array, (Sequence, np.ndarray))
|
|
79
|
-
or isinstance(array, str)
|
|
80
|
-
):
|
|
90
|
+
if not isinstance(array, (Sequence, np.ndarray)) or isinstance(array, str):
|
|
81
91
|
array = [array]
|
|
82
92
|
array = np.asarray(array)
|
|
83
93
|
if np.issubdtype(array.dtype, np.object_):
|
|
@@ -107,19 +117,13 @@ class BinaryCIFData(_Component):
|
|
|
107
117
|
|
|
108
118
|
@staticmethod
|
|
109
119
|
def deserialize(content):
|
|
110
|
-
encoding = [
|
|
111
|
-
|
|
112
|
-
]
|
|
113
|
-
return BinaryCIFData(
|
|
114
|
-
decode_stepwise(content["data"], encoding), encoding
|
|
115
|
-
)
|
|
120
|
+
encoding = [deserialize_encoding(enc) for enc in content["encoding"]]
|
|
121
|
+
return BinaryCIFData(decode_stepwise(content["data"], encoding), encoding)
|
|
116
122
|
|
|
117
123
|
def serialize(self):
|
|
118
124
|
serialized_data = encode_stepwise(self._array, self._encoding)
|
|
119
125
|
if not isinstance(serialized_data, bytes):
|
|
120
|
-
raise SerializationError(
|
|
121
|
-
"Final encoding must return 'bytes'"
|
|
122
|
-
)
|
|
126
|
+
raise SerializationError("Final encoding must return 'bytes'")
|
|
123
127
|
serialized_encoding = [enc.serialize() for enc in self._encoding]
|
|
124
128
|
return {"data": serialized_data, "encoding": serialized_encoding}
|
|
125
129
|
|
|
@@ -190,8 +194,7 @@ class BinaryCIFColumn(_Component):
|
|
|
190
194
|
mask = BinaryCIFData(mask)
|
|
191
195
|
if len(data) != len(mask):
|
|
192
196
|
raise IndexError(
|
|
193
|
-
f"Data has length {len(data)}, "
|
|
194
|
-
f"but mask has length {len(mask)}"
|
|
197
|
+
f"Data has length {len(data)}, " f"but mask has length {len(mask)}"
|
|
195
198
|
)
|
|
196
199
|
self._data = data
|
|
197
200
|
self._mask = mask
|
|
@@ -290,9 +293,7 @@ class BinaryCIFColumn(_Component):
|
|
|
290
293
|
array = np.full(len(self._data), masked_value, dtype=dtype)
|
|
291
294
|
|
|
292
295
|
present_mask = self._mask.array == MaskValue.PRESENT
|
|
293
|
-
array[present_mask] = (
|
|
294
|
-
self._data.array[present_mask].astype(dtype)
|
|
295
|
-
)
|
|
296
|
+
array[present_mask] = self._data.array[present_mask].astype(dtype)
|
|
296
297
|
return array
|
|
297
298
|
|
|
298
299
|
@staticmethod
|
|
@@ -300,13 +301,14 @@ class BinaryCIFColumn(_Component):
|
|
|
300
301
|
return BinaryCIFColumn(
|
|
301
302
|
BinaryCIFData.deserialize(content["data"]),
|
|
302
303
|
BinaryCIFData.deserialize(content["mask"])
|
|
303
|
-
if content["mask"] is not None
|
|
304
|
+
if content["mask"] is not None
|
|
305
|
+
else None,
|
|
304
306
|
)
|
|
305
307
|
|
|
306
308
|
def serialize(self):
|
|
307
309
|
return {
|
|
308
310
|
"data": self._data.serialize(),
|
|
309
|
-
"mask": self._mask.serialize() if self._mask is not None else None
|
|
311
|
+
"mask": self._mask.serialize() if self._mask is not None else None,
|
|
310
312
|
}
|
|
311
313
|
|
|
312
314
|
def __len__(self):
|
|
@@ -392,10 +394,8 @@ class BinaryCIFCategory(_HierarchicalContainer):
|
|
|
392
394
|
@staticmethod
|
|
393
395
|
def deserialize(content):
|
|
394
396
|
return BinaryCIFCategory(
|
|
395
|
-
BinaryCIFCategory._deserialize_elements(
|
|
396
|
-
|
|
397
|
-
),
|
|
398
|
-
content["rowCount"]
|
|
397
|
+
BinaryCIFCategory._deserialize_elements(content["columns"], "name"),
|
|
398
|
+
content["rowCount"],
|
|
399
399
|
)
|
|
400
400
|
|
|
401
401
|
def serialize(self):
|
|
@@ -470,9 +470,7 @@ class BinaryCIFBlock(_HierarchicalContainer):
|
|
|
470
470
|
@staticmethod
|
|
471
471
|
def deserialize(content):
|
|
472
472
|
return BinaryCIFBlock(
|
|
473
|
-
BinaryCIFBlock._deserialize_elements(
|
|
474
|
-
content["categories"], "name"
|
|
475
|
-
)
|
|
473
|
+
BinaryCIFBlock._deserialize_elements(content["categories"], "name")
|
|
476
474
|
)
|
|
477
475
|
|
|
478
476
|
def serialize(self):
|
|
@@ -559,16 +557,14 @@ class BinaryCIFFile(File, _HierarchicalContainer):
|
|
|
559
557
|
@staticmethod
|
|
560
558
|
def deserialize(content):
|
|
561
559
|
return BinaryCIFFile(
|
|
562
|
-
BinaryCIFFile._deserialize_elements(
|
|
563
|
-
content["dataBlocks"], "header"
|
|
564
|
-
)
|
|
560
|
+
BinaryCIFFile._deserialize_elements(content["dataBlocks"], "header")
|
|
565
561
|
)
|
|
566
562
|
|
|
567
563
|
def serialize(self):
|
|
568
564
|
return {"dataBlocks": self._serialize_elements("header")}
|
|
569
565
|
|
|
570
566
|
@classmethod
|
|
571
|
-
def read(
|
|
567
|
+
def read(cls, file):
|
|
572
568
|
"""
|
|
573
569
|
Read a *BinaryCIF* file.
|
|
574
570
|
|
|
@@ -587,18 +583,14 @@ class BinaryCIFFile(File, _HierarchicalContainer):
|
|
|
587
583
|
if is_open_compatible(file):
|
|
588
584
|
with open(file, "rb") as f:
|
|
589
585
|
return BinaryCIFFile.deserialize(
|
|
590
|
-
msgpack.unpackb(
|
|
591
|
-
f.read(), use_list=True, raw=False
|
|
592
|
-
)
|
|
586
|
+
msgpack.unpackb(f.read(), use_list=True, raw=False)
|
|
593
587
|
)
|
|
594
588
|
# File object
|
|
595
589
|
else:
|
|
596
590
|
if not is_binary(file):
|
|
597
591
|
raise TypeError("A file opened in 'binary' mode is required")
|
|
598
592
|
return BinaryCIFFile.deserialize(
|
|
599
|
-
msgpack.unpackb(
|
|
600
|
-
file.read(), use_list=True, raw=False
|
|
601
|
-
)
|
|
593
|
+
msgpack.unpackb(file.read(), use_list=True, raw=False)
|
|
602
594
|
)
|
|
603
595
|
|
|
604
596
|
def write(self, file):
|