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,562 @@
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 utility for handling data on residue level, rather than
7
+ atom level.
8
+ """
9
+
10
+ __name__ = "biotite.structure"
11
+ __author__ = "Patrick Kunzmann"
12
+ __all__ = ["get_residue_starts", "apply_residue_wise", "spread_residue_wise",
13
+ "get_residue_masks", "get_residue_starts_for",
14
+ "get_residue_positions", "get_residues", "get_residue_count",
15
+ "residue_iter"]
16
+
17
+ import numpy as np
18
+ from .atoms import AtomArray, AtomArrayStack
19
+ from .resutil import *
20
+
21
+
22
+ def get_residue_starts(array, add_exclusive_stop=False):
23
+ """
24
+ Get indices for an atom array, each indicating the beginning of
25
+ a residue.
26
+
27
+ A new residue starts, either when the chain ID, residue ID,
28
+ insertion code or residue name changes from one to the next atom.
29
+
30
+ Parameters
31
+ ----------
32
+ array : AtomArray or AtomArrayStack
33
+ The atom array (stack) to get the residue starts from.
34
+ add_exclusive_stop : bool, optional
35
+ If true, the exclusive stop of the input atom array, i.e.
36
+ ``array.array_length()``, is added to the returned array of
37
+ start indices as last element.
38
+
39
+ Returns
40
+ -------
41
+ starts : ndarray, dtype=int
42
+ The start indices of residues in `array`.
43
+
44
+ Notes
45
+ -----
46
+ This method is internally used by all other residue-related
47
+ functions.
48
+
49
+ Examples
50
+ --------
51
+
52
+ >>> print(get_residue_starts(atom_array))
53
+ [ 0 16 35 56 75 92 116 135 157 169 176 183 197 208 219 226 250 264
54
+ 278 292]
55
+ >>> print(get_residue_starts(atom_array, add_exclusive_stop=True))
56
+ [ 0 16 35 56 75 92 116 135 157 169 176 183 197 208 219 226 250 264
57
+ 278 292 304]
58
+ """
59
+ # These mask are 'true' at indices where the value changes
60
+ chain_id_changes = (array.chain_id[1:] != array.chain_id[:-1])
61
+ res_id_changes = (array.res_id[1:] != array.res_id[:-1] )
62
+ ins_code_changes = (array.ins_code[1:] != array.ins_code[:-1])
63
+ res_name_changes = (array.res_name[1:] != array.res_name[:-1])
64
+
65
+ # If any of these annotation arrays change, a new residue starts
66
+ residue_change_mask = (
67
+ chain_id_changes |
68
+ res_id_changes |
69
+ ins_code_changes |
70
+ res_name_changes
71
+ )
72
+
73
+ # Convert mask to indices
74
+ # Add 1, to shift the indices from the end of a residue
75
+ # to the start of a new residue
76
+ residue_starts = np.where(residue_change_mask)[0] +1
77
+
78
+ # The first residue is not included yet -> Insert '[0]'
79
+ if add_exclusive_stop:
80
+ return np.concatenate(([0], residue_starts, [array.array_length()]))
81
+ else:
82
+ return np.concatenate(([0], residue_starts))
83
+
84
+
85
+ def apply_residue_wise(array, data, function, axis=None):
86
+ """
87
+ Apply a function to intervals of data, where each interval
88
+ corresponds to one residue.
89
+
90
+ The function takes an atom array (stack) and an data array
91
+ (`ndarray`) of the same length. The function iterates through the
92
+ residue IDs of the atom array (stack) and identifies intervals of
93
+ the same ID. Then the data is
94
+ partitioned into the same intervals, and each interval (also an
95
+ :class:`ndarray`) is put as parameter into `function`. Each return value is
96
+ stored as element in the resulting :class:`ndarray`, therefore each element
97
+ corresponds to one residue.
98
+
99
+ Parameters
100
+ ----------
101
+ array : AtomArray or AtomArrayStack
102
+ The atom array (stack) to determine the residues from.
103
+ data : ndarray
104
+ The data, whose intervals are the parameter for `function`. Must
105
+ have same length as `array`.
106
+ function : function
107
+ The `function` must have either the form *f(data)* or
108
+ *f(data, axis)* in case `axis` is given. Every `function` call
109
+ must return a value with the same shape and data type.
110
+ axis : int, optional
111
+ This value is given to the `axis` parameter of `function`.
112
+
113
+ Returns
114
+ -------
115
+ processed_data : ndarray
116
+ Residue-wise evaluation of `data` by `function`. The size of the
117
+ first dimension of this array is equal to the amount of
118
+ residues.
119
+
120
+ Examples
121
+ --------
122
+ Calculate residue-wise SASA from atom-wise SASA of a 20 residue
123
+ peptide.
124
+
125
+ >>> sasa_per_atom = sasa(atom_array)
126
+ >>> print(len(sasa_per_atom))
127
+ 304
128
+ >>> sasa_per_residue = apply_residue_wise(atom_array, sasa_per_atom, np.nansum)
129
+ >>> print(len(sasa_per_residue))
130
+ 20
131
+ >>> print(sasa_per_residue)
132
+ [157.979 117.136 94.983 115.485 113.583 23.471 93.013 144.173 61.561
133
+ 38.885 0.792 114.053 108.568 27.888 83.583 113.016 114.318 74.281
134
+ 47.811 172.035]
135
+
136
+ Calculate the centroids of each residue for the same peptide.
137
+
138
+ >>> print(len(atom_array))
139
+ 304
140
+ >>> centroids = apply_residue_wise(atom_array, atom_array.coord,
141
+ ... np.average, axis=0)
142
+ >>> print(len(centroids))
143
+ 20
144
+ >>> print(centroids)
145
+ [[-9.582 3.378 -2.073]
146
+ [-4.670 5.816 -1.860]
147
+ [-2.461 3.060 3.076]
148
+ [-7.211 -0.396 1.013]
149
+ [-4.698 -1.080 -4.284]
150
+ [ 1.172 0.206 1.038]
151
+ [-2.160 -2.245 3.541]
152
+ [-3.682 -5.540 -2.895]
153
+ [ 0.711 -5.409 -2.549]
154
+ [ 2.002 -6.322 1.695]
155
+ [ 2.799 -3.140 2.327]
156
+ [ 5.901 -2.489 4.845]
157
+ [ 6.754 -6.712 3.094]
158
+ [ 5.699 -5.101 -1.209]
159
+ [ 9.295 -2.970 -1.835]
160
+ [ 5.518 -1.521 -3.473]
161
+ [ 7.219 3.673 -0.684]
162
+ [ 4.007 4.364 2.674]
163
+ [ 0.341 5.575 -0.254]
164
+ [ 1.194 10.416 1.130]]
165
+ """
166
+ starts = get_residue_starts(array, add_exclusive_stop=True)
167
+ return apply_segment_wise(starts, data, function, axis)
168
+
169
+
170
+ def spread_residue_wise(array, input_data):
171
+ """
172
+ Expand residue-wise data to atom-wise data.
173
+
174
+ Each value in the residue-wise input is assigned to all atoms of
175
+ this residue:
176
+
177
+ ``output_data[i] = input_data[j]``,
178
+ *i* is incremented from atom to atom,
179
+ *j* is incremented every residue change.
180
+
181
+ Parameters
182
+ ----------
183
+ array : AtomArray or AtomArrayStack
184
+ The atom array (stack) to determine the residues from.
185
+ input_data : ndarray
186
+ The data to be spread. The length of axis=0 must be equal to
187
+ the amount of different residue IDs in `array`.
188
+
189
+ Returns
190
+ -------
191
+ output_data : ndarray
192
+ Residue-wise spread `input_data`. Length is the same as
193
+ `array_length()` of `array`.
194
+
195
+ Examples
196
+ --------
197
+ Spread secondary structure annotation to every atom of a 20 residue
198
+ peptide (with 304 atoms).
199
+
200
+ >>> sse = annotate_sse(atom_array, "A")
201
+ >>> print(len(sse))
202
+ 20
203
+ >>> print(sse)
204
+ ['c' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
205
+ 'c' 'c']
206
+ >>> atom_wise_sse = spread_residue_wise(atom_array, sse)
207
+ >>> print(len(atom_wise_sse))
208
+ 304
209
+ >>> print(atom_wise_sse)
210
+ ['c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'a' 'a'
211
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
212
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
213
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
214
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
215
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
216
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
217
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
218
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a'
219
+ 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
220
+ 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
221
+ 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
222
+ 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
223
+ 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
224
+ 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
225
+ 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
226
+ 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c']
227
+ """
228
+ starts = get_residue_starts(array, add_exclusive_stop=True)
229
+ return spread_segment_wise(starts, input_data)
230
+
231
+
232
+ def get_residue_masks(array, indices):
233
+ """
234
+ Get boolean masks indicating the residues to which the given atom
235
+ indices belong.
236
+
237
+ Parameters
238
+ ----------
239
+ array : AtomArray, shape=(n,) or AtomArrayStack, shape=(m,n)
240
+ The atom array (stack) to determine the residues from.
241
+ indices : ndarray, dtype=int, shape=(k,)
242
+ These indices indicate the atoms to get the corresponding
243
+ residues for.
244
+ Negative indices are not allowed.
245
+
246
+ Returns
247
+ -------
248
+ residues_masks : ndarray, dtype=bool, shape=(k,n)
249
+ Multiple boolean masks, one for each given index in `indices`.
250
+ Each array masks the atoms that belong to the same residue as
251
+ the atom at the given index.
252
+
253
+ See also
254
+ --------
255
+ get_residue_starts_for
256
+ get_residue_positions
257
+
258
+ Examples
259
+ --------
260
+
261
+ >>> indices = [5, 42]
262
+ >>> residue_masks = get_residue_masks(atom_array, indices)
263
+ >>> print(atom_array[indices[0]])
264
+ A 1 ASN CG C -10.915 3.130 -2.611
265
+ >>> print(atom_array[residue_masks[0]])
266
+ A 1 ASN N N -8.901 4.127 -0.555
267
+ A 1 ASN CA C -8.608 3.135 -1.618
268
+ A 1 ASN C C -7.117 2.964 -1.897
269
+ A 1 ASN O O -6.634 1.849 -1.758
270
+ A 1 ASN CB C -9.437 3.396 -2.889
271
+ A 1 ASN CG C -10.915 3.130 -2.611
272
+ A 1 ASN OD1 O -11.269 2.700 -1.524
273
+ A 1 ASN ND2 N -11.806 3.406 -3.543
274
+ A 1 ASN H1 H -8.330 3.957 0.261
275
+ A 1 ASN H2 H -8.740 5.068 -0.889
276
+ A 1 ASN H3 H -9.877 4.041 -0.293
277
+ A 1 ASN HA H -8.930 2.162 -1.239
278
+ A 1 ASN HB2 H -9.310 4.417 -3.193
279
+ A 1 ASN HB3 H -9.108 2.719 -3.679
280
+ A 1 ASN HD21 H -11.572 3.791 -4.444
281
+ A 1 ASN HD22 H -12.757 3.183 -3.294
282
+ >>> print(atom_array[indices[1]])
283
+ A 3 TYR CD2 C -1.820 4.326 3.332
284
+ >>> print(atom_array[residue_masks[1]])
285
+ A 3 TYR N N -4.354 3.455 -0.111
286
+ A 3 TYR CA C -3.690 2.738 0.981
287
+ A 3 TYR C C -4.102 1.256 1.074
288
+ A 3 TYR O O -3.291 0.409 1.442
289
+ A 3 TYR CB C -3.964 3.472 2.302
290
+ A 3 TYR CG C -2.824 3.339 3.290
291
+ A 3 TYR CD1 C -2.746 2.217 4.138
292
+ A 3 TYR CD2 C -1.820 4.326 3.332
293
+ A 3 TYR CE1 C -1.657 2.076 5.018
294
+ A 3 TYR CE2 C -0.725 4.185 4.205
295
+ A 3 TYR CZ C -0.639 3.053 5.043
296
+ A 3 TYR OH O 0.433 2.881 5.861
297
+ A 3 TYR H H -4.934 4.245 0.120
298
+ A 3 TYR HA H -2.615 2.768 0.796
299
+ A 3 TYR HB2 H -4.117 4.513 2.091
300
+ A 3 TYR HB3 H -4.886 3.096 2.750
301
+ A 3 TYR HD1 H -3.513 1.456 4.101
302
+ A 3 TYR HD2 H -1.877 5.200 2.695
303
+ A 3 TYR HE1 H -1.576 1.221 5.669
304
+ A 3 TYR HE2 H 0.033 4.952 4.233
305
+ A 3 TYR HH H 1.187 3.395 5.567
306
+ """
307
+ starts = get_residue_starts(array, add_exclusive_stop=True)
308
+ return get_segment_masks(starts, indices)
309
+
310
+
311
+ def get_residue_starts_for(array, indices):
312
+ """
313
+ For each given atom index, get the index that points to the
314
+ start of the residue that atom belongs to.
315
+
316
+ Parameters
317
+ ----------
318
+ array : AtomArray or AtomArrayStack
319
+ The atom array (stack) to determine the residues from.
320
+ indices : ndarray, dtype=int, shape=(k,)
321
+ These indices point to the atoms to get the corresponding
322
+ residue starts for.
323
+ Negative indices are not allowed.
324
+
325
+ Returns
326
+ -------
327
+ start_indices : ndarray, dtype=int, shape=(k,)
328
+ The indices that point to the residue starts for the input
329
+ `indices`.
330
+
331
+ See also
332
+ --------
333
+ get_residue_masks
334
+ get_residue_positions
335
+
336
+ Examples
337
+ --------
338
+
339
+ >>> indices = [5, 42]
340
+ >>> residue_starts = get_residue_starts_for(atom_array, indices)
341
+ >>> print(residue_starts)
342
+ [ 0 35]
343
+ >>> print(atom_array[indices[0]])
344
+ A 1 ASN CG C -10.915 3.130 -2.611
345
+ >>> print(atom_array[residue_starts[0]])
346
+ A 1 ASN N N -8.901 4.127 -0.555
347
+ >>> print(atom_array[indices[1]])
348
+ A 3 TYR CD2 C -1.820 4.326 3.332
349
+ >>> print(atom_array[residue_starts[1]])
350
+ A 3 TYR N N -4.354 3.455 -0.111
351
+ """
352
+ starts = get_residue_starts(array, add_exclusive_stop=True)
353
+ return get_segment_starts_for(starts, indices)
354
+
355
+
356
+ def get_residue_positions(array, indices):
357
+ """
358
+ For each given atom index, obtain the position of the residue
359
+ corresponding to this index in the input `array`.
360
+
361
+ For example, the position of the first residue in the atom array is
362
+ ``0``, the the position of the second residue is ``1``, etc.
363
+
364
+ Parameters
365
+ ----------
366
+ array : AtomArray or AtomArrayStack
367
+ The atom array (stack) to determine the residues from.
368
+ indices : ndarray, dtype=int, shape=(k,)
369
+ These indices point to the atoms to get the corresponding
370
+ residue positions for.
371
+ Negative indices are not allowed.
372
+
373
+ Returns
374
+ -------
375
+ start_indices : ndarray, dtype=int, shape=(k,)
376
+ The indices that point to the position of the residues.
377
+
378
+ See also
379
+ --------
380
+ get_residue_masks
381
+ get_residue_starts_for
382
+
383
+ Examples
384
+ --------
385
+ >>> atom_index = [5, 42]
386
+ >>> print(atom_array.res_name[atom_index])
387
+ ['ASN' 'TYR']
388
+ >>> _, residues = get_residues(atom_array)
389
+ >>> print(residues)
390
+ ['ASN' 'LEU' 'TYR' 'ILE' 'GLN' 'TRP' 'LEU' 'LYS' 'ASP' 'GLY' 'GLY' 'PRO'
391
+ 'SER' 'SER' 'GLY' 'ARG' 'PRO' 'PRO' 'PRO' 'SER']
392
+ >>> residue_index = get_residue_positions(atom_array, atom_index)
393
+ >>> print(residue_index)
394
+ [0 2]
395
+ >>> print(residues[residue_index])
396
+ ['ASN' 'TYR']
397
+ """
398
+ starts = get_residue_starts(array, add_exclusive_stop=True)
399
+ return get_segment_positions(starts, indices)
400
+
401
+
402
+ def get_residues(array):
403
+ """
404
+ Get the residue IDs and names of an atom array (stack).
405
+
406
+ The residues are listed in the same order they occur in the array
407
+ (stack).
408
+
409
+ Parameters
410
+ ----------
411
+ array : AtomArray or AtomArrayStack
412
+ The atom array (stack) to determine the residues from.
413
+
414
+ Returns
415
+ -------
416
+ ids : ndarray, dtype=int
417
+ List of residue IDs.
418
+ names : ndarray, dtype="U5"
419
+ List of residue names.
420
+
421
+ Examples
422
+ --------
423
+ Get the residue names of a 20 residue peptide.
424
+
425
+ >>> print(atom_array.res_name)
426
+ ['ASN' 'ASN' 'ASN' 'ASN' 'ASN' 'ASN' 'ASN' 'ASN' 'ASN' 'ASN' 'ASN' 'ASN'
427
+ 'ASN' 'ASN' 'ASN' 'ASN' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU'
428
+ 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'TYR'
429
+ 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR'
430
+ 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'TYR' 'ILE' 'ILE' 'ILE' 'ILE'
431
+ 'ILE' 'ILE' 'ILE' 'ILE' 'ILE' 'ILE' 'ILE' 'ILE' 'ILE' 'ILE' 'ILE' 'ILE'
432
+ 'ILE' 'ILE' 'ILE' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN'
433
+ 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'GLN' 'TRP' 'TRP' 'TRP' 'TRP'
434
+ 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP'
435
+ 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'TRP' 'LEU' 'LEU' 'LEU' 'LEU'
436
+ 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU' 'LEU'
437
+ 'LEU' 'LEU' 'LEU' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS'
438
+ 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS' 'LYS'
439
+ 'LYS' 'ASP' 'ASP' 'ASP' 'ASP' 'ASP' 'ASP' 'ASP' 'ASP' 'ASP' 'ASP' 'ASP'
440
+ 'ASP' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY'
441
+ 'GLY' 'GLY' 'GLY' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO'
442
+ 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER'
443
+ 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER'
444
+ 'SER' 'SER' 'SER' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'GLY' 'ARG' 'ARG'
445
+ 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG'
446
+ 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'ARG' 'PRO' 'PRO'
447
+ 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO'
448
+ 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO'
449
+ 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO' 'PRO'
450
+ 'PRO' 'PRO' 'PRO' 'PRO' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER' 'SER'
451
+ 'SER' 'SER' 'SER' 'SER']
452
+ >>> ids, names = get_residues(atom_array)
453
+ >>> print(names)
454
+ ['ASN' 'LEU' 'TYR' 'ILE' 'GLN' 'TRP' 'LEU' 'LYS' 'ASP' 'GLY' 'GLY' 'PRO'
455
+ 'SER' 'SER' 'GLY' 'ARG' 'PRO' 'PRO' 'PRO' 'SER']
456
+ """
457
+ starts = get_residue_starts(array)
458
+ return array.res_id[starts], array.res_name[starts]
459
+
460
+
461
+ def get_residue_count(array):
462
+ """
463
+ Get the amount of residues in an atom array (stack).
464
+
465
+ The count is determined from the `res_id` and `chain_id` annotation.
466
+ Each time the residue ID or chain ID changes,
467
+ the count is incremented. Special rules apply to hetero residues.
468
+
469
+ Parameters
470
+ ----------
471
+ array : AtomArray or AtomArrayStack
472
+ The atom array (stack) to determine the residues from.
473
+
474
+ Returns
475
+ -------
476
+ count : int
477
+ Amount of residues.
478
+ """
479
+ return len(get_residue_starts(array))
480
+
481
+
482
+ def residue_iter(array):
483
+ """
484
+ Iterate over all residues in an atom array (stack).
485
+
486
+ Parameters
487
+ ----------
488
+ array : AtomArray or AtomArrayStack
489
+ The atom array (stack) to iterate over.
490
+
491
+ Yields
492
+ ------
493
+ residue : AtomArray or AtomArrayStack
494
+ A single residue of the input `array`.
495
+
496
+ Examples
497
+ --------
498
+
499
+ >>> for res in residue_iter(atom_array[:50]):
500
+ ... print("New residue")
501
+ ... print(res)
502
+ ... print()
503
+ New residue
504
+ A 1 ASN N N -8.901 4.127 -0.555
505
+ A 1 ASN CA C -8.608 3.135 -1.618
506
+ A 1 ASN C C -7.117 2.964 -1.897
507
+ A 1 ASN O O -6.634 1.849 -1.758
508
+ A 1 ASN CB C -9.437 3.396 -2.889
509
+ A 1 ASN CG C -10.915 3.130 -2.611
510
+ A 1 ASN OD1 O -11.269 2.700 -1.524
511
+ A 1 ASN ND2 N -11.806 3.406 -3.543
512
+ A 1 ASN H1 H -8.330 3.957 0.261
513
+ A 1 ASN H2 H -8.740 5.068 -0.889
514
+ A 1 ASN H3 H -9.877 4.041 -0.293
515
+ A 1 ASN HA H -8.930 2.162 -1.239
516
+ A 1 ASN HB2 H -9.310 4.417 -3.193
517
+ A 1 ASN HB3 H -9.108 2.719 -3.679
518
+ A 1 ASN HD21 H -11.572 3.791 -4.444
519
+ A 1 ASN HD22 H -12.757 3.183 -3.294
520
+ <BLANKLINE>
521
+ New residue
522
+ A 2 LEU N N -6.379 4.031 -2.228
523
+ A 2 LEU CA C -4.923 4.002 -2.452
524
+ A 2 LEU C C -4.136 3.187 -1.404
525
+ A 2 LEU O O -3.391 2.274 -1.760
526
+ A 2 LEU CB C -4.411 5.450 -2.619
527
+ A 2 LEU CG C -4.795 6.450 -1.495
528
+ A 2 LEU CD1 C -3.612 6.803 -0.599
529
+ A 2 LEU CD2 C -5.351 7.748 -2.084
530
+ A 2 LEU H H -6.821 4.923 -2.394
531
+ A 2 LEU HA H -4.750 3.494 -3.403
532
+ A 2 LEU HB2 H -3.340 5.414 -2.672
533
+ A 2 LEU HB3 H -4.813 5.817 -3.564
534
+ A 2 LEU HG H -5.568 6.022 -0.858
535
+ A 2 LEU HD11 H -3.207 5.905 -0.146
536
+ A 2 LEU HD12 H -2.841 7.304 -1.183
537
+ A 2 LEU HD13 H -3.929 7.477 0.197
538
+ A 2 LEU HD21 H -4.607 8.209 -2.736
539
+ A 2 LEU HD22 H -6.255 7.544 -2.657
540
+ A 2 LEU HD23 H -5.592 8.445 -1.281
541
+ <BLANKLINE>
542
+ New residue
543
+ A 3 TYR N N -4.354 3.455 -0.111
544
+ A 3 TYR CA C -3.690 2.738 0.981
545
+ A 3 TYR C C -4.102 1.256 1.074
546
+ A 3 TYR O O -3.291 0.409 1.442
547
+ A 3 TYR CB C -3.964 3.472 2.302
548
+ A 3 TYR CG C -2.824 3.339 3.290
549
+ A 3 TYR CD1 C -2.746 2.217 4.138
550
+ A 3 TYR CD2 C -1.820 4.326 3.332
551
+ A 3 TYR CE1 C -1.657 2.076 5.018
552
+ A 3 TYR CE2 C -0.725 4.185 4.205
553
+ A 3 TYR CZ C -0.639 3.053 5.043
554
+ A 3 TYR OH O 0.433 2.881 5.861
555
+ A 3 TYR H H -4.934 4.245 0.120
556
+ A 3 TYR HA H -2.615 2.768 0.796
557
+ A 3 TYR HB2 H -4.117 4.513 2.091
558
+ <BLANKLINE>
559
+ """
560
+ # The exclusive stop is appended to the residue starts
561
+ starts = get_residue_starts(array, add_exclusive_stop=True)
562
+ return segment_iter(array, starts)