biotite 1.5.0__cp314-cp314-macosx_10_13_x86_64.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 (354) hide show
  1. biotite/__init__.py +18 -0
  2. biotite/application/__init__.py +69 -0
  3. biotite/application/application.py +276 -0
  4. biotite/application/autodock/__init__.py +12 -0
  5. biotite/application/autodock/app.py +500 -0
  6. biotite/application/blast/__init__.py +14 -0
  7. biotite/application/blast/alignment.py +92 -0
  8. biotite/application/blast/webapp.py +428 -0
  9. biotite/application/clustalo/__init__.py +12 -0
  10. biotite/application/clustalo/app.py +223 -0
  11. biotite/application/dssp/__init__.py +12 -0
  12. biotite/application/dssp/app.py +216 -0
  13. biotite/application/localapp.py +342 -0
  14. biotite/application/mafft/__init__.py +12 -0
  15. biotite/application/mafft/app.py +116 -0
  16. biotite/application/msaapp.py +363 -0
  17. biotite/application/muscle/__init__.py +13 -0
  18. biotite/application/muscle/app3.py +227 -0
  19. biotite/application/muscle/app5.py +163 -0
  20. biotite/application/sra/__init__.py +18 -0
  21. biotite/application/sra/app.py +447 -0
  22. biotite/application/tantan/__init__.py +12 -0
  23. biotite/application/tantan/app.py +199 -0
  24. biotite/application/util.py +77 -0
  25. biotite/application/viennarna/__init__.py +18 -0
  26. biotite/application/viennarna/rnaalifold.py +310 -0
  27. biotite/application/viennarna/rnafold.py +254 -0
  28. biotite/application/viennarna/rnaplot.py +208 -0
  29. biotite/application/viennarna/util.py +77 -0
  30. biotite/application/webapp.py +76 -0
  31. biotite/copyable.py +71 -0
  32. biotite/database/__init__.py +23 -0
  33. biotite/database/afdb/__init__.py +12 -0
  34. biotite/database/afdb/download.py +197 -0
  35. biotite/database/entrez/__init__.py +15 -0
  36. biotite/database/entrez/check.py +60 -0
  37. biotite/database/entrez/dbnames.py +101 -0
  38. biotite/database/entrez/download.py +228 -0
  39. biotite/database/entrez/key.py +44 -0
  40. biotite/database/entrez/query.py +263 -0
  41. biotite/database/error.py +16 -0
  42. biotite/database/pubchem/__init__.py +21 -0
  43. biotite/database/pubchem/download.py +258 -0
  44. biotite/database/pubchem/error.py +30 -0
  45. biotite/database/pubchem/query.py +819 -0
  46. biotite/database/pubchem/throttle.py +98 -0
  47. biotite/database/rcsb/__init__.py +13 -0
  48. biotite/database/rcsb/download.py +161 -0
  49. biotite/database/rcsb/query.py +963 -0
  50. biotite/database/uniprot/__init__.py +13 -0
  51. biotite/database/uniprot/check.py +40 -0
  52. biotite/database/uniprot/download.py +126 -0
  53. biotite/database/uniprot/query.py +292 -0
  54. biotite/file.py +244 -0
  55. biotite/interface/__init__.py +19 -0
  56. biotite/interface/openmm/__init__.py +20 -0
  57. biotite/interface/openmm/state.py +93 -0
  58. biotite/interface/openmm/system.py +227 -0
  59. biotite/interface/pymol/__init__.py +201 -0
  60. biotite/interface/pymol/cgo.py +346 -0
  61. biotite/interface/pymol/convert.py +185 -0
  62. biotite/interface/pymol/display.py +267 -0
  63. biotite/interface/pymol/object.py +1228 -0
  64. biotite/interface/pymol/shapes.py +178 -0
  65. biotite/interface/pymol/startup.py +169 -0
  66. biotite/interface/rdkit/__init__.py +19 -0
  67. biotite/interface/rdkit/mol.py +490 -0
  68. biotite/interface/version.py +94 -0
  69. biotite/interface/warning.py +19 -0
  70. biotite/sequence/__init__.py +84 -0
  71. biotite/sequence/align/__init__.py +199 -0
  72. biotite/sequence/align/alignment.py +702 -0
  73. biotite/sequence/align/banded.cpython-314-darwin.so +0 -0
  74. biotite/sequence/align/banded.pyx +652 -0
  75. biotite/sequence/align/buckets.py +71 -0
  76. biotite/sequence/align/cigar.py +425 -0
  77. biotite/sequence/align/kmeralphabet.cpython-314-darwin.so +0 -0
  78. biotite/sequence/align/kmeralphabet.pyx +595 -0
  79. biotite/sequence/align/kmersimilarity.cpython-314-darwin.so +0 -0
  80. biotite/sequence/align/kmersimilarity.pyx +233 -0
  81. biotite/sequence/align/kmertable.cpython-314-darwin.so +0 -0
  82. biotite/sequence/align/kmertable.pyx +3411 -0
  83. biotite/sequence/align/localgapped.cpython-314-darwin.so +0 -0
  84. biotite/sequence/align/localgapped.pyx +892 -0
  85. biotite/sequence/align/localungapped.cpython-314-darwin.so +0 -0
  86. biotite/sequence/align/localungapped.pyx +279 -0
  87. biotite/sequence/align/matrix.py +631 -0
  88. biotite/sequence/align/matrix_data/3Di.mat +24 -0
  89. biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
  90. biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
  91. biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
  92. biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
  93. biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
  94. biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
  95. biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
  96. biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
  97. biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
  98. biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
  99. biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
  100. biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
  101. biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
  102. biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
  103. biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
  104. biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
  105. biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
  106. biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
  107. biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
  108. biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
  109. biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
  110. biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
  111. biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
  112. biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
  113. biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
  114. biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
  115. biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
  116. biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
  117. biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
  118. biotite/sequence/align/matrix_data/GONNET.mat +26 -0
  119. biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
  120. biotite/sequence/align/matrix_data/MATCH.mat +25 -0
  121. biotite/sequence/align/matrix_data/NUC.mat +25 -0
  122. biotite/sequence/align/matrix_data/PAM10.mat +34 -0
  123. biotite/sequence/align/matrix_data/PAM100.mat +34 -0
  124. biotite/sequence/align/matrix_data/PAM110.mat +34 -0
  125. biotite/sequence/align/matrix_data/PAM120.mat +34 -0
  126. biotite/sequence/align/matrix_data/PAM130.mat +34 -0
  127. biotite/sequence/align/matrix_data/PAM140.mat +34 -0
  128. biotite/sequence/align/matrix_data/PAM150.mat +34 -0
  129. biotite/sequence/align/matrix_data/PAM160.mat +34 -0
  130. biotite/sequence/align/matrix_data/PAM170.mat +34 -0
  131. biotite/sequence/align/matrix_data/PAM180.mat +34 -0
  132. biotite/sequence/align/matrix_data/PAM190.mat +34 -0
  133. biotite/sequence/align/matrix_data/PAM20.mat +34 -0
  134. biotite/sequence/align/matrix_data/PAM200.mat +34 -0
  135. biotite/sequence/align/matrix_data/PAM210.mat +34 -0
  136. biotite/sequence/align/matrix_data/PAM220.mat +34 -0
  137. biotite/sequence/align/matrix_data/PAM230.mat +34 -0
  138. biotite/sequence/align/matrix_data/PAM240.mat +34 -0
  139. biotite/sequence/align/matrix_data/PAM250.mat +34 -0
  140. biotite/sequence/align/matrix_data/PAM260.mat +34 -0
  141. biotite/sequence/align/matrix_data/PAM270.mat +34 -0
  142. biotite/sequence/align/matrix_data/PAM280.mat +34 -0
  143. biotite/sequence/align/matrix_data/PAM290.mat +34 -0
  144. biotite/sequence/align/matrix_data/PAM30.mat +34 -0
  145. biotite/sequence/align/matrix_data/PAM300.mat +34 -0
  146. biotite/sequence/align/matrix_data/PAM310.mat +34 -0
  147. biotite/sequence/align/matrix_data/PAM320.mat +34 -0
  148. biotite/sequence/align/matrix_data/PAM330.mat +34 -0
  149. biotite/sequence/align/matrix_data/PAM340.mat +34 -0
  150. biotite/sequence/align/matrix_data/PAM350.mat +34 -0
  151. biotite/sequence/align/matrix_data/PAM360.mat +34 -0
  152. biotite/sequence/align/matrix_data/PAM370.mat +34 -0
  153. biotite/sequence/align/matrix_data/PAM380.mat +34 -0
  154. biotite/sequence/align/matrix_data/PAM390.mat +34 -0
  155. biotite/sequence/align/matrix_data/PAM40.mat +34 -0
  156. biotite/sequence/align/matrix_data/PAM400.mat +34 -0
  157. biotite/sequence/align/matrix_data/PAM410.mat +34 -0
  158. biotite/sequence/align/matrix_data/PAM420.mat +34 -0
  159. biotite/sequence/align/matrix_data/PAM430.mat +34 -0
  160. biotite/sequence/align/matrix_data/PAM440.mat +34 -0
  161. biotite/sequence/align/matrix_data/PAM450.mat +34 -0
  162. biotite/sequence/align/matrix_data/PAM460.mat +34 -0
  163. biotite/sequence/align/matrix_data/PAM470.mat +34 -0
  164. biotite/sequence/align/matrix_data/PAM480.mat +34 -0
  165. biotite/sequence/align/matrix_data/PAM490.mat +34 -0
  166. biotite/sequence/align/matrix_data/PAM50.mat +34 -0
  167. biotite/sequence/align/matrix_data/PAM500.mat +34 -0
  168. biotite/sequence/align/matrix_data/PAM60.mat +34 -0
  169. biotite/sequence/align/matrix_data/PAM70.mat +34 -0
  170. biotite/sequence/align/matrix_data/PAM80.mat +34 -0
  171. biotite/sequence/align/matrix_data/PAM90.mat +34 -0
  172. biotite/sequence/align/matrix_data/PB.license +21 -0
  173. biotite/sequence/align/matrix_data/PB.mat +18 -0
  174. biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
  175. biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
  176. biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
  177. biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
  178. biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
  179. biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
  180. biotite/sequence/align/multiple.cpython-314-darwin.so +0 -0
  181. biotite/sequence/align/multiple.pyx +619 -0
  182. biotite/sequence/align/pairwise.cpython-314-darwin.so +0 -0
  183. biotite/sequence/align/pairwise.pyx +585 -0
  184. biotite/sequence/align/permutation.cpython-314-darwin.so +0 -0
  185. biotite/sequence/align/permutation.pyx +313 -0
  186. biotite/sequence/align/primes.txt +821 -0
  187. biotite/sequence/align/selector.cpython-314-darwin.so +0 -0
  188. biotite/sequence/align/selector.pyx +954 -0
  189. biotite/sequence/align/statistics.py +264 -0
  190. biotite/sequence/align/tracetable.cpython-314-darwin.so +0 -0
  191. biotite/sequence/align/tracetable.pxd +64 -0
  192. biotite/sequence/align/tracetable.pyx +370 -0
  193. biotite/sequence/alphabet.py +555 -0
  194. biotite/sequence/annotation.py +836 -0
  195. biotite/sequence/codec.cpython-314-darwin.so +0 -0
  196. biotite/sequence/codec.pyx +155 -0
  197. biotite/sequence/codon.py +476 -0
  198. biotite/sequence/codon_tables.txt +202 -0
  199. biotite/sequence/graphics/__init__.py +33 -0
  200. biotite/sequence/graphics/alignment.py +1101 -0
  201. biotite/sequence/graphics/color_schemes/3di_flower.json +48 -0
  202. biotite/sequence/graphics/color_schemes/autumn.json +51 -0
  203. biotite/sequence/graphics/color_schemes/blossom.json +51 -0
  204. biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
  205. biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
  206. biotite/sequence/graphics/color_schemes/flower.json +51 -0
  207. biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
  208. biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
  209. biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
  210. biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
  211. biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
  212. biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
  213. biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
  214. biotite/sequence/graphics/color_schemes/ocean.json +51 -0
  215. biotite/sequence/graphics/color_schemes/pb_flower.json +40 -0
  216. biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
  217. biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
  218. biotite/sequence/graphics/color_schemes/spring.json +51 -0
  219. biotite/sequence/graphics/color_schemes/sunset.json +51 -0
  220. biotite/sequence/graphics/color_schemes/wither.json +51 -0
  221. biotite/sequence/graphics/colorschemes.py +170 -0
  222. biotite/sequence/graphics/dendrogram.py +231 -0
  223. biotite/sequence/graphics/features.py +544 -0
  224. biotite/sequence/graphics/logo.py +102 -0
  225. biotite/sequence/graphics/plasmid.py +712 -0
  226. biotite/sequence/io/__init__.py +12 -0
  227. biotite/sequence/io/fasta/__init__.py +22 -0
  228. biotite/sequence/io/fasta/convert.py +283 -0
  229. biotite/sequence/io/fasta/file.py +265 -0
  230. biotite/sequence/io/fastq/__init__.py +19 -0
  231. biotite/sequence/io/fastq/convert.py +117 -0
  232. biotite/sequence/io/fastq/file.py +507 -0
  233. biotite/sequence/io/genbank/__init__.py +17 -0
  234. biotite/sequence/io/genbank/annotation.py +269 -0
  235. biotite/sequence/io/genbank/file.py +573 -0
  236. biotite/sequence/io/genbank/metadata.py +336 -0
  237. biotite/sequence/io/genbank/sequence.py +173 -0
  238. biotite/sequence/io/general.py +201 -0
  239. biotite/sequence/io/gff/__init__.py +26 -0
  240. biotite/sequence/io/gff/convert.py +128 -0
  241. biotite/sequence/io/gff/file.py +449 -0
  242. biotite/sequence/phylo/__init__.py +36 -0
  243. biotite/sequence/phylo/nj.cpython-314-darwin.so +0 -0
  244. biotite/sequence/phylo/nj.pyx +221 -0
  245. biotite/sequence/phylo/tree.cpython-314-darwin.so +0 -0
  246. biotite/sequence/phylo/tree.pyx +1169 -0
  247. biotite/sequence/phylo/upgma.cpython-314-darwin.so +0 -0
  248. biotite/sequence/phylo/upgma.pyx +164 -0
  249. biotite/sequence/profile.py +561 -0
  250. biotite/sequence/search.py +117 -0
  251. biotite/sequence/seqtypes.py +720 -0
  252. biotite/sequence/sequence.py +373 -0
  253. biotite/setup_ccd.py +197 -0
  254. biotite/structure/__init__.py +135 -0
  255. biotite/structure/alphabet/__init__.py +25 -0
  256. biotite/structure/alphabet/encoder.py +332 -0
  257. biotite/structure/alphabet/encoder_weights_3di.kerasify +0 -0
  258. biotite/structure/alphabet/i3d.py +109 -0
  259. biotite/structure/alphabet/layers.py +86 -0
  260. biotite/structure/alphabet/pb.license +21 -0
  261. biotite/structure/alphabet/pb.py +170 -0
  262. biotite/structure/alphabet/unkerasify.py +128 -0
  263. biotite/structure/atoms.py +1562 -0
  264. biotite/structure/basepairs.py +1403 -0
  265. biotite/structure/bonds.cpython-314-darwin.so +0 -0
  266. biotite/structure/bonds.pyx +2036 -0
  267. biotite/structure/box.py +724 -0
  268. biotite/structure/celllist.cpython-314-darwin.so +0 -0
  269. biotite/structure/celllist.pyx +864 -0
  270. biotite/structure/chains.py +310 -0
  271. biotite/structure/charges.cpython-314-darwin.so +0 -0
  272. biotite/structure/charges.pyx +520 -0
  273. biotite/structure/compare.py +683 -0
  274. biotite/structure/density.py +109 -0
  275. biotite/structure/dotbracket.py +213 -0
  276. biotite/structure/error.py +39 -0
  277. biotite/structure/filter.py +591 -0
  278. biotite/structure/geometry.py +817 -0
  279. biotite/structure/graphics/__init__.py +13 -0
  280. biotite/structure/graphics/atoms.py +243 -0
  281. biotite/structure/graphics/rna.py +298 -0
  282. biotite/structure/hbond.py +425 -0
  283. biotite/structure/info/__init__.py +24 -0
  284. biotite/structure/info/atom_masses.json +121 -0
  285. biotite/structure/info/atoms.py +98 -0
  286. biotite/structure/info/bonds.py +149 -0
  287. biotite/structure/info/ccd.py +200 -0
  288. biotite/structure/info/components.bcif +0 -0
  289. biotite/structure/info/groups.py +128 -0
  290. biotite/structure/info/masses.py +121 -0
  291. biotite/structure/info/misc.py +137 -0
  292. biotite/structure/info/radii.py +267 -0
  293. biotite/structure/info/standardize.py +185 -0
  294. biotite/structure/integrity.py +213 -0
  295. biotite/structure/io/__init__.py +29 -0
  296. biotite/structure/io/dcd/__init__.py +13 -0
  297. biotite/structure/io/dcd/file.py +67 -0
  298. biotite/structure/io/general.py +243 -0
  299. biotite/structure/io/gro/__init__.py +14 -0
  300. biotite/structure/io/gro/file.py +343 -0
  301. biotite/structure/io/mol/__init__.py +20 -0
  302. biotite/structure/io/mol/convert.py +112 -0
  303. biotite/structure/io/mol/ctab.py +420 -0
  304. biotite/structure/io/mol/header.py +120 -0
  305. biotite/structure/io/mol/mol.py +149 -0
  306. biotite/structure/io/mol/sdf.py +940 -0
  307. biotite/structure/io/netcdf/__init__.py +13 -0
  308. biotite/structure/io/netcdf/file.py +64 -0
  309. biotite/structure/io/pdb/__init__.py +20 -0
  310. biotite/structure/io/pdb/convert.py +389 -0
  311. biotite/structure/io/pdb/file.py +1380 -0
  312. biotite/structure/io/pdb/hybrid36.cpython-314-darwin.so +0 -0
  313. biotite/structure/io/pdb/hybrid36.pyx +242 -0
  314. biotite/structure/io/pdbqt/__init__.py +15 -0
  315. biotite/structure/io/pdbqt/convert.py +113 -0
  316. biotite/structure/io/pdbqt/file.py +688 -0
  317. biotite/structure/io/pdbx/__init__.py +23 -0
  318. biotite/structure/io/pdbx/bcif.py +674 -0
  319. biotite/structure/io/pdbx/cif.py +1091 -0
  320. biotite/structure/io/pdbx/component.py +251 -0
  321. biotite/structure/io/pdbx/compress.py +362 -0
  322. biotite/structure/io/pdbx/convert.py +2113 -0
  323. biotite/structure/io/pdbx/encoding.cpython-314-darwin.so +0 -0
  324. biotite/structure/io/pdbx/encoding.pyx +1078 -0
  325. biotite/structure/io/trajfile.py +696 -0
  326. biotite/structure/io/trr/__init__.py +13 -0
  327. biotite/structure/io/trr/file.py +43 -0
  328. biotite/structure/io/util.py +38 -0
  329. biotite/structure/io/xtc/__init__.py +13 -0
  330. biotite/structure/io/xtc/file.py +43 -0
  331. biotite/structure/mechanics.py +72 -0
  332. biotite/structure/molecules.py +337 -0
  333. biotite/structure/pseudoknots.py +622 -0
  334. biotite/structure/rdf.py +245 -0
  335. biotite/structure/repair.py +302 -0
  336. biotite/structure/residues.py +716 -0
  337. biotite/structure/rings.py +451 -0
  338. biotite/structure/sasa.cpython-314-darwin.so +0 -0
  339. biotite/structure/sasa.pyx +322 -0
  340. biotite/structure/segments.py +328 -0
  341. biotite/structure/sequence.py +110 -0
  342. biotite/structure/spacegroups.json +1567 -0
  343. biotite/structure/spacegroups.license +26 -0
  344. biotite/structure/sse.py +306 -0
  345. biotite/structure/superimpose.py +511 -0
  346. biotite/structure/tm.py +581 -0
  347. biotite/structure/transform.py +736 -0
  348. biotite/structure/util.py +160 -0
  349. biotite/version.py +34 -0
  350. biotite/visualize.py +375 -0
  351. biotite-1.5.0.dist-info/METADATA +162 -0
  352. biotite-1.5.0.dist-info/RECORD +354 -0
  353. biotite-1.5.0.dist-info/WHEEL +6 -0
  354. biotite-1.5.0.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,696 @@
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"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["TrajectoryFile"]
8
+
9
+ import abc
10
+ import itertools
11
+ import numpy as np
12
+ from biotite.file import File
13
+ from biotite.structure.atoms import AtomArray, AtomArrayStack, from_template
14
+
15
+
16
+ class TrajectoryFile(File, metaclass=abc.ABCMeta):
17
+ """
18
+ This file class represents a trajectory file interfacing a
19
+ trajectory file class from `biotraj`.
20
+
21
+ A trajectory file stores atom coordinates over multiple (time)
22
+ frames. The file formats are usually binary and involve sometimes
23
+ heavy compression, so that a large number of frames can be stored
24
+ in relatively small space.
25
+
26
+ Notes
27
+ -----
28
+ When extracting data from the file, only a reference to the
29
+ data arrays stored in this file are created.
30
+ The same is true, when setting data in the file.
31
+ Therefore, it is strongly recommended to make a copy of the
32
+ respective array, if the array is modified.
33
+ """
34
+
35
+ def __init__(self):
36
+ super().__init__()
37
+ self._coord = None
38
+ self._time = None
39
+ self._box = None
40
+ self._model_count = None
41
+
42
+ @classmethod
43
+ def read(
44
+ cls, file_name, start=None, stop=None, step=None, atom_i=None, chunk_size=None
45
+ ):
46
+ """
47
+ Read a trajectory file.
48
+
49
+ A trajectory file can be seen as a file representation of an
50
+ :class:`AtomArrayStack`.
51
+ Therefore, `start`, `stop` and `step` represent slice parameters
52
+ of the index of the first dimension and
53
+ `atom_i` represents an index array for the second dimension.
54
+
55
+ Parameters
56
+ ----------
57
+ file_name : str or Path
58
+ The path of the file to be read.
59
+ Any other file-like object cannot be used.
60
+ start : int, optional
61
+ The frame index, where file parsing is started. If no value
62
+ is given, parsing starts at the first frame.
63
+ The index starts at 0.
64
+ stop : int, optional
65
+ The exclusive frame index, where file parsing ends.
66
+ If no value is given, parsing stops after the last frame.
67
+ The index starts at 0.
68
+ step : int, optional
69
+ If this value is set, the function reads only every n-th
70
+ frame from the file.
71
+ atom_i : ndarray, dtype=int, optional
72
+ If this parameter is set, only the atoms at the given
73
+ indices are read from each frame.
74
+ chunk_size : int, optional
75
+ If this parameter is set, the trajectory is read in chunks:
76
+ Only the number of frames specified by this parameter are
77
+ read at once.
78
+ The resulting chunks of frames are automatically
79
+ concatenated, after all chunks are collected.
80
+ Use this parameter, if a :class:`MemoryError` is raised
81
+ when a trajectory file is read.
82
+ Although lower values can decrease the memory consumption of
83
+ reading trajectories, they also increase the computation
84
+ time.
85
+
86
+ Returns
87
+ -------
88
+ file_object : TrajectoryFile
89
+ The parsed trajectory file.
90
+ """
91
+ file = cls()
92
+
93
+ if chunk_size is not None:
94
+ if chunk_size < 1:
95
+ raise ValueError("Chunk size must be greater than 0")
96
+ # Chunk size must be a multiple of step size to ensure that
97
+ # the step distance at the chunk border is the same as
98
+ # within a chunk
99
+ # -> round chunk size up to a multiple of step size
100
+ if step is not None and chunk_size % step != 0:
101
+ chunk_size = ((chunk_size // step) + 1) * step
102
+
103
+ traj_type = cls.traj_type()
104
+ with traj_type(str(file_name), "r") as f:
105
+ if start is None:
106
+ start = 0
107
+ # Discard atoms before start
108
+ if start != 0:
109
+ if chunk_size is None or chunk_size > start:
110
+ f.read(n_frames=start, stride=None, atom_indices=atom_i)
111
+ else:
112
+ TrajectoryFile._read_chunk_wise(
113
+ f, start, None, atom_i, chunk_size, discard=True
114
+ )
115
+
116
+ # The upcoming frames are saved
117
+ # Calculate the amount of frames to be read
118
+ if stop is None:
119
+ n_frames = None
120
+ else:
121
+ n_frames = stop - start
122
+ if step is not None and n_frames is not None:
123
+ # Divide number of frames by 'step' in order to convert
124
+ # 'step' into 'stride'
125
+ # Since the 0th frame is always included,
126
+ # the number of frames is decremented before division
127
+ # and incremented afterwards again
128
+ n_frames = ((n_frames - 1) // step) + 1
129
+
130
+ # Read frames
131
+ if chunk_size is None:
132
+ result = f.read(n_frames, stride=step, atom_indices=atom_i)
133
+ else:
134
+ result = TrajectoryFile._read_chunk_wise(
135
+ f, n_frames, step, atom_i, chunk_size, discard=False
136
+ )
137
+
138
+ # nm to Angstrom
139
+ coord, box, time = cls.process_read_values(result)
140
+ file.set_coord(coord)
141
+ file.set_box(box)
142
+ file.set_time(time)
143
+
144
+ return file
145
+
146
+ @classmethod
147
+ def read_iter(
148
+ cls, file_name, start=None, stop=None, step=None, atom_i=None, stack_size=None
149
+ ):
150
+ """
151
+ Create an iterator over each frame of the given trajectory file
152
+ in the selected range.
153
+
154
+ Parameters
155
+ ----------
156
+ file_name : str or Path
157
+ The path of the file to be read.
158
+ Any other file-like object cannot be used.
159
+ start : int, optional
160
+ The frame index, where file parsing is started. If no value
161
+ is given, parsing starts at the first frame.
162
+ The index starts at 0.
163
+ stop : int, optional
164
+ The exclusive frame index, where file parsing ends.
165
+ If no value is given, parsing stops at the end of file.
166
+ The index starts at 0.
167
+ step : int, optional
168
+ If this value is set, the function reads only every n-th
169
+ frame from the file.
170
+ atom_i : ndarray, dtype=int, optional
171
+ If this parameter is set, only the atoms at the given
172
+ indices are read from each frame.
173
+ stack_size : int, optional
174
+ If this parameter is set, the given number of frames *m* are
175
+ read at once.
176
+ As result an additional dimension is added to the return
177
+ values.
178
+ If the number of frames is not a multiple of `stack_size`,
179
+ the final stack is smaller than `stack_size`.
180
+
181
+ Yields
182
+ ------
183
+ coord : ndarray, dtype=float32, shape=(n,3) or shape=(m,n,3)
184
+ The atom coordinates in the current frame or stack.
185
+ box : ndarray, dtype=float32, shape=(3,3) or shape=(m,3,3) or None
186
+ The box vectors of the current frame or stack.
187
+ time : float or ndarray, dtype=float32, shape=(n,) or None
188
+ The simulation time of the current frame or stack in *ps*.
189
+
190
+ See Also
191
+ --------
192
+ read_iter_structure :
193
+ Get an :class:`AtomArray` for each frame or an :class:`AtomArrayStack`
194
+ for each chunk of frames instead.
195
+
196
+ Notes
197
+ -----
198
+ The `step` parameter does currently not work for *DCD* files.
199
+ """
200
+ traj_type = cls.traj_type()
201
+ with traj_type(str(file_name), "r") as f:
202
+ if start is None:
203
+ start = 0
204
+ # Discard atoms before start
205
+ if start != 0:
206
+ f.read(n_frames=start, stride=None, atom_indices=atom_i)
207
+
208
+ # The upcoming frames are read
209
+ # Calculate the amount of frames to be read
210
+ if stop is None:
211
+ n_frames = None
212
+ else:
213
+ n_frames = stop - start
214
+ if step is not None and n_frames is not None:
215
+ # Divide number of frames by 'step' in order to convert
216
+ # 'step' into 'stride'
217
+ # Since the 0th frame is always included,
218
+ # the number of frames is decremented before division
219
+ # and incremented afterwards again
220
+ n_frames = ((n_frames - 1) // step) + 1
221
+
222
+ # Read frames
223
+ if stack_size is None:
224
+ remaining_frames = n_frames
225
+ while remaining_frames is None or remaining_frames > 0:
226
+ result = f.read(1, stride=step, atom_indices=atom_i)
227
+ if len(result[0]) == 0:
228
+ # Empty array was read
229
+ # -> no frames left -> stop iteration
230
+ break
231
+ coord, box, time = cls.process_read_values(result)
232
+ # Only one frame
233
+ # -> only one element in first dimension
234
+ # -> remove first dimension
235
+ coord = coord[0]
236
+ box = box[0] if box is not None else None
237
+ time = float(time[0]) if time is not None else None
238
+ yield coord, box, time
239
+ if remaining_frames is not None:
240
+ remaining_frames -= 1
241
+
242
+ else:
243
+ remaining_frames = n_frames
244
+ while remaining_frames is None or remaining_frames > 0:
245
+ n_frames = (
246
+ min(remaining_frames, stack_size)
247
+ if remaining_frames is not None
248
+ else stack_size
249
+ )
250
+ result = f.read(n_frames, stride=step, atom_indices=atom_i)
251
+ if len(result[0]) == 0:
252
+ # Empty array was read
253
+ # -> no frames left -> stop iteration
254
+ break
255
+ coord, box, time = cls.process_read_values(result)
256
+ yield coord, box, time
257
+ if remaining_frames is not None:
258
+ remaining_frames -= stack_size
259
+
260
+ @classmethod
261
+ def read_iter_structure(
262
+ cls,
263
+ file_name,
264
+ template,
265
+ start=None,
266
+ stop=None,
267
+ step=None,
268
+ atom_i=None,
269
+ stack_size=None,
270
+ ):
271
+ """
272
+ Create an iterator over each frame of the given trajectory file
273
+ in the selected range.
274
+
275
+ In contrast to :func:`read_iter()`, this function creates an
276
+ iterator over the structure as :class:`AtomArray`.
277
+ Since trajectory files usually only contain atom coordinate
278
+ information and no topology information, this method requires
279
+ a template atom array or stack. This template can be acquired
280
+ for example from a PDB file, which is associated with the
281
+ trajectory file.
282
+
283
+ Parameters
284
+ ----------
285
+ file_name : str or Path
286
+ The path of the file to be read.
287
+ Any other file-like object cannot be used.
288
+ template : AtomArray or AtomArrayStack
289
+ The template array or stack, where the atom annotation data
290
+ is taken from.
291
+ start : int, optional
292
+ The frame index, where file parsing is started. If no value
293
+ is given, parsing starts at the first frame.
294
+ The index starts at 0.
295
+ stop : int, optional
296
+ The exclusive frame index, where file parsing ends.
297
+ If no value is given, parsing stops at the end of file.
298
+ The index starts at 0.
299
+ step : int, optional
300
+ If this value is set, the function reads only every n-th
301
+ frame from the file.
302
+ atom_i : ndarray, dtype=int, optional
303
+ If this parameter is set, only the atoms at the given
304
+ indices are read from each frame in the file.
305
+ stack_size : int, optional
306
+ If this parameter is set, multiple frames are combined into
307
+ an :class:`AtomArrayStack`.
308
+ The number of frames in the :class:`AtomArrayStack` is
309
+ determined by this parameter.
310
+ If the number of frames is not a multiple of `stack_size`,
311
+ the final stack is smaller than `stack_size`.
312
+
313
+ Yields
314
+ ------
315
+ structure : AtomArray or AtomArrayStack
316
+ The structure of the current frame as :class:`AtomArray`.
317
+ If `stack_size` is set, multiple frames are returned as
318
+ :class:`AtomArrayStack`.
319
+
320
+ See Also
321
+ --------
322
+ read_iter :
323
+ Get an the raw data for each frame or for each chunk of frames instead.
324
+
325
+ Notes
326
+ -----
327
+ This iterator creates a new copy of the given template for every
328
+ frame
329
+ (or stack of frames, if `stack_size` is set).
330
+ If a higher efficiency is required, please use the
331
+ :func:`read_iter()` function.
332
+
333
+ The `step` parameter does currently not work for *DCD* files.
334
+ """
335
+ if isinstance(template, AtomArrayStack):
336
+ template = template[0]
337
+ elif not isinstance(template, AtomArray):
338
+ raise TypeError(
339
+ f"An 'AtomArray' or 'AtomArrayStack' is expected as template, "
340
+ f"not '{type(template).__name__}'"
341
+ )
342
+
343
+ for coord, box, _ in cls.read_iter(
344
+ file_name, start, stop, step, atom_i, stack_size
345
+ ):
346
+ if stack_size is None:
347
+ frame = template.copy()
348
+ frame.coord = coord
349
+ frame.box = box
350
+ yield frame
351
+ else:
352
+ yield from_template(template, coord, box)
353
+
354
+ def write(self, file_name):
355
+ """
356
+ Write the content into a trajectory file.
357
+
358
+ Parameters
359
+ ----------
360
+ file_name : str or Path
361
+ The path of the file to be read.
362
+ Any other file-like object cannot be used.
363
+ """
364
+ traj_type = self.traj_type()
365
+ param = self.prepare_write_values(self._coord, self._box, self._time)
366
+ with traj_type(str(file_name), "w") as f:
367
+ f.write(**param)
368
+
369
+ @classmethod
370
+ def write_iter(cls, file_name, coord, box=None, time=None):
371
+ """
372
+ Iterate over the given `coord` and write each item into
373
+ the file specified by `file_name`.
374
+
375
+ In contrast to :meth:`write()`, the data is not stored in an
376
+ intermediate :class:`TrajectoryFile`, but is directly written
377
+ to the file.
378
+ Hence, this class method may save a large amount of memory if
379
+ a large file should be written, if `coord` are provided as
380
+ generator.
381
+
382
+ Parameters
383
+ ----------
384
+ file_name : str or Path
385
+ The path of the file to be read.
386
+ Any other file-like object cannot be used.
387
+ coord : generator or array-like of ndarray, shape=(n,3), dtype=float
388
+ The atom coordinates for each frame.
389
+ box : generator or array-like of ndarray, shape=(3,3), dtype=float, optional
390
+ The three box vectors for each frame.
391
+ time : generator or array-like of float, optional
392
+ The simulation time in *ps* for each frame.
393
+
394
+ Notes
395
+ -----
396
+ The `time` parameter has no effect for *DCD* files.
397
+ """
398
+ if box is None:
399
+ box = itertools.repeat(None)
400
+ if time is None:
401
+ time = itertools.repeat(None)
402
+
403
+ traj_type = cls.traj_type()
404
+ with traj_type(str(file_name), "w") as f:
405
+ for c, b, t in zip(coord, box, time):
406
+ if c.ndim != 2:
407
+ raise IndexError(
408
+ f"Expected ndarray with 2 dimensions, got {c.ndim}"
409
+ )
410
+ # Add new dimension of length one
411
+ # for compatibility with 'prepare_write_values()'
412
+ c = c[np.newaxis, :]
413
+ if b is not None:
414
+ b = np.expand_dims(b, axis=0)
415
+ if t is not None:
416
+ t = np.expand_dims(t, axis=0)
417
+ param = cls.prepare_write_values(c, b, t)
418
+ f.write(**param)
419
+
420
+ def get_coord(self):
421
+ """
422
+ Extract only the atom coordinates from the trajectory file.
423
+
424
+ Returns
425
+ -------
426
+ coord : ndarray, dtype=float, shape=(m,n,3)
427
+ The coordinates stored in the trajectory file.
428
+ """
429
+ return self._coord
430
+
431
+ def get_time(self):
432
+ """
433
+ Get the simlation time in *ps* values for each frame.
434
+
435
+ Returns
436
+ -------
437
+ time : ndarray, dtype=float, shape=(m,)
438
+ A one dimensional array containing the time values for the
439
+ frames, that were read from the file.
440
+ """
441
+ return self._time
442
+
443
+ def get_box(self):
444
+ """
445
+ Get the box vectors for each frame.
446
+
447
+ Returns
448
+ -------
449
+ box : ndarray, dtype=float, shape=(m,3,3)
450
+ An array containing the box dimensions for the
451
+ frames, that were read from the file.
452
+ """
453
+ return self._box
454
+
455
+ def set_coord(self, coord):
456
+ """
457
+ Set the atom coordinates in the trajectory file.
458
+
459
+ Parameters
460
+ ----------
461
+ coord : ndarray, dtype=float, shape=(m,n,3)
462
+ The coordinates to be set.
463
+ """
464
+ self._check_model_count(coord)
465
+ self._coord = coord
466
+
467
+ def set_time(self, time):
468
+ """
469
+ Set the simulation time of each frame in the trajectory file.
470
+
471
+ Parameters
472
+ ----------
473
+ time : ndarray, dtype=float, shape=(m,)
474
+ The simulation time in *ps* to be set.
475
+ """
476
+ self._check_model_count(time)
477
+ self._time = time
478
+
479
+ def set_box(self, box):
480
+ """
481
+ Set the periodic box vectors of each frame in the trajectory
482
+ file.
483
+
484
+ Parameters
485
+ ----------
486
+ box : ndarray, dtype=float, shape=(m,3,3)
487
+ The box vectors to be set.
488
+ """
489
+ self._check_model_count(box)
490
+ self._box = box
491
+
492
+ def get_structure(self, template):
493
+ """
494
+ Convert the trajectory file content into an
495
+ :class:`AtomArrayStack`.
496
+
497
+ Since trajectory files usually only contain atom coordinate
498
+ information and no topology information, this method requires
499
+ a template atom array or stack. This template can be acquired
500
+ for example from a PDB file, which is associated with the
501
+ trajectory file.
502
+
503
+ Parameters
504
+ ----------
505
+ template : AtomArray or AtomArrayStack
506
+ The template array or stack, where the atom annotation data
507
+ is taken from.
508
+
509
+ Returns
510
+ -------
511
+ array_stack : AtomArrayStack
512
+ A stack containing the annontation arrays from `template`
513
+ but the coordinates and the simulation boxes from the
514
+ trajectory file.
515
+ """
516
+ return from_template(template, self.get_coord(), self.get_box())
517
+
518
+ def set_structure(self, structure, time=None):
519
+ """
520
+ Write an atom array (stack) into the trajectory file object.
521
+
522
+ The topology information (chain, residue, etc.) is not saved in
523
+ the file.
524
+
525
+ Parameters
526
+ ----------
527
+ structure : AtomArray or AtomArrayStack
528
+ The structure to be put into the trajectory file.
529
+ time : ndarray, dtype=float, shape=(n,), optional
530
+ The simulation time for each frame in `structure`.
531
+ """
532
+ coord = structure.coord
533
+ box = structure.box
534
+ if coord.ndim == 2:
535
+ coord = coord[np.newaxis, :, :]
536
+ if box is not None and box.ndim == 2:
537
+ box = box[np.newaxis, :, :]
538
+ self.set_coord(coord)
539
+ if box is not None:
540
+ self.set_box(box)
541
+ if time is not None:
542
+ self.set_time(time)
543
+
544
+ def copy(self):
545
+ """
546
+ This operation is not implemented for trajectory files.
547
+
548
+ Raises
549
+ ------
550
+ NotImplementedError
551
+ """
552
+ raise NotImplementedError("Copying is not implemented for trajectory files")
553
+
554
+ @classmethod
555
+ @abc.abstractmethod
556
+ def traj_type(cls):
557
+ """
558
+ The ``biotraj`` files class to be used.
559
+
560
+ PROTECTED: Override when inheriting.
561
+
562
+ Returns
563
+ -------
564
+ class
565
+ An ``biotraj`` subclass of :class:`TrajectoryFile`.
566
+ """
567
+ pass
568
+
569
+ @classmethod
570
+ @abc.abstractmethod
571
+ def process_read_values(cls, read_values):
572
+ """
573
+ Convert the return value of the `read()` method of the
574
+ respective :class:`biotraj.TrajectoryFile` into coordinates,
575
+ simulation box and simulation time.
576
+
577
+ PROTECTED: Override when inheriting.
578
+
579
+ Parameters
580
+ ----------
581
+ read_values : tuple
582
+ The return value of the respective
583
+ :func:`biotraj.TrajectoryFile.read()` method.
584
+
585
+ Returns
586
+ -------
587
+ coord : ndarray, dtype=float, shape=(m,n,3)
588
+ The atom coordinates in Å for each frame.
589
+ box : ndarray, dtype=float, shape=(m,3,3) or None
590
+ The box vectors in Å for each frame.
591
+ time : ndarray, dtype=float, shape=(m,) or None
592
+ The simulation time in ps for each frame.
593
+ """
594
+ pass
595
+
596
+ @classmethod
597
+ @abc.abstractmethod
598
+ def prepare_write_values(cls, coord, box, time):
599
+ """
600
+ Convert the `coord`, `box` and `time` attribute into a
601
+ dictionary that is given as *kwargs* to the respective
602
+ :func:`biotraj.TrajectoryFile.write()` method.
603
+
604
+ PROTECTED: Override when inheriting.
605
+
606
+ Parameters
607
+ ----------
608
+ coord : ndarray, dtype=float, shape=(m,n,3)
609
+ The atom coordinates in Å for each frame.
610
+ box : ndarray, dtype=float, shape=(m,3,3)
611
+ The box vectors in Å for each frame.
612
+ time : ndarray, dtype=float, shape=(m,)
613
+ The simulation time in ps for each frame.
614
+
615
+ Returns
616
+ -------
617
+ parameters : dict
618
+ This dictionary is given as *kwargs* parameter to the
619
+ respective :func:`biotraj.TrajectoryFile.write()` method.
620
+ """
621
+ pass
622
+
623
+ def _check_model_count(self, array):
624
+ """
625
+ Check if the amount of models in the given array is equal to
626
+ the amount of models in the file.
627
+ If not, raise an exception.
628
+ If the amount of models in the file is not set yet, set it with
629
+ the amount of models in the array.
630
+ """
631
+ if array is None:
632
+ return
633
+ if self._model_count is None:
634
+ self._model_count = len(array)
635
+ else:
636
+ if self._model_count != len(array):
637
+ raise ValueError(
638
+ f"{len(array)} models were given, "
639
+ f"but the file contains {self._model_count} models"
640
+ )
641
+
642
+ @staticmethod
643
+ def _read_chunk_wise(file, n_frames, step, atom_i, chunk_size, discard=False):
644
+ """
645
+ Similar to :func:`read()`, just for chunk-wise reading of the
646
+ trajectory.
647
+
648
+ `n_frames` is already the actual number of frames in the output
649
+ arrays, i.e. the original number was divided by `step`.
650
+ """
651
+ chunks = []
652
+ remaining_frames = n_frames
653
+ # If n_frames is None, this is condition is never False
654
+ # -> break out of loop when read chunk is empty (see below)
655
+ while remaining_frames != 0:
656
+ if remaining_frames is not None:
657
+ n = min(remaining_frames, chunk_size)
658
+ else:
659
+ n = chunk_size
660
+ try:
661
+ chunk = file.read(n_frames=n, stride=step, atom_indices=atom_i)
662
+ except ValueError as e:
663
+ # biotraj raises exception because no coordinates can be
664
+ # concatenated
665
+ # -> all frames have been read
666
+ # -> stop reading chunks
667
+ if str(e) != "need at least one array to concatenate":
668
+ raise
669
+ else:
670
+ break
671
+ if len(chunk[0]) == 0:
672
+ # Coordinates have a length of 0
673
+ # -> all frames have been read
674
+ # -> stop reading chunks
675
+ break
676
+ if not discard:
677
+ chunks.append(chunk)
678
+ if remaining_frames is not None:
679
+ remaining_frames -= n
680
+
681
+ if not discard:
682
+ # Assemble the chunks into contiguous arrays
683
+ # for each value (coord, box, time)
684
+ result = [None] * len(chunks[0])
685
+ # Iterate over all values in the result tuple
686
+ # and concatenate the corresponding value from each chunk,
687
+ # if the value is not None
688
+ # The amount of values is determined from the first chunk
689
+ for i in range(len(chunks[0])):
690
+ if chunks[0][i] is not None:
691
+ result[i] = np.concatenate([chunk[i] for chunk in chunks])
692
+ else:
693
+ result[i] = None
694
+ return tuple(result)
695
+ else:
696
+ return None
@@ -0,0 +1,13 @@
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 trajectories in the
7
+ uncompressed *Gromacs* TRR format.
8
+ """
9
+
10
+ __name__ = "biotite.structure.io.trr"
11
+ __author__ = "Patrick Kunzmann"
12
+
13
+ from .file import *