biotite 0.41.1__cp312-cp312-macosx_10_16_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 (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-312-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-312-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-312-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-312-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-312-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-312-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-312-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-312-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-312-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-312-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-312-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-312-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-312-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-312-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-312-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-312-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-312-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-312-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-312-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-312-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-312-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-312-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-312-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-312-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-312-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,274 @@
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 calculation of characteristic values when
7
+ comparing multiple structures with each other.
8
+ """
9
+
10
+ __name__ = "biotite.structure"
11
+ __author__ = "Patrick Kunzmann"
12
+ __all__ = ["rmsd", "rmspd", "rmsf", "average"]
13
+
14
+ import numpy as np
15
+ from .atoms import Atom, AtomArray, AtomArrayStack, coord
16
+ from .geometry import index_distance
17
+ from .util import vector_dot
18
+
19
+
20
+ def rmsd(reference, subject):
21
+ r"""
22
+ Calculate the RMSD between two structures.
23
+
24
+ The *root-mean-square-deviation* (RMSD) indicates the overall
25
+ deviation of each model of a structure to a reference structure.
26
+ It is defined as:
27
+
28
+ .. math:: RMSD = \sqrt{ \frac{1}{n} \sum\limits_{i=1}^n (x_i - x_{ref,i})^2}
29
+
30
+ Parameters
31
+ ----------
32
+ reference : AtomArray or ndarray, dtype=float, shape=(n,3)
33
+ The reference structure.
34
+ Alternatively, coordinates can be provided directly as
35
+ :class:`ndarray`.
36
+ subject : AtomArray or AtomArrayStack or ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
37
+ Structure(s) to be compared with `reference`.
38
+ Alternatively, coordinates can be provided directly as
39
+ :class:`ndarray`.
40
+
41
+ Returns
42
+ -------
43
+ rmsd : float or ndarray, dtype=float, shape=(m,)
44
+ RMSD between subject and reference.
45
+ If subject is an :class:`AtomArray` a float is returned.
46
+ If subject is an :class:`AtomArrayStack` a :class:`ndarray`
47
+ containing the RMSD for each model is returned.
48
+
49
+ See Also
50
+ --------
51
+ rmsf
52
+
53
+ Notes
54
+ -----
55
+ This function does not superimpose the subject to its reference.
56
+ In most cases :func:`superimpose()` should be called prior to this
57
+ function.
58
+
59
+ Examples
60
+ --------
61
+
62
+ Calculate the RMSD of all models to the first model:
63
+
64
+ >>> superimposed, _ = superimpose(atom_array, atom_array_stack)
65
+ >>> rms = rmsd(atom_array, superimposed)
66
+ >>> print(np.around(rms, decimals=3))
67
+ [0.000 1.928 2.103 2.209 1.806 2.172 2.704 1.360 2.337 1.818 1.879 2.471
68
+ 1.939 2.035 2.167 1.789 1.653 2.348 2.247 2.529 1.583 2.115 2.131 2.050
69
+ 2.512 2.666 2.206 2.397 2.328 1.868 2.316 1.984 2.124 1.761 2.642 1.721
70
+ 2.571 2.579]
71
+ """
72
+ return np.sqrt(np.mean(_sq_euclidian(reference, subject), axis=-1))
73
+
74
+ def rmspd(reference, subject, periodic=False, box=None):
75
+ r"""
76
+ Calculate the RMSD of atom pair distances for given structures
77
+ relative to those found in a reference structure.
78
+
79
+ Unlike the standard RMSD, the *root-mean-square-pairwise-deviation*
80
+ (RMSPD) is a fit-free method to determine deviations between
81
+ a structure and a preset reference.
82
+
83
+ .. math:: RMSPD = \sqrt{ \frac{1}{n^2} \sum\limits_{i=1}^n \sum\limits_{j \neq i}^n (d_{ij} - d_{ref,ij})^2}
84
+
85
+ Parameters
86
+ ----------
87
+ reference : AtomArray or ndarray, dtype=float, shape=(n,3)
88
+ The reference structure.
89
+ Alternatively, coordinates can be provided directly as
90
+ :class:`ndarray`.
91
+ subject : AtomArray or AtomArrayStack or ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
92
+ Structure(s) to be compared with `reference`.
93
+ Alternatively, coordinates can be provided directly as
94
+ :class:`ndarray`.
95
+ periodic : bool, optional
96
+ If set to true, periodic boundary conditions are taken into
97
+ account (minimum-image convention).
98
+ The `box` attribute of the `atoms` parameter is used for
99
+ calculation.
100
+ An alternative box can be provided via the `box` parameter.
101
+ By default, periodicity is ignored.
102
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
103
+ If this parameter is set, the given box is used instead of the
104
+ `box` attribute of `atoms`.
105
+
106
+ Returns
107
+ -------
108
+ rmspd : float or ndarray, dtype=float, shape=(m,)
109
+ Atom pair distance RMSD between subject and reference.
110
+ If subject is an :class:`AtomArray` a float is returned.
111
+ If subject is an :class:`AtomArrayStack` a :class:`ndarray`
112
+ containing the RMSD for each model is returned.
113
+
114
+ Warnings
115
+ --------
116
+ Internally, this function uses :func:`index_distance()`.
117
+ For non-orthorombic boxes (at least one angle deviates from
118
+ 90 degrees), periodic boundary conditions should be corrected
119
+ prior to the computation of RMSPDs with `periodic` set to false
120
+ to ensure correct results.
121
+ (e.g. with :func:`remove_pbc()`).
122
+
123
+ See also
124
+ --------
125
+ index_distance
126
+ remove_pbc
127
+ rmsd
128
+ """
129
+ # Compute index pairs in reference structure -> pair_ij for j < i
130
+ reflen = reference.array_length()
131
+ index_i = np.repeat(np.arange(reflen), reflen)
132
+ index_j = np.tile(np.arange(reflen), reflen)
133
+ pairs = np.stack([index_i, index_j]).T
134
+ refdist = index_distance(reference, pairs, periodic=periodic, box=box)
135
+ subjdist = index_distance(subject, pairs, periodic=periodic, box=box)
136
+
137
+ rmspd = np.sqrt(np.sum((subjdist - refdist)**2, axis = -1))/reflen
138
+ return rmspd
139
+
140
+ def rmsf(reference, subject):
141
+ r"""
142
+ Calculate the RMSF between two structures.
143
+
144
+ The *root-mean-square-fluctuation* (RMSF) indicates the positional
145
+ deviation of a structure to a reference structure, averaged over all
146
+ models.
147
+ Usually the reference structure, is the average over all models.
148
+ The RMSF is defined as:
149
+
150
+ .. math:: RMSF(i) = \sqrt{ \frac{1}{T} \sum\limits_{t=1}^T (x_i(t) - x_{ref,i}(t))^2}
151
+
152
+ Parameters
153
+ ----------
154
+ reference : AtomArray or ndarray, dtype=float, shape=(n,3)
155
+ The reference structure.
156
+ Alternatively, coordinates can be provided directly as
157
+ :class:`ndarray`.
158
+ subject : AtomArrayStack or ndarray, dtype=float, shape=(m,n,3)
159
+ Structures to be compared with `reference`.
160
+ The time *t* is represented by the models in the
161
+ :class:`AtomArrayStack`.
162
+ Alternatively, coordinates can be provided directly as
163
+ :class:`ndarray`.
164
+
165
+ Returns
166
+ -------
167
+ rmsf : ndarray, dtype=float, shape=(n,)
168
+ RMSF between subject and reference structure.
169
+ Each element gives the RMSF for the atom at the respective
170
+ index.
171
+
172
+ See Also
173
+ --------
174
+ rmsd
175
+
176
+ Notes
177
+ -----
178
+ This function does not superimpose the subject to its reference.
179
+ In most cases :func:`superimpose()` should be called prior to this
180
+ function.
181
+
182
+ Examples
183
+ --------
184
+
185
+ Calculate the :math:`C_\alpha` RMSF of all models to the average
186
+ model:
187
+
188
+ >>> ca = atom_array_stack[:, atom_array_stack.atom_name == "CA"]
189
+ >>> ca_average = average(ca)
190
+ >>> ca, _ = superimpose(ca_average, ca)
191
+ >>> print(rmsf(ca_average, ca))
192
+ [1.372 0.360 0.265 0.261 0.288 0.204 0.196 0.306 0.353 0.238 0.266 0.317
193
+ 0.358 0.448 0.586 0.369 0.332 0.396 0.410 0.968]
194
+ """
195
+ return np.sqrt(np.mean(_sq_euclidian(reference, subject), axis=-2))
196
+
197
+
198
+ def average(atoms):
199
+ """
200
+ Calculate an average structure.
201
+
202
+ The average structure has the average coordinates
203
+ of the input models.
204
+
205
+ Parameters
206
+ ----------
207
+ atoms : AtomArrayStack or ndarray, dtype=float, shape=(m,n,3)
208
+ The structure models to be averaged.
209
+ Alternatively, coordinates can be provided directly as
210
+ :class:`ndarray`.
211
+
212
+ Returns
213
+ -------
214
+ average : AtomArray or ndarray, dtype=float, shape=(n,3)
215
+ Structure with averaged atom coordinates.
216
+ If `atoms` is a :class:`ndarray` and :class:`ndarray` is also
217
+ returned.
218
+
219
+ See Also
220
+ --------
221
+ rmsd, rmsf
222
+
223
+ Notes
224
+ -----
225
+ The calculated average structure is not suitable for visualization
226
+ or geometric calculations, since bond lengths and angles will
227
+ deviate from meaningful values.
228
+ This method is rather useful to provide a reference structure for
229
+ calculation of e.g. the RMSD or RMSF.
230
+ """
231
+ coords = coord(atoms)
232
+ if coords.ndim != 3:
233
+ raise TypeError(
234
+ "Expected an AtomArrayStack or an ndarray with shape (m,n,3)"
235
+ )
236
+ mean_coords = np.mean(coords, axis=0)
237
+ if isinstance(atoms, AtomArrayStack):
238
+ mean_array = atoms[0].copy()
239
+ mean_array.coord = mean_coords
240
+ return mean_array
241
+ else:
242
+ return mean_coords
243
+
244
+
245
+ def _sq_euclidian(reference, subject):
246
+ """
247
+ Calculate squared euclidian distance between atoms in two
248
+ structures.
249
+
250
+ Parameters
251
+ ----------
252
+ reference : AtomArray or ndarray, dtype=float, shape=(n,3)
253
+ Reference structure.
254
+ subject : AtomArray or AtomArrayStack or ndarray, dtype=float, shape=(n,3) or shape=(m,n,3)
255
+ Structure(s) whose atoms squared euclidian distance to
256
+ `reference` is measured.
257
+
258
+ Returns
259
+ -------
260
+ ndarray, dtype=float, shape=(n,) or shape=(m,n)
261
+ Squared euclidian distance between subject and reference.
262
+ If subject is an :class:`AtomArray` a 1-D array is returned.
263
+ If subject is an :class:`AtomArrayStack` a 2-D array is
264
+ returned.
265
+ In this case the first dimension indexes the AtomArray.
266
+ """
267
+ reference_coord = coord(reference)
268
+ subject_coord = coord(subject)
269
+ if reference_coord.ndim != 2:
270
+ raise TypeError(
271
+ "Expected an AtomArray or an ndarray with shape (n,3) as reference"
272
+ )
273
+ dif = subject_coord - reference_coord
274
+ return vector_dot(dif, dif)
@@ -0,0 +1,114 @@
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 to calculate atomistic densities.
7
+ """
8
+
9
+ __name__ = "biotite.structure"
10
+ __author__ = "Daniel Bauer"
11
+ __all__ = ["density"]
12
+
13
+ import numpy as np
14
+ from .atoms import coord
15
+
16
+
17
+ def density(atoms, selection=None, delta=1.0, bins=None,
18
+ density=False, weights=None):
19
+ r"""
20
+ Compute the density of the selected atoms.
21
+
22
+ This creates a 3d histogram over the coordinates of selected atoms.
23
+ By default, the grid for the histogram is built based on the
24
+ coordinates of the given `atoms` with an even gridspacing of
25
+ `delta` in all three dimensions.
26
+ Alternatively, a custom grid can be used.
27
+
28
+ Parameters
29
+ ----------
30
+ atoms : AtomArray or AtomArrayStack or ndarray, shape=(n,3) or shape=(m,n,3)
31
+ The density is calculated based on these atoms.
32
+ Alternatively, the coordinates can be directly provided as
33
+ `ndarray`.
34
+ selection : ndarray, dtype=bool, shape=(n,), optional
35
+ Boolean mask for `atoms` to calculate the density only on a set
36
+ of atoms.
37
+ delta : float, optional
38
+ Distance between grid points for density calculation (in Å).
39
+ bins : int or sequence of scalars or str, optional
40
+ Bins for the RDF.
41
+
42
+ - If `bins` is an `int`, it defines the number of bins.
43
+ - If `bins` is a sequence, it defines the bin edges, ignoring
44
+ the actual coordinates of the `atoms` selection.
45
+ - If `bins` is a string, it defines the function used to
46
+ calculate the bins.
47
+
48
+ See :func:`numpy.histogramdd()` for further details.
49
+ density : boolean, optional
50
+ If False, the number of samples in each bin is returned.
51
+ Otherwise, returns the probability density function of each bin.
52
+ See :func:`numpy.histogramdd()` for further details.
53
+ weights: ndarray, shape=(n,) or shape=(m,n), optional
54
+ An array of values to weight the contribution of *n* atoms in
55
+ *m* models.
56
+ If the shape is *(n,)*, the weights will be interpreted as
57
+ *per atom*.
58
+ A shape of *(m,n)* allows to additionally weight atoms on a
59
+ *per model* basis.
60
+
61
+ Returns
62
+ -------
63
+ H : ndarray, dtype=float
64
+ The threedimensional histogram of the selected atoms.
65
+ The histogram takes the atoms in all models into account.
66
+ The length of the histogram depends on `atoms` coordinates and
67
+ `delta`, or the supplied `bins` input parameter.
68
+ edges : list of ndarray, dtype=float
69
+ A list containing the 3 arrays describing the bin edges.
70
+ """
71
+ coords = coord(atoms)
72
+
73
+ is_stack = coords.ndim == 3
74
+
75
+ # Define the grid for coordinate binning based on coordinates of
76
+ # supplied atoms
77
+ # This makes the binning independent of a supplied box vector and
78
+ # fluctuating box dimensions are not a problem
79
+ # However, this means that the user has to make sure the region of
80
+ # interest is in the center of the box, i.e. by centering the
81
+ # investigated protein in the box.
82
+ if bins is None:
83
+ if is_stack:
84
+ axis = (0, 1)
85
+ else:
86
+ axis = 0
87
+ grid_min, grid_max = np.min(
88
+ coords, axis=axis), np.max(coords, axis=axis
89
+ )
90
+ bins = [
91
+ np.arange(grid_min[0], grid_max[0]+delta, delta),
92
+ np.arange(grid_min[1], grid_max[1]+delta, delta),
93
+ np.arange(grid_min[2], grid_max[2]+delta, delta),
94
+ ]
95
+
96
+ if selection is None:
97
+ selected_coords = coords
98
+ else:
99
+ selected_coords = coords[...,selection, :]
100
+
101
+ # Reshape the coords into Nx3
102
+ coords = selected_coords.reshape((np.prod(selected_coords.shape[:-1]), 3))
103
+
104
+ # We need a weight value per coordinate, but input might be per atom
105
+ if weights is not None:
106
+ if is_stack and len(weights.shape) < 2:
107
+ weights = np.tile(weights, len(selected_coords))
108
+ weights = weights.reshape(coords.shape[0])
109
+
110
+ # Calculate the histogram
111
+ hist = np.histogramdd(
112
+ coords, bins=bins, density=density, weights=weights
113
+ )
114
+ return hist
@@ -0,0 +1,216 @@
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 handles conversion of RNA structures to
7
+ dot-bracket-notation.
8
+ """
9
+
10
+ __name__ = "biotite.structure"
11
+ __author__ = "Tom David Müller"
12
+ __all__ = ["dot_bracket_from_structure", "dot_bracket",
13
+ "base_pairs_from_dot_bracket"]
14
+
15
+ import numpy as np
16
+ from .basepairs import base_pairs
17
+ from .pseudoknots import pseudoknots
18
+ from .residues import get_residue_count, get_residue_positions
19
+
20
+ _OPENING_BRACKETS = "([{<ABCDEFGHIJKLMNOPQRSTUVWXYZ"
21
+ _OPENING_BRACKETS_BYTES = _OPENING_BRACKETS.encode()
22
+ _CLOSING_BRACKETS = ")]}>abcdefghijklmnopqrstuvwxyz"
23
+ _CLOSING_BRACKETS_BYTES = _CLOSING_BRACKETS.encode()
24
+
25
+
26
+ def dot_bracket_from_structure(
27
+ nucleic_acid_strand, scores=None, max_pseudoknot_order=None):
28
+ """
29
+ Represent a nucleic-acid-strand in dot-bracket-letter-notation
30
+ (DBL-notation). :footcite:`Antczak2018`
31
+
32
+ Parameters
33
+ ----------
34
+ atom_array : AtomArray
35
+ The nucleic acid strand to be represented in DBL-notation.
36
+ scores : ndarray, dtype=int, shape=(n,) (default: None)
37
+ The score for each base pair, which is passed on to
38
+ :func:`pseudoknots()`.
39
+ max_pseudoknot_order : int (default: None)
40
+ The maximum pseudoknot order to be found. If a base pair would
41
+ be of a higher order, it is represented as unpaired. If ``None``
42
+ is given, all base pairs are evaluated.
43
+
44
+ Returns
45
+ -------
46
+ notations : list [str, ...]
47
+ The DBL-notation for each solution from :func:`pseudoknots()`.
48
+
49
+ See Also
50
+ --------
51
+ base_pairs
52
+ pseudoknots
53
+
54
+ References
55
+ ----------
56
+
57
+ .. footbibliography::
58
+ """
59
+ basepairs = base_pairs(nucleic_acid_strand)
60
+ if len(basepairs) == 0:
61
+ return ['']
62
+ basepairs = get_residue_positions(nucleic_acid_strand, basepairs)
63
+ length = get_residue_count(nucleic_acid_strand)
64
+ return dot_bracket(basepairs, length, scores=scores,
65
+ max_pseudoknot_order=max_pseudoknot_order)
66
+
67
+ def dot_bracket(basepairs, length, scores=None, max_pseudoknot_order=None):
68
+ """
69
+ Represent a nucleic acid strand in dot-bracket-letter-notation
70
+ (DBL-notation). :footcite:`Antczak2018`
71
+
72
+ The nucleic acid strand is represented as nucleotide sequence,
73
+ where the nucleotides are counted continiously from zero.
74
+
75
+ Parameters
76
+ ----------
77
+ basepairs : ndarray, shape=(n,2)
78
+ Each row corresponds to the positions of the bases in the
79
+ strand.
80
+ length : int
81
+ The number of bases in the strand.
82
+ scores : ndarray, dtype=int, shape=(n,) (default: None)
83
+ The score for each base pair, which is passed on to
84
+ :func:`pseudoknots()`
85
+ max_pseudoknot_order : int (default: None)
86
+ The maximum pseudoknot order to be found. If a base pair would
87
+ be of a higher order, it is represented as unpaired. If ``None``
88
+ is given, all pseudoknot orders are evaluated.
89
+
90
+ Returns
91
+ -------
92
+ notations : list [str, ...]
93
+ The DBL-notation for each solution from :func:`pseudoknots()`.
94
+
95
+ Examples
96
+ --------
97
+ The sequence ``ACGTC`` has a length of 5. If there was to be a
98
+ pairing interaction between the ``A`` and ``T``, `basepairs` would
99
+ have the form:
100
+
101
+ >>> import numpy as np
102
+ >>> basepairs = np.array([[0, 3]])
103
+
104
+ The DBL Notation can then be found with ``dot_bracket()``:
105
+
106
+ >>> dot_bracket(basepairs, 5)[0]
107
+ '(..).'
108
+
109
+
110
+ See Also
111
+ --------
112
+ dot_bracket_from_structure
113
+ base_pairs
114
+ pseudoknots
115
+
116
+ References
117
+ ----------
118
+
119
+ .. footbibliography::
120
+ """
121
+ # Make sure the lower residue is on the left for each row
122
+ basepairs = np.sort(basepairs, axis=1)
123
+
124
+ # Get pseudoknot order
125
+ pseudoknot_order = pseudoknots(basepairs, scores=scores,
126
+ max_pseudoknot_order=max_pseudoknot_order)
127
+
128
+ # Each optimal pseudoknot order solution is represented in
129
+ # dot-bracket-notation
130
+ notations = [
131
+ bytearray((b"."*length)) for _ in range(len(pseudoknot_order))
132
+ ]
133
+ for s, solution in enumerate(pseudoknot_order):
134
+ for basepair, order in zip(basepairs, solution):
135
+ if order == -1:
136
+ continue
137
+ notations[s][basepair[0]] = _OPENING_BRACKETS_BYTES[order]
138
+ notations[s][basepair[1]] = _CLOSING_BRACKETS_BYTES[order]
139
+ return [notation.decode() for notation in notations]
140
+
141
+ def base_pairs_from_dot_bracket(dot_bracket_notation):
142
+ """
143
+ Extract the base pairs from a nucleic-acid-strand in
144
+ dot-bracket-letter-notation (DBL-notation). :footcite:`Antczak2018`
145
+
146
+ The nucleic acid strand is represented as nucleotide sequence,
147
+ where the nucleotides are counted continiously from zero.
148
+
149
+ Parameters
150
+ ----------
151
+ dot_bracket_notation : str
152
+ The DBL-notation.
153
+
154
+ Returns
155
+ -------
156
+ basepairs : ndarray, shape=(n,2)
157
+ Each row corresponds to the positions of the bases in the
158
+ sequence.
159
+
160
+ Examples
161
+ --------
162
+ The notation string ``'(..).'`` contains a base pair between the
163
+ indices 0 and 3. This pairing interaction can be extracted
164
+ conveniently by the use of :func:`base_pairs_from_dot_bracket()`:
165
+
166
+ >>> base_pairs_from_dot_bracket('(..).')
167
+ array([[0, 3]])
168
+
169
+ See Also
170
+ --------
171
+ dot_bracket
172
+
173
+ References
174
+ ----------
175
+
176
+ .. footbibliography::
177
+ """
178
+ basepairs = []
179
+ opened_brackets = [[] for _ in range(len(_OPENING_BRACKETS))]
180
+
181
+ # Iterate through input string and extract base pairs
182
+ for pos, symbol in enumerate(dot_bracket_notation):
183
+
184
+ if symbol in _OPENING_BRACKETS:
185
+ # Add opening residues to list (separate list for each
186
+ # bracket type)
187
+ index = _OPENING_BRACKETS.index(symbol)
188
+ opened_brackets[index].append(pos)
189
+
190
+ elif symbol in _CLOSING_BRACKETS:
191
+ # For each closing bracket, the the base pair consists out
192
+ # of the current index and the last index added to the list
193
+ # in `opened_brackets` corresponding to the same bracket
194
+ # type.
195
+ index = _CLOSING_BRACKETS.index(symbol)
196
+ basepairs.append((opened_brackets[index].pop(), pos))
197
+
198
+ else:
199
+ if symbol != ".":
200
+ raise ValueError(
201
+ f"'{symbol}' is an invalid character for DBL-notation"
202
+ )
203
+
204
+ for not_closed in opened_brackets:
205
+ if not_closed != []:
206
+ raise ValueError(
207
+ "Invalid DBL-notation, not all opening brackets have a "
208
+ "closing bracket"
209
+ )
210
+
211
+
212
+ # Sort the base pair indices in ascending order
213
+ basepairs = np.array(basepairs)
214
+ if len(basepairs) > 0:
215
+ basepairs = basepairs[np.argsort(basepairs[:, 0])]
216
+ return basepairs
@@ -0,0 +1,31 @@
1
+ # This source code is part of the Biotite package and is distributed
2
+ # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
3
+ # information..
4
+
5
+ """
6
+ This module contains all possible errors of the `structure` subpackage.
7
+ """
8
+
9
+ __name__ = "biotite.structure"
10
+ __author__ = "Patrick Kunzmann"
11
+ __all__ = ["BadStructureError", "IncompleteStructureWarning",
12
+ "UnexpectedStructureWarning"]
13
+
14
+
15
+ class BadStructureError(Exception):
16
+ """
17
+ Indicates that a structure is not suitable for a certain operation.
18
+ """
19
+ pass
20
+
21
+ class IncompleteStructureWarning(Warning):
22
+ """
23
+ Indicates that a structure is not complete.
24
+ """
25
+ pass
26
+
27
+ class UnexpectedStructureWarning(Warning):
28
+ """
29
+ Indicates that a structure was not expected.
30
+ """
31
+ pass