biotite 0.41.1__cp311-cp311-macosx_10_16_arm64.whl

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

Potentially problematic release.


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

Files changed (340) hide show
  1. biotite/__init__.py +19 -0
  2. biotite/application/__init__.py +43 -0
  3. biotite/application/application.py +265 -0
  4. biotite/application/autodock/__init__.py +12 -0
  5. biotite/application/autodock/app.py +505 -0
  6. biotite/application/blast/__init__.py +14 -0
  7. biotite/application/blast/alignment.py +83 -0
  8. biotite/application/blast/webapp.py +421 -0
  9. biotite/application/clustalo/__init__.py +12 -0
  10. biotite/application/clustalo/app.py +238 -0
  11. biotite/application/dssp/__init__.py +12 -0
  12. biotite/application/dssp/app.py +152 -0
  13. biotite/application/localapp.py +306 -0
  14. biotite/application/mafft/__init__.py +12 -0
  15. biotite/application/mafft/app.py +122 -0
  16. biotite/application/msaapp.py +374 -0
  17. biotite/application/muscle/__init__.py +13 -0
  18. biotite/application/muscle/app3.py +254 -0
  19. biotite/application/muscle/app5.py +171 -0
  20. biotite/application/sra/__init__.py +18 -0
  21. biotite/application/sra/app.py +456 -0
  22. biotite/application/tantan/__init__.py +12 -0
  23. biotite/application/tantan/app.py +222 -0
  24. biotite/application/util.py +59 -0
  25. biotite/application/viennarna/__init__.py +18 -0
  26. biotite/application/viennarna/rnaalifold.py +304 -0
  27. biotite/application/viennarna/rnafold.py +269 -0
  28. biotite/application/viennarna/rnaplot.py +187 -0
  29. biotite/application/viennarna/util.py +72 -0
  30. biotite/application/webapp.py +77 -0
  31. biotite/copyable.py +71 -0
  32. biotite/database/__init__.py +23 -0
  33. biotite/database/entrez/__init__.py +15 -0
  34. biotite/database/entrez/check.py +61 -0
  35. biotite/database/entrez/dbnames.py +89 -0
  36. biotite/database/entrez/download.py +223 -0
  37. biotite/database/entrez/key.py +44 -0
  38. biotite/database/entrez/query.py +223 -0
  39. biotite/database/error.py +15 -0
  40. biotite/database/pubchem/__init__.py +21 -0
  41. biotite/database/pubchem/download.py +260 -0
  42. biotite/database/pubchem/error.py +20 -0
  43. biotite/database/pubchem/query.py +827 -0
  44. biotite/database/pubchem/throttle.py +99 -0
  45. biotite/database/rcsb/__init__.py +13 -0
  46. biotite/database/rcsb/download.py +167 -0
  47. biotite/database/rcsb/query.py +959 -0
  48. biotite/database/uniprot/__init__.py +13 -0
  49. biotite/database/uniprot/check.py +32 -0
  50. biotite/database/uniprot/download.py +134 -0
  51. biotite/database/uniprot/query.py +209 -0
  52. biotite/file.py +251 -0
  53. biotite/sequence/__init__.py +73 -0
  54. biotite/sequence/align/__init__.py +49 -0
  55. biotite/sequence/align/alignment.py +658 -0
  56. biotite/sequence/align/banded.cpython-311-darwin.so +0 -0
  57. biotite/sequence/align/banded.pyx +652 -0
  58. biotite/sequence/align/buckets.py +69 -0
  59. biotite/sequence/align/cigar.py +434 -0
  60. biotite/sequence/align/kmeralphabet.cpython-311-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-311-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-311-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-311-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-311-darwin.so +0 -0
  69. biotite/sequence/align/localungapped.pyx +279 -0
  70. biotite/sequence/align/matrix.py +405 -0
  71. biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
  72. biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
  73. biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
  74. biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
  75. biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
  76. biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
  77. biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
  78. biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
  79. biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
  80. biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
  81. biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
  82. biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
  83. biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
  84. biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
  85. biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
  86. biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
  87. biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
  88. biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
  89. biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
  90. biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
  91. biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
  92. biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
  93. biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
  94. biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
  95. biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
  96. biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
  97. biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
  98. biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
  99. biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
  100. biotite/sequence/align/matrix_data/GONNET.mat +26 -0
  101. biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
  102. biotite/sequence/align/matrix_data/MATCH.mat +25 -0
  103. biotite/sequence/align/matrix_data/NUC.mat +25 -0
  104. biotite/sequence/align/matrix_data/PAM10.mat +34 -0
  105. biotite/sequence/align/matrix_data/PAM100.mat +34 -0
  106. biotite/sequence/align/matrix_data/PAM110.mat +34 -0
  107. biotite/sequence/align/matrix_data/PAM120.mat +34 -0
  108. biotite/sequence/align/matrix_data/PAM130.mat +34 -0
  109. biotite/sequence/align/matrix_data/PAM140.mat +34 -0
  110. biotite/sequence/align/matrix_data/PAM150.mat +34 -0
  111. biotite/sequence/align/matrix_data/PAM160.mat +34 -0
  112. biotite/sequence/align/matrix_data/PAM170.mat +34 -0
  113. biotite/sequence/align/matrix_data/PAM180.mat +34 -0
  114. biotite/sequence/align/matrix_data/PAM190.mat +34 -0
  115. biotite/sequence/align/matrix_data/PAM20.mat +34 -0
  116. biotite/sequence/align/matrix_data/PAM200.mat +34 -0
  117. biotite/sequence/align/matrix_data/PAM210.mat +34 -0
  118. biotite/sequence/align/matrix_data/PAM220.mat +34 -0
  119. biotite/sequence/align/matrix_data/PAM230.mat +34 -0
  120. biotite/sequence/align/matrix_data/PAM240.mat +34 -0
  121. biotite/sequence/align/matrix_data/PAM250.mat +34 -0
  122. biotite/sequence/align/matrix_data/PAM260.mat +34 -0
  123. biotite/sequence/align/matrix_data/PAM270.mat +34 -0
  124. biotite/sequence/align/matrix_data/PAM280.mat +34 -0
  125. biotite/sequence/align/matrix_data/PAM290.mat +34 -0
  126. biotite/sequence/align/matrix_data/PAM30.mat +34 -0
  127. biotite/sequence/align/matrix_data/PAM300.mat +34 -0
  128. biotite/sequence/align/matrix_data/PAM310.mat +34 -0
  129. biotite/sequence/align/matrix_data/PAM320.mat +34 -0
  130. biotite/sequence/align/matrix_data/PAM330.mat +34 -0
  131. biotite/sequence/align/matrix_data/PAM340.mat +34 -0
  132. biotite/sequence/align/matrix_data/PAM350.mat +34 -0
  133. biotite/sequence/align/matrix_data/PAM360.mat +34 -0
  134. biotite/sequence/align/matrix_data/PAM370.mat +34 -0
  135. biotite/sequence/align/matrix_data/PAM380.mat +34 -0
  136. biotite/sequence/align/matrix_data/PAM390.mat +34 -0
  137. biotite/sequence/align/matrix_data/PAM40.mat +34 -0
  138. biotite/sequence/align/matrix_data/PAM400.mat +34 -0
  139. biotite/sequence/align/matrix_data/PAM410.mat +34 -0
  140. biotite/sequence/align/matrix_data/PAM420.mat +34 -0
  141. biotite/sequence/align/matrix_data/PAM430.mat +34 -0
  142. biotite/sequence/align/matrix_data/PAM440.mat +34 -0
  143. biotite/sequence/align/matrix_data/PAM450.mat +34 -0
  144. biotite/sequence/align/matrix_data/PAM460.mat +34 -0
  145. biotite/sequence/align/matrix_data/PAM470.mat +34 -0
  146. biotite/sequence/align/matrix_data/PAM480.mat +34 -0
  147. biotite/sequence/align/matrix_data/PAM490.mat +34 -0
  148. biotite/sequence/align/matrix_data/PAM50.mat +34 -0
  149. biotite/sequence/align/matrix_data/PAM500.mat +34 -0
  150. biotite/sequence/align/matrix_data/PAM60.mat +34 -0
  151. biotite/sequence/align/matrix_data/PAM70.mat +34 -0
  152. biotite/sequence/align/matrix_data/PAM80.mat +34 -0
  153. biotite/sequence/align/matrix_data/PAM90.mat +34 -0
  154. biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
  155. biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
  156. biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
  157. biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
  158. biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
  159. biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
  160. biotite/sequence/align/multiple.cpython-311-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-311-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-311-darwin.so +0 -0
  165. biotite/sequence/align/permutation.pyx +305 -0
  166. biotite/sequence/align/primes.txt +821 -0
  167. biotite/sequence/align/selector.cpython-311-darwin.so +0 -0
  168. biotite/sequence/align/selector.pyx +956 -0
  169. biotite/sequence/align/statistics.py +265 -0
  170. biotite/sequence/align/tracetable.cpython-311-darwin.so +0 -0
  171. biotite/sequence/align/tracetable.pxd +64 -0
  172. biotite/sequence/align/tracetable.pyx +370 -0
  173. biotite/sequence/alphabet.py +566 -0
  174. biotite/sequence/annotation.py +829 -0
  175. biotite/sequence/codec.cpython-311-darwin.so +0 -0
  176. biotite/sequence/codec.pyx +155 -0
  177. biotite/sequence/codon.py +466 -0
  178. biotite/sequence/codon_tables.txt +202 -0
  179. biotite/sequence/graphics/__init__.py +33 -0
  180. biotite/sequence/graphics/alignment.py +1034 -0
  181. biotite/sequence/graphics/color_schemes/autumn.json +51 -0
  182. biotite/sequence/graphics/color_schemes/blossom.json +51 -0
  183. biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
  184. biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
  185. biotite/sequence/graphics/color_schemes/flower.json +51 -0
  186. biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
  187. biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
  188. biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
  189. biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
  190. biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
  191. biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
  192. biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
  193. biotite/sequence/graphics/color_schemes/ocean.json +51 -0
  194. biotite/sequence/graphics/color_schemes/pb_flower.json +39 -0
  195. biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
  196. biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
  197. biotite/sequence/graphics/color_schemes/spring.json +51 -0
  198. biotite/sequence/graphics/color_schemes/sunset.json +51 -0
  199. biotite/sequence/graphics/color_schemes/wither.json +51 -0
  200. biotite/sequence/graphics/colorschemes.py +139 -0
  201. biotite/sequence/graphics/dendrogram.py +184 -0
  202. biotite/sequence/graphics/features.py +510 -0
  203. biotite/sequence/graphics/logo.py +110 -0
  204. biotite/sequence/graphics/plasmid.py +661 -0
  205. biotite/sequence/io/__init__.py +12 -0
  206. biotite/sequence/io/fasta/__init__.py +22 -0
  207. biotite/sequence/io/fasta/convert.py +273 -0
  208. biotite/sequence/io/fasta/file.py +278 -0
  209. biotite/sequence/io/fastq/__init__.py +19 -0
  210. biotite/sequence/io/fastq/convert.py +120 -0
  211. biotite/sequence/io/fastq/file.py +551 -0
  212. biotite/sequence/io/genbank/__init__.py +17 -0
  213. biotite/sequence/io/genbank/annotation.py +277 -0
  214. biotite/sequence/io/genbank/file.py +575 -0
  215. biotite/sequence/io/genbank/metadata.py +324 -0
  216. biotite/sequence/io/genbank/sequence.py +172 -0
  217. biotite/sequence/io/general.py +192 -0
  218. biotite/sequence/io/gff/__init__.py +26 -0
  219. biotite/sequence/io/gff/convert.py +133 -0
  220. biotite/sequence/io/gff/file.py +434 -0
  221. biotite/sequence/phylo/__init__.py +36 -0
  222. biotite/sequence/phylo/nj.cpython-311-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-311-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-311-darwin.so +0 -0
  227. biotite/sequence/phylo/upgma.pyx +164 -0
  228. biotite/sequence/profile.py +456 -0
  229. biotite/sequence/search.py +116 -0
  230. biotite/sequence/seqtypes.py +556 -0
  231. biotite/sequence/sequence.py +374 -0
  232. biotite/structure/__init__.py +132 -0
  233. biotite/structure/atoms.py +1455 -0
  234. biotite/structure/basepairs.py +1415 -0
  235. biotite/structure/bonds.cpython-311-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-311-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-311-darwin.so +0 -0
  242. biotite/structure/charges.pyx +520 -0
  243. biotite/structure/compare.py +274 -0
  244. biotite/structure/density.py +114 -0
  245. biotite/structure/dotbracket.py +216 -0
  246. biotite/structure/error.py +31 -0
  247. biotite/structure/filter.py +585 -0
  248. biotite/structure/geometry.py +697 -0
  249. biotite/structure/graphics/__init__.py +13 -0
  250. biotite/structure/graphics/atoms.py +226 -0
  251. biotite/structure/graphics/rna.py +282 -0
  252. biotite/structure/hbond.py +409 -0
  253. biotite/structure/info/__init__.py +25 -0
  254. biotite/structure/info/atom_masses.json +121 -0
  255. biotite/structure/info/atoms.py +82 -0
  256. biotite/structure/info/bonds.py +145 -0
  257. biotite/structure/info/ccd/README.rst +8 -0
  258. biotite/structure/info/ccd/amino_acids.txt +1663 -0
  259. biotite/structure/info/ccd/carbohydrates.txt +1135 -0
  260. biotite/structure/info/ccd/components.bcif +0 -0
  261. biotite/structure/info/ccd/nucleotides.txt +798 -0
  262. biotite/structure/info/ccd.py +95 -0
  263. biotite/structure/info/groups.py +90 -0
  264. biotite/structure/info/masses.py +123 -0
  265. biotite/structure/info/misc.py +144 -0
  266. biotite/structure/info/radii.py +197 -0
  267. biotite/structure/info/standardize.py +196 -0
  268. biotite/structure/integrity.py +268 -0
  269. biotite/structure/io/__init__.py +30 -0
  270. biotite/structure/io/ctab.py +72 -0
  271. biotite/structure/io/dcd/__init__.py +13 -0
  272. biotite/structure/io/dcd/file.py +65 -0
  273. biotite/structure/io/general.py +257 -0
  274. biotite/structure/io/gro/__init__.py +14 -0
  275. biotite/structure/io/gro/file.py +343 -0
  276. biotite/structure/io/mmtf/__init__.py +21 -0
  277. biotite/structure/io/mmtf/assembly.py +214 -0
  278. biotite/structure/io/mmtf/convertarray.cpython-311-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-311-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-311-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-311-darwin.so +0 -0
  285. biotite/structure/io/mmtf/encode.pyx +183 -0
  286. biotite/structure/io/mmtf/file.py +233 -0
  287. biotite/structure/io/mol/__init__.py +20 -0
  288. biotite/structure/io/mol/convert.py +115 -0
  289. biotite/structure/io/mol/ctab.py +414 -0
  290. biotite/structure/io/mol/header.py +116 -0
  291. biotite/structure/io/mol/mol.py +193 -0
  292. biotite/structure/io/mol/sdf.py +916 -0
  293. biotite/structure/io/netcdf/__init__.py +13 -0
  294. biotite/structure/io/netcdf/file.py +63 -0
  295. biotite/structure/io/npz/__init__.py +20 -0
  296. biotite/structure/io/npz/file.py +152 -0
  297. biotite/structure/io/pdb/__init__.py +20 -0
  298. biotite/structure/io/pdb/convert.py +293 -0
  299. biotite/structure/io/pdb/file.py +1240 -0
  300. biotite/structure/io/pdb/hybrid36.cpython-311-darwin.so +0 -0
  301. biotite/structure/io/pdb/hybrid36.pyx +242 -0
  302. biotite/structure/io/pdbqt/__init__.py +15 -0
  303. biotite/structure/io/pdbqt/convert.py +107 -0
  304. biotite/structure/io/pdbqt/file.py +640 -0
  305. biotite/structure/io/pdbx/__init__.py +23 -0
  306. biotite/structure/io/pdbx/bcif.py +648 -0
  307. biotite/structure/io/pdbx/cif.py +1032 -0
  308. biotite/structure/io/pdbx/component.py +246 -0
  309. biotite/structure/io/pdbx/convert.py +1597 -0
  310. biotite/structure/io/pdbx/encoding.cpython-311-darwin.so +0 -0
  311. biotite/structure/io/pdbx/encoding.pyx +950 -0
  312. biotite/structure/io/pdbx/legacy.py +267 -0
  313. biotite/structure/io/tng/__init__.py +13 -0
  314. biotite/structure/io/tng/file.py +46 -0
  315. biotite/structure/io/trajfile.py +710 -0
  316. biotite/structure/io/trr/__init__.py +13 -0
  317. biotite/structure/io/trr/file.py +46 -0
  318. biotite/structure/io/xtc/__init__.py +13 -0
  319. biotite/structure/io/xtc/file.py +46 -0
  320. biotite/structure/mechanics.py +75 -0
  321. biotite/structure/molecules.py +353 -0
  322. biotite/structure/pseudoknots.py +642 -0
  323. biotite/structure/rdf.py +243 -0
  324. biotite/structure/repair.py +253 -0
  325. biotite/structure/residues.py +562 -0
  326. biotite/structure/resutil.py +178 -0
  327. biotite/structure/sasa.cpython-311-darwin.so +0 -0
  328. biotite/structure/sasa.pyx +322 -0
  329. biotite/structure/sequence.py +112 -0
  330. biotite/structure/sse.py +327 -0
  331. biotite/structure/superimpose.py +727 -0
  332. biotite/structure/transform.py +504 -0
  333. biotite/structure/util.py +98 -0
  334. biotite/temp.py +86 -0
  335. biotite/version.py +16 -0
  336. biotite/visualize.py +251 -0
  337. biotite-0.41.1.dist-info/METADATA +187 -0
  338. biotite-0.41.1.dist-info/RECORD +340 -0
  339. biotite-0.41.1.dist-info/WHEEL +4 -0
  340. biotite-0.41.1.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,697 @@
1
+ # This source code is part of the Biotite package and is distributed
2
+ # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
3
+ # information.
4
+
5
+ """
6
+ This module provides functions for geometric measurements between atoms
7
+ in a structure, mainly lenghts and angles.
8
+ """
9
+
10
+ __name__ = "biotite.structure"
11
+ __author__ = "Patrick Kunzmann"
12
+ __all__ = ["displacement", "index_displacement", "distance", "index_distance",
13
+ "angle", "index_angle", "dihedral", "index_dihedral",
14
+ "dihedral_backbone", "centroid"]
15
+
16
+ import numpy as np
17
+ from .atoms import Atom, AtomArray, AtomArrayStack, coord
18
+ from .util import vector_dot, norm_vector
19
+ from .filter import filter_peptide_backbone
20
+ from .chains import chain_iter
21
+ from .box import (coord_to_fraction, fraction_to_coord,
22
+ move_inside_box, is_orthogonal)
23
+ from .error import BadStructureError
24
+
25
+
26
+ def displacement(atoms1, atoms2, box=None):
27
+ """
28
+ Measure the displacement vector, i.e. the vector difference, from
29
+ one array of atom coordinates to another array of coordinates.
30
+
31
+ Parameters
32
+ ----------
33
+ atoms1, atoms2 : ndarray, shape=(m,n,3) or ndarray, shape=(n,3) or ndarray, shape=(3,) or Atom or AtomArray or AtomArrayStack
34
+ The atoms to measure the displacement between.
35
+ The vector from `atoms1` to `atoms2` is measured.
36
+ The dimensions may vary.
37
+ Alternatively an ndarray containing the coordinates can be
38
+ provided.
39
+ Usual *NumPy* broadcasting rules apply.
40
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
41
+ If this parameter is set, periodic boundary conditions are
42
+ taken into account (minimum-image convention), based on
43
+ the box vectors given with this parameter.
44
+ The shape *(m,3,3)* is only allowed, when the input coordinates
45
+ comprise multiple models.
46
+
47
+ Returns
48
+ -------
49
+ disp : ndarray, shape=(m,n,3) or ndarray, shape=(n,3) or ndarray, shape=(3,)
50
+ The displacement vector(s). The shape is equal to the shape of
51
+ the input `atoms` with the highest dimensionality.
52
+
53
+ See also
54
+ --------
55
+ index_displacement
56
+ """
57
+ v1 = coord(atoms1)
58
+ v2 = coord(atoms2)
59
+ # Decide subtraction order based on shape, since an array can be
60
+ # only subtracted by an array with less dimensions
61
+ if len(v1.shape) <= len(v2.shape):
62
+ diff = v2 - v1
63
+ else:
64
+ diff = -(v1 - v2)
65
+
66
+ # Use minimum-image convention if box is given
67
+ if box is not None:
68
+ # Transform difference vector
69
+ # from coordinates into fractions of box vectors
70
+ # for faster calculation laster on
71
+ fractions = coord_to_fraction(diff, box)
72
+ # Move vectors into box
73
+ fractions = fractions % 1
74
+ # Check for each model if the box vectors are orthogonal
75
+ orthogonality = is_orthogonal(box)
76
+ disp = np.zeros(fractions.shape, dtype=diff.dtype)
77
+ if fractions.ndim == 1:
78
+ # Single atom
79
+ # Transform into two dimensions
80
+ # to match signature of '_displacement_xxx()'
81
+ fractions = fractions[np.newaxis, :]
82
+ disp = disp[np.newaxis, :]
83
+ if orthogonality:
84
+ _displacement_orthogonal_box(
85
+ fractions, box, disp
86
+ )
87
+ else:
88
+ _displacement_triclinic_box(
89
+ fractions.astype(diff.dtype, copy=False),
90
+ box.astype(diff.dtype, copy=False),
91
+ disp
92
+ )
93
+ # Transform back
94
+ disp = disp[0]
95
+ if fractions.ndim == 2:
96
+ # Single model
97
+ if orthogonality:
98
+ _displacement_orthogonal_box(
99
+ fractions, box, disp
100
+ )
101
+ else:
102
+ _displacement_triclinic_box(
103
+ fractions.astype(diff.dtype, copy=False),
104
+ box.astype(diff.dtype, copy=False),
105
+ disp
106
+ )
107
+ elif fractions.ndim == 3:
108
+ # Multiple models
109
+ # (Model count) x (Atom count)
110
+ for i in range(len(fractions)):
111
+ if box.ndim == 2:
112
+ box_for_model = box
113
+ orthogonality_for_model = orthogonality
114
+ elif box.ndim == 3:
115
+ box_for_model = box[i]
116
+ orthogonality_for_model = orthogonality[i]
117
+ else:
118
+ raise ValueError(f"{box.ndim} are to many box dimensions")
119
+ if orthogonality_for_model:
120
+ _displacement_orthogonal_box(
121
+ fractions[i], box_for_model, disp[i]
122
+ )
123
+ else:
124
+ _displacement_triclinic_box(
125
+ fractions[i].astype(diff.dtype, copy=False),
126
+ box_for_model.astype(diff.dtype, copy=False),
127
+ disp[i]
128
+ )
129
+ else:
130
+ raise ValueError(
131
+ f"{diff.shape} is an invalid shape for atom coordinates"
132
+ )
133
+ return disp
134
+
135
+ else:
136
+ return diff
137
+
138
+
139
+ def index_displacement(*args, **kwargs):
140
+ """
141
+ index_displacement(atoms, indices, periodic=False, box=None)
142
+
143
+ Measure the displacement, i.e. the vector difference, between pairs
144
+ of atoms.
145
+
146
+ The pairs refer to indices of a given atom array, whose pairwise
147
+ displacement should be calculated.
148
+ If an atom array stack is provided, the distances are calculated for
149
+ each frame/model.
150
+ In contrast to the :func:`distance()` function, this function is
151
+ able to take periodic boundary conditions into account.
152
+
153
+ Parameters
154
+ ----------
155
+ atoms : AtomArray or AtomArrayStack or ndarray, shape=(n,3) or shape=(m,n,3)
156
+ The atoms the `indices` parameter refers to.
157
+ The pairwise distances are calculated for these pairs.
158
+ Alternatively, the atom coordinates can be directly provided as
159
+ :class:`ndarray`.
160
+ indices : ndarray, shape=(k,2)
161
+ Pairs of indices that point to `atoms`.
162
+ The displacement is measured from ``indices[x,0]`` to
163
+ ``indices[x,1]``.
164
+ periodic : bool, optional
165
+ If set to true, periodic boundary conditions are taken into
166
+ account (minimum-image convention).
167
+ The `box` attribute of the `atoms` parameter is used for
168
+ calculation.
169
+ An alternative box can be provided via the `box` parameter.
170
+ By default, periodicity is ignored.
171
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
172
+ If this parameter is set, the given box is used instead of the
173
+ `box` attribute of `atoms`.
174
+
175
+ Returns
176
+ -------
177
+ disp : ndarray, shape=(k,) or shape=(m,k)
178
+ The pairwise displacements.
179
+ If `atoms` is an atom array stack, The distances are
180
+ calculated for each model.
181
+
182
+ Warnings
183
+ --------
184
+ In case `periodic` is set to true and if the box is not orthorhombic
185
+ (at least one angle deviates from 90 degrees),
186
+ the calculation requires approximately 8 times as long as in the
187
+ orthorhombic case.
188
+ Furthermore, it is not guaranteed, that the lowest-distance periodic
189
+ copy is found for non-orthorhombic boxes; this is especially true
190
+ for heavily skewed boxes.
191
+
192
+ See also
193
+ --------
194
+ displacement
195
+ """
196
+ return _call_non_index_function(displacement, 2, *args, **kwargs)
197
+
198
+
199
+ def distance(atoms1, atoms2, box=None):
200
+ """
201
+ Measure the euclidian distance between atoms.
202
+
203
+ Parameters
204
+ ----------
205
+ atoms1, atoms2 : ndarray or Atom or AtomArray or AtomArrayStack
206
+ The atoms to measure the distances between.
207
+ The dimensions may vary.
208
+ Alternatively an ndarray containing the coordinates can be
209
+ provided.
210
+ Usual *NumPy* broadcasting rules apply.
211
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
212
+ If this parameter is set, periodic boundary conditions are
213
+ taken into account (minimum-image convention), based on
214
+ the box vectors given with this parameter.
215
+ The shape *(m,3,3)* is only allowed, when the input coordinates
216
+ comprise multiple models.
217
+
218
+ Returns
219
+ -------
220
+ dist : float or ndarray
221
+ The atom distances.
222
+ The shape is equal to the shape of the input `atoms` with the
223
+ highest dimensionality minus the last axis.
224
+
225
+ See also
226
+ --------
227
+ index_distance
228
+ """
229
+ diff = displacement(atoms1, atoms2, box)
230
+ return np.sqrt(vector_dot(diff, diff))
231
+
232
+
233
+ def index_distance(*args, **kwargs):
234
+ """
235
+ index_distance(atoms, indices, periodic=False, box=None)
236
+
237
+ Measure the euclidian distance between pairs of atoms.
238
+
239
+ The pairs refer to indices of a given atom array, whose pairwise
240
+ distances should be calculated.
241
+ If an atom array stack is provided, the distances are calculated for
242
+ each frame/model.
243
+ In contrast to the :func:`distance()` function, this function is
244
+ able to take periodic boundary conditions into account.
245
+
246
+ Parameters
247
+ ----------
248
+ atoms : AtomArray or AtomArrayStack or ndarray, shape=(n,3) or shape=(m,n,3)
249
+ The atoms the `indices` parameter refers to.
250
+ The pairwise distances are calculated for these pairs.
251
+ Alternatively, the atom coordinates can be directly provided as
252
+ :class:`ndarray`.
253
+ indices : ndarray, shape=(k,2)
254
+ Pairs of indices that point to `atoms`.
255
+ periodic : bool, optional
256
+ If set to true, periodic boundary conditions are taken into
257
+ account (minimum-image convention).
258
+ The `box` attribute of the `atoms` parameter is used for
259
+ calculation.
260
+ An alternative box can be provided via the `box` parameter.
261
+ By default, periodicity is ignored.
262
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
263
+ If this parameter is set, the given box is used instead of the
264
+ `box` attribute of `atoms`.
265
+
266
+ Returns
267
+ -------
268
+ dist : ndarray, shape=(k,) or shape=(m,k)
269
+ The pairwise distances.
270
+ If `atoms` is an atom array stack, The distances are
271
+ calculated for each model.
272
+
273
+ Warnings
274
+ --------
275
+ In case `periodic` is set to true and if the box is not orthorhombic
276
+ (at least one angle deviates from 90 degrees),
277
+ the calculation requires approximately 8 times as long as in the
278
+ orthorhombic case.
279
+ Furthermore, it is not guaranteed, that the lowest-distance periodic
280
+ copy is found for non-orthorhombic boxes; this is especially true
281
+ for heavily skewed boxes.
282
+
283
+ See also
284
+ --------
285
+ distance
286
+ """
287
+ return _call_non_index_function(distance, 2, *args, **kwargs)
288
+
289
+
290
+ def angle(atoms1, atoms2, atoms3, box=None):
291
+ """
292
+ Measure the angle between 3 atoms.
293
+
294
+ Parameters
295
+ ----------
296
+ atoms1, atoms2, atoms3 : ndarray or Atom or AtomArray or AtomArrayStack
297
+ The atoms to measure the angle between. Alternatively an
298
+ ndarray containing the coordinates can be provided.
299
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
300
+ If this parameter is set, periodic boundary conditions are
301
+ taken into account (minimum-image convention), based on
302
+ the box vectors given with this parameter.
303
+ The shape *(m,3,3)* is only allowed, when the input coordinates
304
+ comprise multiple models.
305
+
306
+ Returns
307
+ -------
308
+ angle : float or ndarray
309
+ The angle(s) between the atoms. The shape is equal to the shape
310
+ of the input `atoms` with the highest dimensionality minus the
311
+ last axis.
312
+
313
+ See also
314
+ --------
315
+ index_angle
316
+ """
317
+ v1 = displacement(atoms1, atoms2, box)
318
+ v2 = displacement(atoms3, atoms2, box)
319
+ norm_vector(v1)
320
+ norm_vector(v2)
321
+ return np.arccos(vector_dot(v1,v2))
322
+
323
+
324
+ def index_angle(*args, **kwargs):
325
+ """
326
+ index_angle(atoms, indices, periodic=False, box=None)
327
+
328
+ Measure the angle between triples of atoms.
329
+
330
+ The triples refer to indices of a given atom array, whose triplewise
331
+ angles should be calculated.
332
+ If an atom array stack is provided, the distances are calculated for
333
+ each frame/model.
334
+
335
+ Parameters
336
+ ----------
337
+ atoms : AtomArray or AtomArrayStack or ndarray, shape=(n,3) or shape=(m,n,3)
338
+ The atoms the `indices` parameter refers to.
339
+ The triplewise distances are calculated for these pairs.
340
+ Alternatively, the atom coordinates can be directly provided as
341
+ :class:`ndarray`.
342
+ indices : ndarray, shape=(k,3)
343
+ Triples of indices that point to `atoms`.
344
+ periodic : bool, optional
345
+ If set to true, periodic boundary conditions are taken into
346
+ account (minimum-image convention).
347
+ The `box` attribute of the `atoms` parameter is used for
348
+ calculation.
349
+ An alternative box can be provided via the `box` parameter.
350
+ By default, periodicity is ignored.
351
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
352
+ If this parameter is set, the given box is used instead of the
353
+ `box` attribute of `atoms`.
354
+
355
+ Returns
356
+ -------
357
+ angle : ndarray, shape=(k,) or shape=(m,k)
358
+ The triplewise angles.
359
+ If `atoms` is an atom array stack, The distances are
360
+ calculated for each model.
361
+
362
+ Warnings
363
+ --------
364
+ In case `periodic` is set to true and if the box is not orthorhombic
365
+ (at least one angle deviates from 90 degrees),
366
+ the calculation requires approximately 8 times as long as in the
367
+ orthorhombic case.
368
+ Furthermore, it is not guaranteed, that the lowest-distance periodic
369
+ copy is found for non-orthorhombic boxes; this is especially true
370
+ for heavily skewed boxes.
371
+
372
+ See also
373
+ --------
374
+ angle
375
+ """
376
+ return _call_non_index_function(angle, 3, *args, **kwargs)
377
+
378
+
379
+ def dihedral(atoms1, atoms2, atoms3, atoms4, box=None):
380
+ """
381
+ Measure the dihedral angle between 4 atoms.
382
+
383
+ Parameters
384
+ ----------
385
+ atoms1, atoms2, atoms3, atoms4 : ndarray or Atom or AtomArray or AtomArrayStack
386
+ The atoms to measure the dihedral angle between.
387
+ Alternatively an ndarray containing the coordinates can be
388
+ provided.
389
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
390
+ If this parameter is set, periodic boundary conditions are
391
+ taken into account (minimum-image convention), based on
392
+ the box vectors given with this parameter.
393
+ The shape *(m,3,3)* is only allowed, when the input coordinates
394
+ comprise multiple models.
395
+
396
+ Returns
397
+ -------
398
+ dihed : float or ndarray
399
+ The dihedral angle(s) between the atoms. The shape is equal to
400
+ the shape of the input `atoms` with the highest dimensionality
401
+ minus the last axis.
402
+
403
+ See Also
404
+ --------
405
+ index_dihedral
406
+ dihedral_backbone
407
+ """
408
+ v1 = displacement(atoms1, atoms2, box)
409
+ v2 = displacement(atoms2, atoms3, box)
410
+ v3 = displacement(atoms3, atoms4, box)
411
+ norm_vector(v1)
412
+ norm_vector(v2)
413
+ norm_vector(v3)
414
+
415
+ n1 = np.cross(v1, v2)
416
+ n2 = np.cross(v2, v3)
417
+
418
+ # Calculation using atan2, to ensure the correct sign of the angle
419
+ x = vector_dot(n1,n2)
420
+ y = vector_dot(np.cross(n1,n2), v2)
421
+ return np.arctan2(y,x)
422
+
423
+
424
+ def index_dihedral(*args, **kwargs):
425
+ """
426
+ index_dihedral(atoms, indices, periodic=False, box=None)
427
+
428
+ Measure the dihedral angle between quadruples of atoms.
429
+
430
+ The triples refer to indices of a given atom array, whose
431
+ quadruplewise dihedral angles should be calculated.
432
+ If an atom array stack is provided, the distances are calculated for
433
+ each frame/model.
434
+
435
+ Parameters
436
+ ----------
437
+ atoms : AtomArray or AtomArrayStack or ndarray, shape=(n,3) or shape=(m,n,3)
438
+ The atoms the `indices` parameter refers to.
439
+ The quadruplewise dihedral angles are calculated for these
440
+ pairs.
441
+ Alternatively, the atom coordinates can be directly provided as
442
+ :class:`ndarray`.
443
+ indices : ndarray, shape=(k,4)
444
+ Quadruples of indices that point to `atoms`.
445
+ periodic : bool, optional
446
+ If set to true, periodic boundary conditions are taken into
447
+ account (minimum-image convention).
448
+ The `box` attribute of the `atoms` parameter is used for
449
+ calculation.
450
+ An alternative box can be provided via the `box` parameter.
451
+ By default, periodicity is ignored.
452
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
453
+ If this parameter is set, the given box is used instead of the
454
+ `box` attribute of `atoms`.
455
+
456
+ Returns
457
+ -------
458
+ dihedral : ndarray, shape=(k,) or shape=(m,k)
459
+ The quadruplewise dihedral angles.
460
+ If `atoms` is an atom array stack, The distances are
461
+ calculated for each model.
462
+
463
+ Warnings
464
+ --------
465
+ In case `periodic` is set to true and if the box is not orthorhombic
466
+ (at least one angle deviates from 90 degrees),
467
+ the calculation requires approximately 8 times as long as in the
468
+ orthorhombic case.
469
+ Furthermore, it is not guaranteed, that the lowest-distance periodic
470
+ copy is found for non-orthorhombic boxes; this is especially true
471
+ for heavily skewed boxes.
472
+
473
+ See also
474
+ --------
475
+ dihedral
476
+ dihedral_backbone
477
+ """
478
+ return _call_non_index_function(dihedral, 4, *args, **kwargs)
479
+
480
+
481
+ def dihedral_backbone(atom_array):
482
+ """
483
+ Measure the characteristic backbone dihedral angles of a protein
484
+ structure.
485
+
486
+ Parameters
487
+ ----------
488
+ atom_array: AtomArray or AtomArrayStack
489
+ The protein structure. A complete backbone, without gaps,
490
+ is required here.
491
+ Chain transitions are allowed, the angles at the transition are
492
+ `NaN`.
493
+ The order of the backbone atoms for each residue must be
494
+ (N, CA, C).
495
+
496
+ Returns
497
+ -------
498
+ phi, psi, omega : ndarray
499
+ An array containing the 3 backbone dihedral angles for every
500
+ CA. 'phi' is not defined at the N-terminus, 'psi' and 'omega'
501
+ are not defined at the C-terminus. In these places the arrays
502
+ have *NaN* values. If an :class:`AtomArrayStack` is given, the
503
+ output angles are 2-dimensional, the first dimension corresponds
504
+ to the model number.
505
+
506
+ Raises
507
+ ------
508
+ BadStructureError
509
+ If the amount of backbone atoms is not equal to amount of
510
+ residues times 3 (for N, CA and C).
511
+
512
+ See Also
513
+ --------
514
+ dihedral
515
+
516
+ Examples
517
+ --------
518
+
519
+ >>> phi, psi, omega = dihedral_backbone(atom_array)
520
+ >>> print(np.stack([np.rad2deg(phi), np.rad2deg(psi)]).T)
521
+ [[ nan -56.145]
522
+ [ -43.980 -51.309]
523
+ [ -66.466 -30.898]
524
+ [ -65.219 -45.945]
525
+ [ -64.747 -30.346]
526
+ [ -73.136 -43.425]
527
+ [ -64.882 -43.255]
528
+ [ -59.509 -25.698]
529
+ [ -77.989 -8.823]
530
+ [ 110.784 8.079]
531
+ [ 55.244 -124.371]
532
+ [ -57.983 -28.766]
533
+ [ -81.834 19.125]
534
+ [-124.057 13.401]
535
+ [ 67.931 25.218]
536
+ [-143.952 131.297]
537
+ [ -70.100 160.068]
538
+ [ -69.484 145.669]
539
+ [ -77.264 124.223]
540
+ [ -78.100 nan]]
541
+ """
542
+ bb_filter = filter_peptide_backbone(atom_array)
543
+ backbone = atom_array[..., bb_filter]
544
+
545
+ if backbone.array_length() % 3 != 0 \
546
+ or (backbone.atom_name[0::3] != "N" ).any() \
547
+ or (backbone.atom_name[1::3] != "CA").any() \
548
+ or (backbone.atom_name[2::3] != "C" ).any():
549
+ raise BadStructureError(
550
+ "The backbone is invalid, must be repeats of (N, CA, C), "
551
+ "maybe a backbone atom is missing"
552
+ )
553
+ phis = []
554
+ psis = []
555
+ omegas = []
556
+ for chain_bb in chain_iter(backbone):
557
+ phi, psi, omega = _dihedral_backbone(chain_bb)
558
+ phis.append(phi)
559
+ psis.append(psi)
560
+ omegas.append(omega)
561
+ return np.concatenate(phis, axis=-1), np.concatenate(psis, axis=-1), \
562
+ np.concatenate(omegas, axis=-1)
563
+
564
+
565
+
566
+ def _dihedral_backbone(chain_bb):
567
+ bb_coord = chain_bb.coord
568
+ # Coordinates for dihedral angle calculation
569
+ # Dim 0: Model index (only for atom array stacks)
570
+ # Dim 1: Angle index
571
+ # Dim 2: X, Y, Z coordinates
572
+ # Dim 3: Atoms involved in dihedral angle
573
+ if isinstance(chain_bb, AtomArray):
574
+ angle_coord_shape = (len(bb_coord)//3, 3, 4)
575
+ elif isinstance(chain_bb, AtomArrayStack):
576
+ angle_coord_shape = (bb_coord.shape[0], bb_coord.shape[1]//3, 3, 4)
577
+ phi_coord = np.full(angle_coord_shape, np.nan)
578
+ psi_coord = np.full(angle_coord_shape, np.nan)
579
+ omega_coord = np.full(angle_coord_shape, np.nan)
580
+
581
+ # Indices for coordinates of CA atoms
582
+ ca_i = np.arange(bb_coord.shape[-2]//3) * 3 + 1
583
+ phi_coord [..., 1: , :, 0] = bb_coord[..., ca_i[1: ]-2 ,:]
584
+ phi_coord [..., 1: , :, 1] = bb_coord[..., ca_i[1: ]-1 ,:]
585
+ phi_coord [..., 1: , :, 2] = bb_coord[..., ca_i[1: ] ,:]
586
+ phi_coord [..., 1: , :, 3] = bb_coord[..., ca_i[1: ]+1 ,:]
587
+ psi_coord [..., :-1, :, 0] = bb_coord[..., ca_i[:-1]-1 ,:]
588
+ psi_coord [..., :-1, :, 1] = bb_coord[..., ca_i[:-1] ,:]
589
+ psi_coord [..., :-1, :, 2] = bb_coord[..., ca_i[:-1]+1 ,:]
590
+ psi_coord [..., :-1, :, 3] = bb_coord[..., ca_i[:-1]+2 ,:]
591
+ omega_coord[..., :-1, :, 0] = bb_coord[..., ca_i[:-1] ,:]
592
+ omega_coord[..., :-1, :, 1] = bb_coord[..., ca_i[:-1]+1 ,:]
593
+ omega_coord[..., :-1, :, 2] = bb_coord[..., ca_i[:-1]+2 ,:]
594
+ omega_coord[..., :-1, :, 3] = bb_coord[..., ca_i[:-1]+3 ,:]
595
+
596
+ phi = dihedral(phi_coord[...,0], phi_coord[...,1],
597
+ phi_coord[...,2], phi_coord[...,3])
598
+ psi = dihedral(psi_coord[...,0], psi_coord[...,1],
599
+ psi_coord[...,2], psi_coord[...,3])
600
+ omega = dihedral(omega_coord[...,0], omega_coord[...,1],
601
+ omega_coord[...,2], omega_coord[...,3])
602
+
603
+ return phi, psi, omega
604
+
605
+
606
+ def centroid(atoms):
607
+ """
608
+ Measure the centroid of a structure.
609
+
610
+ Parameters
611
+ ----------
612
+ atoms: ndarray or AtomArray or AtomArrayStack
613
+ The structures to determine the centroid from.
614
+ Alternatively an ndarray containing the coordinates can be
615
+ provided.
616
+
617
+ Returns
618
+ -------
619
+ centroid : float or ndarray
620
+ The centroid of the structure(s). :class:`ndarray` is returned when
621
+ an :class:`AtomArrayStack` is given (centroid for each model).
622
+ """
623
+ return np.mean(coord(atoms), axis=-2)
624
+
625
+
626
+ def _call_non_index_function(function, expected_amount,
627
+ atoms, indices, periodic=False, box=None):
628
+ """
629
+ Call an `xxx()` function based on the parameters given to a
630
+ `index_xxx()` function.
631
+ """
632
+ if indices.shape[-1] != expected_amount:
633
+ raise ValueError(
634
+ f"Expected length {expected_amount} in the last dimension "
635
+ f"of the indices, but got length {indices.shape[-1]}"
636
+ )
637
+ coord_list = []
638
+ for i in range(expected_amount):
639
+ coord_list.append(coord(atoms)[..., indices[:,i], :])
640
+ if periodic:
641
+ if box is None:
642
+ if isinstance(atoms, (AtomArray, AtomArrayStack)):
643
+ box = atoms.box
644
+ else:
645
+ raise ValueError(
646
+ "If `atoms` are coordinates, "
647
+ "the box must be set explicitly"
648
+ )
649
+ else:
650
+ box = None
651
+ return function(*coord_list, box)
652
+
653
+
654
+ def _displacement_orthogonal_box(fractions, box, disp):
655
+ """
656
+ Fill in the PBC-aware displacement vector for non-PBC-aware
657
+ displacements given as fractions of given box vectors.
658
+ """
659
+ # Fraction components are guaranteed to be positive
660
+ # Use fraction vector components with lower absolute
661
+ # -> new_vec[i] = vec[i] - 1 if vec[i] > 0.5 else vec[i]
662
+ fractions[fractions > 0.5] -= 1
663
+ disp[:] = fraction_to_coord(fractions, box)
664
+
665
+
666
+ def _displacement_triclinic_box(fractions, box, disp):
667
+ """
668
+ Fill in the PBC-aware displacement vector for non-PBC-aware
669
+ displacements given as fractions of given box vectors.
670
+ """
671
+ diffs = fraction_to_coord(fractions, box)
672
+ # Fraction components are guaranteed to be positive
673
+ # Test all 3 fraction vector components
674
+ # with positive and negative sign
675
+ # (i,j,k in {-1, 0})
676
+ # Hence, 8 periodic copies are tested
677
+ periodic_shift = []
678
+ for i in range(-1, 1):
679
+ for j in range(-1, 1):
680
+ for k in range(-1, 1):
681
+ x = i*box[0,0] + j*box[1,0] + k*box[2,0]
682
+ y = i*box[0,1] + j*box[1,1] + k*box[2,1]
683
+ z = i*box[0,2] + j*box[1,2] + k*box[2,2]
684
+ periodic_shift.append([x,y,z])
685
+ periodic_shift = np.array(periodic_shift, dtype=disp.dtype)
686
+ # Create 8 periodically shifted variants for each atom
687
+ shifted_diffs = diffs[:, np.newaxis, :] + periodic_shift[np.newaxis, :, :]
688
+ # Find for each atom the periodically shifted variant with lowest
689
+ # distance
690
+ # Lowest squared distance -> lowest distance
691
+ sq_distance = vector_dot(shifted_diffs, shifted_diffs)
692
+ # for each given non-PBC-aware displacement find the PBC-aware
693
+ # displacement with the lowest distance
694
+ disp[:] = shifted_diffs[
695
+ np.arange(len(shifted_diffs)),
696
+ np.argmin(sq_distance, axis=1)
697
+ ]
@@ -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
+ A subpackage for visualizing structure related objects.
7
+ """
8
+
9
+ __name__ = "biotite.structure.graphics"
10
+ __author__ = "Patrick Kunzmann, Tom David Müller"
11
+
12
+ from .atoms import *
13
+ from .rna import *