biotite 0.39.0__cp312-cp312-win_amd64.whl → 0.41.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.

Files changed (121) hide show
  1. biotite/__init__.py +3 -3
  2. biotite/application/dssp/app.py +18 -18
  3. biotite/database/pubchem/download.py +23 -23
  4. biotite/database/pubchem/query.py +7 -7
  5. biotite/database/rcsb/download.py +19 -14
  6. biotite/file.py +17 -9
  7. biotite/sequence/align/banded.c +256 -235
  8. biotite/sequence/align/banded.cp312-win_amd64.pyd +0 -0
  9. biotite/sequence/align/cigar.py +60 -15
  10. biotite/sequence/align/kmeralphabet.c +241 -220
  11. biotite/sequence/align/kmeralphabet.cp312-win_amd64.pyd +0 -0
  12. biotite/sequence/align/kmersimilarity.c +213 -194
  13. biotite/sequence/align/kmersimilarity.cp312-win_amd64.pyd +0 -0
  14. biotite/sequence/align/kmertable.cp312-win_amd64.pyd +0 -0
  15. biotite/sequence/align/kmertable.cpp +231 -203
  16. biotite/sequence/align/localgapped.c +256 -235
  17. biotite/sequence/align/localgapped.cp312-win_amd64.pyd +0 -0
  18. biotite/sequence/align/localungapped.c +233 -212
  19. biotite/sequence/align/localungapped.cp312-win_amd64.pyd +0 -0
  20. biotite/sequence/align/multiple.c +253 -232
  21. biotite/sequence/align/multiple.cp312-win_amd64.pyd +0 -0
  22. biotite/sequence/align/pairwise.c +272 -251
  23. biotite/sequence/align/pairwise.cp312-win_amd64.pyd +0 -0
  24. biotite/sequence/align/permutation.c +213 -194
  25. biotite/sequence/align/permutation.cp312-win_amd64.pyd +0 -0
  26. biotite/sequence/align/selector.c +215 -195
  27. biotite/sequence/align/selector.cp312-win_amd64.pyd +0 -0
  28. biotite/sequence/align/tracetable.c +213 -193
  29. biotite/sequence/align/tracetable.cp312-win_amd64.pyd +0 -0
  30. biotite/sequence/annotation.py +2 -2
  31. biotite/sequence/codec.c +233 -212
  32. biotite/sequence/codec.cp312-win_amd64.pyd +0 -0
  33. biotite/sequence/io/fasta/convert.py +27 -24
  34. biotite/sequence/phylo/nj.c +213 -194
  35. biotite/sequence/phylo/nj.cp312-win_amd64.pyd +0 -0
  36. biotite/sequence/phylo/tree.c +225 -200
  37. biotite/sequence/phylo/tree.cp312-win_amd64.pyd +0 -0
  38. biotite/sequence/phylo/upgma.c +213 -194
  39. biotite/sequence/phylo/upgma.cp312-win_amd64.pyd +0 -0
  40. biotite/structure/__init__.py +2 -0
  41. biotite/structure/basepairs.py +7 -12
  42. biotite/structure/bonds.c +1435 -1277
  43. biotite/structure/bonds.cp312-win_amd64.pyd +0 -0
  44. biotite/structure/celllist.c +215 -195
  45. biotite/structure/celllist.cp312-win_amd64.pyd +0 -0
  46. biotite/structure/charges.c +1050 -1099
  47. biotite/structure/charges.cp312-win_amd64.pyd +0 -0
  48. biotite/structure/dotbracket.py +2 -0
  49. biotite/structure/filter.py +30 -37
  50. biotite/structure/info/__init__.py +5 -8
  51. biotite/structure/info/atoms.py +31 -68
  52. biotite/structure/info/bonds.py +47 -101
  53. biotite/structure/info/ccd/README.rst +8 -0
  54. biotite/structure/info/ccd/amino_acids.txt +1663 -0
  55. biotite/structure/info/ccd/carbohydrates.txt +1135 -0
  56. biotite/structure/info/ccd/components.bcif +0 -0
  57. biotite/structure/info/ccd/nucleotides.txt +798 -0
  58. biotite/structure/info/ccd.py +95 -0
  59. biotite/structure/info/groups.py +90 -0
  60. biotite/structure/info/masses.py +21 -20
  61. biotite/structure/info/misc.py +78 -25
  62. biotite/structure/info/standardize.py +17 -12
  63. biotite/structure/integrity.py +19 -70
  64. biotite/structure/io/__init__.py +2 -4
  65. biotite/structure/io/ctab.py +12 -106
  66. biotite/structure/io/general.py +167 -181
  67. biotite/structure/io/gro/file.py +16 -16
  68. biotite/structure/io/mmtf/__init__.py +3 -0
  69. biotite/structure/io/mmtf/convertarray.c +217 -196
  70. biotite/structure/io/mmtf/convertarray.cp312-win_amd64.pyd +0 -0
  71. biotite/structure/io/mmtf/convertfile.c +215 -195
  72. biotite/structure/io/mmtf/convertfile.cp312-win_amd64.pyd +0 -0
  73. biotite/structure/io/mmtf/decode.c +223 -202
  74. biotite/structure/io/mmtf/decode.cp312-win_amd64.pyd +0 -0
  75. biotite/structure/io/mmtf/encode.c +213 -194
  76. biotite/structure/io/mmtf/encode.cp312-win_amd64.pyd +0 -0
  77. biotite/structure/io/mmtf/file.py +34 -26
  78. biotite/structure/io/mol/__init__.py +4 -2
  79. biotite/structure/io/mol/convert.py +71 -7
  80. biotite/structure/io/mol/ctab.py +414 -0
  81. biotite/structure/io/mol/header.py +116 -0
  82. biotite/structure/io/mol/{file.py → mol.py} +69 -82
  83. biotite/structure/io/mol/sdf.py +909 -0
  84. biotite/structure/io/npz/__init__.py +3 -0
  85. biotite/structure/io/npz/file.py +21 -18
  86. biotite/structure/io/pdb/__init__.py +3 -3
  87. biotite/structure/io/pdb/file.py +89 -34
  88. biotite/structure/io/pdb/hybrid36.c +63 -43
  89. biotite/structure/io/pdb/hybrid36.cp312-win_amd64.pyd +0 -0
  90. biotite/structure/io/pdbqt/file.py +32 -32
  91. biotite/structure/io/pdbx/__init__.py +12 -6
  92. biotite/structure/io/pdbx/bcif.py +648 -0
  93. biotite/structure/io/pdbx/cif.py +1032 -0
  94. biotite/structure/io/pdbx/component.py +246 -0
  95. biotite/structure/io/pdbx/convert.py +858 -386
  96. biotite/structure/io/pdbx/encoding.c +112803 -0
  97. biotite/structure/io/pdbx/encoding.cp312-win_amd64.pyd +0 -0
  98. biotite/structure/io/pdbx/legacy.py +267 -0
  99. biotite/structure/molecules.py +151 -151
  100. biotite/structure/repair.py +253 -0
  101. biotite/structure/sasa.c +213 -194
  102. biotite/structure/sasa.cp312-win_amd64.pyd +0 -0
  103. biotite/structure/sequence.py +112 -0
  104. biotite/structure/superimpose.py +618 -116
  105. {biotite-0.39.0.dist-info → biotite-0.41.0.dist-info}/METADATA +3 -3
  106. {biotite-0.39.0.dist-info → biotite-0.41.0.dist-info}/RECORD +109 -103
  107. {biotite-0.39.0.dist-info → biotite-0.41.0.dist-info}/WHEEL +1 -1
  108. biotite/structure/info/amino_acids.json +0 -1556
  109. biotite/structure/info/amino_acids.py +0 -42
  110. biotite/structure/info/carbohydrates.json +0 -1122
  111. biotite/structure/info/carbohydrates.py +0 -39
  112. biotite/structure/info/intra_bonds.msgpack +0 -0
  113. biotite/structure/info/link_types.msgpack +0 -1
  114. biotite/structure/info/nucleotides.json +0 -772
  115. biotite/structure/info/nucleotides.py +0 -39
  116. biotite/structure/info/residue_masses.msgpack +0 -0
  117. biotite/structure/info/residue_names.msgpack +0 -3
  118. biotite/structure/info/residues.msgpack +0 -0
  119. biotite/structure/io/pdbx/file.py +0 -652
  120. {biotite-0.39.0.dist-info → biotite-0.41.0.dist-info}/LICENSE.rst +0 -0
  121. {biotite-0.39.0.dist-info → biotite-0.41.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,267 @@
1
+ # This source code is part of the Biotite package and is distributed
2
+ # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
3
+ # information.
4
+
5
+ __name__ = "biotite.structure.io.pdbx"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["PDBxFile"]
8
+
9
+ import copy
10
+ from collections.abc import MutableMapping
11
+ import warnings
12
+ from .cif import CIFFile, CIFBlock, CIFCategory, CIFColumn
13
+ from ....file import File, InvalidFileError
14
+
15
+
16
+ class PDBxFile(File, MutableMapping):
17
+ """
18
+ This class represents the legacy interface to CIF files.
19
+
20
+ The categories of the file can be accessed using the
21
+ :meth:`get_category()`/:meth:`set_category()` methods.
22
+ The content of each category is represented by a dictionary.
23
+ The dictionary contains the entry
24
+ (e.g. *label_entity_id* in *atom_site*) as key.
25
+ The corresponding values are either strings in *non-looped*
26
+ categories, or 1-D numpy arrays of string objects in case of
27
+ *looped* categories.
28
+
29
+ A category can be changed or added using :meth:`set_category()`:
30
+ If a string-valued dictionary is provided, a *non-looped* category
31
+ will be created; if an array-valued dictionary is given, a
32
+ *looped* category will be created. In case of arrays, it is
33
+ important that all arrays have the same size.
34
+
35
+ Alternatively, The content of this file can also be read/write
36
+ accessed using dictionary-like indexing:
37
+ You can either provide a data block and a category or only a
38
+ category, in which case the first data block is taken.
39
+
40
+ DEPRECATED: Use :class:`CIFFile` instead.
41
+
42
+ Notes
43
+ -----
44
+ This class is also able to detect and parse multiline entries in the
45
+ file. However, when writing a category no multiline values are used.
46
+ This could lead to long lines.
47
+
48
+ This class uses a lazy category dictionary creation: When reading
49
+ the file only the line positions of all categories are checked. The
50
+ time consuming task of dictionary creation is done when
51
+ :meth:`get_category()` is called.
52
+
53
+ Examples
54
+ --------
55
+ Read the file and get author names:
56
+
57
+ >>> import os.path
58
+ >>> file = PDBxFile.read(os.path.join(path_to_structures, "1l2y.cif"))
59
+ >>> author_dict = file.get_category("citation_author", block="1L2Y")
60
+ >>> print(author_dict["name"])
61
+ ['Neidigh, J.W.' 'Fesinmeyer, R.M.' 'Andersen, N.H.']
62
+
63
+ Dictionary style indexing, no specification of data block:
64
+
65
+ >>> print(file["citation_author"]["name"])
66
+ ['Neidigh, J.W.' 'Fesinmeyer, R.M.' 'Andersen, N.H.']
67
+
68
+ Get the structure from the file:
69
+
70
+ >>> arr = get_structure(file)
71
+ >>> print(type(arr).__name__)
72
+ AtomArrayStack
73
+ >>> arr = get_structure(file, model=1)
74
+ >>> print(type(arr).__name__)
75
+ AtomArray
76
+
77
+ Modify atom array and write it back into the file:
78
+
79
+ >>> arr_mod = rotate(arr, [1,2,3])
80
+ >>> set_structure(file, arr_mod)
81
+ >>> file.write(os.path.join(path_to_directory, "1l2y_mod.cif"))
82
+ """
83
+
84
+ def __init__(self):
85
+ warnings.warn(
86
+ "'PDBxFile' is deprecated, use 'CIFFile' instead",
87
+ DeprecationWarning
88
+ )
89
+ super().__init__()
90
+ self._cif_file = CIFFile()
91
+
92
+ @property
93
+ def cif_file(self):
94
+ return self._cif_file
95
+
96
+ @property
97
+ def lines(self):
98
+ return self._cif_file.lines
99
+
100
+ @classmethod
101
+ def read(cls, file):
102
+ """
103
+ Read a PDBx/mmCIF file.
104
+
105
+ Parameters
106
+ ----------
107
+ file : file-like object or str
108
+ The file to be read.
109
+ Alternatively a file path can be supplied.
110
+
111
+ Returns
112
+ -------
113
+ file_object : PDBxFile
114
+ The parsed file.
115
+ """
116
+ pdbx_file = PDBxFile()
117
+ pdbx_file._cif_file = CIFFile.read(file)
118
+ return pdbx_file
119
+
120
+ def write(self, file):
121
+ self._cif_file.write(file)
122
+
123
+
124
+ def get_block_names(self):
125
+ """
126
+ Get the names of all data blocks in the file.
127
+
128
+ Returns
129
+ -------
130
+ blocks : list
131
+ List of data block names.
132
+ """
133
+ return sorted(self._cif_file.keys())
134
+
135
+ def get_category(self, category, block=None, expect_looped=False):
136
+ """
137
+ Get the dictionary for a given category.
138
+
139
+ Parameters
140
+ ----------
141
+ category : string
142
+ The name of the category. The leading underscore is omitted.
143
+ block : string, optional
144
+ The name of the data block. Default is the first
145
+ (and most times only) data block of the file.
146
+ expect_looped : bool, optional
147
+ If set to true, the returned dictionary will always contain
148
+ arrays (only if the category exists):
149
+ If the category is *non-looped*, each array will contain
150
+ only one element.
151
+
152
+ Returns
153
+ -------
154
+ category_dict : dict of (str or ndarray, dtype=str) or None
155
+ A entry keyed dictionary. The corresponding values are
156
+ strings or array of strings for *non-looped* and
157
+ *looped* categories, respectively.
158
+ Returns None, if the data block does not contain the given
159
+ category.
160
+ """
161
+ if block is None:
162
+ try:
163
+ block = self.get_block_names()[0]
164
+ except IndexError:
165
+ raise InvalidFileError("File is empty")
166
+
167
+ if category not in self._cif_file[block]:
168
+ return None
169
+
170
+ category_dict = {}
171
+ for column_name, column in self._cif_file[block][category].items():
172
+ if not expect_looped and len(column) == 1:
173
+ category_dict[column_name] = column.as_item()
174
+ else:
175
+ category_dict[column_name] = column.as_array()
176
+ return category_dict
177
+
178
+ def set_category(self, category, category_dict, block=None):
179
+ """
180
+ Set the content of a category.
181
+
182
+ If the category is already existing, all lines corresponding
183
+ to the category are replaced. Otherwise a new category is
184
+ created and the lines are appended at the end of the data block.
185
+
186
+ Parameters
187
+ ----------
188
+ category : string
189
+ The name of the category. The leading underscore is omitted.
190
+ category_dict : dict
191
+ The category content. The dictionary must have strings
192
+ (subcategories) as keys and strings or :class:`ndarray`
193
+ objects as values.
194
+ block : string, optional
195
+ The name of the data block. Default is the first
196
+ (and most times only) data block of the file. If the
197
+ block is not contained in the file yet, a new block is
198
+ appended at the end of the file.
199
+ """
200
+ if block is None:
201
+ try:
202
+ block = self.get_block_names()[0]
203
+ except IndexError:
204
+ raise InvalidFileError(
205
+ "File is empty, give an explicit data block"
206
+ )
207
+
208
+ if block not in self._cif_file:
209
+ self._cif_file = CIFBlock()
210
+ self._cif_file[block][category] = CIFCategory({
211
+ column_name: CIFColumn(array)
212
+ for column_name, array in category_dict.items()
213
+ })
214
+
215
+ def __copy_fill__(self, clone):
216
+ super().__copy_fill__(clone)
217
+ clone._cif_file = copy.deepcopy(self._cif_file)
218
+
219
+ def __setitem__(self, index, item):
220
+ block, category_name = self._full_index(index)
221
+ self.set_category(category_name, item, block=block)
222
+
223
+ def __getitem__(self, index):
224
+ block, category_name = self._full_index(index)
225
+ return self.get_category(category_name, block=block)
226
+
227
+ def __delitem__(self, index):
228
+ block, category_name = self._full_index(index)
229
+ del self._cif_file[block][category_name]
230
+
231
+ def __contains__(self, index):
232
+ block, category_name = self._full_index(index)
233
+ return (block, category_name) in self._categories
234
+
235
+ def __iter__(self):
236
+ try:
237
+ block = self.get_block_names()[0]
238
+ except IndexError:
239
+ raise InvalidFileError(
240
+ "File is empty, give an explicit data block"
241
+ )
242
+
243
+ return iter(self._cif_file[block])
244
+
245
+ def __len__(self):
246
+ try:
247
+ block = self.get_block_names()[0]
248
+ except IndexError:
249
+ raise InvalidFileError(
250
+ "File is empty, give an explicit data block"
251
+ )
252
+
253
+ return len(self._cif_file[block])
254
+
255
+ def _full_index(self, index):
256
+ """
257
+ Converts a an integer or tuple index into a block and a category
258
+ name.
259
+ """
260
+ if isinstance(index, tuple):
261
+ return index[0], index[1]
262
+ elif isinstance(index, str):
263
+ return self.get_block_names()[0], index
264
+ else:
265
+ raise TypeError(
266
+ f"'{type(index).__name__}' is an invalid index type"
267
+ )
@@ -30,7 +30,7 @@ def get_molecule_indices(array):
30
30
  array : AtomArray or AtomArrayStack or BondList
31
31
  The input structure with an associated :class:`BondList`.
32
32
  Alternatively, the :class:`BondList` can be directly supplied.
33
-
33
+
34
34
  Returns
35
35
  -------
36
36
  indices : list of ndarray, dtype=int
@@ -38,7 +38,7 @@ def get_molecule_indices(array):
38
38
  atoms of a single molecule.
39
39
  Consequently, the length of this list is equal to the number of
40
40
  molecules in the input `array`.
41
-
41
+
42
42
  See also
43
43
  --------
44
44
  get_molecule_masks
@@ -63,54 +63,54 @@ def get_molecule_indices(array):
63
63
  >>> print(len(indices))
64
64
  2
65
65
  >>> print(atp[indices[0]])
66
- HET 0 ATP PG P 1.200 -0.226 -6.850
67
- HET 0 ATP O1G O 1.740 1.140 -6.672
68
- HET 0 ATP O2G O 2.123 -1.036 -7.891
69
- HET 0 ATP O3G O -0.302 -0.139 -7.421
70
- HET 0 ATP PB P 0.255 -0.130 -4.446
71
- HET 0 ATP O1B O 0.810 1.234 -4.304
72
- HET 0 ATP O2B O -1.231 -0.044 -5.057
73
- HET 0 ATP O3B O 1.192 -0.990 -5.433
74
- HET 0 ATP PA P -0.745 0.068 -2.071
75
- HET 0 ATP O1A O -2.097 0.143 -2.669
76
- HET 0 ATP O2A O -0.125 1.549 -1.957
77
- HET 0 ATP O3A O 0.203 -0.840 -3.002
78
- HET 0 ATP HOG2 H 2.100 -0.546 -8.725
79
- HET 0 ATP HOG3 H -0.616 -1.048 -7.522
80
- HET 0 ATP HOB2 H -1.554 -0.952 -5.132
81
- HET 0 ATP HOA2 H 0.752 1.455 -1.563
66
+ HET 0 ATP PG P 1.200 -0.230 -6.850
67
+ HET 0 ATP O1G O 1.740 1.140 -6.670
68
+ HET 0 ATP O2G O 2.120 -1.040 -7.890
69
+ HET 0 ATP O3G O -0.300 -0.140 -7.420
70
+ HET 0 ATP PB P 0.260 -0.130 -4.450
71
+ HET 0 ATP O1B O 0.810 1.230 -4.300
72
+ HET 0 ATP O2B O -1.230 -0.040 -5.060
73
+ HET 0 ATP O3B O 1.190 -0.990 -5.430
74
+ HET 0 ATP PA P -0.740 0.070 -2.070
75
+ HET 0 ATP O1A O -2.100 0.140 -2.670
76
+ HET 0 ATP O2A O -0.120 1.550 -1.960
77
+ HET 0 ATP O3A O 0.200 -0.840 -3.000
78
+ HET 0 ATP HOG2 H 2.100 -0.550 -8.730
79
+ HET 0 ATP HOG3 H -0.620 -1.050 -7.520
80
+ HET 0 ATP HOB2 H -1.550 -0.950 -5.130
81
+ HET 0 ATP HOA2 H 0.750 1.460 -1.560
82
82
  >>> print(atp[indices[1]])
83
- HET 0 ATP O5' O -0.844 -0.587 -0.604
84
- HET 0 ATP C5' C -1.694 0.260 0.170
85
- HET 0 ATP C4' C -1.831 -0.309 1.584
86
- HET 0 ATP O4' O -0.542 -0.355 2.234
87
- HET 0 ATP C3' C -2.683 0.630 2.465
88
- HET 0 ATP O3' O -4.033 0.165 2.534
89
- HET 0 ATP C2' C -2.011 0.555 3.856
90
- HET 0 ATP O2' O -2.926 0.043 4.827
91
- HET 0 ATP C1' C -0.830 -0.418 3.647
92
- HET 0 ATP N9 N 0.332 0.015 4.425
93
- HET 0 ATP C8 C 1.302 0.879 4.012
94
- HET 0 ATP N7 N 2.184 1.042 4.955
95
- HET 0 ATP C5 C 1.833 0.300 6.033
96
- HET 0 ATP C6 C 2.391 0.077 7.303
97
- HET 0 ATP N6 N 3.564 0.706 7.681
98
- HET 0 ATP N1 N 1.763 -0.747 8.135
99
- HET 0 ATP C2 C 0.644 -1.352 7.783
100
- HET 0 ATP N3 N 0.088 -1.178 6.602
101
- HET 0 ATP C4 C 0.644 -0.371 5.704
102
- HET 0 ATP H5'1 H -2.678 0.312 -0.296
103
- HET 0 ATP H5'2 H -1.263 1.259 0.221
104
- HET 0 ATP H4' H -2.275 -1.304 1.550
105
- HET 0 ATP H3' H -2.651 1.649 2.078
106
- HET 0 ATP HO3' H -4.515 0.788 3.094
107
- HET 0 ATP H2' H -1.646 1.537 4.157
108
- HET 0 ATP HO2' H -3.667 0.662 4.867
109
- HET 0 ATP H1' H -1.119 -1.430 3.931
110
- HET 0 ATP H8 H 1.334 1.357 3.044
111
- HET 0 ATP HN61 H 3.938 0.548 8.562
112
- HET 0 ATP HN62 H 4.015 1.303 7.064
113
- HET 0 ATP H2 H 0.166 -2.014 8.490
83
+ HET 0 ATP O5' O -0.840 -0.590 -0.600
84
+ HET 0 ATP C5' C -1.690 0.260 0.170
85
+ HET 0 ATP C4' C -1.830 -0.310 1.580
86
+ HET 0 ATP O4' O -0.540 -0.360 2.230
87
+ HET 0 ATP C3' C -2.680 0.630 2.460
88
+ HET 0 ATP O3' O -4.030 0.160 2.530
89
+ HET 0 ATP C2' C -2.010 0.560 3.860
90
+ HET 0 ATP O2' O -2.930 0.040 4.830
91
+ HET 0 ATP C1' C -0.830 -0.420 3.650
92
+ HET 0 ATP N9 N 0.330 0.020 4.430
93
+ HET 0 ATP C8 C 1.300 0.880 4.010
94
+ HET 0 ATP N7 N 2.180 1.040 4.960
95
+ HET 0 ATP C5 C 1.830 0.300 6.030
96
+ HET 0 ATP C6 C 2.390 0.080 7.300
97
+ HET 0 ATP N6 N 3.560 0.710 7.680
98
+ HET 0 ATP N1 N 1.760 -0.750 8.140
99
+ HET 0 ATP C2 C 0.640 -1.350 7.780
100
+ HET 0 ATP N3 N 0.090 -1.180 6.600
101
+ HET 0 ATP C4 C 0.640 -0.370 5.700
102
+ HET 0 ATP H5'1 H -2.680 0.310 -0.300
103
+ HET 0 ATP H5'2 H -1.260 1.260 0.220
104
+ HET 0 ATP H4' H -2.280 -1.300 1.550
105
+ HET 0 ATP H3' H -2.650 1.650 2.080
106
+ HET 0 ATP HO3' H -4.520 0.790 3.090
107
+ HET 0 ATP H2' H -1.650 1.540 4.160
108
+ HET 0 ATP HO2' H -3.670 0.660 4.870
109
+ HET 0 ATP H1' H -1.120 -1.430 3.930
110
+ HET 0 ATP H8 H 1.330 1.360 3.040
111
+ HET 0 ATP HN61 H 3.940 0.550 8.560
112
+ HET 0 ATP HN62 H 4.020 1.300 7.060
113
+ HET 0 ATP H2 H 0.170 -2.010 8.490
114
114
  """
115
115
  if isinstance(array, BondList):
116
116
  bonds = array
@@ -123,7 +123,7 @@ def get_molecule_indices(array):
123
123
  f"Expected a 'BondList', 'AtomArray' or 'AtomArrayStack', "
124
124
  f"not '{type(array).__name__}'"
125
125
  )
126
-
126
+
127
127
  molecule_indices = []
128
128
  visited_mask = np.zeros(bonds.get_atom_count(), dtype=bool)
129
129
  while not visited_mask.all():
@@ -148,15 +148,15 @@ def get_molecule_masks(array):
148
148
  array : AtomArray, shape=(n,) or AtomArrayStack, shape=(m,n) or BondList
149
149
  The input structure with an associated :class:`BondList`.
150
150
  Alternatively, the :class:`BondList` can be directly supplied.
151
-
151
+
152
152
  Returns
153
153
  -------
154
- masks : ndarray, shape=(k,n), dtype=bool,
154
+ masks : ndarray, shape=(k,n), dtype=bool,
155
155
  Each element in the array is a boolean mask referring to the
156
156
  atoms of a single molecule.
157
157
  Consequently, the length of this list is equal to the number of
158
158
  molecules in the input `array`.
159
-
159
+
160
160
  See also
161
161
  --------
162
162
  get_molecule_indices
@@ -181,54 +181,54 @@ def get_molecule_masks(array):
181
181
  >>> print(len(masks))
182
182
  2
183
183
  >>> print(atp[masks[0]])
184
- HET 0 ATP PG P 1.200 -0.226 -6.850
185
- HET 0 ATP O1G O 1.740 1.140 -6.672
186
- HET 0 ATP O2G O 2.123 -1.036 -7.891
187
- HET 0 ATP O3G O -0.302 -0.139 -7.421
188
- HET 0 ATP PB P 0.255 -0.130 -4.446
189
- HET 0 ATP O1B O 0.810 1.234 -4.304
190
- HET 0 ATP O2B O -1.231 -0.044 -5.057
191
- HET 0 ATP O3B O 1.192 -0.990 -5.433
192
- HET 0 ATP PA P -0.745 0.068 -2.071
193
- HET 0 ATP O1A O -2.097 0.143 -2.669
194
- HET 0 ATP O2A O -0.125 1.549 -1.957
195
- HET 0 ATP O3A O 0.203 -0.840 -3.002
196
- HET 0 ATP HOG2 H 2.100 -0.546 -8.725
197
- HET 0 ATP HOG3 H -0.616 -1.048 -7.522
198
- HET 0 ATP HOB2 H -1.554 -0.952 -5.132
199
- HET 0 ATP HOA2 H 0.752 1.455 -1.563
184
+ HET 0 ATP PG P 1.200 -0.230 -6.850
185
+ HET 0 ATP O1G O 1.740 1.140 -6.670
186
+ HET 0 ATP O2G O 2.120 -1.040 -7.890
187
+ HET 0 ATP O3G O -0.300 -0.140 -7.420
188
+ HET 0 ATP PB P 0.260 -0.130 -4.450
189
+ HET 0 ATP O1B O 0.810 1.230 -4.300
190
+ HET 0 ATP O2B O -1.230 -0.040 -5.060
191
+ HET 0 ATP O3B O 1.190 -0.990 -5.430
192
+ HET 0 ATP PA P -0.740 0.070 -2.070
193
+ HET 0 ATP O1A O -2.100 0.140 -2.670
194
+ HET 0 ATP O2A O -0.120 1.550 -1.960
195
+ HET 0 ATP O3A O 0.200 -0.840 -3.000
196
+ HET 0 ATP HOG2 H 2.100 -0.550 -8.730
197
+ HET 0 ATP HOG3 H -0.620 -1.050 -7.520
198
+ HET 0 ATP HOB2 H -1.550 -0.950 -5.130
199
+ HET 0 ATP HOA2 H 0.750 1.460 -1.560
200
200
  >>> print(atp[masks[1]])
201
- HET 0 ATP O5' O -0.844 -0.587 -0.604
202
- HET 0 ATP C5' C -1.694 0.260 0.170
203
- HET 0 ATP C4' C -1.831 -0.309 1.584
204
- HET 0 ATP O4' O -0.542 -0.355 2.234
205
- HET 0 ATP C3' C -2.683 0.630 2.465
206
- HET 0 ATP O3' O -4.033 0.165 2.534
207
- HET 0 ATP C2' C -2.011 0.555 3.856
208
- HET 0 ATP O2' O -2.926 0.043 4.827
209
- HET 0 ATP C1' C -0.830 -0.418 3.647
210
- HET 0 ATP N9 N 0.332 0.015 4.425
211
- HET 0 ATP C8 C 1.302 0.879 4.012
212
- HET 0 ATP N7 N 2.184 1.042 4.955
213
- HET 0 ATP C5 C 1.833 0.300 6.033
214
- HET 0 ATP C6 C 2.391 0.077 7.303
215
- HET 0 ATP N6 N 3.564 0.706 7.681
216
- HET 0 ATP N1 N 1.763 -0.747 8.135
217
- HET 0 ATP C2 C 0.644 -1.352 7.783
218
- HET 0 ATP N3 N 0.088 -1.178 6.602
219
- HET 0 ATP C4 C 0.644 -0.371 5.704
220
- HET 0 ATP H5'1 H -2.678 0.312 -0.296
221
- HET 0 ATP H5'2 H -1.263 1.259 0.221
222
- HET 0 ATP H4' H -2.275 -1.304 1.550
223
- HET 0 ATP H3' H -2.651 1.649 2.078
224
- HET 0 ATP HO3' H -4.515 0.788 3.094
225
- HET 0 ATP H2' H -1.646 1.537 4.157
226
- HET 0 ATP HO2' H -3.667 0.662 4.867
227
- HET 0 ATP H1' H -1.119 -1.430 3.931
228
- HET 0 ATP H8 H 1.334 1.357 3.044
229
- HET 0 ATP HN61 H 3.938 0.548 8.562
230
- HET 0 ATP HN62 H 4.015 1.303 7.064
231
- HET 0 ATP H2 H 0.166 -2.014 8.490
201
+ HET 0 ATP O5' O -0.840 -0.590 -0.600
202
+ HET 0 ATP C5' C -1.690 0.260 0.170
203
+ HET 0 ATP C4' C -1.830 -0.310 1.580
204
+ HET 0 ATP O4' O -0.540 -0.360 2.230
205
+ HET 0 ATP C3' C -2.680 0.630 2.460
206
+ HET 0 ATP O3' O -4.030 0.160 2.530
207
+ HET 0 ATP C2' C -2.010 0.560 3.860
208
+ HET 0 ATP O2' O -2.930 0.040 4.830
209
+ HET 0 ATP C1' C -0.830 -0.420 3.650
210
+ HET 0 ATP N9 N 0.330 0.020 4.430
211
+ HET 0 ATP C8 C 1.300 0.880 4.010
212
+ HET 0 ATP N7 N 2.180 1.040 4.960
213
+ HET 0 ATP C5 C 1.830 0.300 6.030
214
+ HET 0 ATP C6 C 2.390 0.080 7.300
215
+ HET 0 ATP N6 N 3.560 0.710 7.680
216
+ HET 0 ATP N1 N 1.760 -0.750 8.140
217
+ HET 0 ATP C2 C 0.640 -1.350 7.780
218
+ HET 0 ATP N3 N 0.090 -1.180 6.600
219
+ HET 0 ATP C4 C 0.640 -0.370 5.700
220
+ HET 0 ATP H5'1 H -2.680 0.310 -0.300
221
+ HET 0 ATP H5'2 H -1.260 1.260 0.220
222
+ HET 0 ATP H4' H -2.280 -1.300 1.550
223
+ HET 0 ATP H3' H -2.650 1.650 2.080
224
+ HET 0 ATP HO3' H -4.520 0.790 3.090
225
+ HET 0 ATP H2' H -1.650 1.540 4.160
226
+ HET 0 ATP HO2' H -3.670 0.660 4.870
227
+ HET 0 ATP H1' H -1.120 -1.430 3.930
228
+ HET 0 ATP H8 H 1.330 1.360 3.040
229
+ HET 0 ATP HN61 H 3.940 0.550 8.560
230
+ HET 0 ATP HN62 H 4.020 1.300 7.060
231
+ HET 0 ATP H2 H 0.170 -2.010 8.490
232
232
  """
233
233
  if isinstance(array, BondList):
234
234
  bonds = array
@@ -241,7 +241,7 @@ def get_molecule_masks(array):
241
241
  f"Expected a 'BondList', 'AtomArray' or 'AtomArrayStack', "
242
242
  f"not '{type(array).__name__}'"
243
243
  )
244
-
244
+
245
245
  molecule_indices = get_molecule_indices(bonds)
246
246
  molecule_masks = np.zeros(
247
247
  (len(molecule_indices), bonds.get_atom_count()),
@@ -265,12 +265,12 @@ def molecule_iter(array):
265
265
  ----------
266
266
  array : AtomArray or AtomArrayStack
267
267
  The input structure with an associated :class:`BondList`.
268
-
268
+
269
269
  Yields
270
270
  ------
271
271
  molecule : AtomArray or AtomArrayStack
272
272
  A single molecule of the input `array`.
273
-
273
+
274
274
  See also
275
275
  --------
276
276
  get_molecule_indices
@@ -289,61 +289,61 @@ def molecule_iter(array):
289
289
  ... print(molecule)
290
290
  ... print()
291
291
  New molecule
292
- HET 0 ATP PG P 1.200 -0.226 -6.850
293
- HET 0 ATP O1G O 1.740 1.140 -6.672
294
- HET 0 ATP O2G O 2.123 -1.036 -7.891
295
- HET 0 ATP O3G O -0.302 -0.139 -7.421
296
- HET 0 ATP PB P 0.255 -0.130 -4.446
297
- HET 0 ATP O1B O 0.810 1.234 -4.304
298
- HET 0 ATP O2B O -1.231 -0.044 -5.057
299
- HET 0 ATP O3B O 1.192 -0.990 -5.433
300
- HET 0 ATP PA P -0.745 0.068 -2.071
301
- HET 0 ATP O1A O -2.097 0.143 -2.669
302
- HET 0 ATP O2A O -0.125 1.549 -1.957
303
- HET 0 ATP O3A O 0.203 -0.840 -3.002
304
- HET 0 ATP HOG2 H 2.100 -0.546 -8.725
305
- HET 0 ATP HOG3 H -0.616 -1.048 -7.522
306
- HET 0 ATP HOB2 H -1.554 -0.952 -5.132
307
- HET 0 ATP HOA2 H 0.752 1.455 -1.563
292
+ HET 0 ATP PG P 1.200 -0.230 -6.850
293
+ HET 0 ATP O1G O 1.740 1.140 -6.670
294
+ HET 0 ATP O2G O 2.120 -1.040 -7.890
295
+ HET 0 ATP O3G O -0.300 -0.140 -7.420
296
+ HET 0 ATP PB P 0.260 -0.130 -4.450
297
+ HET 0 ATP O1B O 0.810 1.230 -4.300
298
+ HET 0 ATP O2B O -1.230 -0.040 -5.060
299
+ HET 0 ATP O3B O 1.190 -0.990 -5.430
300
+ HET 0 ATP PA P -0.740 0.070 -2.070
301
+ HET 0 ATP O1A O -2.100 0.140 -2.670
302
+ HET 0 ATP O2A O -0.120 1.550 -1.960
303
+ HET 0 ATP O3A O 0.200 -0.840 -3.000
304
+ HET 0 ATP HOG2 H 2.100 -0.550 -8.730
305
+ HET 0 ATP HOG3 H -0.620 -1.050 -7.520
306
+ HET 0 ATP HOB2 H -1.550 -0.950 -5.130
307
+ HET 0 ATP HOA2 H 0.750 1.460 -1.560
308
308
  <BLANKLINE>
309
309
  New molecule
310
- HET 0 ATP O5' O -0.844 -0.587 -0.604
311
- HET 0 ATP C5' C -1.694 0.260 0.170
312
- HET 0 ATP C4' C -1.831 -0.309 1.584
313
- HET 0 ATP O4' O -0.542 -0.355 2.234
314
- HET 0 ATP C3' C -2.683 0.630 2.465
315
- HET 0 ATP O3' O -4.033 0.165 2.534
316
- HET 0 ATP C2' C -2.011 0.555 3.856
317
- HET 0 ATP O2' O -2.926 0.043 4.827
318
- HET 0 ATP C1' C -0.830 -0.418 3.647
319
- HET 0 ATP N9 N 0.332 0.015 4.425
320
- HET 0 ATP C8 C 1.302 0.879 4.012
321
- HET 0 ATP N7 N 2.184 1.042 4.955
322
- HET 0 ATP C5 C 1.833 0.300 6.033
323
- HET 0 ATP C6 C 2.391 0.077 7.303
324
- HET 0 ATP N6 N 3.564 0.706 7.681
325
- HET 0 ATP N1 N 1.763 -0.747 8.135
326
- HET 0 ATP C2 C 0.644 -1.352 7.783
327
- HET 0 ATP N3 N 0.088 -1.178 6.602
328
- HET 0 ATP C4 C 0.644 -0.371 5.704
329
- HET 0 ATP H5'1 H -2.678 0.312 -0.296
330
- HET 0 ATP H5'2 H -1.263 1.259 0.221
331
- HET 0 ATP H4' H -2.275 -1.304 1.550
332
- HET 0 ATP H3' H -2.651 1.649 2.078
333
- HET 0 ATP HO3' H -4.515 0.788 3.094
334
- HET 0 ATP H2' H -1.646 1.537 4.157
335
- HET 0 ATP HO2' H -3.667 0.662 4.867
336
- HET 0 ATP H1' H -1.119 -1.430 3.931
337
- HET 0 ATP H8 H 1.334 1.357 3.044
338
- HET 0 ATP HN61 H 3.938 0.548 8.562
339
- HET 0 ATP HN62 H 4.015 1.303 7.064
340
- HET 0 ATP H2 H 0.166 -2.014 8.490
310
+ HET 0 ATP O5' O -0.840 -0.590 -0.600
311
+ HET 0 ATP C5' C -1.690 0.260 0.170
312
+ HET 0 ATP C4' C -1.830 -0.310 1.580
313
+ HET 0 ATP O4' O -0.540 -0.360 2.230
314
+ HET 0 ATP C3' C -2.680 0.630 2.460
315
+ HET 0 ATP O3' O -4.030 0.160 2.530
316
+ HET 0 ATP C2' C -2.010 0.560 3.860
317
+ HET 0 ATP O2' O -2.930 0.040 4.830
318
+ HET 0 ATP C1' C -0.830 -0.420 3.650
319
+ HET 0 ATP N9 N 0.330 0.020 4.430
320
+ HET 0 ATP C8 C 1.300 0.880 4.010
321
+ HET 0 ATP N7 N 2.180 1.040 4.960
322
+ HET 0 ATP C5 C 1.830 0.300 6.030
323
+ HET 0 ATP C6 C 2.390 0.080 7.300
324
+ HET 0 ATP N6 N 3.560 0.710 7.680
325
+ HET 0 ATP N1 N 1.760 -0.750 8.140
326
+ HET 0 ATP C2 C 0.640 -1.350 7.780
327
+ HET 0 ATP N3 N 0.090 -1.180 6.600
328
+ HET 0 ATP C4 C 0.640 -0.370 5.700
329
+ HET 0 ATP H5'1 H -2.680 0.310 -0.300
330
+ HET 0 ATP H5'2 H -1.260 1.260 0.220
331
+ HET 0 ATP H4' H -2.280 -1.300 1.550
332
+ HET 0 ATP H3' H -2.650 1.650 2.080
333
+ HET 0 ATP HO3' H -4.520 0.790 3.090
334
+ HET 0 ATP H2' H -1.650 1.540 4.160
335
+ HET 0 ATP HO2' H -3.670 0.660 4.870
336
+ HET 0 ATP H1' H -1.120 -1.430 3.930
337
+ HET 0 ATP H8 H 1.330 1.360 3.040
338
+ HET 0 ATP HN61 H 3.940 0.550 8.560
339
+ HET 0 ATP HN62 H 4.020 1.300 7.060
340
+ HET 0 ATP H2 H 0.170 -2.010 8.490
341
341
  <BLANKLINE>
342
342
  """
343
343
  if array.bonds is None:
344
344
  raise ValueError("An associated BondList is required")
345
345
  bonds = array.bonds
346
-
346
+
347
347
  visited_mask = np.zeros(bonds.get_atom_count(), dtype=bool)
348
348
  while not visited_mask.all():
349
349
  # Take the first atom that has not been considered yet as root