biotite 0.39.0__cp312-cp312-macosx_11_0_arm64.whl → 0.40.0__cp312-cp312-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of biotite might be problematic. Click here for more details.

Files changed (104) hide show
  1. biotite/__init__.py +3 -3
  2. biotite/application/dssp/app.py +18 -18
  3. biotite/database/rcsb/download.py +19 -14
  4. biotite/sequence/align/banded.c +256 -235
  5. biotite/sequence/align/banded.cpython-312-darwin.so +0 -0
  6. biotite/sequence/align/kmeralphabet.c +241 -220
  7. biotite/sequence/align/kmeralphabet.cpython-312-darwin.so +0 -0
  8. biotite/sequence/align/kmersimilarity.c +213 -194
  9. biotite/sequence/align/kmersimilarity.cpython-312-darwin.so +0 -0
  10. biotite/sequence/align/kmertable.cpp +231 -203
  11. biotite/sequence/align/kmertable.cpython-312-darwin.so +0 -0
  12. biotite/sequence/align/localgapped.c +256 -235
  13. biotite/sequence/align/localgapped.cpython-312-darwin.so +0 -0
  14. biotite/sequence/align/localungapped.c +233 -212
  15. biotite/sequence/align/localungapped.cpython-312-darwin.so +0 -0
  16. biotite/sequence/align/multiple.c +253 -232
  17. biotite/sequence/align/multiple.cpython-312-darwin.so +0 -0
  18. biotite/sequence/align/pairwise.c +272 -251
  19. biotite/sequence/align/pairwise.cpython-312-darwin.so +0 -0
  20. biotite/sequence/align/permutation.c +213 -194
  21. biotite/sequence/align/permutation.cpython-312-darwin.so +0 -0
  22. biotite/sequence/align/selector.c +215 -195
  23. biotite/sequence/align/selector.cpython-312-darwin.so +0 -0
  24. biotite/sequence/align/tracetable.c +213 -193
  25. biotite/sequence/align/tracetable.cpython-312-darwin.so +0 -0
  26. biotite/sequence/codec.c +233 -212
  27. biotite/sequence/codec.cpython-312-darwin.so +0 -0
  28. biotite/sequence/phylo/nj.c +213 -194
  29. biotite/sequence/phylo/nj.cpython-312-darwin.so +0 -0
  30. biotite/sequence/phylo/tree.c +225 -200
  31. biotite/sequence/phylo/tree.cpython-312-darwin.so +0 -0
  32. biotite/sequence/phylo/upgma.c +213 -194
  33. biotite/sequence/phylo/upgma.cpython-312-darwin.so +0 -0
  34. biotite/structure/basepairs.py +7 -12
  35. biotite/structure/bonds.c +1173 -1224
  36. biotite/structure/bonds.cpython-312-darwin.so +0 -0
  37. biotite/structure/celllist.c +215 -195
  38. biotite/structure/celllist.cpython-312-darwin.so +0 -0
  39. biotite/structure/charges.c +1050 -1099
  40. biotite/structure/charges.cpython-312-darwin.so +0 -0
  41. biotite/structure/filter.py +30 -37
  42. biotite/structure/info/__init__.py +5 -8
  43. biotite/structure/info/atoms.py +25 -67
  44. biotite/structure/info/bonds.py +46 -100
  45. biotite/structure/info/ccd/README.rst +8 -0
  46. biotite/structure/info/ccd/amino_acids.txt +1646 -0
  47. biotite/structure/info/ccd/carbohydrates.txt +1133 -0
  48. biotite/structure/info/ccd/components.bcif +0 -0
  49. biotite/structure/info/ccd/nucleotides.txt +797 -0
  50. biotite/structure/info/ccd.py +95 -0
  51. biotite/structure/info/groups.py +90 -0
  52. biotite/structure/info/masses.py +21 -20
  53. biotite/structure/info/misc.py +11 -22
  54. biotite/structure/info/standardize.py +17 -12
  55. biotite/structure/io/__init__.py +2 -4
  56. biotite/structure/io/ctab.py +1 -1
  57. biotite/structure/io/general.py +37 -43
  58. biotite/structure/io/mmtf/__init__.py +3 -0
  59. biotite/structure/io/mmtf/convertarray.c +217 -196
  60. biotite/structure/io/mmtf/convertarray.cpython-312-darwin.so +0 -0
  61. biotite/structure/io/mmtf/convertfile.c +215 -195
  62. biotite/structure/io/mmtf/convertfile.cpython-312-darwin.so +0 -0
  63. biotite/structure/io/mmtf/decode.c +223 -202
  64. biotite/structure/io/mmtf/decode.cpython-312-darwin.so +0 -0
  65. biotite/structure/io/mmtf/encode.c +213 -194
  66. biotite/structure/io/mmtf/encode.cpython-312-darwin.so +0 -0
  67. biotite/structure/io/mmtf/file.py +34 -26
  68. biotite/structure/io/npz/__init__.py +3 -0
  69. biotite/structure/io/npz/file.py +21 -18
  70. biotite/structure/io/pdb/__init__.py +3 -3
  71. biotite/structure/io/pdb/file.py +5 -3
  72. biotite/structure/io/pdb/hybrid36.c +63 -43
  73. biotite/structure/io/pdb/hybrid36.cpython-312-darwin.so +0 -0
  74. biotite/structure/io/pdbqt/file.py +32 -32
  75. biotite/structure/io/pdbx/__init__.py +13 -6
  76. biotite/structure/io/pdbx/bcif.py +649 -0
  77. biotite/structure/io/pdbx/cif.py +1028 -0
  78. biotite/structure/io/pdbx/component.py +243 -0
  79. biotite/structure/io/pdbx/convert.py +707 -359
  80. biotite/structure/io/pdbx/encoding.c +112803 -0
  81. biotite/structure/io/pdbx/encoding.cpython-312-darwin.so +0 -0
  82. biotite/structure/io/pdbx/error.py +14 -0
  83. biotite/structure/io/pdbx/legacy.py +267 -0
  84. biotite/structure/molecules.py +151 -151
  85. biotite/structure/sasa.c +213 -194
  86. biotite/structure/sasa.cpython-312-darwin.so +0 -0
  87. biotite/structure/superimpose.py +158 -115
  88. {biotite-0.39.0.dist-info → biotite-0.40.0.dist-info}/METADATA +2 -2
  89. {biotite-0.39.0.dist-info → biotite-0.40.0.dist-info}/RECORD +92 -90
  90. {biotite-0.39.0.dist-info → biotite-0.40.0.dist-info}/WHEEL +1 -1
  91. biotite/structure/info/amino_acids.json +0 -1556
  92. biotite/structure/info/amino_acids.py +0 -42
  93. biotite/structure/info/carbohydrates.json +0 -1122
  94. biotite/structure/info/carbohydrates.py +0 -39
  95. biotite/structure/info/intra_bonds.msgpack +0 -0
  96. biotite/structure/info/link_types.msgpack +0 -1
  97. biotite/structure/info/nucleotides.json +0 -772
  98. biotite/structure/info/nucleotides.py +0 -39
  99. biotite/structure/info/residue_masses.msgpack +0 -0
  100. biotite/structure/info/residue_names.msgpack +0 -3
  101. biotite/structure/info/residues.msgpack +0 -0
  102. biotite/structure/io/pdbx/file.py +0 -652
  103. {biotite-0.39.0.dist-info → biotite-0.40.0.dist-info}/LICENSE.rst +0 -0
  104. {biotite-0.39.0.dist-info → biotite-0.40.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,14 @@
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__ = ["SerializationError", "DeserializationError"]
8
+
9
+
10
+ class SerializationError(Exception):
11
+ pass
12
+
13
+ class DeserializationError(Exception):
14
+ pass
@@ -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
+ )