biotite 0.41.1__cp310-cp310-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-310-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-310-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-310-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-310-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-310-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-310-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-310-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-310-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-310-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-310-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-310-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-310-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-310-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-310-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-310-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-310-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-310-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-310-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-310-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-310-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-310-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-310-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-310-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-310-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-310-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,243 @@
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 the radial distribution function.
7
+ """
8
+
9
+ __name__ = "biotite.structure"
10
+ __author__ = "Daniel Bauer, Patrick Kunzmann"
11
+ __all__ = ["rdf"]
12
+
13
+ from numbers import Integral
14
+ import numpy as np
15
+ from .atoms import Atom, AtomArray, stack, array, coord, AtomArrayStack
16
+ from .box import box_volume
17
+ from .geometry import displacement
18
+ from .util import vector_dot
19
+ from .celllist import CellList
20
+
21
+
22
+ def rdf(center, atoms, selection=None, interval=(0, 10), bins=100, box=None,
23
+ periodic=False):
24
+ r"""
25
+ Compute the radial distribution function *g(r)* (RDF) for one or
26
+ multiple given central positions based on a given system of
27
+ particles.
28
+
29
+ Parameters
30
+ ----------
31
+ center : Atom or AtomArray or AtomArrayStack or ndarray, dtype=float
32
+ Coordinates or atoms(s) to use as origin(s) for RDF calculation.
33
+
34
+ - If a single :class:`Atom` or a :class:`ndarray` with shape
35
+ *(3,)* is given, the RDF is only calculated for this position.
36
+ - If an :class:`AtomArray` or a :class:`ndarray` with shape
37
+ *(n,3)* is given, the calculated RDF histogram is an average
38
+ over *n* postions.
39
+ - If an :class:`AtomArrayStack` or a :class:`ndarray` with shape
40
+ *(m,n,3)* is given, different centers are used for each model
41
+ *m*.
42
+ The calculated RDF histogram is an average over *m*
43
+ models and *n* positions.
44
+ This requires `atoms` to be an :class:`AtomArrayStack`.
45
+
46
+ atoms : AtomArray or AtomArrayStack
47
+ The distribution is calculated based on these atoms.
48
+ When an an :class:`AtomArrayStack` is provided, the RDF
49
+ histogram is averaged over all models.
50
+ Please not that `atoms` must have an associated box,
51
+ unless `box` is set.
52
+ selection : ndarray, dtype=bool, shape=(n,), optional
53
+ Boolean mask for `atoms` to limit the RDF calculation to
54
+ specific atoms.
55
+ interval : tuple, optional
56
+ The range in which the RDF is calculated.
57
+ bins : int or sequence of scalars or str, optional
58
+ Bins for the RDF.
59
+
60
+ - If `bins` is an `int`, it defines the number of bins for the
61
+ given `interval`.
62
+ - If `bins` is a sequence, it defines the bin edges, ignoring
63
+ the `interval` parameter. The output `bins` has the length
64
+ of this input parameter reduced by one.
65
+ - If `bins` is a string, it defines the function used to
66
+ calculate the bins.
67
+
68
+ See `numpy.histogram()` for further details.
69
+ box : ndarray, shape=(3,3) or shape=(m,3,3), optional
70
+ If this parameter is set, the given box is used instead of the
71
+ `box` attribute of `atoms`.
72
+ Must have shape *(3,3)* if atoms is an :class:`AtomArray` or
73
+ *(m,3,3)* if atoms is an :class:`AtomArrayStack`, respectively.
74
+ periodic : bool, optional
75
+ Defines if periodic boundary conditions are taken into account.
76
+
77
+ Returns
78
+ -------
79
+ bins : ndarray, dtype=float, shape=n
80
+ The centers of the histogram bins.
81
+ The length of the array is given by the `bins` input parameter.
82
+ rdf : ndarry, dtype=float, shape=n
83
+ RDF values for every bin.
84
+
85
+ Notes
86
+ -----
87
+ Since the RDF depends on the average particle density of the system,
88
+ this function strictly requires an box.
89
+
90
+ Examples
91
+ --------
92
+ Calculate the oxygen-oxygen radial distribution function of water.
93
+ The range of the histogram starts at 0.2 Å, in order to
94
+ ignore the counts for the density for each oxygen to itself.
95
+
96
+ >>> from os.path import join
97
+ >>> waterbox = load_structure(join(path_to_structures, "waterbox.gro"))
98
+ >>> oxygens = waterbox[:, waterbox.atom_name == 'OW']
99
+ >>> bins, g_r = rdf(oxygens, oxygens, bins=49, interval=(0.2, 10), periodic=True)
100
+
101
+ Print the RDF depending on the radius. Bins are in Å.
102
+
103
+ >>> for x, y in zip(bins, g_r):
104
+ ... print(f"{x:.2f} {y:.2f}")
105
+ 0.30 0.00
106
+ 0.50 0.00
107
+ 0.70 0.04
108
+ 0.90 0.02
109
+ 1.10 0.03
110
+ 1.30 0.06
111
+ 1.50 0.03
112
+ 1.70 0.04
113
+ 1.90 0.04
114
+ 2.10 0.04
115
+ 2.30 0.04
116
+ 2.50 0.16
117
+ 2.70 1.99
118
+ 2.90 2.22
119
+ 3.10 1.34
120
+ 3.30 1.04
121
+ 3.50 0.97
122
+ 3.70 0.94
123
+ 3.90 0.97
124
+ 4.10 0.94
125
+ 4.30 0.98
126
+ 4.50 0.97
127
+ 4.70 0.96
128
+ 4.90 0.99
129
+ 5.10 0.99
130
+ 5.30 1.02
131
+ 5.50 1.02
132
+ 5.70 0.99
133
+ 5.90 0.98
134
+ 6.10 0.98
135
+ 6.30 0.99
136
+ 6.50 1.02
137
+ 6.70 1.02
138
+ 6.90 1.00
139
+ 7.10 1.01
140
+ 7.30 1.01
141
+ 7.50 1.00
142
+ 7.70 1.01
143
+ 7.90 0.99
144
+ 8.10 0.99
145
+ 8.30 0.99
146
+ 8.50 0.99
147
+ 8.70 0.99
148
+ 8.90 1.00
149
+ 9.10 1.01
150
+ 9.30 1.01
151
+ 9.50 1.00
152
+ 9.70 1.00
153
+ 9.90 0.99
154
+
155
+ Find the radius for the first solvation shell.
156
+ In this simple case, the density peak is identified by finding
157
+ the maximum of the function.
158
+
159
+ >>> peak_position = np.argmax(g_r)
160
+ >>> print(f"{bins[peak_position]/10:.2f} nm")
161
+ 0.29 nm
162
+ """
163
+ if isinstance(atoms, AtomArray):
164
+ # Reshape always to a stack for easier calculation
165
+ atoms = stack([atoms])
166
+ if selection is not None:
167
+ atoms = atoms[..., selection]
168
+
169
+ atom_coord = atoms.coord
170
+
171
+ if box is None:
172
+ if atoms.box is None:
173
+ raise ValueError("A box must be supplied")
174
+ else:
175
+ box = atoms.box
176
+ elif box.ndim == 2 and atoms.stack_depth() == 1:
177
+ box = box[np.newaxis, :, :]
178
+
179
+ center = coord(center)
180
+ if center.ndim == 1:
181
+ center = center.reshape((1, 1) + center.shape)
182
+ elif center.ndim == 2:
183
+ center = center.reshape((1,) + center.shape)
184
+
185
+ if box.shape[0] != center.shape[0] or box.shape[0] != atom_coord.shape[0]:
186
+ raise ValueError(
187
+ "Center, box, and atoms must have the same model count"
188
+ )
189
+
190
+ # Calculate distance histogram
191
+ edges = _calculate_edges(interval, bins)
192
+ # Make histogram of quared distances to save computation time
193
+ # of sqrt calculation
194
+ sq_edges = edges**2
195
+ threshold_dist = edges[-1]
196
+ cell_size = threshold_dist
197
+ disp = []
198
+ for i in range(atoms.stack_depth()):
199
+ # Use cell list to efficiently preselect atoms that are in range
200
+ # of the desired bin range
201
+ cell_list = CellList(atom_coord[i], cell_size, periodic, box[i])
202
+ # 'cell_radius=1' is used in 'get_atoms_in_cells()'
203
+ # This is enough to find all atoms that are in the given
204
+ # interval (and more), since the size of each cell is as large
205
+ # as the last edge of the bins
206
+ near_atom_mask = cell_list.get_atoms_in_cells(center[i], as_mask=True)
207
+ # Calculate distances of each center to preselected atoms
208
+ # for each center
209
+ for j in range(center.shape[1]):
210
+ dist_box = box[i] if periodic else None
211
+ # Calculate squared distances
212
+ disp.append(displacement(
213
+ center[i,j], atom_coord[i, near_atom_mask[j]], box=dist_box
214
+ ))
215
+ # Make one array from multiple arrays with different length
216
+ disp = np.concatenate(disp)
217
+ sq_distances = vector_dot(disp, disp)
218
+ hist, _ = np.histogram(sq_distances, bins=sq_edges)
219
+
220
+ # Normalize with average particle density (N/V) in each bin
221
+ bin_volume = (4 / 3 * np.pi * np.power(edges[1: ], 3)) \
222
+ - (4 / 3 * np.pi * np.power(edges[:-1], 3))
223
+ n_frames = len(atoms)
224
+ volume = box_volume(box).mean()
225
+ density = atoms.array_length() / volume
226
+ g_r = hist / (bin_volume * density * n_frames)
227
+
228
+ # Normalize with number of centers
229
+ g_r /= center.shape[1]
230
+
231
+ bin_centers = (edges[:-1] + edges[1:]) * 0.5
232
+
233
+ return bin_centers, g_r
234
+
235
+
236
+ def _calculate_edges(interval, bins):
237
+ if isinstance(bins, Integral):
238
+ if bins < 1:
239
+ raise ValueError("At least one bin is required")
240
+ return np.linspace(*interval, bins+1)
241
+ else:
242
+ # 'bins' contains edges
243
+ return np.array(bins, dtype=float)
@@ -0,0 +1,253 @@
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 functionalities for repairing malformed structures.
7
+ """
8
+
9
+ __name__ = "biotite.structure"
10
+ __author__ = "Patrick Kunzmann, Daniel Bauer"
11
+ __all__ = ["renumber_atom_ids", "renumber_res_ids",
12
+ "create_continuous_res_ids", "infer_elements", "create_atom_names"]
13
+
14
+ from collections import Counter
15
+ import warnings
16
+ import numpy as np
17
+ from .atoms import AtomArray, AtomArrayStack
18
+ from .residues import get_residue_starts
19
+ from .chains import get_chain_starts
20
+
21
+
22
+ def renumber_atom_ids(array, start=None):
23
+ """
24
+ Renumber the atom IDs of the given array.
25
+
26
+ DEPRECATED.
27
+
28
+ Parameters
29
+ ----------
30
+ array : AtomArray or AtomArrayStack
31
+ The array to be checked.
32
+ start : int, optional
33
+ The starting index for renumbering.
34
+ The first ID in the array is taken by default.
35
+
36
+ Returns
37
+ -------
38
+ array : AtomArray or AtomArrayStack
39
+ The renumbered array.
40
+ """
41
+ warnings.warn(
42
+ "'renumber_atom_ids()' is deprecated",
43
+ DeprecationWarning
44
+ )
45
+ if "atom_id" not in array.get_annotation_categories():
46
+ raise ValueError("The atom array must have the 'atom_id' annotation")
47
+ if start is None:
48
+ start = array.atom_id[0]
49
+ array = array.copy()
50
+ array.atom_id = np.arange(start, array.shape[-1]+1)
51
+ return array
52
+
53
+
54
+ def renumber_res_ids(array, start=None):
55
+ """
56
+ Renumber the residue IDs of the given array, so that are continuous.
57
+
58
+ DEPRECATED: Use :func:`create_continuous_res_ids()`instead.
59
+
60
+ Parameters
61
+ ----------
62
+ array : AtomArray or AtomArrayStack
63
+ The array to be checked.
64
+ start : int, optional
65
+ The starting index for renumbering.
66
+ The first ID in the array is taken by default.
67
+
68
+ Returns
69
+ -------
70
+ array : AtomArray or AtomArrayStack
71
+ The renumbered array.
72
+ """
73
+ warnings.warn(
74
+ "'renumber_res_ids()' is deprecated, use 'create_continuous_res_ids()'",
75
+ DeprecationWarning
76
+ )
77
+ if start is None:
78
+ start = array.res_id[0]
79
+ diff = np.diff(array.res_id)
80
+ diff[diff != 0] = 1
81
+ new_res_ids = np.concatenate(([start], diff)).cumsum()
82
+ array = array.copy()
83
+ array.res_id = new_res_ids
84
+ return array
85
+
86
+
87
+ def create_continuous_res_ids(atoms, restart_each_chain=True):
88
+ """
89
+ Create an array of continuous residue IDs for a given structure.
90
+
91
+ This means that residue IDs are incremented by 1 for each residue.
92
+
93
+ Parameters
94
+ ----------
95
+ atoms : AtomArray or AtomArrayStack
96
+ The atoms for which the continuous residue IDs should be created.
97
+ restart_each_chain : bool, optional
98
+ If true, the residue IDs are reset to 1 for each chain.
99
+
100
+ Returns
101
+ -------
102
+ res_ids : ndarray, dtype=int
103
+ The continuous residue IDs.
104
+
105
+ Examples
106
+ --------
107
+
108
+ >>> # Remove a residue to make the residue IDs discontinuous
109
+ >>> atom_array = atom_array[atom_array.res_id != 5]
110
+ >>> res_ids, _ = get_residues(atom_array)
111
+ >>> print(res_ids)
112
+ [ 1 2 3 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
113
+ >>> atom_array.res_id = create_continuous_res_ids(atom_array)
114
+ >>> res_ids, _ = get_residues(atom_array)
115
+ >>> print(res_ids)
116
+ [ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
117
+
118
+ """
119
+ res_ids_diff = np.zeros(atoms.array_length(), dtype=int)
120
+ res_starts = get_residue_starts(atoms)
121
+ res_ids_diff[res_starts] = 1
122
+ res_ids = np.cumsum(res_ids_diff)
123
+
124
+ if restart_each_chain:
125
+ chain_starts = get_chain_starts(atoms)
126
+ for start in chain_starts:
127
+ res_ids[start:] -= res_ids[start] - 1
128
+
129
+ return res_ids
130
+
131
+
132
+ def infer_elements(atoms):
133
+ """
134
+ Infer the elements of atoms based on their atom name.
135
+
136
+ Parameters
137
+ ----------
138
+ atoms : AtomArray or AtomArrayStack or array-like of str
139
+ The atoms for which the elements should be inferred.
140
+ Alternatively the atom names can be passed directly.
141
+
142
+ Returns
143
+ -------
144
+ elements : ndarray, dtype=str
145
+ The inferred elements.
146
+
147
+ See Also
148
+ --------
149
+ create_atoms_names : The opposite of this function
150
+
151
+ Examples
152
+ --------
153
+
154
+ >>> print(infer_elements(atom_array)[:10])
155
+ ['N' 'C' 'C' 'O' 'C' 'C' 'O' 'N' 'H' 'H']
156
+ >>> print(infer_elements(["CA", "C", "C1", "OD1", "HD21", "1H", "FE"]))
157
+ ['C' 'C' 'C' 'O' 'H' 'H' 'FE']
158
+
159
+ """
160
+ if isinstance(atoms, (AtomArray, AtomArrayStack)):
161
+ atom_names = atoms.atom_name
162
+ else:
163
+ atom_names = atoms
164
+ return np.array([_guess_element(name) for name in atom_names])
165
+
166
+
167
+ def create_atom_names(atoms):
168
+ """
169
+ Create atom names for a single residue based on elements.
170
+
171
+ The atom names are simply enumerated separately for each element.
172
+
173
+ Parameters
174
+ ----------
175
+ atoms : AtomArray or AtomArrayStack or array-like of str
176
+ The atoms for which the atom names should be created.
177
+ Alternatively the elements can be passed directly.
178
+
179
+ Returns
180
+ -------
181
+ atom_names : ndarray, dtype=str
182
+ The atom names.
183
+
184
+ See Also
185
+ --------
186
+ infer_elements : The opposite of this function
187
+
188
+ Notes
189
+ -----
190
+ The atom names created this way may differ from the ones in the
191
+ original source, as different schemes for atom naming exist.
192
+ This function only ensures that the created atom names are unique.
193
+ This is e.g. necessary for writing bonds to PDBx files.
194
+
195
+ Note that this function should be used only on single residues,
196
+ otherwise enumeration would continue in the next residue.
197
+
198
+ Examples
199
+ --------
200
+
201
+ >>> atoms = residue("URA") # Uracil
202
+ >>> print(atoms.element)
203
+ ['N' 'C' 'O' 'N' 'C' 'O' 'C' 'C' 'H' 'H' 'H' 'H']
204
+ >>> print(create_atom_names(atoms))
205
+ ['N1' 'C1' 'O1' 'N2' 'C2' 'O2' 'C3' 'C4' 'H1' 'H2' 'H3' 'H4']
206
+ """
207
+ if isinstance(atoms, (AtomArray, AtomArrayStack)):
208
+ elements = atoms.element
209
+ else:
210
+ elements = atoms
211
+
212
+ atom_names = np.zeros(len(elements), dtype="U6")
213
+ element_counter = Counter()
214
+ for i, elem in enumerate(elements):
215
+ element_counter[elem] += 1
216
+ atom_names[i] = f"{elem}{element_counter[elem]}"
217
+ return atom_names
218
+
219
+
220
+ _elements = [elem.upper() for elem in
221
+ ["H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg",
222
+ "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe",
223
+ "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y",
224
+ "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te",
225
+ "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb",
226
+ "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt",
227
+ "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa",
228
+ "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf",
229
+ "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts",
230
+ "Og"]
231
+ ]
232
+ def _guess_element(atom_name):
233
+ # remove digits (1H -> H)
234
+ elem = "".join([i for i in atom_name if not i.isdigit()])
235
+ elem = elem.upper()
236
+ if len(elem) == 0:
237
+ return ""
238
+
239
+ # Some often used elements for biomolecules
240
+ if elem.startswith("C") or elem.startswith("N") or \
241
+ elem.startswith("O") or elem.startswith("S") or \
242
+ elem.startswith("H"):
243
+ return elem[0]
244
+
245
+ # Exactly match element abbreviations
246
+ try:
247
+ return _elements[_elements.index(elem[:2])]
248
+ except ValueError:
249
+ try:
250
+ return _elements[_elements.index(elem[0])]
251
+ except ValueError:
252
+ warnings.warn(f"Could not infer element for '{atom_name}'")
253
+ return ""