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,243 @@
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
+ """
6
+ This module contains internally abstract classes for representing parts
7
+ of CIF/BinaryCIF files, such as categories and columns.
8
+ """
9
+
10
+ __name__ = "biotite.structure.io.pdbx"
11
+ __author__ = "Patrick Kunzmann"
12
+ __all__ = ["MaskValue"]
13
+
14
+ from enum import IntEnum
15
+ from abc import ABCMeta, abstractmethod
16
+ from collections.abc import MutableMapping
17
+ from .error import SerializationError, DeserializationError
18
+
19
+
20
+ class MaskValue(IntEnum):
21
+ """
22
+ This enum type represents the possible values of a mask array.
23
+
24
+ - `PRESENT` : A value is present.
25
+ - `INAPPLICABLE` : For this row no value is applicable or
26
+ inappropriate (``.`` in *CIF*).
27
+ In some cases it may also refer to a default value for the
28
+ respective column.
29
+ - `MISSING` : For this row the value is missing or unknown
30
+ (``?`` in *CIF*).
31
+ """
32
+ PRESENT = 0
33
+ INAPPLICABLE = 1
34
+ MISSING = 2
35
+
36
+
37
+ class _Component(metaclass=ABCMeta):
38
+ """
39
+ Base class for all components in a CIF/BinaryCIF file.
40
+ """
41
+
42
+ @staticmethod
43
+ def subcomponent_class():
44
+ """
45
+ Get the class of the components that are stored in this component.
46
+
47
+ Returns
48
+ -------
49
+ subcomponent_class : type
50
+ The class of the subcomponent.
51
+ If this component already represents the lowest level, i.e.
52
+ it does not contain subcomponents, ``None`` is
53
+ returned.
54
+ """
55
+ return None
56
+
57
+ @staticmethod
58
+ def supercomponent_class():
59
+ """
60
+ Get the class of the component that contains this component.
61
+
62
+ Returns
63
+ -------
64
+ supercomponent_class : type
65
+ The class of the supercomponent.
66
+ If this component present already the highest level, i.e.
67
+ it is not contained in another component, ``None`` is
68
+ returned.
69
+ """
70
+ return None
71
+
72
+ @staticmethod
73
+ @abstractmethod
74
+ def deserialize(content):
75
+ """
76
+ Create this component by deserializing the given content.
77
+
78
+ Parameters
79
+ ----------
80
+ content : str or dict
81
+ The content to be deserialized.
82
+ The type of this parameter depends on the file format.
83
+ In case of *CIF* files, this is the text of the lines
84
+ that represent this component.
85
+ In case of *BinaryCIF* files, this is a dictionary
86
+ parsed from the *MessagePack* data.
87
+ """
88
+ raise NotImplementedError()
89
+
90
+ @abstractmethod
91
+ def serialize(self):
92
+ """
93
+ Convert this component into a Python object that can be written
94
+ to a file.
95
+
96
+ Returns
97
+ -------
98
+ content : str or dict
99
+ The content to be serialized.
100
+ The type of this return value depends on the file format.
101
+ In case of *CIF* files, this is the text of the lines
102
+ that represent this component.
103
+ In case of *BinaryCIF* files, this is a dictionary
104
+ that can be encoded into *MessagePack*.
105
+ """
106
+ raise NotImplementedError()
107
+
108
+
109
+ class _HierarchicalContainer(_Component, MutableMapping,
110
+ metaclass=ABCMeta):
111
+ """
112
+ A container for hierarchical data in BinaryCIF files.
113
+ For example, the file contains multiple blocks, each block contains
114
+ multiple categories and each category contains multiple columns.
115
+
116
+ It uses lazy deserialization:
117
+ A component is only deserialized from the serialized data, if it
118
+ is accessed.
119
+ The deserialized component is then cached in the container.
120
+ """
121
+
122
+ def __init__(self, elements=None):
123
+ if elements is None:
124
+ elements = {}
125
+ for element in elements.values():
126
+ if not isinstance(element, (dict, self.subcomponent_class())):
127
+ raise TypeError(
128
+ f"Expected '{self.subcomponent_class().__name__}', "
129
+ f"but got '{type(element).__name__}'"
130
+ )
131
+ self._elements = elements
132
+
133
+ @staticmethod
134
+ def _deserialize_elements(content, take_key_from):
135
+ """
136
+ Lazily deserialize the elements of this container.
137
+
138
+ Parameters
139
+ ----------
140
+ content : dict
141
+ The serialized content describing the elements for this
142
+ container.
143
+ take_key_from : str
144
+ The key in each element of `content`, whose value is used as
145
+ the key for the respective element.
146
+
147
+ Returns
148
+ -------
149
+ elements : dict
150
+ The elements that should be stored in this container.
151
+ This return value can be given to the constructor.
152
+ """
153
+ elements = {}
154
+ for serialized_element in content:
155
+ key = serialized_element[take_key_from]
156
+ # Lazy deserialization
157
+ # -> keep serialized for now and deserialize later if needed
158
+ elements[key] = serialized_element
159
+ return elements
160
+
161
+ def _serialize_elements(self, store_key_in=None):
162
+ """
163
+ Serialize the elements that are stored in this container.
164
+
165
+ Each element that is still serialized (due to lazy
166
+ deserialization), is kept as it is.
167
+
168
+ Parameters
169
+ ----------
170
+ store_key_in: str, optional
171
+ If given, the key of each element is stored as value in the
172
+ serialized element.
173
+ This is basically the reverse operation of `take_key_from` in
174
+ :meth:`_deserialize_elements()`.
175
+ """
176
+ serialized_elements = []
177
+ for key, element in self._elements.items():
178
+ if isinstance(element, self.subcomponent_class()):
179
+ try:
180
+ serialized_element = element.serialize()
181
+ except:
182
+ raise SerializationError(
183
+ f"Failed to serialize element '{key}'"
184
+ )
185
+ else:
186
+ # Element is already stored in serialized form
187
+ serialized_element = element
188
+ if store_key_in is not None:
189
+ serialized_element[store_key_in] = key
190
+ serialized_elements.append(serialized_element)
191
+ return serialized_elements
192
+
193
+ def __getitem__(self, key):
194
+ element = self._elements[key]
195
+ if not isinstance(element, self.subcomponent_class()):
196
+ # Element is stored in serialized form
197
+ # -> must be deserialized first
198
+ try:
199
+ element = self.subcomponent_class().deserialize(element)
200
+ except:
201
+ raise DeserializationError(
202
+ f"Failed to deserialize element '{key}'"
203
+ )
204
+ # Update container with deserialized object
205
+ self._elements[key] = element
206
+ return element
207
+
208
+ def __setitem__(self, key, element):
209
+ if isinstance(element, self.subcomponent_class()):
210
+ pass
211
+ elif isinstance(element, _HierarchicalContainer):
212
+ # A common mistake may be to use the wrong container type
213
+ raise TypeError(
214
+ f"Expected '{self.subcomponent_class().__name__}', "
215
+ f"but got '{type(element).__name__}'"
216
+ )
217
+ else:
218
+ try:
219
+ element = self.subcomponent_class().deserialize(element)
220
+ except:
221
+ raise DeserializationError(
222
+ f"Failed to deserialize given value"
223
+ )
224
+ self._elements[key] = element
225
+
226
+ def __delitem__(self, key):
227
+ del self._elements[key]
228
+
229
+ def __iter__(self):
230
+ return iter(self._elements)
231
+
232
+ def __len__(self):
233
+ return len(self._elements)
234
+
235
+ def __eq__(self, other):
236
+ if not isinstance(other, type(self)):
237
+ return False
238
+ if set(self.keys()) != set(other.keys()):
239
+ return False
240
+ for key in self.keys():
241
+ if self[key] != other[key]:
242
+ return False
243
+ return True