biotite 1.0.1__cp311-cp311-win_amd64.whl → 1.2.0__cp311-cp311-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/application/application.py +3 -3
- biotite/application/autodock/app.py +1 -1
- biotite/application/blast/webapp.py +1 -1
- biotite/application/clustalo/app.py +1 -1
- biotite/application/dssp/app.py +13 -3
- biotite/application/localapp.py +36 -2
- biotite/application/msaapp.py +10 -10
- biotite/application/muscle/app3.py +5 -18
- biotite/application/muscle/app5.py +5 -5
- biotite/application/sra/app.py +0 -5
- biotite/application/util.py +22 -2
- biotite/application/viennarna/rnaalifold.py +8 -8
- biotite/application/viennarna/rnaplot.py +9 -3
- biotite/application/viennarna/util.py +1 -1
- biotite/application/webapp.py +1 -1
- biotite/database/afdb/__init__.py +12 -0
- biotite/database/afdb/download.py +191 -0
- biotite/database/entrez/dbnames.py +10 -0
- biotite/database/entrez/download.py +9 -10
- biotite/database/entrez/key.py +1 -1
- biotite/database/entrez/query.py +5 -4
- biotite/database/pubchem/download.py +6 -6
- biotite/database/pubchem/error.py +10 -0
- biotite/database/pubchem/query.py +12 -23
- biotite/database/rcsb/download.py +3 -2
- biotite/database/rcsb/query.py +8 -9
- biotite/database/uniprot/check.py +22 -17
- biotite/database/uniprot/download.py +3 -6
- biotite/database/uniprot/query.py +4 -5
- biotite/file.py +14 -2
- biotite/interface/__init__.py +19 -0
- biotite/interface/openmm/__init__.py +16 -0
- biotite/interface/openmm/state.py +93 -0
- biotite/interface/openmm/system.py +227 -0
- biotite/interface/pymol/__init__.py +198 -0
- biotite/interface/pymol/cgo.py +346 -0
- biotite/interface/pymol/convert.py +185 -0
- biotite/interface/pymol/display.py +267 -0
- biotite/interface/pymol/object.py +1226 -0
- biotite/interface/pymol/shapes.py +178 -0
- biotite/interface/pymol/startup.py +169 -0
- biotite/interface/rdkit/__init__.py +15 -0
- biotite/interface/rdkit/mol.py +490 -0
- biotite/interface/version.py +71 -0
- biotite/interface/warning.py +19 -0
- biotite/sequence/align/__init__.py +0 -4
- biotite/sequence/align/alignment.py +49 -14
- biotite/sequence/align/banded.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/banded.pyx +26 -26
- biotite/sequence/align/cigar.py +2 -2
- biotite/sequence/align/kmeralphabet.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/kmeralphabet.pyx +19 -2
- biotite/sequence/align/kmersimilarity.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.pyx +58 -48
- biotite/sequence/align/localgapped.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/localgapped.pyx +47 -47
- biotite/sequence/align/localungapped.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/localungapped.pyx +10 -10
- biotite/sequence/align/matrix.py +284 -57
- biotite/sequence/align/matrix_data/3Di.mat +24 -0
- biotite/sequence/align/matrix_data/PB.license +21 -0
- biotite/sequence/align/matrix_data/PB.mat +18 -0
- biotite/sequence/align/multiple.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/pairwise.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/pairwise.pyx +35 -35
- biotite/sequence/align/permutation.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/selector.cp311-win_amd64.pyd +0 -0
- biotite/sequence/align/selector.pyx +2 -2
- biotite/sequence/align/statistics.py +1 -1
- biotite/sequence/align/tracetable.cp311-win_amd64.pyd +0 -0
- biotite/sequence/alphabet.py +5 -2
- biotite/sequence/annotation.py +19 -13
- biotite/sequence/codec.cp311-win_amd64.pyd +0 -0
- biotite/sequence/codon.py +1 -2
- biotite/sequence/graphics/alignment.py +25 -39
- biotite/sequence/graphics/color_schemes/3di_flower.json +48 -0
- biotite/sequence/graphics/color_schemes/pb_flower.json +2 -1
- biotite/sequence/graphics/colorschemes.py +44 -11
- biotite/sequence/graphics/dendrogram.py +4 -2
- biotite/sequence/graphics/features.py +2 -2
- biotite/sequence/graphics/logo.py +10 -12
- biotite/sequence/io/fasta/convert.py +1 -2
- biotite/sequence/io/fasta/file.py +1 -1
- biotite/sequence/io/fastq/file.py +3 -3
- biotite/sequence/io/genbank/file.py +3 -3
- biotite/sequence/io/genbank/sequence.py +2 -0
- biotite/sequence/io/gff/convert.py +1 -1
- biotite/sequence/io/gff/file.py +1 -2
- biotite/sequence/phylo/nj.cp311-win_amd64.pyd +0 -0
- biotite/sequence/phylo/tree.cp311-win_amd64.pyd +0 -0
- biotite/sequence/phylo/upgma.cp311-win_amd64.pyd +0 -0
- biotite/sequence/profile.py +105 -29
- biotite/sequence/search.py +0 -1
- biotite/sequence/seqtypes.py +136 -8
- biotite/sequence/sequence.py +1 -2
- biotite/setup_ccd.py +197 -0
- biotite/structure/__init__.py +6 -3
- biotite/structure/alphabet/__init__.py +25 -0
- biotite/structure/alphabet/encoder.py +332 -0
- biotite/structure/alphabet/encoder_weights_3di.kerasify +0 -0
- biotite/structure/alphabet/i3d.py +109 -0
- biotite/structure/alphabet/layers.py +86 -0
- biotite/structure/alphabet/pb.license +21 -0
- biotite/structure/alphabet/pb.py +170 -0
- biotite/structure/alphabet/unkerasify.py +128 -0
- biotite/structure/atoms.py +163 -66
- biotite/structure/basepairs.py +26 -26
- biotite/structure/bonds.cp311-win_amd64.pyd +0 -0
- biotite/structure/bonds.pyx +79 -25
- biotite/structure/box.py +19 -21
- biotite/structure/celllist.cp311-win_amd64.pyd +0 -0
- biotite/structure/celllist.pyx +83 -67
- biotite/structure/chains.py +5 -37
- biotite/structure/charges.cp311-win_amd64.pyd +0 -0
- biotite/structure/compare.py +420 -13
- biotite/structure/density.py +1 -1
- biotite/structure/dotbracket.py +27 -28
- biotite/structure/filter.py +8 -8
- biotite/structure/geometry.py +74 -127
- biotite/structure/hbond.py +17 -19
- biotite/structure/info/__init__.py +1 -0
- biotite/structure/info/atoms.py +24 -15
- biotite/structure/info/bonds.py +12 -6
- biotite/structure/info/ccd.py +125 -34
- biotite/structure/info/{ccd/components.bcif → components.bcif} +0 -0
- biotite/structure/info/groups.py +62 -19
- biotite/structure/info/masses.py +9 -6
- biotite/structure/info/misc.py +15 -22
- biotite/structure/info/radii.py +92 -22
- biotite/structure/info/standardize.py +4 -4
- biotite/structure/integrity.py +4 -6
- biotite/structure/io/general.py +2 -2
- biotite/structure/io/gro/file.py +8 -9
- biotite/structure/io/mol/convert.py +1 -1
- biotite/structure/io/mol/ctab.py +33 -28
- biotite/structure/io/mol/mol.py +1 -1
- biotite/structure/io/mol/sdf.py +80 -53
- biotite/structure/io/pdb/convert.py +4 -3
- biotite/structure/io/pdb/file.py +85 -25
- biotite/structure/io/pdb/hybrid36.cp311-win_amd64.pyd +0 -0
- biotite/structure/io/pdbqt/file.py +36 -36
- biotite/structure/io/pdbx/__init__.py +1 -0
- biotite/structure/io/pdbx/bcif.py +54 -15
- biotite/structure/io/pdbx/cif.py +92 -66
- biotite/structure/io/pdbx/component.py +15 -4
- biotite/structure/io/pdbx/compress.py +321 -0
- biotite/structure/io/pdbx/convert.py +410 -75
- biotite/structure/io/pdbx/encoding.cp311-win_amd64.pyd +0 -0
- biotite/structure/io/pdbx/encoding.pyx +98 -17
- biotite/structure/io/trajfile.py +9 -6
- biotite/structure/io/util.py +38 -0
- biotite/structure/mechanics.py +0 -1
- biotite/structure/molecules.py +141 -156
- biotite/structure/pseudoknots.py +7 -13
- biotite/structure/repair.py +2 -4
- biotite/structure/residues.py +13 -24
- biotite/structure/rings.py +335 -0
- biotite/structure/sasa.cp311-win_amd64.pyd +0 -0
- biotite/structure/sasa.pyx +2 -1
- biotite/structure/segments.py +69 -11
- biotite/structure/sequence.py +0 -1
- biotite/structure/sse.py +0 -2
- biotite/structure/superimpose.py +74 -62
- biotite/structure/tm.py +581 -0
- biotite/structure/transform.py +12 -25
- biotite/structure/util.py +76 -4
- biotite/version.py +9 -4
- biotite/visualize.py +111 -1
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/METADATA +6 -2
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/RECORD +173 -143
- biotite/structure/info/ccd/README.rst +0 -8
- biotite/structure/info/ccd/amino_acids.txt +0 -1663
- biotite/structure/info/ccd/carbohydrates.txt +0 -1135
- biotite/structure/info/ccd/nucleotides.txt +0 -798
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/WHEEL +0 -0
- {biotite-1.0.1.dist-info → biotite-1.2.0.dist-info}/licenses/LICENSE.rst +0 -0
biotite/structure/io/general.py
CHANGED
|
@@ -34,7 +34,7 @@ def load_structure(file_path, template=None, **kwargs):
|
|
|
34
34
|
The path to structure file.
|
|
35
35
|
template : AtomArray or AtomArrayStack or file-like object or str, optional
|
|
36
36
|
Only required when reading a trajectory file.
|
|
37
|
-
kwargs
|
|
37
|
+
**kwargs
|
|
38
38
|
Additional parameters will be passed to either the
|
|
39
39
|
:func:`get_structure()` or :func:`read()` method of the file
|
|
40
40
|
object.
|
|
@@ -146,7 +146,7 @@ def save_structure(file_path, array, **kwargs):
|
|
|
146
146
|
The path to structure file.
|
|
147
147
|
array : AtomArray or AtomArrayStack
|
|
148
148
|
The structure to be saved.
|
|
149
|
-
kwargs
|
|
149
|
+
**kwargs
|
|
150
150
|
Additional parameters will be passed to the respective `set_structure`
|
|
151
151
|
method.
|
|
152
152
|
|
biotite/structure/io/gro/file.py
CHANGED
|
@@ -48,7 +48,6 @@ class GROFile(TextFile):
|
|
|
48
48
|
>>> file = GROFile()
|
|
49
49
|
>>> file.set_structure(array_stack_mod)
|
|
50
50
|
>>> file.write(os.path.join(path_to_directory, "1l2y_mod.gro"))
|
|
51
|
-
|
|
52
51
|
"""
|
|
53
52
|
|
|
54
53
|
def get_model_count(self):
|
|
@@ -89,13 +88,13 @@ class GROFile(TextFile):
|
|
|
89
88
|
The return type depends on the `model` parameter.
|
|
90
89
|
"""
|
|
91
90
|
|
|
92
|
-
def
|
|
91
|
+
def _get_atom_line_i(model_start_i, model_atom_counts):
|
|
93
92
|
"""
|
|
94
93
|
Helper function to get the indices of all atoms for a model
|
|
95
94
|
"""
|
|
96
95
|
return np.arange(model_start_i + 1, model_start_i + 1 + model_atom_counts)
|
|
97
96
|
|
|
98
|
-
def
|
|
97
|
+
def _set_box_dimen(box_param):
|
|
99
98
|
"""
|
|
100
99
|
Helper function to create the box vectors from the values
|
|
101
100
|
in the GRO file
|
|
@@ -145,7 +144,7 @@ class GROFile(TextFile):
|
|
|
145
144
|
|
|
146
145
|
# Line indices for annotation determination is determined
|
|
147
146
|
# from model 1
|
|
148
|
-
annot_i =
|
|
147
|
+
annot_i = _get_atom_line_i(model_start_i[0], length)
|
|
149
148
|
else:
|
|
150
149
|
if model == 0:
|
|
151
150
|
raise ValueError("The model index must not be 0")
|
|
@@ -160,7 +159,7 @@ class GROFile(TextFile):
|
|
|
160
159
|
length = model_atom_counts[model - 1]
|
|
161
160
|
array = AtomArray(length)
|
|
162
161
|
|
|
163
|
-
annot_i =
|
|
162
|
+
annot_i = _get_atom_line_i(model_start_i[model - 1], length)
|
|
164
163
|
|
|
165
164
|
# Replace empty strings for elements with guessed types
|
|
166
165
|
# i is index in array, line_i is line index
|
|
@@ -183,11 +182,11 @@ class GROFile(TextFile):
|
|
|
183
182
|
# Box is stored in last line (after coordinates)
|
|
184
183
|
box_i = atom_i[-1] + 1
|
|
185
184
|
box_param = [float(e) * 10 for e in self.lines[box_i].split()]
|
|
186
|
-
array.box =
|
|
185
|
+
array.box = _set_box_dimen(box_param)
|
|
187
186
|
|
|
188
187
|
elif isinstance(array, AtomArrayStack):
|
|
189
188
|
for m in range(len(model_start_i)):
|
|
190
|
-
atom_i =
|
|
189
|
+
atom_i = _get_atom_line_i(model_start_i[m], model_atom_counts[m])
|
|
191
190
|
for i, line_i in enumerate(atom_i):
|
|
192
191
|
line = self.lines[line_i]
|
|
193
192
|
array.coord[m, i, 0] = float(line[20:28]) * 10
|
|
@@ -196,7 +195,7 @@ class GROFile(TextFile):
|
|
|
196
195
|
# Box is stored in last line (after coordinates)
|
|
197
196
|
box_i = atom_i[-1] + 1
|
|
198
197
|
box_param = [float(e) * 10 for e in self.lines[box_i].split()]
|
|
199
|
-
box =
|
|
198
|
+
box = _set_box_dimen(box_param)
|
|
200
199
|
# Create a box in the stack if not already existing
|
|
201
200
|
# and the box is not a dummy
|
|
202
201
|
if box is not None:
|
|
@@ -311,7 +310,7 @@ class GROFile(TextFile):
|
|
|
311
310
|
|
|
312
311
|
for i in range(array.stack_depth()):
|
|
313
312
|
self.lines.append(
|
|
314
|
-
f"Generated by Biotite at {datetime.now()}, model={i+1}"
|
|
313
|
+
f"Generated by Biotite at {datetime.now()}, model={i + 1}"
|
|
315
314
|
)
|
|
316
315
|
self.lines.append(str(array.array_length()))
|
|
317
316
|
|
biotite/structure/io/mol/ctab.py
CHANGED
|
@@ -19,24 +19,19 @@ from biotite.file import InvalidFileError
|
|
|
19
19
|
from biotite.structure.atoms import AtomArray, AtomArrayStack
|
|
20
20
|
from biotite.structure.bonds import BondList, BondType
|
|
21
21
|
from biotite.structure.error import BadStructureError
|
|
22
|
+
from biotite.structure.io.util import number_of_integer_digits
|
|
22
23
|
|
|
23
24
|
BOND_TYPE_MAPPING = {
|
|
24
25
|
1: BondType.SINGLE,
|
|
25
26
|
2: BondType.DOUBLE,
|
|
26
27
|
3: BondType.TRIPLE,
|
|
28
|
+
4: BondType.AROMATIC,
|
|
27
29
|
5: BondType.ANY,
|
|
28
|
-
6: BondType.
|
|
29
|
-
7: BondType.
|
|
30
|
+
6: BondType.AROMATIC_SINGLE,
|
|
31
|
+
7: BondType.AROMATIC_DOUBLE,
|
|
30
32
|
8: BondType.ANY,
|
|
31
33
|
}
|
|
32
|
-
BOND_TYPE_MAPPING_REV = {
|
|
33
|
-
BondType.SINGLE: 1,
|
|
34
|
-
BondType.DOUBLE: 2,
|
|
35
|
-
BondType.TRIPLE: 3,
|
|
36
|
-
BondType.AROMATIC_SINGLE: 1,
|
|
37
|
-
BondType.AROMATIC_DOUBLE: 2,
|
|
38
|
-
BondType.ANY: 8,
|
|
39
|
-
}
|
|
34
|
+
BOND_TYPE_MAPPING_REV = {v: k for k, v in BOND_TYPE_MAPPING.items()}
|
|
40
35
|
|
|
41
36
|
CHARGE_MAPPING = {0: 0, 1: 3, 2: 2, 3: 1, 5: -1, 6: -2, 7: -3}
|
|
42
37
|
CHARGE_MAPPING_REV = {val: key for key, val in CHARGE_MAPPING.items()}
|
|
@@ -56,7 +51,7 @@ def read_structure_from_ctab(ctab_lines):
|
|
|
56
51
|
----------
|
|
57
52
|
ctab_lines : lines of str
|
|
58
53
|
The lines containing the *ctab*.
|
|
59
|
-
Must begin with the *counts* line and end with the `M END` line
|
|
54
|
+
Must begin with the *counts* line and end with the `M END` line.
|
|
60
55
|
|
|
61
56
|
Returns
|
|
62
57
|
-------
|
|
@@ -71,7 +66,6 @@ def read_structure_from_ctab(ctab_lines):
|
|
|
71
66
|
`<https://discover.3ds.com/sites/default/files/2020-08/biovia_ctfileformats_2020.pdf>`_.
|
|
72
67
|
|
|
73
68
|
.. footbibliography::
|
|
74
|
-
|
|
75
69
|
"""
|
|
76
70
|
match _get_version(ctab_lines[0]):
|
|
77
71
|
case "V2000":
|
|
@@ -119,11 +113,10 @@ def write_structure_to_ctab(atoms, default_bond_type=BondType.ANY, version=None)
|
|
|
119
113
|
`<https://discover.3ds.com/sites/default/files/2020-08/biovia_ctfileformats_2020.pdf>`_.
|
|
120
114
|
|
|
121
115
|
.. footbibliography::
|
|
122
|
-
|
|
123
116
|
"""
|
|
124
117
|
if isinstance(atoms, AtomArrayStack):
|
|
125
118
|
raise TypeError(
|
|
126
|
-
"An 'AtomArrayStack' was given,
|
|
119
|
+
"An 'AtomArrayStack' was given, but only a single model can be written"
|
|
127
120
|
)
|
|
128
121
|
if atoms.bonds is None:
|
|
129
122
|
raise BadStructureError("Input AtomArray has no associated BondList")
|
|
@@ -141,8 +134,7 @@ def write_structure_to_ctab(atoms, default_bond_type=BondType.ANY, version=None)
|
|
|
141
134
|
atoms.array_length(), atoms.bonds.get_bond_count()
|
|
142
135
|
):
|
|
143
136
|
raise ValueError(
|
|
144
|
-
"The given number of atoms or bonds is too large "
|
|
145
|
-
"for V2000 format"
|
|
137
|
+
"The given number of atoms or bonds is too large for V2000 format"
|
|
146
138
|
)
|
|
147
139
|
return _write_structure_to_ctab_v2000(atoms, default_bond_type)
|
|
148
140
|
case "V3000":
|
|
@@ -174,7 +166,7 @@ def _read_structure_from_ctab_v2000(ctab_lines):
|
|
|
174
166
|
charge = CHARGE_MAPPING.get(int(line[36:39]))
|
|
175
167
|
if charge is None:
|
|
176
168
|
warnings.warn(
|
|
177
|
-
f"Cannot handle MDL charge type {int(line[36
|
|
169
|
+
f"Cannot handle MDL charge type {int(line[36:39])}, "
|
|
178
170
|
f"0 is used instead"
|
|
179
171
|
)
|
|
180
172
|
charge = 0
|
|
@@ -194,7 +186,7 @@ def _read_structure_from_ctab_v2000(ctab_lines):
|
|
|
194
186
|
bond_type = BOND_TYPE_MAPPING.get(int(line[6:9]))
|
|
195
187
|
if bond_type is None:
|
|
196
188
|
warnings.warn(
|
|
197
|
-
f"Cannot handle MDL bond type {int(line[6
|
|
189
|
+
f"Cannot handle MDL bond type {int(line[6:9])}, "
|
|
198
190
|
f"BondType.ANY is used instead"
|
|
199
191
|
)
|
|
200
192
|
bond_type = BondType.ANY
|
|
@@ -247,8 +239,7 @@ def _read_structure_from_ctab_v3000(ctab_lines):
|
|
|
247
239
|
bond_type = BOND_TYPE_MAPPING.get(v30_type)
|
|
248
240
|
if bond_type is None:
|
|
249
241
|
warnings.warn(
|
|
250
|
-
f"Cannot handle MDL bond type {v30_type}, "
|
|
251
|
-
f"BondType.ANY is used instead"
|
|
242
|
+
f"Cannot handle MDL bond type {v30_type}, BondType.ANY is used instead"
|
|
252
243
|
)
|
|
253
244
|
bond_type = BondType.ANY
|
|
254
245
|
bond_array[i, 0] = v30_atom_indices[v30_atom_index_1]
|
|
@@ -307,10 +298,17 @@ def _write_structure_to_ctab_v2000(atoms, default_bond_type):
|
|
|
307
298
|
" 0 0 0 0 0 0 0 1 V2000"
|
|
308
299
|
)
|
|
309
300
|
|
|
301
|
+
for i, coord_name in enumerate(["x", "y", "z"]):
|
|
302
|
+
n_coord_digits = number_of_integer_digits(atoms.coord[:, i])
|
|
303
|
+
if n_coord_digits > 5:
|
|
304
|
+
raise BadStructureError(
|
|
305
|
+
f"5 pre-decimal columns for {coord_name}-coordinates are "
|
|
306
|
+
f"available, but array would require {n_coord_digits}"
|
|
307
|
+
)
|
|
310
308
|
atom_lines = [
|
|
311
|
-
f"{atoms.coord[i,0]:>10.4f}"
|
|
312
|
-
f"{atoms.coord[i,1]:>10.4f}"
|
|
313
|
-
f"{atoms.coord[i,2]:>10.4f}"
|
|
309
|
+
f"{atoms.coord[i, 0]:>10.4f}"
|
|
310
|
+
f"{atoms.coord[i, 1]:>10.4f}"
|
|
311
|
+
f"{atoms.coord[i, 2]:>10.4f}"
|
|
314
312
|
f" {atoms.element[i].capitalize():3}"
|
|
315
313
|
f"{0:>2}" # Mass difference -> unused
|
|
316
314
|
f"{CHARGE_MAPPING_REV.get(charge[i], 0):>3d}"
|
|
@@ -321,7 +319,7 @@ def _write_structure_to_ctab_v2000(atoms, default_bond_type):
|
|
|
321
319
|
|
|
322
320
|
default_bond_value = BOND_TYPE_MAPPING_REV[default_bond_type]
|
|
323
321
|
bond_lines = [
|
|
324
|
-
f"{i+1:>3d}{j+1:>3d}"
|
|
322
|
+
f"{i + 1:>3d}{j + 1:>3d}"
|
|
325
323
|
f"{BOND_TYPE_MAPPING_REV.get(bond_type, default_bond_value):>3d}"
|
|
326
324
|
+ f"{0:>3d}"
|
|
327
325
|
* 4
|
|
@@ -337,7 +335,7 @@ def _write_structure_to_ctab_v2000(atoms, default_bond_type):
|
|
|
337
335
|
):
|
|
338
336
|
charge_lines.append(
|
|
339
337
|
f"M CHG{len(batch):>3d}"
|
|
340
|
-
+ "".join(f" {atom_i+1:>3d} {c:>3d}" for atom_i, c in batch)
|
|
338
|
+
+ "".join(f" {atom_i + 1:>3d} {c:>3d}" for atom_i, c in batch)
|
|
341
339
|
)
|
|
342
340
|
|
|
343
341
|
return [counts_line] + atom_lines + bond_lines + charge_lines + ["M END"]
|
|
@@ -351,12 +349,19 @@ def _write_structure_to_ctab_v3000(atoms, default_bond_type):
|
|
|
351
349
|
|
|
352
350
|
counts_line = f"COUNTS {atoms.array_length()} {atoms.bonds.get_bond_count()} 0 0 0"
|
|
353
351
|
|
|
352
|
+
for i, coord_name in enumerate(["x", "y", "z"]):
|
|
353
|
+
n_coord_digits = number_of_integer_digits(atoms.coord[:, i])
|
|
354
|
+
if n_coord_digits > 5:
|
|
355
|
+
raise BadStructureError(
|
|
356
|
+
f"5 pre-decimal columns for {coord_name}-coordinates are "
|
|
357
|
+
f"available, but array would require {n_coord_digits}"
|
|
358
|
+
)
|
|
354
359
|
atom_lines = [
|
|
355
360
|
f"{i + 1}"
|
|
356
361
|
f" {_quote(atoms.element[i].capitalize())}"
|
|
357
|
-
f" {atoms.coord[i,0]:.4f}"
|
|
358
|
-
f" {atoms.coord[i,1]:.4f}"
|
|
359
|
-
f" {atoms.coord[i,2]:.4f}"
|
|
362
|
+
f" {atoms.coord[i, 0]:.4f}"
|
|
363
|
+
f" {atoms.coord[i, 1]:.4f}"
|
|
364
|
+
f" {atoms.coord[i, 2]:.4f}"
|
|
360
365
|
# 'aamap' is unused
|
|
361
366
|
f" 0"
|
|
362
367
|
f" {_to_property(charges[i])}"
|
biotite/structure/io/mol/mol.py
CHANGED
biotite/structure/io/mol/sdf.py
CHANGED
|
@@ -78,7 +78,6 @@ class Metadata(MutableMapping):
|
|
|
78
78
|
>>> print(metadata[Metadata.Key(number=42, name="bar")])
|
|
79
79
|
dolor sit amet,
|
|
80
80
|
consectetur
|
|
81
|
-
|
|
82
81
|
"""
|
|
83
82
|
|
|
84
83
|
@dataclass(frozen=True, kw_only=True)
|
|
@@ -144,12 +143,18 @@ class Metadata(MutableMapping):
|
|
|
144
143
|
@staticmethod
|
|
145
144
|
def deserialize(text):
|
|
146
145
|
"""
|
|
147
|
-
Create
|
|
146
|
+
Create a :class:`Metadata.Key` object by deserializing the given text
|
|
147
|
+
content.
|
|
148
148
|
|
|
149
149
|
Parameters
|
|
150
150
|
----------
|
|
151
|
-
|
|
151
|
+
text : str
|
|
152
152
|
The content to be deserialized.
|
|
153
|
+
|
|
154
|
+
Returns
|
|
155
|
+
-------
|
|
156
|
+
key : Metadata.Key
|
|
157
|
+
The parsed key.
|
|
153
158
|
"""
|
|
154
159
|
# Omit the leading '>'
|
|
155
160
|
key_components = text[1:].split()
|
|
@@ -207,12 +212,17 @@ class Metadata(MutableMapping):
|
|
|
207
212
|
@staticmethod
|
|
208
213
|
def deserialize(text):
|
|
209
214
|
"""
|
|
210
|
-
Create
|
|
215
|
+
Create a :class:`Metadata` objtect by deserializing the given text content.
|
|
211
216
|
|
|
212
217
|
Parameters
|
|
213
218
|
----------
|
|
214
|
-
|
|
219
|
+
text : str
|
|
215
220
|
The content to be deserialized.
|
|
221
|
+
|
|
222
|
+
Returns
|
|
223
|
+
-------
|
|
224
|
+
metadata : Metadata
|
|
225
|
+
The parsed metadata.
|
|
216
226
|
"""
|
|
217
227
|
metadata = {}
|
|
218
228
|
current_key = None
|
|
@@ -314,19 +324,19 @@ class SDRecord:
|
|
|
314
324
|
>>> record = SDRecord(header=Header(mol_name="ALA", dimensions="3D"))
|
|
315
325
|
>>> record.set_structure(atoms)
|
|
316
326
|
>>> print(record.get_structure())
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
0 N -0.966 0.493 1.500
|
|
328
|
+
0 C 0.257 0.418 0.692
|
|
329
|
+
0 C -0.094 0.017 -0.716
|
|
330
|
+
0 O -1.056 -0.682 -0.923
|
|
331
|
+
0 C 1.204 -0.620 1.296
|
|
332
|
+
0 O 0.661 0.439 -1.742
|
|
333
|
+
0 H -1.383 -0.425 1.482
|
|
334
|
+
0 H -0.676 0.661 2.452
|
|
335
|
+
0 H 0.746 1.392 0.682
|
|
336
|
+
0 H 1.459 -0.330 2.316
|
|
337
|
+
0 H 0.715 -1.594 1.307
|
|
338
|
+
0 H 2.113 -0.676 0.697
|
|
339
|
+
0 H 0.435 0.182 -2.647
|
|
330
340
|
>>> # Add the record to an SD file
|
|
331
341
|
>>> file = SDFile()
|
|
332
342
|
>>> file["ALA"] = record
|
|
@@ -335,19 +345,19 @@ class SDRecord:
|
|
|
335
345
|
3D
|
|
336
346
|
<BLANKLINE>
|
|
337
347
|
13 12 0 0 0 0 0 0 0 1 V2000
|
|
338
|
-
-0.
|
|
339
|
-
0.
|
|
340
|
-
-0.
|
|
341
|
-
-1.
|
|
342
|
-
1.
|
|
343
|
-
0.
|
|
344
|
-
-1.
|
|
345
|
-
-0.
|
|
346
|
-
0.
|
|
347
|
-
1.
|
|
348
|
-
0.
|
|
349
|
-
2.
|
|
350
|
-
0.
|
|
348
|
+
-0.9660 0.4930 1.5000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
349
|
+
0.2570 0.4180 0.6920 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
350
|
+
-0.0940 0.0170 -0.7160 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
351
|
+
-1.0560 -0.6820 -0.9230 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
352
|
+
1.2040 -0.6200 1.2960 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
353
|
+
0.6610 0.4390 -1.7420 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
354
|
+
-1.3830 -0.4250 1.4820 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
355
|
+
-0.6760 0.6610 2.4520 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
356
|
+
0.7460 1.3920 0.6820 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
357
|
+
1.4590 -0.3300 2.3160 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
358
|
+
0.7150 -1.5940 1.3070 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
359
|
+
2.1130 -0.6760 0.6970 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
360
|
+
0.4350 0.1820 -2.6470 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
351
361
|
1 2 1 0 0 0 0
|
|
352
362
|
1 7 1 0 0 0 0
|
|
353
363
|
1 8 1 0 0 0 0
|
|
@@ -362,6 +372,7 @@ class SDRecord:
|
|
|
362
372
|
6 13 1 0 0 0 0
|
|
363
373
|
M END
|
|
364
374
|
$$$$
|
|
375
|
+
<BLANKLINE>
|
|
365
376
|
"""
|
|
366
377
|
|
|
367
378
|
def __init__(self, header=None, ctab=None, metadata=None):
|
|
@@ -422,19 +433,23 @@ class SDRecord:
|
|
|
422
433
|
self._metadata = Metadata(metadata)
|
|
423
434
|
else:
|
|
424
435
|
raise TypeError(
|
|
425
|
-
"Expected 'Metadata' or Mapping, "
|
|
426
|
-
f"but got '{type(metadata).__name__}'"
|
|
436
|
+
f"Expected 'Metadata' or Mapping, but got '{type(metadata).__name__}'"
|
|
427
437
|
)
|
|
428
438
|
|
|
429
439
|
@staticmethod
|
|
430
440
|
def deserialize(text):
|
|
431
441
|
"""
|
|
432
|
-
Create an
|
|
442
|
+
Create an :class:`SDRecord` by deserializing the given text content.
|
|
433
443
|
|
|
434
444
|
Parameters
|
|
435
445
|
----------
|
|
436
|
-
|
|
446
|
+
text : str
|
|
437
447
|
The content to be deserialized.
|
|
448
|
+
|
|
449
|
+
Returns
|
|
450
|
+
-------
|
|
451
|
+
record : SDRecord
|
|
452
|
+
The parsed record.
|
|
438
453
|
"""
|
|
439
454
|
lines = text.splitlines()
|
|
440
455
|
ctab_end = _get_ctab_stop(lines)
|
|
@@ -493,7 +508,7 @@ class SDRecord:
|
|
|
493
508
|
|
|
494
509
|
Parameters
|
|
495
510
|
----------
|
|
496
|
-
|
|
511
|
+
atoms : AtomArray
|
|
497
512
|
The array to be saved into this file.
|
|
498
513
|
Must have an associated :class:`BondList`.
|
|
499
514
|
default_bond_type : BondType, optional
|
|
@@ -538,11 +553,18 @@ class SDFile(File, MutableMapping):
|
|
|
538
553
|
:class:`SDRecord` object via :func:`get_structure()` or
|
|
539
554
|
:func:`set_structure()`, respectively.
|
|
540
555
|
|
|
556
|
+
Parameters
|
|
557
|
+
----------
|
|
558
|
+
records : dict (str -> SDRecord), optional
|
|
559
|
+
The initial records of the file.
|
|
560
|
+
Maps the record names to the corresponding :class:`SDRecord` objects.
|
|
561
|
+
By default no initial records are added.
|
|
562
|
+
|
|
541
563
|
Attributes
|
|
542
564
|
----------
|
|
543
565
|
record : CIFBlock
|
|
544
566
|
The sole record of the file.
|
|
545
|
-
If the file contains multiple
|
|
567
|
+
If the file contains multiple records, an exception is raised.
|
|
546
568
|
|
|
547
569
|
Examples
|
|
548
570
|
--------
|
|
@@ -678,19 +700,19 @@ class SDFile(File, MutableMapping):
|
|
|
678
700
|
<BLANKLINE>
|
|
679
701
|
<BLANKLINE>
|
|
680
702
|
13 12 0 0 0 0 0 0 0 1 V2000
|
|
681
|
-
-0.
|
|
682
|
-
0.
|
|
683
|
-
-0.
|
|
684
|
-
-1.
|
|
685
|
-
1.
|
|
686
|
-
0.
|
|
687
|
-
-1.
|
|
688
|
-
-0.
|
|
689
|
-
0.
|
|
690
|
-
1.
|
|
691
|
-
0.
|
|
692
|
-
2.
|
|
693
|
-
0.
|
|
703
|
+
-0.9660 0.4930 1.5000 N 0 0 0 0 0 0 0 0 0 0 0 0
|
|
704
|
+
0.2570 0.4180 0.6920 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
705
|
+
-0.0940 0.0170 -0.7160 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
706
|
+
-1.0560 -0.6820 -0.9230 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
707
|
+
1.2040 -0.6200 1.2960 C 0 0 0 0 0 0 0 0 0 0 0 0
|
|
708
|
+
0.6610 0.4390 -1.7420 O 0 0 0 0 0 0 0 0 0 0 0 0
|
|
709
|
+
-1.3830 -0.4250 1.4820 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
710
|
+
-0.6760 0.6610 2.4520 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
711
|
+
0.7460 1.3920 0.6820 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
712
|
+
1.4590 -0.3300 2.3160 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
713
|
+
0.7150 -1.5940 1.3070 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
714
|
+
2.1130 -0.6760 0.6970 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
715
|
+
0.4350 0.1820 -2.6470 H 0 0 0 0 0 0 0 0 0 0 0 0
|
|
694
716
|
1 2 1 0 0 0 0
|
|
695
717
|
1 7 1 0 0 0 0
|
|
696
718
|
1 8 1 0 0 0 0
|
|
@@ -731,12 +753,17 @@ class SDFile(File, MutableMapping):
|
|
|
731
753
|
@staticmethod
|
|
732
754
|
def deserialize(text):
|
|
733
755
|
"""
|
|
734
|
-
Create an
|
|
756
|
+
Create an :class:`SDFile` by deserializing the given text content.
|
|
735
757
|
|
|
736
758
|
Parameters
|
|
737
759
|
----------
|
|
738
|
-
|
|
760
|
+
text : str
|
|
739
761
|
The content to be deserialized.
|
|
762
|
+
|
|
763
|
+
Returns
|
|
764
|
+
-------
|
|
765
|
+
file_object : SDFile
|
|
766
|
+
The parsed file.
|
|
740
767
|
"""
|
|
741
768
|
lines = text.splitlines()
|
|
742
769
|
record_ends = np.array(
|
|
@@ -895,7 +922,7 @@ def _to_metadata_key(key):
|
|
|
895
922
|
return Metadata.Key(name=key)
|
|
896
923
|
else:
|
|
897
924
|
raise TypeError(
|
|
898
|
-
"Expected 'Metadata.Key' or str,
|
|
925
|
+
f"Expected 'Metadata.Key' or str, but got '{type(key).__name__}'"
|
|
899
926
|
)
|
|
900
927
|
|
|
901
928
|
|
|
@@ -89,14 +89,13 @@ def get_structure(
|
|
|
89
89
|
-------
|
|
90
90
|
array : AtomArray or AtomArrayStack
|
|
91
91
|
The return type depends on the `model` parameter.
|
|
92
|
-
|
|
93
92
|
"""
|
|
94
93
|
return pdb_file.get_structure(model, altloc, extra_fields, include_bonds)
|
|
95
94
|
|
|
96
95
|
|
|
97
96
|
def set_structure(pdb_file, array, hybrid36=False):
|
|
98
97
|
"""
|
|
99
|
-
|
|
98
|
+
Write an :class:`AtomArray` or :class:`AtomArrayStack` into a
|
|
100
99
|
:class:`PDBFile`.
|
|
101
100
|
|
|
102
101
|
This function is a thin wrapper around the :class:`PDBFile` method
|
|
@@ -114,7 +113,7 @@ def set_structure(pdb_file, array, hybrid36=False):
|
|
|
114
113
|
array : AtomArray or AtomArrayStack
|
|
115
114
|
The structure to be written. If a stack is given, each array in
|
|
116
115
|
the stack will be in a separate model.
|
|
117
|
-
hybrid36: boolean, optional
|
|
116
|
+
hybrid36 : boolean, optional
|
|
118
117
|
Defines wether the file should be written in hybrid-36 format.
|
|
119
118
|
|
|
120
119
|
Notes
|
|
@@ -218,6 +217,8 @@ def get_assembly(
|
|
|
218
217
|
assembly : AtomArray or AtomArrayStack
|
|
219
218
|
The assembly.
|
|
220
219
|
The return type depends on the `model` parameter.
|
|
220
|
+
Contains the `sym_id` annotation, which enumerates the copies of the asymmetric
|
|
221
|
+
unit in the assembly.
|
|
221
222
|
|
|
222
223
|
Examples
|
|
223
224
|
--------
|