biotite 1.1.0__cp313-cp313-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of biotite might be problematic. Click here for more details.

Files changed (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-darwin.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-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +595 -0
  62. biotite/sequence/align/kmersimilarity.cpython-313-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-313-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3411 -0
  66. biotite/sequence/align/localgapped.cpython-313-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-313-darwin.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-darwin.so +0 -0
  164. biotite/sequence/align/multiple.pyx +620 -0
  165. biotite/sequence/align/pairwise.cpython-313-darwin.so +0 -0
  166. biotite/sequence/align/pairwise.pyx +587 -0
  167. biotite/sequence/align/permutation.cpython-313-darwin.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-darwin.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-darwin.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-darwin.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-darwin.so +0 -0
  227. biotite/sequence/phylo/nj.pyx +221 -0
  228. biotite/sequence/phylo/tree.cpython-313-darwin.so +0 -0
  229. biotite/sequence/phylo/tree.pyx +1169 -0
  230. biotite/sequence/phylo/upgma.cpython-313-darwin.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-darwin.so +0 -0
  249. biotite/structure/bonds.pyx +1972 -0
  250. biotite/structure/box.py +588 -0
  251. biotite/structure/celllist.cpython-313-darwin.so +0 -0
  252. biotite/structure/celllist.pyx +849 -0
  253. biotite/structure/chains.py +314 -0
  254. biotite/structure/charges.cpython-313-darwin.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-darwin.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-darwin.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-darwin.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 +4 -0
  332. biotite-1.1.0.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,588 @@
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
+ Functions related to working with the simulation box or unit cell
7
+ of a structure
8
+ """
9
+
10
+ __name__ = "biotite.structure"
11
+ __author__ = "Patrick Kunzmann"
12
+ __all__ = [
13
+ "vectors_from_unitcell",
14
+ "unitcell_from_vectors",
15
+ "box_volume",
16
+ "repeat_box",
17
+ "repeat_box_coord",
18
+ "move_inside_box",
19
+ "remove_pbc",
20
+ "remove_pbc_from_coord",
21
+ "coord_to_fraction",
22
+ "fraction_to_coord",
23
+ "is_orthogonal",
24
+ ]
25
+
26
+ from numbers import Integral
27
+ import numpy as np
28
+ import numpy.linalg as linalg
29
+ from biotite.structure.atoms import repeat
30
+ from biotite.structure.chains import get_chain_masks, get_chain_starts
31
+ from biotite.structure.error import BadStructureError
32
+ from biotite.structure.molecules import get_molecule_masks
33
+ from biotite.structure.util import vector_dot
34
+
35
+
36
+ def vectors_from_unitcell(len_a, len_b, len_c, alpha, beta, gamma):
37
+ """
38
+ Calculate the three vectors spanning a box from the unit cell
39
+ lengths and angles.
40
+
41
+ The return value of this function are the three box vectors as
42
+ required for the :attr:`box` attribute in atom arrays and stacks.
43
+
44
+ Parameters
45
+ ----------
46
+ len_a, len_b, len_c : float
47
+ The lengths of the three box/unit cell vectors *a*, *b* and *c*.
48
+ alpha, beta, gamma:
49
+ The angles between the box vectors in radians.
50
+ *alpha* is the angle between *b* and *c*,
51
+ *beta* between *a* and *c*, *gamma* between *a* and *b*
52
+
53
+ Returns
54
+ -------
55
+ box : ndarray, dtype=float, shape=(3,3)
56
+ The three box vectors.
57
+ The vector components are in the last dimension.
58
+ The value can be directly used as :attr:`box` attribute in an
59
+ atom array.
60
+
61
+ See also
62
+ --------
63
+ unitcell_from_vectors
64
+ """
65
+ a_x = len_a
66
+ b_x = len_b * np.cos(gamma)
67
+ b_y = len_b * np.sin(gamma)
68
+ c_x = len_c * np.cos(beta)
69
+ c_y = len_c * (np.cos(alpha) - np.cos(beta) * np.cos(gamma)) / np.sin(gamma)
70
+ c_z = np.sqrt(len_c * len_c - c_x * c_x - c_y * c_y)
71
+ box = np.array([[a_x, 0, 0], [b_x, b_y, 0], [c_x, c_y, c_z]], dtype=np.float32)
72
+
73
+ # Fix numerical errors, as values, that are actually 0,
74
+ # might not be calculated as such
75
+ tol = 1e-4 * (len_a + len_b + len_c)
76
+ box[np.abs(box) < tol] = 0
77
+
78
+ return box
79
+
80
+
81
+ def unitcell_from_vectors(box):
82
+ """
83
+ Get the unit cell lengths and angles from box vectors.
84
+
85
+ This is the reverse operation of :func:`vectors_from_unitcell()`.
86
+
87
+ Parameters
88
+ ----------
89
+ box : ndarray, shape=(3,3)
90
+ The box vectors
91
+
92
+ Returns
93
+ -------
94
+ len_a, len_b, len_c : float
95
+ The lengths of the three box/unit cell vectors *a*, *b* and *c*.
96
+ alpha, beta, gamma : float
97
+ The angles between the box vectors in radians.
98
+
99
+ See also
100
+ --------
101
+ vectors_from_unitcell
102
+ """
103
+ a = box[0]
104
+ b = box[1]
105
+ c = box[2]
106
+ len_a = linalg.norm(a)
107
+ len_b = linalg.norm(b)
108
+ len_c = linalg.norm(c)
109
+ alpha = np.arccos(np.dot(b, c) / (len_b * len_c))
110
+ beta = np.arccos(np.dot(a, c) / (len_a * len_c))
111
+ gamma = np.arccos(np.dot(a, b) / (len_a * len_b))
112
+ return len_a, len_b, len_c, alpha, beta, gamma
113
+
114
+
115
+ def box_volume(box):
116
+ """
117
+ Get the volume of one ore multiple boxes.
118
+
119
+ Parameters
120
+ ----------
121
+ box : ndarray, shape=(3,3) or shape=(m,3,3)
122
+ One or multiple boxes to get the volume for.
123
+
124
+ Returns
125
+ -------
126
+ volume : float or ndarray, shape=(m,)
127
+ """
128
+ # Using the triple product
129
+ return np.abs(linalg.det(box))
130
+
131
+
132
+ def repeat_box(atoms, amount=1):
133
+ r"""
134
+ Repeat the atoms in a box by duplicating and placing them in
135
+ adjacent boxes.
136
+
137
+ The output atom array (stack) contains the original atoms (central
138
+ box) and duplicates of them in the given amount of adjacent boxes.
139
+ The coordinates of the duplicate atoms are translated accordingly
140
+ by the box coordinates.
141
+
142
+ Parameters
143
+ ----------
144
+ atoms : AtomArray or AtomArrayStack
145
+ The atoms to be repeated.
146
+ If `atoms` is a :class:`AtomArrayStack`, the atoms are repeated
147
+ for each model, according to the box of each model.
148
+ amount : int, optional
149
+ The amount of boxes that are created in each direction of the
150
+ central box.
151
+ Hence, the total amount of boxes is
152
+ :math:`(1 + 2 \cdot \text{amount}) ^ 3`.
153
+ By default, one box is created in each direction, totalling in
154
+ 27 boxes.
155
+
156
+ Returns
157
+ -------
158
+ repeated : AtomArray or AtomArrayStack
159
+ The repeated atoms.
160
+ Includes the original atoms (central box) in the beginning of
161
+ the atom array (stack).
162
+ indices : ndarray, dtype=int, shape=(n,3)
163
+ Indices to the atoms in the original atom array (stack).
164
+ Equal to
165
+ ``numpy.tile(np.arange(atoms.array_length()), (1 + 2 * amount) ** 3)``.
166
+
167
+ See also
168
+ --------
169
+ repeat_box_coord
170
+
171
+ Examples
172
+ --------
173
+
174
+ >>> array = AtomArray(length=2)
175
+ >>> array.coord = np.array([[1,5,3], [-1,2,5]], dtype=float)
176
+ >>> array.box = np.array([[10,0,0], [0,10,0], [0,0,10]], dtype=float)
177
+ >>> repeated, indices = repeat_box(array)
178
+ >>> print(repeated.coord)
179
+ [[ 1. 5. 3.]
180
+ [ -1. 2. 5.]
181
+ [ -9. -5. -7.]
182
+ [-11. -8. -5.]
183
+ [ -9. -5. 3.]
184
+ [-11. -8. 5.]
185
+ [ -9. -5. 13.]
186
+ [-11. -8. 15.]
187
+ [ -9. 5. -7.]
188
+ [-11. 2. -5.]
189
+ [ -9. 5. 3.]
190
+ [-11. 2. 5.]
191
+ [ -9. 5. 13.]
192
+ [-11. 2. 15.]
193
+ [ -9. 15. -7.]
194
+ [-11. 12. -5.]
195
+ [ -9. 15. 3.]
196
+ [-11. 12. 5.]
197
+ [ -9. 15. 13.]
198
+ [-11. 12. 15.]
199
+ [ 1. -5. -7.]
200
+ [ -1. -8. -5.]
201
+ [ 1. -5. 3.]
202
+ [ -1. -8. 5.]
203
+ [ 1. -5. 13.]
204
+ [ -1. -8. 15.]
205
+ [ 1. 5. -7.]
206
+ [ -1. 2. -5.]
207
+ [ 1. 5. 13.]
208
+ [ -1. 2. 15.]
209
+ [ 1. 15. -7.]
210
+ [ -1. 12. -5.]
211
+ [ 1. 15. 3.]
212
+ [ -1. 12. 5.]
213
+ [ 1. 15. 13.]
214
+ [ -1. 12. 15.]
215
+ [ 11. -5. -7.]
216
+ [ 9. -8. -5.]
217
+ [ 11. -5. 3.]
218
+ [ 9. -8. 5.]
219
+ [ 11. -5. 13.]
220
+ [ 9. -8. 15.]
221
+ [ 11. 5. -7.]
222
+ [ 9. 2. -5.]
223
+ [ 11. 5. 3.]
224
+ [ 9. 2. 5.]
225
+ [ 11. 5. 13.]
226
+ [ 9. 2. 15.]
227
+ [ 11. 15. -7.]
228
+ [ 9. 12. -5.]
229
+ [ 11. 15. 3.]
230
+ [ 9. 12. 5.]
231
+ [ 11. 15. 13.]
232
+ [ 9. 12. 15.]]
233
+ >>> print(indices)
234
+ [0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
235
+ 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1]
236
+ """
237
+ if atoms.box is None:
238
+ raise BadStructureError("Structure has no box")
239
+
240
+ repeat_coord, indices = repeat_box_coord(atoms.coord, atoms.box)
241
+ # Unroll repeated coordinates for input to 'repeat()'
242
+ if repeat_coord.ndim == 2:
243
+ repeat_coord = repeat_coord.reshape(-1, atoms.array_length(), 3)
244
+ else: # ndim == 3
245
+ repeat_coord = repeat_coord.reshape(
246
+ atoms.stack_depth(), -1, atoms.array_length(), 3
247
+ )
248
+ repeat_coord = np.swapaxes(repeat_coord, 0, 1)
249
+ return repeat(atoms, repeat_coord), indices
250
+
251
+
252
+ def repeat_box_coord(coord, box, amount=1):
253
+ r"""
254
+ Similar to :func:`repeat_box()`, repeat the coordinates in a box by
255
+ duplicating and placing them in adjacent boxes.
256
+
257
+ Parameters
258
+ ----------
259
+ coord : ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
260
+ The coordinates to be repeated.
261
+ box : ndarray, dtype=float, shape=(3,3) or shape=(m,3,3)
262
+ The reference box.
263
+ If only one box is provided, i.e. the shape is *(3,3)*,
264
+ the box is used for all models *m*, if the coordinates shape
265
+ is *(m,n,3)*.
266
+ amount : int, optional
267
+ The amount of boxes that are created in each direction of the
268
+ central box.
269
+ Hence, the total amount of boxes is
270
+ :math:`(1 + 2 \cdot \text{amount}) ^ 3`.
271
+ By default, one box is created in each direction, totalling in
272
+ 27 boxes.
273
+
274
+ Returns
275
+ -------
276
+ repeated : ndarray, dtype=float, shape=(p,3) or shape=(m,p,3)
277
+ The repeated coordinates, with the same dimension as the input
278
+ `coord`.
279
+ Includes the original coordinates (central box) in the beginning
280
+ of the array.
281
+ indices : ndarray, dtype=int, shape=(p,3)
282
+ Indices to the coordinates in the original array.
283
+ Equal to
284
+ ``numpy.tile(np.arange(coord.shape[-2]), (1 + 2 * amount) ** 3)``.
285
+ """
286
+ if not isinstance(amount, Integral):
287
+ raise TypeError("The amount must be an integer")
288
+ # List of numpy arrays for each box repeat
289
+ coords_for_boxes = [coord]
290
+ for i in range(-amount, amount + 1):
291
+ for j in range(-amount, amount + 1):
292
+ for k in range(-amount, amount + 1):
293
+ # Omit the central box
294
+ if i != 0 or j != 0 or k != 0:
295
+ temp_coord = coord.copy()
296
+ # Shift coordinates to adjacent box/unit cell
297
+ translation_vec = np.sum(
298
+ box * np.array([i, j, k])[:, np.newaxis], axis=-2
299
+ )
300
+ # 'newaxis' to perform same translation on all
301
+ # atoms for each model
302
+ temp_coord += translation_vec[..., np.newaxis, :]
303
+ coords_for_boxes.append(temp_coord)
304
+ return (
305
+ np.concatenate(coords_for_boxes, axis=-2),
306
+ np.tile(np.arange(coord.shape[-2]), (1 + 2 * amount) ** 3),
307
+ )
308
+
309
+
310
+ def move_inside_box(coord, box):
311
+ r"""
312
+ Move all coordinates into the given box, with the box vectors
313
+ originating at *(0,0,0)*.
314
+
315
+ Coordinates are outside the box, when they cannot be represented by
316
+ a linear combination of the box vectors with scalar factors
317
+ :math:`0 \le a_i \le 1`.
318
+ In this case the affected coordinates are translated by the box
319
+ vectors, so that they are inside the box.
320
+
321
+ Parameters
322
+ ----------
323
+ coord : ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
324
+ The coordinates for one or multiple models.
325
+ box : ndarray, dtype=float, shape=(3,3) or shape=(m,3,3)
326
+ The box(es) for one or multiple models.
327
+ When `coord` is given for multiple models, :attr:`box` must be
328
+ given for multiple models as well.
329
+
330
+ Returns
331
+ -------
332
+ moved_coord : ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
333
+ The moved coordinates.
334
+ Has the same shape is the input `coord`.
335
+
336
+ Examples
337
+ --------
338
+
339
+ >>> box = np.array([[10,0,0], [0,10,0], [0,0,10]], dtype=float)
340
+ >>> inside_coord = [ 1, 2, 3]
341
+ >>> outside_coord = [ 1, 22, 54]
342
+ >>> other_outside_coord = [-4, 8, 6]
343
+ >>> coord = np.stack([inside_coord, outside_coord, other_outside_coord])
344
+ >>> print(coord)
345
+ [[ 1 2 3]
346
+ [ 1 22 54]
347
+ [-4 8 6]]
348
+ >>> moved_coord = move_inside_box(coord, box)
349
+ >>> print(moved_coord.astype(int))
350
+ [[1 2 3]
351
+ [1 2 4]
352
+ [6 8 6]]
353
+ """
354
+ fractions = coord_to_fraction(coord, box)
355
+ fractions_rem = fractions % 1
356
+ return fraction_to_coord(fractions_rem, box)
357
+
358
+
359
+ def remove_pbc(atoms, selection=None):
360
+ """
361
+ Remove segmentation caused by periodic boundary conditions from each
362
+ molecule in the given structure.
363
+
364
+ In this process the centroid of each molecule is moved into the
365
+ dimensions of the box.
366
+ To determine the molecules the structure is required to have an
367
+ associated `BondList`.
368
+ Otherwise segmentation removal is performed on a per-chain basis.
369
+
370
+ Parameters
371
+ ----------
372
+ atoms : AtomArray, shape=(n,) or AtomArrayStack, shape=(m,n)
373
+ The potentially segmented structure.
374
+ The :attr:`box` attribute must be set in the structure.
375
+ An associated :attr:`bonds` attribute is recommended.
376
+ selection : ndarray, dtype=bool, shape=(n,)
377
+ Specifies which parts of `atoms` are sanitized, i.e the
378
+ segmentation is removed.
379
+
380
+ Returns
381
+ -------
382
+ sanitized_atoms : AtomArray or AtomArrayStack
383
+ The input structure with removed segmentation over periodic
384
+ boundaries.
385
+
386
+ See also
387
+ --------
388
+ remove_pbc_from_coord
389
+
390
+ Notes
391
+ -----
392
+ This function ensures that adjacent atoms in the input
393
+ :class:`AtomArray`/:class:`AtomArrayStack` are spatially close to
394
+ each other, i.e. their distance to each other is be smaller than the
395
+ half box size.
396
+ """
397
+ # Avoid circular import
398
+ from biotite.structure.geometry import centroid
399
+
400
+ if atoms.box is None:
401
+ raise BadStructureError("The 'box' attribute must be set in the structure")
402
+ new_atoms = atoms.copy()
403
+
404
+ if atoms.bonds is not None:
405
+ molecule_masks = get_molecule_masks(atoms)
406
+ else:
407
+ molecule_masks = get_chain_masks(atoms, get_chain_starts(atoms))
408
+
409
+ for mask in molecule_masks:
410
+ if selection is not None:
411
+ mask &= selection
412
+ # Remove segmentation in molecule
413
+ new_atoms.coord[..., mask, :] = remove_pbc_from_coord(
414
+ new_atoms.coord[..., mask, :], atoms.box
415
+ )
416
+ # Put center of molecule into box
417
+ center = centroid(new_atoms.coord[..., mask, :])[..., np.newaxis, :]
418
+ center_in_box = move_inside_box(center, new_atoms.box)
419
+ new_atoms.coord[..., mask, :] += center_in_box - center
420
+
421
+ return new_atoms
422
+
423
+
424
+ def remove_pbc_from_coord(coord, box):
425
+ """
426
+ Remove segmentation caused by periodic boundary conditions from
427
+ given coordinates.
428
+
429
+ In this process the first coordinate is taken as origin and
430
+ is moved inside the box.
431
+ All other coordinates are assembled relative to the origin by using
432
+ the displacement coordinates in adjacent array positions.
433
+ Basically, this function performs the reverse action of
434
+ :func:`move_inside_box()`.
435
+
436
+ Parameters
437
+ ----------
438
+ coord : ndarray, dtype=float, shape=(m,n,3) or shape=(n,3)
439
+ The coordinates of the potentially segmented structure.
440
+ box : ndarray, dtype=float, shape=(m,3,3) or shape=(3,3)
441
+ The simulation box or unit cell that is used as periodic
442
+ boundary.
443
+ The amount of dimensions must fit the `coord` parameter.
444
+
445
+ Returns
446
+ -------
447
+ sanitized_coord : ndarray, dtype=float, shape=(m,n,3) or shape=(n,3)
448
+ The reassembled coordinates.
449
+
450
+ See also
451
+ --------
452
+ remove_pbc_from_coord
453
+ move_inside_box
454
+
455
+ Notes
456
+ -----
457
+ This function solves a common problem from MD simulation output:
458
+ When atoms move over the periodic boundary, they reappear on the
459
+ other side of the box, segmenting the structure.
460
+ This function reassembles the given coordinates, removing the
461
+ segmentation.
462
+ """
463
+
464
+ # Import in function to avoid circular import
465
+ from biotite.structure.geometry import index_displacement
466
+
467
+ # Get the PBC-sanitized displacements of all coordinates
468
+ # to the respective next coordinate
469
+ index_pairs = np.stack(
470
+ [np.arange(0, coord.shape[-2] - 1), np.arange(1, coord.shape[-2])], axis=1
471
+ )
472
+ neighbour_disp = index_displacement(coord, index_pairs, box=box, periodic=True)
473
+ # Get the PBC-sanitized displacements of all but the first
474
+ # coordinates to (0,0,0)
475
+ absolute_disp = np.cumsum(neighbour_disp, axis=-2)
476
+ # The first coordinate should be inside the box
477
+ base_coord = move_inside_box(coord[..., 0:1, :], box)
478
+ # The new coordinates are obtained by adding the displacements
479
+ # to the new origin
480
+ sanitized_coord = np.zeros(coord.shape, coord.dtype)
481
+ sanitized_coord[..., 0:1, :] = base_coord
482
+ sanitized_coord[..., 1:, :] = base_coord + absolute_disp
483
+ return sanitized_coord
484
+
485
+
486
+ def coord_to_fraction(coord, box):
487
+ """
488
+ Transform coordinates to fractions of box vectors.
489
+
490
+ Parameters
491
+ ----------
492
+ coord : ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
493
+ The coordinates for one or multiple models.
494
+ box : ndarray, dtype=float, shape=(3,3) or shape=(m,3,3)
495
+ The box(es) for one or multiple models.
496
+ When `coord` is given for multiple models, :attr:`box` must be
497
+ given for multiple models as well.
498
+
499
+ Returns
500
+ -------
501
+ fraction : ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
502
+ The fractions of the box vectors.
503
+
504
+ See also
505
+ --------
506
+ fraction_to_coord
507
+
508
+ Examples
509
+ --------
510
+
511
+ >>> box = np.array([[5,0,0], [0,5,0], [0,5,5]], dtype=float)
512
+ >>> coord = np.array(
513
+ ... [[1,1,1], [10,0,0], [0,0,10], [-5,2,1]],
514
+ ... dtype=float
515
+ ... )
516
+ >>> print(coord)
517
+ [[ 1. 1. 1.]
518
+ [10. 0. 0.]
519
+ [ 0. 0. 10.]
520
+ [-5. 2. 1.]]
521
+ >>> fractions = coord_to_fraction(coord, box)
522
+ >>> print(fractions)
523
+ [[ 0.2 0.0 0.2]
524
+ [ 2.0 0.0 0.0]
525
+ [ 0.0 -2.0 2.0]
526
+ [-1.0 0.2 0.2]]
527
+ """
528
+ return np.matmul(coord, linalg.inv(box))
529
+
530
+
531
+ def fraction_to_coord(fraction, box):
532
+ """
533
+ Transform fractions of box vectors to coordinates.
534
+
535
+ This is the reverse operation of :func:`coord_to_fraction()`.
536
+
537
+ Parameters
538
+ ----------
539
+ fraction : ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
540
+ The fractions of the box vectors for one or multiple models.
541
+ box : ndarray, dtype=float, shape=(3,3) or shape=(m,3,3)
542
+ The box(es) for one or multiple models.
543
+ When `coord` is given for multiple models, :attr:`box` must be
544
+ given for multiple models as well.
545
+
546
+ Returns
547
+ -------
548
+ coord : ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
549
+ The coordinates.
550
+
551
+ See also
552
+ --------
553
+ coord_to_fraction
554
+ """
555
+ return np.matmul(fraction, box)
556
+
557
+
558
+ def is_orthogonal(box):
559
+ """
560
+ Check, whether a box or multiple boxes is/are orthogonal.
561
+
562
+ A box is orthogonal when the dot product of all box vectors with
563
+ each other is 0.
564
+
565
+ Parameters
566
+ ----------
567
+ box : ndarray, dtype=float, shape=(3,3) or shape=(m,3,3)
568
+ A single box or multiple boxes.
569
+
570
+ Returns
571
+ -------
572
+ is_orthgonal : bool or ndarray, shape=(m,), dtype=bool
573
+ True, if the box vectors are orthogonal, false otherwise
574
+
575
+ Notes
576
+ -----
577
+ Due to possible numerical errors, this function also evaluates two
578
+ vectors as orthogonal, when their dot product is not exactly zero,
579
+ but it is within a small tolerance (:math:`10^{-6}`).
580
+ """
581
+ # Fix numerical errors, as values, that are actually 0,
582
+ # might not be calculated as such
583
+ tol = 1e-6
584
+ return (
585
+ (np.abs(vector_dot(box[..., 0, :], box[..., 1, :])) < tol)
586
+ & (np.abs(vector_dot(box[..., 0, :], box[..., 2, :])) < tol)
587
+ & (np.abs(vector_dot(box[..., 1, :], box[..., 2, :])) < tol)
588
+ )