biotite 0.41.1__cp310-cp310-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-310-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-310-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-310-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-310-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-310-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-310-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-310-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-310-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-310-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-310-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-310-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-310-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-310-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-310-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-310-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-310-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-310-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-310-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-310-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-310-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-310-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-310-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-310-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-310-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-310-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,257 @@
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 a convenience function for loading structures from
7
+ general structure files.
8
+ """
9
+
10
+ __name__ = "biotite.structure.io"
11
+ __author__ = "Patrick Kunzmann"
12
+ __all__ = ["load_structure", "save_structure"]
13
+
14
+ import datetime
15
+ import os.path
16
+ import io
17
+ from ..atoms import AtomArrayStack
18
+
19
+
20
+ def load_structure(file_path, template=None, **kwargs):
21
+ """
22
+ Load an :class:`AtomArray` or class`AtomArrayStack` from a structure
23
+ file without the need to manually instantiate a :class:`File`
24
+ object.
25
+
26
+ Internally this function uses a :class:`File` object, based on the
27
+ file extension.
28
+ Trajectory files furthermore require specification of the `template`
29
+ parameter.
30
+
31
+ Parameters
32
+ ----------
33
+ file_path : str
34
+ The path to structure file.
35
+ template : AtomArray or AtomArrayStack or file-like object or str, optional
36
+ Only required when reading a trajectory file.
37
+ kwargs
38
+ Additional parameters will be passed to either the
39
+ :func:`get_structure()` or :func:`read()` method of the file
40
+ object.
41
+ This does not affect files given via the `template` parameter.
42
+ The only exception is the `atom_i`, which is applied to the template
43
+ as well if number of atoms do not match.
44
+
45
+ Returns
46
+ -------
47
+ array : AtomArray or AtomArrayStack
48
+ If the file contains multiple models, an AtomArrayStack is
49
+ returned, otherwise an AtomArray is returned.
50
+
51
+ Raises
52
+ ------
53
+ ValueError
54
+ If the file format (i.e. the file extension) is unknown.
55
+ TypeError
56
+ If a trajectory file is loaded without specifying the
57
+ `template` parameter.
58
+ """
59
+ # Optionally load template from file
60
+ if isinstance(template, (io.IOBase, str)):
61
+ template = load_structure(template)
62
+
63
+ # We only need the suffix here
64
+ _, suffix = os.path.splitext(file_path)
65
+ match suffix:
66
+ case ".pdb":
67
+ from .pdb import PDBFile
68
+ file = PDBFile.read(file_path)
69
+ array = file.get_structure(**kwargs)
70
+ return _as_single_model_if_possible(array)
71
+ case ".pdbqt":
72
+ from .pdbqt import PDBQTFile
73
+ file = PDBQTFile.read(file_path)
74
+ array = file.get_structure(**kwargs)
75
+ return _as_single_model_if_possible(array)
76
+ case ".cif" | ".pdbx":
77
+ from .pdbx import CIFFile, get_structure
78
+ file = CIFFile.read(file_path)
79
+ array = get_structure(file, **kwargs)
80
+ return _as_single_model_if_possible(array)
81
+ case ".bcif":
82
+ from .pdbx import BinaryCIFFile, get_structure
83
+ file = BinaryCIFFile.read(file_path)
84
+ array = get_structure(file, **kwargs)
85
+ return _as_single_model_if_possible(array)
86
+ case ".gro":
87
+ from .gro import GROFile
88
+ file = GROFile.read(file_path)
89
+ array = file.get_structure(**kwargs)
90
+ return _as_single_model_if_possible(array)
91
+ case ".mmtf":
92
+ from .mmtf import MMTFFile, get_structure
93
+ file = MMTFFile.read(file_path)
94
+ array = get_structure(file, **kwargs)
95
+ return _as_single_model_if_possible(array)
96
+ case ".npz":
97
+ from .npz import NpzFile
98
+ file = NpzFile.read(file_path)
99
+ array = file.get_structure(**kwargs)
100
+ return _as_single_model_if_possible(array)
101
+ case ".mol":
102
+ from .mol import MOLFile
103
+ file = MOLFile.read(file_path)
104
+ array = file.get_structure(**kwargs)
105
+ # MOL and SDF files only contain a single model
106
+ return array
107
+ case ".sdf" | ".sd":
108
+ from .mol import SDFile, get_structure
109
+ file = SDFile.read(file_path)
110
+ array = get_structure(file, **kwargs)
111
+ return array
112
+ case ".trr" | ".xtc" | ".tng" | ".dcd" | ".netcdf":
113
+ if template is None:
114
+ raise TypeError(
115
+ "Template must be specified for trajectory files"
116
+ )
117
+ # Filter template for atom ids, if an unfiltered template
118
+ if (
119
+ "atom_i" in kwargs
120
+ and template.shape[-1] != len(kwargs["atom_i"])
121
+ ):
122
+ template = template[..., kwargs["atom_i"]]
123
+ from .trr import TRRFile
124
+ from .xtc import XTCFile
125
+ from .tng import TNGFile
126
+ from .dcd import DCDFile
127
+ from .netcdf import NetCDFFile
128
+ if suffix == ".trr":
129
+ traj_file_cls = TRRFile
130
+ if suffix == ".xtc":
131
+ traj_file_cls = XTCFile
132
+ if suffix == ".tng":
133
+ traj_file_cls = TNGFile
134
+ if suffix == ".dcd":
135
+ traj_file_cls = DCDFile
136
+ if suffix == ".netcdf":
137
+ traj_file_cls = NetCDFFile
138
+ file = traj_file_cls.read(file_path, **kwargs)
139
+ return file.get_structure(template)
140
+ case unknown_suffix:
141
+ raise ValueError(f"Unknown file format '{unknown_suffix}'")
142
+
143
+
144
+ def save_structure(file_path, array, **kwargs):
145
+ """
146
+ Save an :class:`AtomArray` or class`AtomArrayStack` to a structure
147
+ file without the need to manually instantiate a :class:`File`
148
+ object.
149
+
150
+ Internally this function uses a :class:`File` object, based on the
151
+ file extension.
152
+
153
+ Parameters
154
+ ----------
155
+ file_path : str
156
+ The path to structure file.
157
+ array : AtomArray or AtomArrayStack
158
+ The structure to be saved.
159
+ kwargs
160
+ Additional parameters will be passed to the respective `set_structure`
161
+ method.
162
+
163
+ Raises
164
+ ------
165
+ ValueError
166
+ If the file format (i.e. the file extension) is unknown.
167
+ """
168
+ # We only need the suffix here
169
+ _, suffix = os.path.splitext(file_path)
170
+ match suffix:
171
+ case ".pdb":
172
+ from .pdb import PDBFile
173
+ file = PDBFile()
174
+ file.set_structure(array, **kwargs)
175
+ file.write(file_path)
176
+ case ".pdbqt":
177
+ from .pdbqt import PDBQTFile
178
+ file = PDBQTFile()
179
+ file.set_structure(array, **kwargs)
180
+ file.write(file_path)
181
+ case ".cif" | ".pdbx":
182
+ from .pdbx import CIFFile, set_structure
183
+ file = CIFFile()
184
+ set_structure(file, array, **kwargs)
185
+ file.write(file_path)
186
+ case ".bcif":
187
+ from .pdbx import BinaryCIFFile, set_structure
188
+ file = BinaryCIFFile()
189
+ set_structure(file, array, **kwargs)
190
+ file.write(file_path)
191
+ case ".gro":
192
+ from .gro import GROFile
193
+ file = GROFile()
194
+ file.set_structure(array, **kwargs)
195
+ file.write(file_path)
196
+ case ".mmtf":
197
+ from .mmtf import MMTFFile, set_structure
198
+ file = MMTFFile()
199
+ set_structure(file, array, **kwargs)
200
+ file.write(file_path)
201
+ case ".npz":
202
+ from .npz import NpzFile
203
+ file = NpzFile()
204
+ file.set_structure(array, **kwargs)
205
+ file.write(file_path)
206
+ case ".mol":
207
+ from .mol import MOLFile
208
+ file = MOLFile()
209
+ file.set_structure(array, **kwargs)
210
+ file.header = _mol_header()
211
+ file.write(file_path)
212
+ case ".sdf" | ".sd":
213
+ from .mol import SDFile, SDRecord, set_structure
214
+ record = SDRecord()
215
+ record.set_structure(array, **kwargs)
216
+ record.header = _mol_header()
217
+ file = SDFile({"Molecule": record})
218
+ file.write(file_path)
219
+ case ".trr" | ".xtc" | ".tng" | ".dcd" | ".netcdf":
220
+ from .trr import TRRFile
221
+ from .xtc import XTCFile
222
+ from .tng import TNGFile
223
+ from .dcd import DCDFile
224
+ from .netcdf import NetCDFFile
225
+ if suffix == ".trr":
226
+ traj_file_cls = TRRFile
227
+ if suffix == ".xtc":
228
+ traj_file_cls = XTCFile
229
+ if suffix == ".tng":
230
+ traj_file_cls = TNGFile
231
+ if suffix == ".dcd":
232
+ traj_file_cls = DCDFile
233
+ if suffix == ".netcdf":
234
+ traj_file_cls = NetCDFFile
235
+ file = traj_file_cls()
236
+ file.set_structure(array, **kwargs)
237
+ file.write(file_path)
238
+ case unknown_suffix:
239
+ raise ValueError(f"Unknown file format '{unknown_suffix}'")
240
+
241
+
242
+ def _as_single_model_if_possible(atoms):
243
+ if isinstance(atoms, AtomArrayStack) and atoms.stack_depth() == 1:
244
+ # Stack containing only one model -> return as atom array
245
+ return atoms[0]
246
+ else:
247
+ return atoms
248
+
249
+
250
+ def _mol_header():
251
+ from .mol import Header
252
+ return Header(
253
+ mol_name="Molecule",
254
+ program="Biotite",
255
+ time=datetime.datetime.now(),
256
+ dimensions="3D",
257
+ )
@@ -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
+ """
6
+ This subpackage is used for reading and writing an :class:`AtomArray` or
7
+ :class:`AtomArrayStack` using the Gro format used by the gromacs
8
+ software package.
9
+ """
10
+
11
+ __name__ = "biotite.structure.io.gro"
12
+ __author__ = "Daniel Bauer"
13
+
14
+ from .file import *
@@ -0,0 +1,343 @@
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.gro"
6
+ __author__ = "Daniel Bauer, Patrick Kunzmann"
7
+ __all__ = ["GROFile"]
8
+
9
+ import numpy as np
10
+ from ...atoms import AtomArray, AtomArrayStack
11
+ from ...box import is_orthogonal
12
+ from ....file import TextFile, InvalidFileError
13
+ from ...repair import infer_elements
14
+ from ...error import BadStructureError
15
+ import copy
16
+ from datetime import datetime
17
+
18
+ _atom_records = {"res_id" : (0, 5),
19
+ "res_name" : (5,10),
20
+ "atom_name" : (10,15),
21
+ "atom_id" : (15,20),
22
+ "coord_x" : (20, 28),
23
+ "coord_y" : (28, 36),
24
+ "coord_z" : (36, 44),
25
+ "v_x" : (44, 52),
26
+ "v_y" : (52, 60),
27
+ "v_z" : (60, 68)}
28
+
29
+
30
+ class GROFile(TextFile):
31
+ r"""
32
+ This class represents a GRO file.
33
+
34
+ This class only provides support for reading/writing the pure atom
35
+ information
36
+
37
+ Examples
38
+ --------
39
+ Load a `\\*.gro` file, modify the structure and save the new
40
+ structure into a new file:
41
+
42
+ >>> import os.path
43
+ >>> file = GROFile.read(os.path.join(path_to_structures, "1l2y.gro"))
44
+ >>> array_stack = file.get_structure()
45
+ >>> array_stack_mod = rotate(array_stack, [1,2,3])
46
+ >>> file = GROFile()
47
+ >>> file.set_structure(array_stack_mod)
48
+ >>> file.write(os.path.join(path_to_directory, "1l2y_mod.gro"))
49
+
50
+ """
51
+ def get_model_count(self):
52
+ """
53
+ Get the number of models contained in this GRO file.
54
+
55
+ Returns
56
+ -------
57
+ model_count : int
58
+ The number of models.
59
+ """
60
+ model_count = 0
61
+ for line in self.lines:
62
+ if _is_int(line):
63
+ model_count += 1
64
+ return model_count
65
+
66
+
67
+ def get_structure(self, model=None):
68
+ """
69
+ Get an :class:`AtomArray` or :class:`AtomArrayStack` from the
70
+ GRO file.
71
+
72
+ Parameters
73
+ ----------
74
+ model : int, optional
75
+ If this parameter is given, the function will return an
76
+ :class:`AtomArray` from the atoms corresponding to the given
77
+ model number (starting at 1).
78
+ Negative values are used to index models starting from the
79
+ last model insted of the first model.
80
+ If this parameter is omitted, an :class:`AtomArrayStack`
81
+ containing all models will be returned, even if the
82
+ structure contains only one model.
83
+
84
+ Returns
85
+ -------
86
+ array : AtomArray or AtomArrayStack
87
+ The return type depends on the `model` parameter.
88
+ """
89
+
90
+ def get_atom_line_i(model_start_i, model_atom_counts):
91
+ """
92
+ Helper function to get the indices of all atoms for a model
93
+ """
94
+ return np.arange(
95
+ model_start_i+1, model_start_i+1+model_atom_counts
96
+ )
97
+
98
+ def set_box_dimen(box_param):
99
+ """
100
+ Helper function to create the box vectors from the values
101
+ in the GRO file
102
+
103
+ Parameters
104
+ ----------
105
+ box_param : list of float
106
+ The box dimensions in the GRO file.
107
+
108
+ Returns
109
+ -------
110
+ box_vectors : ndarray, dtype=float, shape=(3,3)
111
+ The atom array compatible box vectors.
112
+ """
113
+ if not any(box_param):
114
+ return None
115
+ if len(box_param) == 3:
116
+ x, y, z = box_param
117
+ return np.array([[x,0,0], [0,y,0], [0,0,z]], dtype=float)
118
+ elif len(box_param) == 9:
119
+ x1, y2, z3, x2, x3, y1, y3, z1, z2 = box_param
120
+ return np.array(
121
+ [[x1,x2,x3], [y1,y2,y3], [z1,z2,z3]], dtype=float
122
+ )
123
+ else:
124
+ raise InvalidFileError(
125
+ f"Invalid amount of box parameters: {len(box_param)}"
126
+ )
127
+
128
+ # Line indices where a new model starts
129
+ model_start_i = np.array([i for i in range(len(self.lines))
130
+ if _is_int(self.lines[i])],
131
+ dtype=int)
132
+
133
+ # Number of atoms in each model
134
+ model_atom_counts = np.array(
135
+ [int(self.lines[i]) for i in model_start_i]
136
+ )
137
+
138
+ if model is None:
139
+ # Check if all models have the same length
140
+ if np.all(model_atom_counts != model_atom_counts[0]):
141
+ raise BadStructureError("The models in the file have unequal "
142
+ "amount of atoms, give an explicit "
143
+ "model instead")
144
+ depth = len(model_start_i)
145
+ length = model_atom_counts[0]
146
+ array = AtomArrayStack(depth, length)
147
+
148
+ # Line indices for annotation determination is determined
149
+ # from model 1
150
+ annot_i = get_atom_line_i(model_start_i[0], length)
151
+ else:
152
+ if model == 0:
153
+ raise ValueError("The model index must not be 0")
154
+ # Negative models mean index starting from last model
155
+ model = len(model_start_i) + model + 1 if model < 0 else model
156
+ if model > len(model_start_i):
157
+ raise ValueError(
158
+ f"The file has {len(model_start_i)} models, "
159
+ f"the given model {model} does not exist"
160
+ )
161
+
162
+ length = model_atom_counts[model-1]
163
+ array = AtomArray(length)
164
+
165
+ annot_i = get_atom_line_i(model_start_i[model-1], length)
166
+
167
+ # Replace empty strings for elements with guessed types
168
+ # i is index in array, line_i is line index
169
+ for i, line_i in enumerate(annot_i):
170
+ line = self.lines[line_i]
171
+ array.res_id[i] = int(line[0:5])
172
+ array.res_name[i] = line[5:10].strip()
173
+ array.atom_name[i] = line[10:15].strip()
174
+ array.element = infer_elements(array.atom_name)
175
+
176
+ # Fill in coordinates and boxes
177
+ if isinstance(array, AtomArray):
178
+ atom_i = annot_i
179
+ for i, line_i in enumerate(atom_i):
180
+ line = self.lines[line_i]
181
+ # gro files use nm instead of A
182
+ array.coord[i,0] = float(line[20:28])*10
183
+ array.coord[i,1] = float(line[28:36])*10
184
+ array.coord[i,2] = float(line[36:44])*10
185
+ # Box is stored in last line (after coordinates)
186
+ box_i = atom_i[-1] + 1
187
+ box_param = [float(e)*10 for e in self.lines[box_i].split()]
188
+ array.box = set_box_dimen(box_param)
189
+
190
+ elif isinstance(array, AtomArrayStack):
191
+ for m in range(len(model_start_i)):
192
+ atom_i = get_atom_line_i(
193
+ model_start_i[m], model_atom_counts[m]
194
+ )
195
+ for i, line_i in enumerate(atom_i):
196
+ line = self.lines[line_i]
197
+ array.coord[m,i,0] = float(line[20:28])*10
198
+ array.coord[m,i,1] = float(line[28:36])*10
199
+ array.coord[m,i,2] = float(line[36:44])*10
200
+ # Box is stored in last line (after coordinates)
201
+ box_i = atom_i[-1] + 1
202
+ box_param = [float(e)*10 for e in self.lines[box_i].split()]
203
+ box = set_box_dimen(box_param)
204
+ # Create a box in the stack if not already existing
205
+ # and the box is not a dummy
206
+ if box is not None:
207
+ if array.box is None:
208
+ array.box = np.zeros((array.stack_depth(), 3, 3))
209
+ array.box[m] = box
210
+
211
+ return array
212
+
213
+
214
+ def set_structure(self, array):
215
+ """
216
+ Set the :class:`AtomArray` or :class:`AtomArrayStack` for the
217
+ file.
218
+
219
+ Parameters
220
+ ----------
221
+ array : AtomArray or AtomArrayStack
222
+ The array or stack to be saved into this file. If a stack
223
+ is given, each array in the stack is saved as separate
224
+ model.
225
+ """
226
+ def get_box_dimen(array):
227
+ """
228
+ GRO files have the box dimensions as last line for each
229
+ model.
230
+ In case, the `box` attribute of the atom array is
231
+ `None`, we simply use the min and max coordinates in xyz
232
+ to get the correct size
233
+
234
+ Parameters
235
+ ----------
236
+ array : AtomArray
237
+ The atom array to get the box dimensions from.
238
+
239
+ Returns
240
+ -------
241
+ box : str
242
+ The box, properly formatted for GRO files.
243
+ """
244
+ if array.box is None:
245
+ coord = array.coord
246
+ bx, by, bz = (coord.max(axis=0) - coord.min(axis=0)) / 10
247
+ return f"{bx:>8.3f} {by:>8.3f} {bz:>8.3f}"
248
+ else:
249
+ box = array.box
250
+ if is_orthogonal(box):
251
+ bx, by, bz = np.diag(box) / 10
252
+ return f"{bx:>9.5f} {by:>9.5f} {bz:>9.5f}"
253
+ else:
254
+ box = box / 10
255
+ box_elements = (
256
+ box[0,0], box[1,1], box[2,2],
257
+ box[0,1], box[0,2],
258
+ box[1,0], box[1,2],
259
+ box[2,0], box[2,1],
260
+ )
261
+ return " ".join([f"{e:>9.5f}" for e in box_elements])
262
+
263
+ if "atom_id" in array.get_annotation_categories():
264
+ atom_id = array.atom_id
265
+ else:
266
+ atom_id = np.arange(1, array.array_length() + 1)
267
+ # Atom IDs are supported up to 99999,
268
+ # but negative IDs are also possible
269
+ gro_atom_id = np.where(
270
+ atom_id > 0,
271
+ ((atom_id - 1) % 99999) + 1,
272
+ atom_id
273
+ )
274
+ # Residue IDs are supported up to 9999,
275
+ # but negative IDs are also possible
276
+ gro_res_id = np.where(
277
+ array.res_id > 0,
278
+ ((array.res_id - 1) % 99999) + 1,
279
+ array.res_id
280
+ )
281
+
282
+ if isinstance(array, AtomArray):
283
+ self.lines = [None] * (array.array_length() + 3)
284
+
285
+ # Write header lines
286
+ self.lines[0] = f"Generated by Biotite at {datetime.now()}"
287
+ self.lines[1] = str(array.array_length())
288
+
289
+ # Write atom lines
290
+ fmt = "{:>5d}{:5s}{:>5s}{:>5d}{:>8.3f}{:>8.3f}{:>8.3f}"
291
+ for i in range(array.array_length()):
292
+ # gro format is in nm -> multiply coords by 10
293
+ self.lines[i+2] = fmt.format(
294
+ gro_res_id[i], array.res_name[i], array.atom_name[i],
295
+ gro_atom_id[i], array.coord[i,0]/10, array.coord[i,1]/10,
296
+ array.coord[i,2]/10
297
+ )
298
+ # Write box lines
299
+ self.lines[-1] = get_box_dimen(array)
300
+ elif isinstance(array, AtomArrayStack):
301
+ self.lines = []
302
+ # The entire information, but the coordinates,
303
+ # is equal for each model
304
+ # Therefore template lines are created
305
+ # which are afterwards applied for each model
306
+ templines = [None] * array.array_length()
307
+ fmt = '{:>5d}{:5s}{:>5s}{:5d}'
308
+ for i in range(array.array_length()):
309
+ templines[i] = fmt.format(gro_res_id[i], array.res_name[i],
310
+ array.atom_name[i], gro_atom_id[i])
311
+
312
+ for i in range(array.stack_depth()):
313
+ self.lines.append(
314
+ f"Generated by Biotite at {datetime.now()}, model={i+1}"
315
+ )
316
+ self.lines.append(str(array.array_length()))
317
+
318
+ # Fill in coordinates for each model
319
+ modellines = copy.copy(templines)
320
+ for j, line in enumerate(modellines):
321
+ # Insert coordinates
322
+ line = (line + "{:>8.3f}{:>8.3f}{:>8.3f}".format(
323
+ array.coord[i,j,0]/10,
324
+ array.coord[i,j,1]/10,
325
+ array.coord[i,j,2]/10))
326
+ modellines[j] = line
327
+ self.lines.extend(modellines)
328
+ self.lines.append(get_box_dimen(array[i]))
329
+ else:
330
+ raise TypeError("An atom array or stack must be provided")
331
+ # Add terminal newline, since PyMOL requires it
332
+ self.lines.append("")
333
+
334
+
335
+ def _is_int(string):
336
+ """
337
+ Return ``True`, if the string can be parsed to an int.
338
+ """
339
+ try:
340
+ int(string)
341
+ return True
342
+ except ValueError:
343
+ return False
@@ -0,0 +1,21 @@
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 subpackage is used for reading and writing an :class:`AtomArray` or
7
+ :class:`AtomArrayStack` using the binary MMTF format. This format
8
+ features a smaller file size and a highly increased I/O operation
9
+ performance, than the text based file formats.
10
+
11
+ DEPRECATED: Use :class:`biotite.structure.io.pdbx.BinaryCIFFile`
12
+ instead.
13
+ """
14
+
15
+ __name__ = "biotite.structure.io.mmtf"
16
+ __author__ = "Patrick Kunzmann"
17
+
18
+ from .assembly import *
19
+ from .file import *
20
+ from .convertfile import *
21
+ from .convertarray import *