biotite 0.41.1__cp312-cp312-macosx_10_16_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 (340) hide show
  1. biotite/__init__.py +19 -0
  2. biotite/application/__init__.py +43 -0
  3. biotite/application/application.py +265 -0
  4. biotite/application/autodock/__init__.py +12 -0
  5. biotite/application/autodock/app.py +505 -0
  6. biotite/application/blast/__init__.py +14 -0
  7. biotite/application/blast/alignment.py +83 -0
  8. biotite/application/blast/webapp.py +421 -0
  9. biotite/application/clustalo/__init__.py +12 -0
  10. biotite/application/clustalo/app.py +238 -0
  11. biotite/application/dssp/__init__.py +12 -0
  12. biotite/application/dssp/app.py +152 -0
  13. biotite/application/localapp.py +306 -0
  14. biotite/application/mafft/__init__.py +12 -0
  15. biotite/application/mafft/app.py +122 -0
  16. biotite/application/msaapp.py +374 -0
  17. biotite/application/muscle/__init__.py +13 -0
  18. biotite/application/muscle/app3.py +254 -0
  19. biotite/application/muscle/app5.py +171 -0
  20. biotite/application/sra/__init__.py +18 -0
  21. biotite/application/sra/app.py +456 -0
  22. biotite/application/tantan/__init__.py +12 -0
  23. biotite/application/tantan/app.py +222 -0
  24. biotite/application/util.py +59 -0
  25. biotite/application/viennarna/__init__.py +18 -0
  26. biotite/application/viennarna/rnaalifold.py +304 -0
  27. biotite/application/viennarna/rnafold.py +269 -0
  28. biotite/application/viennarna/rnaplot.py +187 -0
  29. biotite/application/viennarna/util.py +72 -0
  30. biotite/application/webapp.py +77 -0
  31. biotite/copyable.py +71 -0
  32. biotite/database/__init__.py +23 -0
  33. biotite/database/entrez/__init__.py +15 -0
  34. biotite/database/entrez/check.py +61 -0
  35. biotite/database/entrez/dbnames.py +89 -0
  36. biotite/database/entrez/download.py +223 -0
  37. biotite/database/entrez/key.py +44 -0
  38. biotite/database/entrez/query.py +223 -0
  39. biotite/database/error.py +15 -0
  40. biotite/database/pubchem/__init__.py +21 -0
  41. biotite/database/pubchem/download.py +260 -0
  42. biotite/database/pubchem/error.py +20 -0
  43. biotite/database/pubchem/query.py +827 -0
  44. biotite/database/pubchem/throttle.py +99 -0
  45. biotite/database/rcsb/__init__.py +13 -0
  46. biotite/database/rcsb/download.py +167 -0
  47. biotite/database/rcsb/query.py +959 -0
  48. biotite/database/uniprot/__init__.py +13 -0
  49. biotite/database/uniprot/check.py +32 -0
  50. biotite/database/uniprot/download.py +134 -0
  51. biotite/database/uniprot/query.py +209 -0
  52. biotite/file.py +251 -0
  53. biotite/sequence/__init__.py +73 -0
  54. biotite/sequence/align/__init__.py +49 -0
  55. biotite/sequence/align/alignment.py +658 -0
  56. biotite/sequence/align/banded.cpython-312-darwin.so +0 -0
  57. biotite/sequence/align/banded.pyx +652 -0
  58. biotite/sequence/align/buckets.py +69 -0
  59. biotite/sequence/align/cigar.py +434 -0
  60. biotite/sequence/align/kmeralphabet.cpython-312-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-312-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-312-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-312-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-312-darwin.so +0 -0
  69. biotite/sequence/align/localungapped.pyx +279 -0
  70. biotite/sequence/align/matrix.py +405 -0
  71. biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
  72. biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
  73. biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
  74. biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
  75. biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
  76. biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
  77. biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
  78. biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
  79. biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
  80. biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
  81. biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
  82. biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
  83. biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
  84. biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
  85. biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
  86. biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
  87. biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
  88. biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
  89. biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
  90. biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
  91. biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
  92. biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
  93. biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
  94. biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
  95. biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
  96. biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
  97. biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
  98. biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
  99. biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
  100. biotite/sequence/align/matrix_data/GONNET.mat +26 -0
  101. biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
  102. biotite/sequence/align/matrix_data/MATCH.mat +25 -0
  103. biotite/sequence/align/matrix_data/NUC.mat +25 -0
  104. biotite/sequence/align/matrix_data/PAM10.mat +34 -0
  105. biotite/sequence/align/matrix_data/PAM100.mat +34 -0
  106. biotite/sequence/align/matrix_data/PAM110.mat +34 -0
  107. biotite/sequence/align/matrix_data/PAM120.mat +34 -0
  108. biotite/sequence/align/matrix_data/PAM130.mat +34 -0
  109. biotite/sequence/align/matrix_data/PAM140.mat +34 -0
  110. biotite/sequence/align/matrix_data/PAM150.mat +34 -0
  111. biotite/sequence/align/matrix_data/PAM160.mat +34 -0
  112. biotite/sequence/align/matrix_data/PAM170.mat +34 -0
  113. biotite/sequence/align/matrix_data/PAM180.mat +34 -0
  114. biotite/sequence/align/matrix_data/PAM190.mat +34 -0
  115. biotite/sequence/align/matrix_data/PAM20.mat +34 -0
  116. biotite/sequence/align/matrix_data/PAM200.mat +34 -0
  117. biotite/sequence/align/matrix_data/PAM210.mat +34 -0
  118. biotite/sequence/align/matrix_data/PAM220.mat +34 -0
  119. biotite/sequence/align/matrix_data/PAM230.mat +34 -0
  120. biotite/sequence/align/matrix_data/PAM240.mat +34 -0
  121. biotite/sequence/align/matrix_data/PAM250.mat +34 -0
  122. biotite/sequence/align/matrix_data/PAM260.mat +34 -0
  123. biotite/sequence/align/matrix_data/PAM270.mat +34 -0
  124. biotite/sequence/align/matrix_data/PAM280.mat +34 -0
  125. biotite/sequence/align/matrix_data/PAM290.mat +34 -0
  126. biotite/sequence/align/matrix_data/PAM30.mat +34 -0
  127. biotite/sequence/align/matrix_data/PAM300.mat +34 -0
  128. biotite/sequence/align/matrix_data/PAM310.mat +34 -0
  129. biotite/sequence/align/matrix_data/PAM320.mat +34 -0
  130. biotite/sequence/align/matrix_data/PAM330.mat +34 -0
  131. biotite/sequence/align/matrix_data/PAM340.mat +34 -0
  132. biotite/sequence/align/matrix_data/PAM350.mat +34 -0
  133. biotite/sequence/align/matrix_data/PAM360.mat +34 -0
  134. biotite/sequence/align/matrix_data/PAM370.mat +34 -0
  135. biotite/sequence/align/matrix_data/PAM380.mat +34 -0
  136. biotite/sequence/align/matrix_data/PAM390.mat +34 -0
  137. biotite/sequence/align/matrix_data/PAM40.mat +34 -0
  138. biotite/sequence/align/matrix_data/PAM400.mat +34 -0
  139. biotite/sequence/align/matrix_data/PAM410.mat +34 -0
  140. biotite/sequence/align/matrix_data/PAM420.mat +34 -0
  141. biotite/sequence/align/matrix_data/PAM430.mat +34 -0
  142. biotite/sequence/align/matrix_data/PAM440.mat +34 -0
  143. biotite/sequence/align/matrix_data/PAM450.mat +34 -0
  144. biotite/sequence/align/matrix_data/PAM460.mat +34 -0
  145. biotite/sequence/align/matrix_data/PAM470.mat +34 -0
  146. biotite/sequence/align/matrix_data/PAM480.mat +34 -0
  147. biotite/sequence/align/matrix_data/PAM490.mat +34 -0
  148. biotite/sequence/align/matrix_data/PAM50.mat +34 -0
  149. biotite/sequence/align/matrix_data/PAM500.mat +34 -0
  150. biotite/sequence/align/matrix_data/PAM60.mat +34 -0
  151. biotite/sequence/align/matrix_data/PAM70.mat +34 -0
  152. biotite/sequence/align/matrix_data/PAM80.mat +34 -0
  153. biotite/sequence/align/matrix_data/PAM90.mat +34 -0
  154. biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
  155. biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
  156. biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
  157. biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
  158. biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
  159. biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
  160. biotite/sequence/align/multiple.cpython-312-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-312-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-312-darwin.so +0 -0
  165. biotite/sequence/align/permutation.pyx +305 -0
  166. biotite/sequence/align/primes.txt +821 -0
  167. biotite/sequence/align/selector.cpython-312-darwin.so +0 -0
  168. biotite/sequence/align/selector.pyx +956 -0
  169. biotite/sequence/align/statistics.py +265 -0
  170. biotite/sequence/align/tracetable.cpython-312-darwin.so +0 -0
  171. biotite/sequence/align/tracetable.pxd +64 -0
  172. biotite/sequence/align/tracetable.pyx +370 -0
  173. biotite/sequence/alphabet.py +566 -0
  174. biotite/sequence/annotation.py +829 -0
  175. biotite/sequence/codec.cpython-312-darwin.so +0 -0
  176. biotite/sequence/codec.pyx +155 -0
  177. biotite/sequence/codon.py +466 -0
  178. biotite/sequence/codon_tables.txt +202 -0
  179. biotite/sequence/graphics/__init__.py +33 -0
  180. biotite/sequence/graphics/alignment.py +1034 -0
  181. biotite/sequence/graphics/color_schemes/autumn.json +51 -0
  182. biotite/sequence/graphics/color_schemes/blossom.json +51 -0
  183. biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
  184. biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
  185. biotite/sequence/graphics/color_schemes/flower.json +51 -0
  186. biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
  187. biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
  188. biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
  189. biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
  190. biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
  191. biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
  192. biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
  193. biotite/sequence/graphics/color_schemes/ocean.json +51 -0
  194. biotite/sequence/graphics/color_schemes/pb_flower.json +39 -0
  195. biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
  196. biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
  197. biotite/sequence/graphics/color_schemes/spring.json +51 -0
  198. biotite/sequence/graphics/color_schemes/sunset.json +51 -0
  199. biotite/sequence/graphics/color_schemes/wither.json +51 -0
  200. biotite/sequence/graphics/colorschemes.py +139 -0
  201. biotite/sequence/graphics/dendrogram.py +184 -0
  202. biotite/sequence/graphics/features.py +510 -0
  203. biotite/sequence/graphics/logo.py +110 -0
  204. biotite/sequence/graphics/plasmid.py +661 -0
  205. biotite/sequence/io/__init__.py +12 -0
  206. biotite/sequence/io/fasta/__init__.py +22 -0
  207. biotite/sequence/io/fasta/convert.py +273 -0
  208. biotite/sequence/io/fasta/file.py +278 -0
  209. biotite/sequence/io/fastq/__init__.py +19 -0
  210. biotite/sequence/io/fastq/convert.py +120 -0
  211. biotite/sequence/io/fastq/file.py +551 -0
  212. biotite/sequence/io/genbank/__init__.py +17 -0
  213. biotite/sequence/io/genbank/annotation.py +277 -0
  214. biotite/sequence/io/genbank/file.py +575 -0
  215. biotite/sequence/io/genbank/metadata.py +324 -0
  216. biotite/sequence/io/genbank/sequence.py +172 -0
  217. biotite/sequence/io/general.py +192 -0
  218. biotite/sequence/io/gff/__init__.py +26 -0
  219. biotite/sequence/io/gff/convert.py +133 -0
  220. biotite/sequence/io/gff/file.py +434 -0
  221. biotite/sequence/phylo/__init__.py +36 -0
  222. biotite/sequence/phylo/nj.cpython-312-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-312-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-312-darwin.so +0 -0
  227. biotite/sequence/phylo/upgma.pyx +164 -0
  228. biotite/sequence/profile.py +456 -0
  229. biotite/sequence/search.py +116 -0
  230. biotite/sequence/seqtypes.py +556 -0
  231. biotite/sequence/sequence.py +374 -0
  232. biotite/structure/__init__.py +132 -0
  233. biotite/structure/atoms.py +1455 -0
  234. biotite/structure/basepairs.py +1415 -0
  235. biotite/structure/bonds.cpython-312-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-312-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-312-darwin.so +0 -0
  242. biotite/structure/charges.pyx +520 -0
  243. biotite/structure/compare.py +274 -0
  244. biotite/structure/density.py +114 -0
  245. biotite/structure/dotbracket.py +216 -0
  246. biotite/structure/error.py +31 -0
  247. biotite/structure/filter.py +585 -0
  248. biotite/structure/geometry.py +697 -0
  249. biotite/structure/graphics/__init__.py +13 -0
  250. biotite/structure/graphics/atoms.py +226 -0
  251. biotite/structure/graphics/rna.py +282 -0
  252. biotite/structure/hbond.py +409 -0
  253. biotite/structure/info/__init__.py +25 -0
  254. biotite/structure/info/atom_masses.json +121 -0
  255. biotite/structure/info/atoms.py +82 -0
  256. biotite/structure/info/bonds.py +145 -0
  257. biotite/structure/info/ccd/README.rst +8 -0
  258. biotite/structure/info/ccd/amino_acids.txt +1663 -0
  259. biotite/structure/info/ccd/carbohydrates.txt +1135 -0
  260. biotite/structure/info/ccd/components.bcif +0 -0
  261. biotite/structure/info/ccd/nucleotides.txt +798 -0
  262. biotite/structure/info/ccd.py +95 -0
  263. biotite/structure/info/groups.py +90 -0
  264. biotite/structure/info/masses.py +123 -0
  265. biotite/structure/info/misc.py +144 -0
  266. biotite/structure/info/radii.py +197 -0
  267. biotite/structure/info/standardize.py +196 -0
  268. biotite/structure/integrity.py +268 -0
  269. biotite/structure/io/__init__.py +30 -0
  270. biotite/structure/io/ctab.py +72 -0
  271. biotite/structure/io/dcd/__init__.py +13 -0
  272. biotite/structure/io/dcd/file.py +65 -0
  273. biotite/structure/io/general.py +257 -0
  274. biotite/structure/io/gro/__init__.py +14 -0
  275. biotite/structure/io/gro/file.py +343 -0
  276. biotite/structure/io/mmtf/__init__.py +21 -0
  277. biotite/structure/io/mmtf/assembly.py +214 -0
  278. biotite/structure/io/mmtf/convertarray.cpython-312-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-312-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-312-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-312-darwin.so +0 -0
  285. biotite/structure/io/mmtf/encode.pyx +183 -0
  286. biotite/structure/io/mmtf/file.py +233 -0
  287. biotite/structure/io/mol/__init__.py +20 -0
  288. biotite/structure/io/mol/convert.py +115 -0
  289. biotite/structure/io/mol/ctab.py +414 -0
  290. biotite/structure/io/mol/header.py +116 -0
  291. biotite/structure/io/mol/mol.py +193 -0
  292. biotite/structure/io/mol/sdf.py +916 -0
  293. biotite/structure/io/netcdf/__init__.py +13 -0
  294. biotite/structure/io/netcdf/file.py +63 -0
  295. biotite/structure/io/npz/__init__.py +20 -0
  296. biotite/structure/io/npz/file.py +152 -0
  297. biotite/structure/io/pdb/__init__.py +20 -0
  298. biotite/structure/io/pdb/convert.py +293 -0
  299. biotite/structure/io/pdb/file.py +1240 -0
  300. biotite/structure/io/pdb/hybrid36.cpython-312-darwin.so +0 -0
  301. biotite/structure/io/pdb/hybrid36.pyx +242 -0
  302. biotite/structure/io/pdbqt/__init__.py +15 -0
  303. biotite/structure/io/pdbqt/convert.py +107 -0
  304. biotite/structure/io/pdbqt/file.py +640 -0
  305. biotite/structure/io/pdbx/__init__.py +23 -0
  306. biotite/structure/io/pdbx/bcif.py +648 -0
  307. biotite/structure/io/pdbx/cif.py +1032 -0
  308. biotite/structure/io/pdbx/component.py +246 -0
  309. biotite/structure/io/pdbx/convert.py +1597 -0
  310. biotite/structure/io/pdbx/encoding.cpython-312-darwin.so +0 -0
  311. biotite/structure/io/pdbx/encoding.pyx +950 -0
  312. biotite/structure/io/pdbx/legacy.py +267 -0
  313. biotite/structure/io/tng/__init__.py +13 -0
  314. biotite/structure/io/tng/file.py +46 -0
  315. biotite/structure/io/trajfile.py +710 -0
  316. biotite/structure/io/trr/__init__.py +13 -0
  317. biotite/structure/io/trr/file.py +46 -0
  318. biotite/structure/io/xtc/__init__.py +13 -0
  319. biotite/structure/io/xtc/file.py +46 -0
  320. biotite/structure/mechanics.py +75 -0
  321. biotite/structure/molecules.py +353 -0
  322. biotite/structure/pseudoknots.py +642 -0
  323. biotite/structure/rdf.py +243 -0
  324. biotite/structure/repair.py +253 -0
  325. biotite/structure/residues.py +562 -0
  326. biotite/structure/resutil.py +178 -0
  327. biotite/structure/sasa.cpython-312-darwin.so +0 -0
  328. biotite/structure/sasa.pyx +322 -0
  329. biotite/structure/sequence.py +112 -0
  330. biotite/structure/sse.py +327 -0
  331. biotite/structure/superimpose.py +727 -0
  332. biotite/structure/transform.py +504 -0
  333. biotite/structure/util.py +98 -0
  334. biotite/temp.py +86 -0
  335. biotite/version.py +16 -0
  336. biotite/visualize.py +251 -0
  337. biotite-0.41.1.dist-info/METADATA +187 -0
  338. biotite-0.41.1.dist-info/RECORD +340 -0
  339. biotite-0.41.1.dist-info/WHEEL +4 -0
  340. biotite-0.41.1.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,214 @@
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.mmtf"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["list_assemblies", "get_assembly"]
8
+
9
+
10
+ import numpy as np
11
+ from .convertfile import get_structure
12
+ from ...chains import get_chain_starts
13
+ from ...util import matrix_rotate
14
+ from ....file import InvalidFileError
15
+
16
+
17
+ def list_assemblies(file):
18
+ """
19
+ List the biological assemblies that are available for the
20
+ structure in the given file.
21
+
22
+ This function receives the data from the ``"bioAssemblyList"`` field
23
+ in the file.
24
+ Consequently, this field must be present in the file.
25
+
26
+ Parameters
27
+ ----------
28
+ file : MMTFFile
29
+ The file object.
30
+
31
+ Returns
32
+ -------
33
+ assemblies : list of str
34
+ A list that contains the available assembly IDs.
35
+
36
+ Examples
37
+ --------
38
+ >>> import os.path
39
+ >>> file = MMTFFile.read(os.path.join(path_to_structures, "1f2n.mmtf"))
40
+ >>> print(list_assemblies(file))
41
+ ['1', '2', '3', '4', '5', '6']
42
+ """
43
+ return [assembly["name"] for assembly in file["bioAssemblyList"]]
44
+
45
+
46
+ def get_assembly(file, assembly_id=None, model=None, altloc="first",
47
+ extra_fields=[], include_bonds=False):
48
+ """
49
+ Build the given biological assembly.
50
+
51
+ This function receives the data from ``bioAssemblyList`` field in
52
+ the file.
53
+ Consequently, this field must be present in the file.
54
+
55
+ Parameters
56
+ ----------
57
+ file : MMTFFile
58
+ The file object.
59
+ assembly_id : str
60
+ The assembly to build.
61
+ Available assembly IDs can be obtained via
62
+ :func:`list_assemblies()`.
63
+ model : int, optional
64
+ If this parameter is given, the function will return an
65
+ :class:`AtomArray` from the atoms corresponding to the given
66
+ model number (starting at 1).
67
+ Negative values are used to index models starting from the
68
+ last model instead of the first model.
69
+ If this parameter is omitted, an :class:`AtomArrayStack`
70
+ containing all models will be returned, even if the
71
+ structure contains only one model.
72
+ altloc : {'first', 'occupancy', 'all'}
73
+ This parameter defines how *altloc* IDs are handled:
74
+ - ``'first'`` - Use atoms that have the first
75
+ *altloc* ID appearing in a residue.
76
+ - ``'occupancy'`` - Use atoms that have the *altloc* ID
77
+ with the highest occupancy for a residue.
78
+ - ``'all'`` - Use all atoms.
79
+ Note that this leads to duplicate atoms.
80
+ When this option is chosen, the ``altloc_id``
81
+ annotation array is added to the returned structure.
82
+ extra_fields : list of str, optional
83
+ The strings in the list are optional annotation categories
84
+ that should be stored in the output array or stack.
85
+ These are valid values:
86
+ ``'atom_id'``, ``'b_factor'``, ``'occupancy'`` and
87
+ ``'charge'``.
88
+ include_bonds : bool, optional
89
+ If set to true, a :class:`BondList` will be created for the
90
+ resulting :class:`AtomArray` containing the bond information
91
+ from the file.
92
+ All bonds have :attr:`BondType.ANY`, since the PDB format
93
+ does not support bond orders.
94
+
95
+ Raises
96
+ ------
97
+ NotImplementedError
98
+ If any transformation required by the assembly only affects a
99
+ part of the atoms (not every chain) and the number of chains
100
+ as detected by :func:`get_chain_count()` is different from
101
+ the ``chainNameList`` field.
102
+ This limitation of this function exists, as the
103
+ :class:`AtomArray` of the asymmetric unit used for constructing
104
+ the assembly has not the chain index information required by the
105
+ ``bioAssemblyList`` field.
106
+ In short, :func:`get_assembly()` does not work for a significant
107
+ portion of the PDB.
108
+ If you require reliable assembly building for any PDB entry,
109
+ you should use the analogous function for PDB or mmCIF files
110
+ instead.
111
+
112
+ Returns
113
+ -------
114
+ assembly : AtomArray or AtomArrayStack
115
+ The assembly.
116
+ The return type depends on the `model` parameter.
117
+
118
+ Examples
119
+ --------
120
+
121
+ >>> import os.path
122
+ >>> file = MMTFFile.read(os.path.join(path_to_structures, "1f2n.mmtf"))
123
+ >>> assembly = get_assembly(file, model=1)
124
+ """
125
+ structure = get_structure(
126
+ file, model, altloc, extra_fields, include_bonds
127
+ )
128
+
129
+ # Get transformations for chosen assembly
130
+ selected_assembly = None
131
+ if not "bioAssemblyList" in file:
132
+ raise InvalidFileError(
133
+ "File does not contain assembly information "
134
+ "(missing 'bioAssemblyList')"
135
+ )
136
+ for assembly in file["bioAssemblyList"]:
137
+ current_assembly_id = assembly["name"]
138
+ transform_list = assembly["transformList"]
139
+ if assembly_id is None or current_assembly_id == assembly_id:
140
+ selected_assembly = transform_list
141
+ break
142
+ if selected_assembly is None:
143
+ raise KeyError(
144
+ f"The assembly ID '{assembly_id}' is not found"
145
+ )
146
+
147
+ # In most cases the transformations in an assembly applies to all
148
+ # atoms equally ('apply_to_all == True')
149
+ # If this is the case, the selection of atoms for each
150
+ # transformation can be omitted, improving the performance
151
+ chain_index_count = len(file["chainNameList"])
152
+ apply_to_all = True
153
+ for transformation in selected_assembly:
154
+ # If the number of affected chains matches the number of total
155
+ # chains, all atoms are affected
156
+ if len(transformation["chainIndexList"]) != chain_index_count:
157
+ apply_to_all = False
158
+ # If the transformations in the assembly do not apply to all atoms,
159
+ # but only to certain chains we need the ranges of these chains
160
+ # in the base structure (the asymmetric unit)
161
+ if not apply_to_all:
162
+ chains_starts = get_chain_starts(
163
+ structure, add_exclusive_stop=True
164
+ )
165
+ # Furthermore the number of chains determined by Biotite via
166
+ # 'get_chain_starts()' must corresponds to the number of chains
167
+ # in the MMTF file
168
+ # If this is not the case the assembly cannot be read using
169
+ # this function due to the shortcoming in 'get_structure()'
170
+ if len(chains_starts) != chain_index_count:
171
+ raise NotImplementedError(
172
+ "The structure file is not suitable for this function, as the "
173
+ "number of chains in the file do not match the automatically "
174
+ "detected number of chains"
175
+ )
176
+
177
+ # Apply transformations for set of chains (or all chains) and add
178
+ # the transformed atoms to assembly
179
+ assembly = None
180
+ for transformation in selected_assembly:
181
+ if apply_to_all:
182
+ affected_coord = structure.coord
183
+ else:
184
+ # Mask atoms affected by this transformation
185
+ affected_mask = np.zeros(structure.array_length(), dtype=bool)
186
+ for chain_i in transformation["chainIndexList"]:
187
+ chain_start = chains_starts[chain_i]
188
+ chain_stop = chains_starts[chain_i+1]
189
+ affected_mask[chain_start : chain_stop] = True
190
+ affected_coord = structure.coord[..., affected_mask, :]
191
+ # Apply the transformation
192
+ transformed_coord = _apply_transformation(
193
+ affected_coord, transformation["matrix"]
194
+ )
195
+ sub_assembly = structure.copy()
196
+ sub_assembly.coord = transformed_coord
197
+ # Add transformed coordinates to assembly
198
+ if assembly is None:
199
+ assembly = sub_assembly
200
+ else:
201
+ assembly += sub_assembly
202
+
203
+ return assembly
204
+
205
+
206
+ def _apply_transformation(coord, mmtf_matrix):
207
+ # Obtain matrix from flattened form
208
+ matrix = np.array(mmtf_matrix).reshape(4, 4)
209
+ # Separate rotation and translation part
210
+ rotation = matrix[:3, :3]
211
+ translation = matrix[:3, 3]
212
+ coord = matrix_rotate(coord, rotation)
213
+ coord += translation
214
+ return coord
@@ -0,0 +1,341 @@
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.mmtf"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["set_structure"]
8
+
9
+ cimport cython
10
+ cimport numpy as np
11
+
12
+ import numpy as np
13
+ from .file import MMTFFile
14
+ from ...atoms import Atom, AtomArray, AtomArrayStack
15
+ from ...bonds import BondList
16
+ from ...error import BadStructureError
17
+ from ...residues import get_residue_starts
18
+ from ...box import unitcell_from_vectors
19
+ from ...info.misc import link_type
20
+
21
+ ctypedef np.int8_t int8
22
+ ctypedef np.int16_t int16
23
+ ctypedef np.int32_t int32
24
+ ctypedef np.uint8_t uint8
25
+ ctypedef np.uint16_t uint16
26
+ ctypedef np.uint32_t uint32
27
+ ctypedef np.uint64_t uint64
28
+ ctypedef np.float32_t float32
29
+
30
+
31
+ def set_structure(file, array):
32
+ """
33
+ set_structure(file, array)
34
+
35
+ Set the relevant fields of an MMTF file with the content of an
36
+ :class:`AtomArray` or :class:`AtomArrayStack`.
37
+
38
+ All required and some optional fields of the MMTF file will be set
39
+ or overriden if the field does already exist. Fields are removed
40
+ when they are optional and when setting the structure information
41
+ could invalidate its content (e.g. altLocList).
42
+
43
+ Parameters
44
+ ----------
45
+ file : MMTFFile
46
+ The file object.
47
+ array : AtomArray or AtomArrayStack
48
+ The structure to be written. If a stack is given, each array in
49
+ the stack will be in a separate model.
50
+
51
+ Notes
52
+ -----
53
+ As the MMTF format only supports one unit cell, individual unit
54
+ cells for each model are not supported.
55
+ Instead only the first box in an :class:`AtomArrayStack` is written
56
+ into the file.
57
+
58
+ Examples
59
+ --------
60
+
61
+ >>> import os.path
62
+ >>> file = MMTFFile()
63
+ >>> set_structure(file, atom_array)
64
+ >>> file.write(os.path.join(path_to_directory, "structure.mmtf"))
65
+
66
+ """
67
+ cdef bint include_bonds = (array.bonds is not None)
68
+
69
+ cdef int i=0, j=0
70
+ cdef array_length = array.array_length()
71
+
72
+
73
+ # Get annotation arrays from atom array (stack)
74
+ cdef np.ndarray arr_chain_id = array.chain_id
75
+ cdef np.ndarray arr_res_id = array.res_id
76
+ cdef np.ndarray arr_ins_code = array.ins_code
77
+ cdef np.ndarray arr_res_name = array.res_name
78
+ cdef np.ndarray arr_hetero = array.hetero
79
+ cdef np.ndarray arr_atom_name = array.atom_name
80
+ cdef np.ndarray arr_element = array.element
81
+ cdef np.ndarray arr_charge = None
82
+ if "charge" in array.get_annotation_categories():
83
+ arr_charge = array.charge
84
+
85
+
86
+ # Residue start indices
87
+ # Since the stop of i is the start of i+1,
88
+ # The exclusive end of the atom array is appended
89
+ # to enable convenient usage in the following loops
90
+ cdef np.ndarray starts = np.append(get_residue_starts(array),
91
+ [array_length])
92
+
93
+
94
+ ### Preparing the group list ###
95
+ # List of 'groupType' dictsfor setting the file's 'groupList'
96
+ cdef list residues
97
+ # Maps 'groupType' values (not the keys) to the index in 'residues'
98
+ # Necessary a 'groupType' are dictionaries, which are not hashable
99
+ cdef dict residue_dict
100
+ # An entry in 'residues'
101
+ cdef dict group_type
102
+ # An entry in 'residue_dict'
103
+ cdef tuple hashable_group_type
104
+ # Index to list of residues
105
+ cdef int residue_i
106
+ # List of indices to list of residues
107
+ cdef np.ndarray res_types
108
+ # Start and exclusive stop of on residue interval
109
+ cdef int start
110
+ cdef int stop
111
+ # Amount of atoms in a residue
112
+ cdef int res_length
113
+ # Name of a residue
114
+ cdef res_name
115
+ # BondList for inter-residue bonds
116
+ # intra-residue bonds are successively removed
117
+ if include_bonds:
118
+ inter_bonds = array.bonds.copy()
119
+ # 'len(starts)-1' since 'starts' has the end
120
+ # of the atom array appended
121
+ res_types = np.zeros(len(starts)-1, dtype=np.int32)
122
+ residues = []
123
+ residue_dict = {}
124
+ for i in range(len(starts)-1):
125
+ start = starts[i]
126
+ stop = starts[i+1]
127
+ res_length = stop - start
128
+ res_name = arr_res_name[start]
129
+ # Get intra-residue bonds of this residue
130
+ if include_bonds:
131
+ intra_bonds = array.bonds[start:stop]
132
+
133
+ # Create 'groupType' dictionary for current residue
134
+ group_type = {}
135
+ group_type["atomNameList"] = tuple(
136
+ arr_atom_name[start:stop].tolist()
137
+ )
138
+ group_type["elementList"] = tuple(
139
+ [e.capitalize() for e in arr_element[start:stop]]
140
+ )
141
+ if arr_charge is not None:
142
+ group_type["formalChargeList"] = tuple(
143
+ arr_charge[start:stop].tolist()
144
+ )
145
+ else:
146
+ group_type["formalChargeList"] = (0,) * (stop-start)
147
+ group_type["groupName"] = res_name
148
+ link = link_type(res_name)
149
+ # Use 'NON-POLYMER' as default
150
+ if link is None:
151
+ link = "NON-POLYMER"
152
+ group_type["chemCompType"] = link
153
+ # Add intra-residue bonds
154
+ if include_bonds:
155
+ intra_bonds = array.bonds[start:stop]
156
+ bond_array = intra_bonds.as_array()
157
+ group_type["bondAtomList"] = tuple(
158
+ bond_array[:,:2].flatten().tolist()
159
+ )
160
+ group_type["bondOrderList"] = tuple(
161
+ bond_array[:,2].tolist()
162
+ )
163
+ else:
164
+ group_type["bondAtomList"] = ()
165
+ group_type["bondOrderList"] = ()
166
+
167
+ # Find index of current residue in later 'groupList'
168
+ hashable_group_type = tuple(group_type.values())
169
+ residue_i = residue_dict.get(hashable_group_type, -1)
170
+ if residue_i == -1:
171
+ # Add new residue if not yet existing in 'groupList'
172
+ residue_i = len(residues)
173
+ residues.append(group_type)
174
+ residue_dict[hashable_group_type] = residue_i
175
+
176
+ # Remove intra-residue bonds from all bonds
177
+ # to obtain inter-residue bonds
178
+ # If the residue is already known is irrelevant for this case
179
+ if include_bonds:
180
+ # Offset is required to obtain original indices
181
+ # for bond removal
182
+ intra_bonds.offset_indices(start)
183
+ inter_bonds.remove_bonds(intra_bonds)
184
+ # Put new or already known residue to sequence of residue types
185
+ res_types[i] = residue_i
186
+
187
+
188
+ ### Convert annotation arrays into MMTF arrays ###
189
+ # Pessimistic assumption on length of arrays
190
+ # -> At maximum as large as atom array
191
+ cdef np.ndarray chain_names = np.zeros(array_length, dtype="U4")
192
+ cdef np.ndarray res_per_chain = np.zeros(array_length, dtype=np.int32)
193
+ # Variables for storing last and current chain ID
194
+ cdef last_chain_id = arr_chain_id[0]
195
+ cdef curr_chain_id
196
+ # Counter for chain length
197
+ cdef int res_counter = 0
198
+ i = 0
199
+ j = 0
200
+ for i in range(len(starts)-1):
201
+ start = starts[i]
202
+ curr_chain_id = arr_chain_id[start]
203
+ if curr_chain_id != last_chain_id:
204
+ # New chain
205
+ chain_names[j] = last_chain_id
206
+ res_per_chain[j] = res_counter
207
+ last_chain_id = curr_chain_id
208
+ # Reset residue-per-chain counter
209
+ res_counter = 1
210
+ j += 1
211
+ else:
212
+ res_counter += 1
213
+ # Add last element
214
+ chain_names[j] = last_chain_id
215
+ res_per_chain[j] = res_counter
216
+ j += 1
217
+ # Trim to correct size
218
+ chain_names = chain_names[:j]
219
+ res_per_chain = res_per_chain[:j]
220
+ # Residue IDs from residue starts
221
+ cdef np.ndarray res_ids = arr_res_id[starts[:-1]].astype(np.int32)
222
+ cdef np.ndarray res_inscodes
223
+ res_inscodes = arr_ins_code[starts[:-1]]
224
+
225
+ ### Adapt arrays for multiple models
226
+ cdef int model_count = 1
227
+ cdef int chains_per_model = len(chain_names)
228
+ if isinstance(array, AtomArrayStack):
229
+ # Multi-model
230
+ model_count = array.stack_depth()
231
+ chain_names = np.tile(chain_names, model_count)
232
+ res_per_chain = np.tile(res_per_chain, model_count)
233
+ res_ids = np.tile(res_ids, model_count)
234
+ res_inscodes = np.tile(res_inscodes, model_count)
235
+ res_types = np.tile(res_types, model_count)
236
+
237
+
238
+ ### Remove arrays from file ###
239
+ # Arrays are removed if they are optional
240
+ # and if setting the structure information invalidates its content
241
+ _delete_record(file, "bondAtomList")
242
+ _delete_record(file, "bondOrderList")
243
+ _delete_record(file, "bFactorList")
244
+ _delete_record(file, "atomIdList")
245
+ _delete_record(file, "altLocList")
246
+ _delete_record(file, "occupancyList")
247
+ _delete_record(file, "secStructList")
248
+ _delete_record(file, "insCodeList")
249
+
250
+
251
+ ### Put prepared arrays into file ###
252
+ cdef np.ndarray coord
253
+ if isinstance(array, AtomArrayStack):
254
+ coord = array.coord.reshape(
255
+ (array.stack_depth() * array.array_length(), 3)
256
+ ).astype(np.float32, copy=False)
257
+ else:
258
+ coord = array.coord.astype(np.float32, copy=False)
259
+ file.set_array("xCoordList", coord[:,0], codec=10, param=1000)
260
+ file.set_array("yCoordList", coord[:,1], codec=10, param=1000)
261
+ file.set_array("zCoordList", coord[:,2], codec=10, param=1000)
262
+
263
+ file["numModels"] = model_count
264
+ file["chainsPerModel"] = [chains_per_model] * model_count
265
+ file["numChains"] = len(chain_names)
266
+ file.set_array("chainNameList", chain_names, codec=5, param=4)
267
+ file.set_array("chainIdList", chain_names, codec=5, param=4)
268
+ file["groupsPerChain"] = res_per_chain.tolist()
269
+ file["numGroups"] = len(res_ids)
270
+ file.set_array("groupIdList", res_ids, codec=8)
271
+ file.set_array("insCodeList", res_inscodes, codec=6)
272
+ file.set_array("groupTypeList", res_types, codec=4)
273
+ file["groupList"] = residues
274
+ file["numAtoms"] = model_count * array_length
275
+
276
+ # Optional annotation arrays
277
+ categories = array.get_annotation_categories()
278
+ if "atom_id" in categories:
279
+ file.set_array("atomIdList",
280
+ np.tile(array.atom_id.astype(np.int32), model_count),
281
+ codec=8)
282
+ if "b_factor" in categories:
283
+ file.set_array("bFactorList",
284
+ np.tile(array.b_factor.astype(np.float32), model_count),
285
+ codec=10, param=100)
286
+ if "occupancy" in categories:
287
+ file.set_array("occupancyList",
288
+ np.tile(array.occupancy.astype(np.float32), model_count),
289
+ codec=9, param=100)
290
+
291
+
292
+ ### Add inter-residue bonds ###
293
+ if include_bonds:
294
+ all_inter_bonds = inter_bonds
295
+ # Repeat the inter-residue bonds for each additional model
296
+ for i in range(model_count-1):
297
+ all_inter_bonds += inter_bonds
298
+ bond_array = all_inter_bonds.as_array()
299
+ file.set_array("bondAtomList",
300
+ bond_array[:,:2].flatten().astype(np.int32),
301
+ codec=4)
302
+ file.set_array("bondOrderList",
303
+ bond_array[:,2].astype(np.int8),
304
+ codec=2)
305
+ file["numBonds"] = array.bonds.get_bond_count() * model_count
306
+ else:
307
+ file["numBonds"] = 0
308
+
309
+
310
+ ### Add unit cell ###
311
+ if array.box is not None:
312
+ if isinstance(array, AtomArray):
313
+ box = array.box
314
+ elif isinstance(array, AtomArrayStack):
315
+ # Use box of first model, since MMTF does not support
316
+ # multiple boxes
317
+ box = array.box[0]
318
+ len_a, len_b, len_c, alpha, beta, gamma = unitcell_from_vectors(box)
319
+ file["unitCell"] = [
320
+ len_a, len_b, len_c,
321
+ np.rad2deg(alpha), np.rad2deg(beta), np.rad2deg(gamma)
322
+ ]
323
+
324
+
325
+ ### Add additional information ###
326
+ # Only set additional information, if not already set
327
+ try:
328
+ val = file["mmtfVersion"]
329
+ except KeyError:
330
+ file["mmtfVersion"] = "1.0.0"
331
+ try:
332
+ val = file["mmtfProducer"]
333
+ except KeyError:
334
+ file["mmtfProducer"] = "UNKNOWN"
335
+
336
+
337
+ def _delete_record(file, record):
338
+ try:
339
+ del file[record]
340
+ except:
341
+ pass