biotite 1.1.0__cp313-cp313-manylinux_2_17_x86_64.manylinux2014_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 (332) 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 +159 -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 +452 -0
  22. biotite/application/tantan/__init__.py +12 -0
  23. biotite/application/tantan/app.py +199 -0
  24. biotite/application/util.py +57 -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 +206 -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/entrez/__init__.py +15 -0
  34. biotite/database/entrez/check.py +60 -0
  35. biotite/database/entrez/dbnames.py +91 -0
  36. biotite/database/entrez/download.py +229 -0
  37. biotite/database/entrez/key.py +44 -0
  38. biotite/database/entrez/query.py +262 -0
  39. biotite/database/error.py +16 -0
  40. biotite/database/pubchem/__init__.py +21 -0
  41. biotite/database/pubchem/download.py +258 -0
  42. biotite/database/pubchem/error.py +20 -0
  43. biotite/database/pubchem/query.py +830 -0
  44. biotite/database/pubchem/throttle.py +98 -0
  45. biotite/database/rcsb/__init__.py +13 -0
  46. biotite/database/rcsb/download.py +159 -0
  47. biotite/database/rcsb/query.py +964 -0
  48. biotite/database/uniprot/__init__.py +13 -0
  49. biotite/database/uniprot/check.py +40 -0
  50. biotite/database/uniprot/download.py +129 -0
  51. biotite/database/uniprot/query.py +293 -0
  52. biotite/file.py +232 -0
  53. biotite/sequence/__init__.py +84 -0
  54. biotite/sequence/align/__init__.py +203 -0
  55. biotite/sequence/align/alignment.py +680 -0
  56. biotite/sequence/align/banded.cpython-313-x86_64-linux-gnu.so +0 -0
  57. biotite/sequence/align/banded.pyx +652 -0
  58. biotite/sequence/align/buckets.py +71 -0
  59. biotite/sequence/align/cigar.py +425 -0
  60. biotite/sequence/align/kmeralphabet.cpython-313-x86_64-linux-gnu.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +595 -0
  62. biotite/sequence/align/kmersimilarity.cpython-313-x86_64-linux-gnu.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-313-x86_64-linux-gnu.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3411 -0
  66. biotite/sequence/align/localgapped.cpython-313-x86_64-linux-gnu.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-313-x86_64-linux-gnu.so +0 -0
  69. biotite/sequence/align/localungapped.pyx +279 -0
  70. biotite/sequence/align/matrix.py +622 -0
  71. biotite/sequence/align/matrix_data/3Di.mat +24 -0
  72. biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
  73. biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
  74. biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
  75. biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
  76. biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
  77. biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
  78. biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
  79. biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
  80. biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
  81. biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
  82. biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
  83. biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
  84. biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
  85. biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
  86. biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
  87. biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
  88. biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
  89. biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
  90. biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
  91. biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
  92. biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
  93. biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
  94. biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
  95. biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
  96. biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
  97. biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
  98. biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
  99. biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
  100. biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
  101. biotite/sequence/align/matrix_data/GONNET.mat +26 -0
  102. biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
  103. biotite/sequence/align/matrix_data/MATCH.mat +25 -0
  104. biotite/sequence/align/matrix_data/NUC.mat +25 -0
  105. biotite/sequence/align/matrix_data/PAM10.mat +34 -0
  106. biotite/sequence/align/matrix_data/PAM100.mat +34 -0
  107. biotite/sequence/align/matrix_data/PAM110.mat +34 -0
  108. biotite/sequence/align/matrix_data/PAM120.mat +34 -0
  109. biotite/sequence/align/matrix_data/PAM130.mat +34 -0
  110. biotite/sequence/align/matrix_data/PAM140.mat +34 -0
  111. biotite/sequence/align/matrix_data/PAM150.mat +34 -0
  112. biotite/sequence/align/matrix_data/PAM160.mat +34 -0
  113. biotite/sequence/align/matrix_data/PAM170.mat +34 -0
  114. biotite/sequence/align/matrix_data/PAM180.mat +34 -0
  115. biotite/sequence/align/matrix_data/PAM190.mat +34 -0
  116. biotite/sequence/align/matrix_data/PAM20.mat +34 -0
  117. biotite/sequence/align/matrix_data/PAM200.mat +34 -0
  118. biotite/sequence/align/matrix_data/PAM210.mat +34 -0
  119. biotite/sequence/align/matrix_data/PAM220.mat +34 -0
  120. biotite/sequence/align/matrix_data/PAM230.mat +34 -0
  121. biotite/sequence/align/matrix_data/PAM240.mat +34 -0
  122. biotite/sequence/align/matrix_data/PAM250.mat +34 -0
  123. biotite/sequence/align/matrix_data/PAM260.mat +34 -0
  124. biotite/sequence/align/matrix_data/PAM270.mat +34 -0
  125. biotite/sequence/align/matrix_data/PAM280.mat +34 -0
  126. biotite/sequence/align/matrix_data/PAM290.mat +34 -0
  127. biotite/sequence/align/matrix_data/PAM30.mat +34 -0
  128. biotite/sequence/align/matrix_data/PAM300.mat +34 -0
  129. biotite/sequence/align/matrix_data/PAM310.mat +34 -0
  130. biotite/sequence/align/matrix_data/PAM320.mat +34 -0
  131. biotite/sequence/align/matrix_data/PAM330.mat +34 -0
  132. biotite/sequence/align/matrix_data/PAM340.mat +34 -0
  133. biotite/sequence/align/matrix_data/PAM350.mat +34 -0
  134. biotite/sequence/align/matrix_data/PAM360.mat +34 -0
  135. biotite/sequence/align/matrix_data/PAM370.mat +34 -0
  136. biotite/sequence/align/matrix_data/PAM380.mat +34 -0
  137. biotite/sequence/align/matrix_data/PAM390.mat +34 -0
  138. biotite/sequence/align/matrix_data/PAM40.mat +34 -0
  139. biotite/sequence/align/matrix_data/PAM400.mat +34 -0
  140. biotite/sequence/align/matrix_data/PAM410.mat +34 -0
  141. biotite/sequence/align/matrix_data/PAM420.mat +34 -0
  142. biotite/sequence/align/matrix_data/PAM430.mat +34 -0
  143. biotite/sequence/align/matrix_data/PAM440.mat +34 -0
  144. biotite/sequence/align/matrix_data/PAM450.mat +34 -0
  145. biotite/sequence/align/matrix_data/PAM460.mat +34 -0
  146. biotite/sequence/align/matrix_data/PAM470.mat +34 -0
  147. biotite/sequence/align/matrix_data/PAM480.mat +34 -0
  148. biotite/sequence/align/matrix_data/PAM490.mat +34 -0
  149. biotite/sequence/align/matrix_data/PAM50.mat +34 -0
  150. biotite/sequence/align/matrix_data/PAM500.mat +34 -0
  151. biotite/sequence/align/matrix_data/PAM60.mat +34 -0
  152. biotite/sequence/align/matrix_data/PAM70.mat +34 -0
  153. biotite/sequence/align/matrix_data/PAM80.mat +34 -0
  154. biotite/sequence/align/matrix_data/PAM90.mat +34 -0
  155. biotite/sequence/align/matrix_data/PB.license +21 -0
  156. biotite/sequence/align/matrix_data/PB.mat +18 -0
  157. biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
  158. biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
  159. biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
  160. biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
  161. biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
  162. biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
  163. biotite/sequence/align/multiple.cpython-313-x86_64-linux-gnu.so +0 -0
  164. biotite/sequence/align/multiple.pyx +620 -0
  165. biotite/sequence/align/pairwise.cpython-313-x86_64-linux-gnu.so +0 -0
  166. biotite/sequence/align/pairwise.pyx +587 -0
  167. biotite/sequence/align/permutation.cpython-313-x86_64-linux-gnu.so +0 -0
  168. biotite/sequence/align/permutation.pyx +313 -0
  169. biotite/sequence/align/primes.txt +821 -0
  170. biotite/sequence/align/selector.cpython-313-x86_64-linux-gnu.so +0 -0
  171. biotite/sequence/align/selector.pyx +954 -0
  172. biotite/sequence/align/statistics.py +264 -0
  173. biotite/sequence/align/tracetable.cpython-313-x86_64-linux-gnu.so +0 -0
  174. biotite/sequence/align/tracetable.pxd +64 -0
  175. biotite/sequence/align/tracetable.pyx +370 -0
  176. biotite/sequence/alphabet.py +555 -0
  177. biotite/sequence/annotation.py +830 -0
  178. biotite/sequence/codec.cpython-313-x86_64-linux-gnu.so +0 -0
  179. biotite/sequence/codec.pyx +155 -0
  180. biotite/sequence/codon.py +477 -0
  181. biotite/sequence/codon_tables.txt +202 -0
  182. biotite/sequence/graphics/__init__.py +33 -0
  183. biotite/sequence/graphics/alignment.py +1115 -0
  184. biotite/sequence/graphics/color_schemes/3di_flower.json +48 -0
  185. biotite/sequence/graphics/color_schemes/autumn.json +51 -0
  186. biotite/sequence/graphics/color_schemes/blossom.json +51 -0
  187. biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
  188. biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
  189. biotite/sequence/graphics/color_schemes/flower.json +51 -0
  190. biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
  191. biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
  192. biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
  193. biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
  194. biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
  195. biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
  196. biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
  197. biotite/sequence/graphics/color_schemes/ocean.json +51 -0
  198. biotite/sequence/graphics/color_schemes/pb_flower.json +40 -0
  199. biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
  200. biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
  201. biotite/sequence/graphics/color_schemes/spring.json +51 -0
  202. biotite/sequence/graphics/color_schemes/sunset.json +51 -0
  203. biotite/sequence/graphics/color_schemes/wither.json +51 -0
  204. biotite/sequence/graphics/colorschemes.py +170 -0
  205. biotite/sequence/graphics/dendrogram.py +229 -0
  206. biotite/sequence/graphics/features.py +544 -0
  207. biotite/sequence/graphics/logo.py +104 -0
  208. biotite/sequence/graphics/plasmid.py +712 -0
  209. biotite/sequence/io/__init__.py +12 -0
  210. biotite/sequence/io/fasta/__init__.py +22 -0
  211. biotite/sequence/io/fasta/convert.py +284 -0
  212. biotite/sequence/io/fasta/file.py +265 -0
  213. biotite/sequence/io/fastq/__init__.py +19 -0
  214. biotite/sequence/io/fastq/convert.py +117 -0
  215. biotite/sequence/io/fastq/file.py +507 -0
  216. biotite/sequence/io/genbank/__init__.py +17 -0
  217. biotite/sequence/io/genbank/annotation.py +269 -0
  218. biotite/sequence/io/genbank/file.py +573 -0
  219. biotite/sequence/io/genbank/metadata.py +336 -0
  220. biotite/sequence/io/genbank/sequence.py +171 -0
  221. biotite/sequence/io/general.py +201 -0
  222. biotite/sequence/io/gff/__init__.py +26 -0
  223. biotite/sequence/io/gff/convert.py +128 -0
  224. biotite/sequence/io/gff/file.py +450 -0
  225. biotite/sequence/phylo/__init__.py +36 -0
  226. biotite/sequence/phylo/nj.cpython-313-x86_64-linux-gnu.so +0 -0
  227. biotite/sequence/phylo/nj.pyx +221 -0
  228. biotite/sequence/phylo/tree.cpython-313-x86_64-linux-gnu.so +0 -0
  229. biotite/sequence/phylo/tree.pyx +1169 -0
  230. biotite/sequence/phylo/upgma.cpython-313-x86_64-linux-gnu.so +0 -0
  231. biotite/sequence/phylo/upgma.pyx +164 -0
  232. biotite/sequence/profile.py +567 -0
  233. biotite/sequence/search.py +118 -0
  234. biotite/sequence/seqtypes.py +713 -0
  235. biotite/sequence/sequence.py +374 -0
  236. biotite/setup_ccd.py +197 -0
  237. biotite/structure/__init__.py +133 -0
  238. biotite/structure/alphabet/__init__.py +25 -0
  239. biotite/structure/alphabet/encoder.py +332 -0
  240. biotite/structure/alphabet/encoder_weights_3di.kerasify +0 -0
  241. biotite/structure/alphabet/i3d.py +110 -0
  242. biotite/structure/alphabet/layers.py +86 -0
  243. biotite/structure/alphabet/pb.license +21 -0
  244. biotite/structure/alphabet/pb.py +171 -0
  245. biotite/structure/alphabet/unkerasify.py +122 -0
  246. biotite/structure/atoms.py +1554 -0
  247. biotite/structure/basepairs.py +1404 -0
  248. biotite/structure/bonds.cpython-313-x86_64-linux-gnu.so +0 -0
  249. biotite/structure/bonds.pyx +1972 -0
  250. biotite/structure/box.py +588 -0
  251. biotite/structure/celllist.cpython-313-x86_64-linux-gnu.so +0 -0
  252. biotite/structure/celllist.pyx +849 -0
  253. biotite/structure/chains.py +314 -0
  254. biotite/structure/charges.cpython-313-x86_64-linux-gnu.so +0 -0
  255. biotite/structure/charges.pyx +520 -0
  256. biotite/structure/compare.py +274 -0
  257. biotite/structure/density.py +109 -0
  258. biotite/structure/dotbracket.py +214 -0
  259. biotite/structure/error.py +39 -0
  260. biotite/structure/filter.py +590 -0
  261. biotite/structure/geometry.py +655 -0
  262. biotite/structure/graphics/__init__.py +13 -0
  263. biotite/structure/graphics/atoms.py +243 -0
  264. biotite/structure/graphics/rna.py +295 -0
  265. biotite/structure/hbond.py +428 -0
  266. biotite/structure/info/__init__.py +24 -0
  267. biotite/structure/info/atom_masses.json +121 -0
  268. biotite/structure/info/atoms.py +81 -0
  269. biotite/structure/info/bonds.py +149 -0
  270. biotite/structure/info/ccd.py +202 -0
  271. biotite/structure/info/components.bcif +0 -0
  272. biotite/structure/info/groups.py +131 -0
  273. biotite/structure/info/masses.py +121 -0
  274. biotite/structure/info/misc.py +138 -0
  275. biotite/structure/info/radii.py +197 -0
  276. biotite/structure/info/standardize.py +186 -0
  277. biotite/structure/integrity.py +215 -0
  278. biotite/structure/io/__init__.py +29 -0
  279. biotite/structure/io/dcd/__init__.py +13 -0
  280. biotite/structure/io/dcd/file.py +67 -0
  281. biotite/structure/io/general.py +243 -0
  282. biotite/structure/io/gro/__init__.py +14 -0
  283. biotite/structure/io/gro/file.py +344 -0
  284. biotite/structure/io/mol/__init__.py +20 -0
  285. biotite/structure/io/mol/convert.py +112 -0
  286. biotite/structure/io/mol/ctab.py +415 -0
  287. biotite/structure/io/mol/header.py +120 -0
  288. biotite/structure/io/mol/mol.py +149 -0
  289. biotite/structure/io/mol/sdf.py +914 -0
  290. biotite/structure/io/netcdf/__init__.py +13 -0
  291. biotite/structure/io/netcdf/file.py +64 -0
  292. biotite/structure/io/pdb/__init__.py +20 -0
  293. biotite/structure/io/pdb/convert.py +307 -0
  294. biotite/structure/io/pdb/file.py +1290 -0
  295. biotite/structure/io/pdb/hybrid36.cpython-313-x86_64-linux-gnu.so +0 -0
  296. biotite/structure/io/pdb/hybrid36.pyx +242 -0
  297. biotite/structure/io/pdbqt/__init__.py +15 -0
  298. biotite/structure/io/pdbqt/convert.py +113 -0
  299. biotite/structure/io/pdbqt/file.py +688 -0
  300. biotite/structure/io/pdbx/__init__.py +23 -0
  301. biotite/structure/io/pdbx/bcif.py +656 -0
  302. biotite/structure/io/pdbx/cif.py +1075 -0
  303. biotite/structure/io/pdbx/component.py +245 -0
  304. biotite/structure/io/pdbx/compress.py +321 -0
  305. biotite/structure/io/pdbx/convert.py +1745 -0
  306. biotite/structure/io/pdbx/encoding.cpython-313-x86_64-linux-gnu.so +0 -0
  307. biotite/structure/io/pdbx/encoding.pyx +1031 -0
  308. biotite/structure/io/trajfile.py +693 -0
  309. biotite/structure/io/trr/__init__.py +13 -0
  310. biotite/structure/io/trr/file.py +43 -0
  311. biotite/structure/io/xtc/__init__.py +13 -0
  312. biotite/structure/io/xtc/file.py +43 -0
  313. biotite/structure/mechanics.py +73 -0
  314. biotite/structure/molecules.py +352 -0
  315. biotite/structure/pseudoknots.py +628 -0
  316. biotite/structure/rdf.py +245 -0
  317. biotite/structure/repair.py +304 -0
  318. biotite/structure/residues.py +572 -0
  319. biotite/structure/sasa.cpython-313-x86_64-linux-gnu.so +0 -0
  320. biotite/structure/sasa.pyx +322 -0
  321. biotite/structure/segments.py +178 -0
  322. biotite/structure/sequence.py +111 -0
  323. biotite/structure/sse.py +308 -0
  324. biotite/structure/superimpose.py +689 -0
  325. biotite/structure/transform.py +530 -0
  326. biotite/structure/util.py +168 -0
  327. biotite/version.py +16 -0
  328. biotite/visualize.py +265 -0
  329. biotite-1.1.0.dist-info/METADATA +190 -0
  330. biotite-1.1.0.dist-info/RECORD +332 -0
  331. biotite-1.1.0.dist-info/WHEEL +6 -0
  332. biotite-1.1.0.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,344 @@
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 copy
10
+ from datetime import datetime
11
+ import numpy as np
12
+ from biotite.file import InvalidFileError, TextFile
13
+ from biotite.structure.atoms import AtomArray, AtomArrayStack
14
+ from biotite.structure.box import is_orthogonal
15
+ from biotite.structure.error import BadStructureError
16
+ from biotite.structure.repair import infer_elements
17
+
18
+ _atom_records = {
19
+ "res_id": (0, 5),
20
+ "res_name": (5, 10),
21
+ "atom_name": (10, 15),
22
+ "atom_id": (15, 20),
23
+ "coord_x": (20, 28),
24
+ "coord_y": (28, 36),
25
+ "coord_z": (36, 44),
26
+ "v_x": (44, 52),
27
+ "v_y": (52, 60),
28
+ "v_z": (60, 68),
29
+ }
30
+
31
+
32
+ class GROFile(TextFile):
33
+ r"""
34
+ This class represents a GRO file.
35
+
36
+ This class only provides support for reading/writing the pure atom
37
+ information
38
+
39
+ Examples
40
+ --------
41
+ Load a `\\*.gro` file, modify the structure and save the new
42
+ structure into a new file:
43
+
44
+ >>> import os.path
45
+ >>> file = GROFile.read(os.path.join(path_to_structures, "1l2y.gro"))
46
+ >>> array_stack = file.get_structure()
47
+ >>> array_stack_mod = rotate(array_stack, [1,2,3])
48
+ >>> file = GROFile()
49
+ >>> file.set_structure(array_stack_mod)
50
+ >>> file.write(os.path.join(path_to_directory, "1l2y_mod.gro"))
51
+
52
+ """
53
+
54
+ def get_model_count(self):
55
+ """
56
+ Get the number of models contained in this GRO file.
57
+
58
+ Returns
59
+ -------
60
+ model_count : int
61
+ The number of models.
62
+ """
63
+ model_count = 0
64
+ for line in self.lines:
65
+ if _is_int(line):
66
+ model_count += 1
67
+ return model_count
68
+
69
+ def get_structure(self, model=None):
70
+ """
71
+ Get an :class:`AtomArray` or :class:`AtomArrayStack` from the
72
+ GRO file.
73
+
74
+ Parameters
75
+ ----------
76
+ model : int, optional
77
+ If this parameter is given, the function will return an
78
+ :class:`AtomArray` from the atoms corresponding to the given
79
+ model number (starting at 1).
80
+ Negative values are used to index models starting from the
81
+ last model insted of the first model.
82
+ If this parameter is omitted, an :class:`AtomArrayStack`
83
+ containing all models will be returned, even if the
84
+ structure contains only one model.
85
+
86
+ Returns
87
+ -------
88
+ array : AtomArray or AtomArrayStack
89
+ The return type depends on the `model` parameter.
90
+ """
91
+
92
+ def get_atom_line_i(model_start_i, model_atom_counts):
93
+ """
94
+ Helper function to get the indices of all atoms for a model
95
+ """
96
+ return np.arange(model_start_i + 1, model_start_i + 1 + model_atom_counts)
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([[x1, x2, x3], [y1, y2, y3], [z1, z2, z3]], dtype=float)
121
+ else:
122
+ raise InvalidFileError(
123
+ f"Invalid amount of box parameters: {len(box_param)}"
124
+ )
125
+
126
+ # Line indices where a new model starts
127
+ model_start_i = np.array(
128
+ [i for i in range(len(self.lines)) if _is_int(self.lines[i])], dtype=int
129
+ )
130
+
131
+ # Number of atoms in each model
132
+ model_atom_counts = np.array([int(self.lines[i]) for i in model_start_i])
133
+
134
+ if model is None:
135
+ # Check if all models have the same length
136
+ if np.all(model_atom_counts != model_atom_counts[0]):
137
+ raise BadStructureError(
138
+ "The models in the file have unequal "
139
+ "amount of atoms, give an explicit "
140
+ "model instead"
141
+ )
142
+ depth = len(model_start_i)
143
+ length = model_atom_counts[0]
144
+ array = AtomArrayStack(depth, length)
145
+
146
+ # Line indices for annotation determination is determined
147
+ # from model 1
148
+ annot_i = get_atom_line_i(model_start_i[0], length)
149
+ else:
150
+ if model == 0:
151
+ raise ValueError("The model index must not be 0")
152
+ # Negative models mean index starting from last model
153
+ model = len(model_start_i) + model + 1 if model < 0 else model
154
+ if model > len(model_start_i):
155
+ raise ValueError(
156
+ f"The file has {len(model_start_i)} models, "
157
+ f"the given model {model} does not exist"
158
+ )
159
+
160
+ length = model_atom_counts[model - 1]
161
+ array = AtomArray(length)
162
+
163
+ annot_i = get_atom_line_i(model_start_i[model - 1], length)
164
+
165
+ # Replace empty strings for elements with guessed types
166
+ # i is index in array, line_i is line index
167
+ for i, line_i in enumerate(annot_i):
168
+ line = self.lines[line_i]
169
+ array.res_id[i] = int(line[0:5])
170
+ array.res_name[i] = line[5:10].strip()
171
+ array.atom_name[i] = line[10:15].strip()
172
+ array.element = infer_elements(array.atom_name)
173
+
174
+ # Fill in coordinates and boxes
175
+ if isinstance(array, AtomArray):
176
+ atom_i = annot_i
177
+ for i, line_i in enumerate(atom_i):
178
+ line = self.lines[line_i]
179
+ # gro files use nm instead of A
180
+ array.coord[i, 0] = float(line[20:28]) * 10
181
+ array.coord[i, 1] = float(line[28:36]) * 10
182
+ array.coord[i, 2] = float(line[36:44]) * 10
183
+ # Box is stored in last line (after coordinates)
184
+ box_i = atom_i[-1] + 1
185
+ box_param = [float(e) * 10 for e in self.lines[box_i].split()]
186
+ array.box = set_box_dimen(box_param)
187
+
188
+ elif isinstance(array, AtomArrayStack):
189
+ for m in range(len(model_start_i)):
190
+ atom_i = get_atom_line_i(model_start_i[m], model_atom_counts[m])
191
+ for i, line_i in enumerate(atom_i):
192
+ line = self.lines[line_i]
193
+ array.coord[m, i, 0] = float(line[20:28]) * 10
194
+ array.coord[m, i, 1] = float(line[28:36]) * 10
195
+ array.coord[m, i, 2] = float(line[36:44]) * 10
196
+ # Box is stored in last line (after coordinates)
197
+ box_i = atom_i[-1] + 1
198
+ box_param = [float(e) * 10 for e in self.lines[box_i].split()]
199
+ box = set_box_dimen(box_param)
200
+ # Create a box in the stack if not already existing
201
+ # and the box is not a dummy
202
+ if box is not None:
203
+ if array.box is None:
204
+ array.box = np.zeros((array.stack_depth(), 3, 3))
205
+ array.box[m] = box
206
+
207
+ return array
208
+
209
+ def set_structure(self, array):
210
+ """
211
+ Set the :class:`AtomArray` or :class:`AtomArrayStack` for the
212
+ file.
213
+
214
+ Parameters
215
+ ----------
216
+ array : AtomArray or AtomArrayStack
217
+ The array or stack to be saved into this file. If a stack
218
+ is given, each array in the stack is saved as separate
219
+ model.
220
+ """
221
+
222
+ def get_box_dimen(array):
223
+ """
224
+ GRO files have the box dimensions as last line for each
225
+ model.
226
+ In case, the `box` attribute of the atom array is
227
+ `None`, we simply use the min and max coordinates in xyz
228
+ to get the correct size
229
+
230
+ Parameters
231
+ ----------
232
+ array : AtomArray
233
+ The atom array to get the box dimensions from.
234
+
235
+ Returns
236
+ -------
237
+ box : str
238
+ The box, properly formatted for GRO files.
239
+ """
240
+ if array.box is None:
241
+ coord = array.coord
242
+ bx, by, bz = (coord.max(axis=0) - coord.min(axis=0)) / 10
243
+ return f"{bx:>8.3f} {by:>8.3f} {bz:>8.3f}"
244
+ else:
245
+ box = array.box
246
+ if is_orthogonal(box):
247
+ bx, by, bz = np.diag(box) / 10
248
+ return f"{bx:>9.5f} {by:>9.5f} {bz:>9.5f}"
249
+ else:
250
+ box = box / 10
251
+ box_elements = (
252
+ box[0, 0],
253
+ box[1, 1],
254
+ box[2, 2],
255
+ box[0, 1],
256
+ box[0, 2],
257
+ box[1, 0],
258
+ box[1, 2],
259
+ box[2, 0],
260
+ box[2, 1],
261
+ )
262
+ return " ".join([f"{e:>9.5f}" for e in box_elements])
263
+
264
+ if "atom_id" in array.get_annotation_categories():
265
+ atom_id = array.atom_id
266
+ else:
267
+ atom_id = np.arange(1, array.array_length() + 1)
268
+ # Atom IDs are supported up to 99999,
269
+ # but negative IDs are also possible
270
+ gro_atom_id = np.where(atom_id > 0, ((atom_id - 1) % 99999) + 1, atom_id)
271
+ # Residue IDs are supported up to 9999,
272
+ # but negative IDs are also possible
273
+ gro_res_id = np.where(
274
+ array.res_id > 0, ((array.res_id - 1) % 99999) + 1, array.res_id
275
+ )
276
+
277
+ if isinstance(array, AtomArray):
278
+ self.lines = [None] * (array.array_length() + 3)
279
+
280
+ # Write header lines
281
+ self.lines[0] = f"Generated by Biotite at {datetime.now()}"
282
+ self.lines[1] = str(array.array_length())
283
+
284
+ # Write atom lines
285
+ fmt = "{:>5d}{:5s}{:>5s}{:>5d}{:>8.3f}{:>8.3f}{:>8.3f}"
286
+ for i in range(array.array_length()):
287
+ # gro format is in nm -> multiply coords by 10
288
+ self.lines[i + 2] = fmt.format(
289
+ gro_res_id[i],
290
+ array.res_name[i],
291
+ array.atom_name[i],
292
+ gro_atom_id[i],
293
+ array.coord[i, 0] / 10,
294
+ array.coord[i, 1] / 10,
295
+ array.coord[i, 2] / 10,
296
+ )
297
+ # Write box lines
298
+ self.lines[-1] = get_box_dimen(array)
299
+ elif isinstance(array, AtomArrayStack):
300
+ self.lines = []
301
+ # The entire information, but the coordinates,
302
+ # is equal for each model
303
+ # Therefore template lines are created
304
+ # which are afterwards applied for each model
305
+ templines = [None] * array.array_length()
306
+ fmt = "{:>5d}{:5s}{:>5s}{:5d}"
307
+ for i in range(array.array_length()):
308
+ templines[i] = fmt.format(
309
+ gro_res_id[i], array.res_name[i], array.atom_name[i], gro_atom_id[i]
310
+ )
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
+ )
327
+ modellines[j] = line
328
+ self.lines.extend(modellines)
329
+ self.lines.append(get_box_dimen(array[i]))
330
+ else:
331
+ raise TypeError("An atom array or stack must be provided")
332
+ # Add terminal newline, since PyMOL requires it
333
+ self.lines.append("")
334
+
335
+
336
+ def _is_int(string):
337
+ """
338
+ Return ``True`, if the string can be parsed to an int.
339
+ """
340
+ try:
341
+ int(string)
342
+ return True
343
+ except ValueError:
344
+ return False
@@ -0,0 +1,20 @@
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
+ The MOL format is used to depict atom positions and bonds for small
7
+ molecules.
8
+ This subpackage is used for reading and writing an :class:`AtomArray`
9
+ in this format.
10
+ Additionally, reading data from the SDF format, which is a wrapper
11
+ around MOL, is also supported.
12
+ """
13
+
14
+ __name__ = "biotite.structure.io.mol"
15
+ __author__ = "Patrick Kunzmann"
16
+
17
+ from .convert import *
18
+ from .header import *
19
+ from .mol import *
20
+ from .sdf import *
@@ -0,0 +1,112 @@
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.mol"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["get_structure", "set_structure"]
8
+
9
+ from biotite.structure.bonds import BondType
10
+ from biotite.structure.io.mol.mol import MOLFile
11
+ from biotite.structure.io.mol.sdf import SDFile, SDRecord
12
+
13
+
14
+ def get_structure(mol_file, record_name=None):
15
+ """
16
+ Get an :class:`AtomArray` from the MOL file.
17
+
18
+ Ths function is a thin wrapper around
19
+ :meth:`MOLFile.get_structure()`.
20
+
21
+ Parameters
22
+ ----------
23
+ mol_file : MOLFile or SDFile or SDRecord
24
+ The file.
25
+ record_name : str, optional
26
+ Has only an effect when `mol_file` is a :class:`SDFile`.
27
+ The name of the record in the SD file.
28
+ By default, the first record is used.
29
+
30
+ Returns
31
+ -------
32
+ array : AtomArray
33
+ This :class:`AtomArray` contains the optional ``charge``
34
+ annotation and has an associated :class:`BondList`.
35
+ All other annotation categories, except ``element`` are
36
+ empty.
37
+ """
38
+ record = _get_record(mol_file, record_name)
39
+ return record.get_structure()
40
+
41
+
42
+ def set_structure(
43
+ mol_file, atoms, default_bond_type=BondType.ANY, version=None, record_name=None
44
+ ):
45
+ """
46
+ Set the :class:`AtomArray` for the MOL file.
47
+
48
+ Ths function is a thin wrapper around
49
+ :meth:`MOLFile.set_structure()`.
50
+
51
+ Parameters
52
+ ----------
53
+ mol_file : MOLFile
54
+ The MOL file.
55
+ array : AtomArray
56
+ The array to be saved into this file.
57
+ Must have an associated :class:`BondList`.
58
+ Bond type fallback for the *Bond block*, if a
59
+ :class:`BondType` has no CTAB counterpart.
60
+ By default, each such bond is treated as
61
+ :attr:`BondType.ANY`.
62
+ default_bond_type : BondType, optional
63
+ Bond type fallback for the *Bond block*, if a :class:`BondType`
64
+ has no CTAB counterpart.
65
+ By default, each such bond is treated as :attr:`BondType.ANY`.
66
+ version : {"V2000", "V3000"}, optional
67
+ The version of the CTAB format.
68
+ ``"V2000"`` uses the *Atom* and *Bond* block, while ``"V3000"``
69
+ uses the *Properties* block.
70
+ By default, ``"V2000"`` is used, unless the number of atoms or
71
+ bonds exceeds 999, in which case ``"V3000"`` is used.
72
+ record_name : str, optional
73
+ Has only an effect when `mol_file` is a :class:`SDFile`.
74
+ The name of the record.
75
+ Default is the first record of the file.
76
+ If the file is empty, a new record will be created.
77
+ """
78
+ record = _get_or_create_record(mol_file, record_name)
79
+ record.set_structure(atoms, default_bond_type, version)
80
+
81
+
82
+ def _get_record(file, record_name):
83
+ if isinstance(file, (MOLFile, SDRecord)):
84
+ return file
85
+ elif isinstance(file, SDFile):
86
+ # Determine record
87
+ if record_name is None:
88
+ return file.record
89
+ else:
90
+ return file[record_name]
91
+ else:
92
+ raise TypeError(f"Unsupported file type '{type(file).__name__}'")
93
+
94
+
95
+ def _get_or_create_record(file, record_name):
96
+ if isinstance(file, (MOLFile, SDRecord)):
97
+ return file
98
+ elif isinstance(file, SDFile):
99
+ if record_name is None:
100
+ if len(file) > 0:
101
+ # Choose first record by default
102
+ record_name = next(iter(file.keys()))
103
+ else:
104
+ # File is empty -> invent a new record name
105
+ record_name = "Molecule"
106
+
107
+ if record_name not in file:
108
+ record = SDRecord()
109
+ file[record_name] = record
110
+ return file[record_name]
111
+ else:
112
+ raise TypeError(f"Unsupported file type '{type(file).__name__}'")