biotite 0.41.1__cp311-cp311-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-311-darwin.so +0 -0
  57. biotite/sequence/align/banded.pyx +652 -0
  58. biotite/sequence/align/buckets.py +69 -0
  59. biotite/sequence/align/cigar.py +434 -0
  60. biotite/sequence/align/kmeralphabet.cpython-311-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-311-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-311-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-311-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-311-darwin.so +0 -0
  69. biotite/sequence/align/localungapped.pyx +279 -0
  70. biotite/sequence/align/matrix.py +405 -0
  71. biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
  72. biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
  73. biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
  74. biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
  75. biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
  76. biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
  77. biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
  78. biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
  79. biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
  80. biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
  81. biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
  82. biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
  83. biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
  84. biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
  85. biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
  86. biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
  87. biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
  88. biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
  89. biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
  90. biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
  91. biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
  92. biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
  93. biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
  94. biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
  95. biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
  96. biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
  97. biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
  98. biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
  99. biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
  100. biotite/sequence/align/matrix_data/GONNET.mat +26 -0
  101. biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
  102. biotite/sequence/align/matrix_data/MATCH.mat +25 -0
  103. biotite/sequence/align/matrix_data/NUC.mat +25 -0
  104. biotite/sequence/align/matrix_data/PAM10.mat +34 -0
  105. biotite/sequence/align/matrix_data/PAM100.mat +34 -0
  106. biotite/sequence/align/matrix_data/PAM110.mat +34 -0
  107. biotite/sequence/align/matrix_data/PAM120.mat +34 -0
  108. biotite/sequence/align/matrix_data/PAM130.mat +34 -0
  109. biotite/sequence/align/matrix_data/PAM140.mat +34 -0
  110. biotite/sequence/align/matrix_data/PAM150.mat +34 -0
  111. biotite/sequence/align/matrix_data/PAM160.mat +34 -0
  112. biotite/sequence/align/matrix_data/PAM170.mat +34 -0
  113. biotite/sequence/align/matrix_data/PAM180.mat +34 -0
  114. biotite/sequence/align/matrix_data/PAM190.mat +34 -0
  115. biotite/sequence/align/matrix_data/PAM20.mat +34 -0
  116. biotite/sequence/align/matrix_data/PAM200.mat +34 -0
  117. biotite/sequence/align/matrix_data/PAM210.mat +34 -0
  118. biotite/sequence/align/matrix_data/PAM220.mat +34 -0
  119. biotite/sequence/align/matrix_data/PAM230.mat +34 -0
  120. biotite/sequence/align/matrix_data/PAM240.mat +34 -0
  121. biotite/sequence/align/matrix_data/PAM250.mat +34 -0
  122. biotite/sequence/align/matrix_data/PAM260.mat +34 -0
  123. biotite/sequence/align/matrix_data/PAM270.mat +34 -0
  124. biotite/sequence/align/matrix_data/PAM280.mat +34 -0
  125. biotite/sequence/align/matrix_data/PAM290.mat +34 -0
  126. biotite/sequence/align/matrix_data/PAM30.mat +34 -0
  127. biotite/sequence/align/matrix_data/PAM300.mat +34 -0
  128. biotite/sequence/align/matrix_data/PAM310.mat +34 -0
  129. biotite/sequence/align/matrix_data/PAM320.mat +34 -0
  130. biotite/sequence/align/matrix_data/PAM330.mat +34 -0
  131. biotite/sequence/align/matrix_data/PAM340.mat +34 -0
  132. biotite/sequence/align/matrix_data/PAM350.mat +34 -0
  133. biotite/sequence/align/matrix_data/PAM360.mat +34 -0
  134. biotite/sequence/align/matrix_data/PAM370.mat +34 -0
  135. biotite/sequence/align/matrix_data/PAM380.mat +34 -0
  136. biotite/sequence/align/matrix_data/PAM390.mat +34 -0
  137. biotite/sequence/align/matrix_data/PAM40.mat +34 -0
  138. biotite/sequence/align/matrix_data/PAM400.mat +34 -0
  139. biotite/sequence/align/matrix_data/PAM410.mat +34 -0
  140. biotite/sequence/align/matrix_data/PAM420.mat +34 -0
  141. biotite/sequence/align/matrix_data/PAM430.mat +34 -0
  142. biotite/sequence/align/matrix_data/PAM440.mat +34 -0
  143. biotite/sequence/align/matrix_data/PAM450.mat +34 -0
  144. biotite/sequence/align/matrix_data/PAM460.mat +34 -0
  145. biotite/sequence/align/matrix_data/PAM470.mat +34 -0
  146. biotite/sequence/align/matrix_data/PAM480.mat +34 -0
  147. biotite/sequence/align/matrix_data/PAM490.mat +34 -0
  148. biotite/sequence/align/matrix_data/PAM50.mat +34 -0
  149. biotite/sequence/align/matrix_data/PAM500.mat +34 -0
  150. biotite/sequence/align/matrix_data/PAM60.mat +34 -0
  151. biotite/sequence/align/matrix_data/PAM70.mat +34 -0
  152. biotite/sequence/align/matrix_data/PAM80.mat +34 -0
  153. biotite/sequence/align/matrix_data/PAM90.mat +34 -0
  154. biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
  155. biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
  156. biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
  157. biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
  158. biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
  159. biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
  160. biotite/sequence/align/multiple.cpython-311-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-311-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-311-darwin.so +0 -0
  165. biotite/sequence/align/permutation.pyx +305 -0
  166. biotite/sequence/align/primes.txt +821 -0
  167. biotite/sequence/align/selector.cpython-311-darwin.so +0 -0
  168. biotite/sequence/align/selector.pyx +956 -0
  169. biotite/sequence/align/statistics.py +265 -0
  170. biotite/sequence/align/tracetable.cpython-311-darwin.so +0 -0
  171. biotite/sequence/align/tracetable.pxd +64 -0
  172. biotite/sequence/align/tracetable.pyx +370 -0
  173. biotite/sequence/alphabet.py +566 -0
  174. biotite/sequence/annotation.py +829 -0
  175. biotite/sequence/codec.cpython-311-darwin.so +0 -0
  176. biotite/sequence/codec.pyx +155 -0
  177. biotite/sequence/codon.py +466 -0
  178. biotite/sequence/codon_tables.txt +202 -0
  179. biotite/sequence/graphics/__init__.py +33 -0
  180. biotite/sequence/graphics/alignment.py +1034 -0
  181. biotite/sequence/graphics/color_schemes/autumn.json +51 -0
  182. biotite/sequence/graphics/color_schemes/blossom.json +51 -0
  183. biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
  184. biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
  185. biotite/sequence/graphics/color_schemes/flower.json +51 -0
  186. biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
  187. biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
  188. biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
  189. biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
  190. biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
  191. biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
  192. biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
  193. biotite/sequence/graphics/color_schemes/ocean.json +51 -0
  194. biotite/sequence/graphics/color_schemes/pb_flower.json +39 -0
  195. biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
  196. biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
  197. biotite/sequence/graphics/color_schemes/spring.json +51 -0
  198. biotite/sequence/graphics/color_schemes/sunset.json +51 -0
  199. biotite/sequence/graphics/color_schemes/wither.json +51 -0
  200. biotite/sequence/graphics/colorschemes.py +139 -0
  201. biotite/sequence/graphics/dendrogram.py +184 -0
  202. biotite/sequence/graphics/features.py +510 -0
  203. biotite/sequence/graphics/logo.py +110 -0
  204. biotite/sequence/graphics/plasmid.py +661 -0
  205. biotite/sequence/io/__init__.py +12 -0
  206. biotite/sequence/io/fasta/__init__.py +22 -0
  207. biotite/sequence/io/fasta/convert.py +273 -0
  208. biotite/sequence/io/fasta/file.py +278 -0
  209. biotite/sequence/io/fastq/__init__.py +19 -0
  210. biotite/sequence/io/fastq/convert.py +120 -0
  211. biotite/sequence/io/fastq/file.py +551 -0
  212. biotite/sequence/io/genbank/__init__.py +17 -0
  213. biotite/sequence/io/genbank/annotation.py +277 -0
  214. biotite/sequence/io/genbank/file.py +575 -0
  215. biotite/sequence/io/genbank/metadata.py +324 -0
  216. biotite/sequence/io/genbank/sequence.py +172 -0
  217. biotite/sequence/io/general.py +192 -0
  218. biotite/sequence/io/gff/__init__.py +26 -0
  219. biotite/sequence/io/gff/convert.py +133 -0
  220. biotite/sequence/io/gff/file.py +434 -0
  221. biotite/sequence/phylo/__init__.py +36 -0
  222. biotite/sequence/phylo/nj.cpython-311-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-311-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-311-darwin.so +0 -0
  227. biotite/sequence/phylo/upgma.pyx +164 -0
  228. biotite/sequence/profile.py +456 -0
  229. biotite/sequence/search.py +116 -0
  230. biotite/sequence/seqtypes.py +556 -0
  231. biotite/sequence/sequence.py +374 -0
  232. biotite/structure/__init__.py +132 -0
  233. biotite/structure/atoms.py +1455 -0
  234. biotite/structure/basepairs.py +1415 -0
  235. biotite/structure/bonds.cpython-311-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-311-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-311-darwin.so +0 -0
  242. biotite/structure/charges.pyx +520 -0
  243. biotite/structure/compare.py +274 -0
  244. biotite/structure/density.py +114 -0
  245. biotite/structure/dotbracket.py +216 -0
  246. biotite/structure/error.py +31 -0
  247. biotite/structure/filter.py +585 -0
  248. biotite/structure/geometry.py +697 -0
  249. biotite/structure/graphics/__init__.py +13 -0
  250. biotite/structure/graphics/atoms.py +226 -0
  251. biotite/structure/graphics/rna.py +282 -0
  252. biotite/structure/hbond.py +409 -0
  253. biotite/structure/info/__init__.py +25 -0
  254. biotite/structure/info/atom_masses.json +121 -0
  255. biotite/structure/info/atoms.py +82 -0
  256. biotite/structure/info/bonds.py +145 -0
  257. biotite/structure/info/ccd/README.rst +8 -0
  258. biotite/structure/info/ccd/amino_acids.txt +1663 -0
  259. biotite/structure/info/ccd/carbohydrates.txt +1135 -0
  260. biotite/structure/info/ccd/components.bcif +0 -0
  261. biotite/structure/info/ccd/nucleotides.txt +798 -0
  262. biotite/structure/info/ccd.py +95 -0
  263. biotite/structure/info/groups.py +90 -0
  264. biotite/structure/info/masses.py +123 -0
  265. biotite/structure/info/misc.py +144 -0
  266. biotite/structure/info/radii.py +197 -0
  267. biotite/structure/info/standardize.py +196 -0
  268. biotite/structure/integrity.py +268 -0
  269. biotite/structure/io/__init__.py +30 -0
  270. biotite/structure/io/ctab.py +72 -0
  271. biotite/structure/io/dcd/__init__.py +13 -0
  272. biotite/structure/io/dcd/file.py +65 -0
  273. biotite/structure/io/general.py +257 -0
  274. biotite/structure/io/gro/__init__.py +14 -0
  275. biotite/structure/io/gro/file.py +343 -0
  276. biotite/structure/io/mmtf/__init__.py +21 -0
  277. biotite/structure/io/mmtf/assembly.py +214 -0
  278. biotite/structure/io/mmtf/convertarray.cpython-311-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-311-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-311-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-311-darwin.so +0 -0
  285. biotite/structure/io/mmtf/encode.pyx +183 -0
  286. biotite/structure/io/mmtf/file.py +233 -0
  287. biotite/structure/io/mol/__init__.py +20 -0
  288. biotite/structure/io/mol/convert.py +115 -0
  289. biotite/structure/io/mol/ctab.py +414 -0
  290. biotite/structure/io/mol/header.py +116 -0
  291. biotite/structure/io/mol/mol.py +193 -0
  292. biotite/structure/io/mol/sdf.py +916 -0
  293. biotite/structure/io/netcdf/__init__.py +13 -0
  294. biotite/structure/io/netcdf/file.py +63 -0
  295. biotite/structure/io/npz/__init__.py +20 -0
  296. biotite/structure/io/npz/file.py +152 -0
  297. biotite/structure/io/pdb/__init__.py +20 -0
  298. biotite/structure/io/pdb/convert.py +293 -0
  299. biotite/structure/io/pdb/file.py +1240 -0
  300. biotite/structure/io/pdb/hybrid36.cpython-311-darwin.so +0 -0
  301. biotite/structure/io/pdb/hybrid36.pyx +242 -0
  302. biotite/structure/io/pdbqt/__init__.py +15 -0
  303. biotite/structure/io/pdbqt/convert.py +107 -0
  304. biotite/structure/io/pdbqt/file.py +640 -0
  305. biotite/structure/io/pdbx/__init__.py +23 -0
  306. biotite/structure/io/pdbx/bcif.py +648 -0
  307. biotite/structure/io/pdbx/cif.py +1032 -0
  308. biotite/structure/io/pdbx/component.py +246 -0
  309. biotite/structure/io/pdbx/convert.py +1597 -0
  310. biotite/structure/io/pdbx/encoding.cpython-311-darwin.so +0 -0
  311. biotite/structure/io/pdbx/encoding.pyx +950 -0
  312. biotite/structure/io/pdbx/legacy.py +267 -0
  313. biotite/structure/io/tng/__init__.py +13 -0
  314. biotite/structure/io/tng/file.py +46 -0
  315. biotite/structure/io/trajfile.py +710 -0
  316. biotite/structure/io/trr/__init__.py +13 -0
  317. biotite/structure/io/trr/file.py +46 -0
  318. biotite/structure/io/xtc/__init__.py +13 -0
  319. biotite/structure/io/xtc/file.py +46 -0
  320. biotite/structure/mechanics.py +75 -0
  321. biotite/structure/molecules.py +353 -0
  322. biotite/structure/pseudoknots.py +642 -0
  323. biotite/structure/rdf.py +243 -0
  324. biotite/structure/repair.py +253 -0
  325. biotite/structure/residues.py +562 -0
  326. biotite/structure/resutil.py +178 -0
  327. biotite/structure/sasa.cpython-311-darwin.so +0 -0
  328. biotite/structure/sasa.pyx +322 -0
  329. biotite/structure/sequence.py +112 -0
  330. biotite/structure/sse.py +327 -0
  331. biotite/structure/superimpose.py +727 -0
  332. biotite/structure/transform.py +504 -0
  333. biotite/structure/util.py +98 -0
  334. biotite/temp.py +86 -0
  335. biotite/version.py +16 -0
  336. biotite/visualize.py +251 -0
  337. biotite-0.41.1.dist-info/METADATA +187 -0
  338. biotite-0.41.1.dist-info/RECORD +340 -0
  339. biotite-0.41.1.dist-info/WHEEL +4 -0
  340. biotite-0.41.1.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,152 @@
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
+ __name__ = "biotite.application.dssp"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["DsspApp"]
8
+
9
+ from tempfile import NamedTemporaryFile
10
+ from ..localapp import LocalApp, cleanup_tempfile
11
+ from ..application import AppState, requires_state
12
+ from ...structure.io.pdbx.cif import CIFFile
13
+ from ...structure.io.pdbx.convert import set_structure
14
+ import numpy as np
15
+
16
+
17
+ class DsspApp(LocalApp):
18
+ r"""
19
+ Annotate the secondary structure of a protein structure using the
20
+ *DSSP* software.
21
+
22
+ Internally this creates a :class:`Popen` instance, which handles
23
+ the execution.
24
+
25
+ DSSP differentiates between 8 different types of secondary
26
+ structure elements:
27
+
28
+ - C: loop, coil or irregular
29
+ - H: :math:`{\alpha}`-helix
30
+ - B: :math:`{\beta}`-bridge
31
+ - E: extended strand, participation in :math:`{\beta}`-ladder
32
+ - G: 3 :sub:`10`-helix
33
+ - I: :math:`{\pi}`-helix
34
+ - T: hydrogen bonded turn
35
+ - S: bend
36
+
37
+ Parameters
38
+ ----------
39
+ atom_array : AtomArray
40
+ The atom array to be annotated.
41
+ bin_path : str, optional
42
+ Path of the *DDSP* binary.
43
+
44
+ Examples
45
+ --------
46
+
47
+ >>> app = DsspApp(atom_array)
48
+ >>> app.start()
49
+ >>> app.join()
50
+ >>> print(app.get_sse())
51
+ ['C' 'H' 'H' 'H' 'H' 'H' 'H' 'H' 'T' 'T' 'G' 'G' 'G' 'G' 'T' 'C' 'C' 'C'
52
+ 'C' 'C']
53
+ """
54
+
55
+ def __init__(self, atom_array, bin_path="mkdssp"):
56
+ super().__init__(bin_path)
57
+
58
+ # mkdssp requires also the
59
+ # 'occupancy', 'b_factor' and 'charge' fields
60
+ # -> Add these annotations to a copy of the input structure
61
+ self._array = atom_array.copy()
62
+ categories = self._array.get_annotation_categories()
63
+ if "charge" not in categories:
64
+ self._array.set_annotation(
65
+ "charge", np.zeros(self._array.array_length(), dtype=int)
66
+ )
67
+ if "b_factor" not in categories:
68
+ self._array.set_annotation(
69
+ "b_factor", np.zeros(self._array.array_length(), dtype=float)
70
+ )
71
+ if "occupancy" not in categories:
72
+ self._array.set_annotation(
73
+ "occupancy", np.ones(self._array.array_length(), dtype=float)
74
+ )
75
+
76
+ self._in_file = NamedTemporaryFile("w", suffix=".cif", delete=False)
77
+ self._out_file = NamedTemporaryFile("r", suffix=".dssp", delete=False)
78
+
79
+ def run(self):
80
+ in_file = CIFFile()
81
+ set_structure(in_file, self._array)
82
+ in_file.write(self._in_file)
83
+ self._in_file.flush()
84
+ self.set_arguments(
85
+ ["-i", self._in_file.name, "-o", self._out_file.name]
86
+ )
87
+ super().run()
88
+
89
+ def evaluate(self):
90
+ super().evaluate()
91
+ lines = self._out_file.read().split("\n")
92
+ # Index where SSE records start
93
+ sse_start = None
94
+ for i, line in enumerate(lines):
95
+ if line.startswith(" # RESIDUE AA STRUCTURE"):
96
+ sse_start = i+1
97
+ if sse_start is None:
98
+ raise ValueError("DSSP file does not contain SSE records")
99
+ # Remove "!" for missing residues
100
+ lines = [
101
+ line for line in lines[sse_start:]
102
+ if len(line) != 0 and line[13] != "!"
103
+ ]
104
+ self._sse = np.zeros(len(lines), dtype="U1")
105
+ # Parse file for SSE letters
106
+ for i, line in enumerate(lines):
107
+ self._sse[i] = line[16]
108
+ self._sse[self._sse == " "] = "C"
109
+
110
+ def clean_up(self):
111
+ super().clean_up()
112
+ cleanup_tempfile(self._in_file)
113
+ cleanup_tempfile(self._out_file)
114
+
115
+ @requires_state(AppState.JOINED)
116
+ def get_sse(self):
117
+ """
118
+ Get the resulting secondary structure assignment.
119
+
120
+ Returns
121
+ -------
122
+ sse : ndarray, dtype="U1"
123
+ An array containing DSSP secondary structure symbols
124
+ corresponding to the residues in the input atom array.
125
+ """
126
+ return self._sse
127
+
128
+ @staticmethod
129
+ def annotate_sse(atom_array, bin_path="mkdssp"):
130
+ """
131
+ Perform a secondary structure assignment to an atom array.
132
+
133
+ This is a convenience function, that wraps the :class:`DsspApp`
134
+ execution.
135
+
136
+ Parameters
137
+ ----------
138
+ atom_array : AtomArray
139
+ The atom array to be annotated.
140
+ bin_path : str, optional
141
+ Path of the DDSP binary.
142
+
143
+ Returns
144
+ -------
145
+ sse : ndarray, dtype="U1"
146
+ An array containing DSSP secondary structure symbols
147
+ corresponding to the residues in the input atom array.
148
+ """
149
+ app = DsspApp(atom_array, bin_path)
150
+ app.start()
151
+ app.join()
152
+ return app.get_sse()
@@ -0,0 +1,306 @@
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
+ __name__ = "biotite.application"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["LocalApp"]
8
+
9
+ import abc
10
+ import copy
11
+ from os import chdir, getcwd, remove
12
+ from .application import Application, AppState, AppStateError, requires_state
13
+ from subprocess import Popen, PIPE, SubprocessError, TimeoutExpired
14
+
15
+ class LocalApp(Application, metaclass=abc.ABCMeta):
16
+ """
17
+ The base class for all locally installed applications, that are used
18
+ via the command line.
19
+
20
+ Internally this creates a :class:`Popen` instance, which handles
21
+ the execution.
22
+
23
+ Parameters
24
+ ----------
25
+ bin_path : str
26
+ Path of the application represented by this class.
27
+ """
28
+
29
+ def __init__(self, bin_path):
30
+ super().__init__()
31
+ self._bin_path = bin_path
32
+ self._arguments = []
33
+ self._options = []
34
+ self._exec_dir = getcwd()
35
+ self._process = None
36
+ self._command = None
37
+ self._stdin_file = None
38
+
39
+ @requires_state(AppState.CREATED)
40
+ def set_arguments(self, arguments):
41
+ """
42
+ Set command line arguments for the application run.
43
+
44
+ PROTECTED: Do not call from outside.
45
+
46
+ Parameters
47
+ ----------
48
+ arguments : list of str
49
+ A list of strings representing the command line options.
50
+ """
51
+ self._arguments = copy.copy(arguments)
52
+
53
+ @requires_state(AppState.CREATED)
54
+ def set_stdin(self, file):
55
+ """
56
+ Set a file as standard input for the application run.
57
+
58
+ PROTECTED: Do not call from outside.
59
+
60
+ Parameters
61
+ ----------
62
+ file : file object
63
+ The file for the standard input.
64
+ Must have a valid file descriptor, e.g. file-like objects
65
+ such as `StringIO` are invalid.
66
+ """
67
+ self._stdin_file = file
68
+
69
+ @requires_state(AppState.CREATED)
70
+ def add_additional_options(self, options):
71
+ """
72
+ Add additional options for the command line program.
73
+ These options are put before the arguments automatically
74
+ determined by the respective :class:`LocalApp` subclass.
75
+
76
+ This method is focused on advanced users, who have knowledge on
77
+ the available options of the command line program and the
78
+ options already used by the :class:`LocalApp` subclasses.
79
+ Ignoring the already used options may result in conflicting
80
+ CLI arguments and potential unexpected results.
81
+ It is recommended to use this method only, when the respective
82
+ :class:`LocalApp` subclass does not provide a method to set the
83
+ desired option.
84
+
85
+ Parameters
86
+ ----------
87
+ options : list of str
88
+ A list of strings representing the command line options.
89
+
90
+ Notes
91
+ -----
92
+ In order to see which options the command line execution used,
93
+ try the :meth:`get_command()` method.
94
+
95
+ Examples
96
+ --------
97
+
98
+ >>> seq1 = ProteinSequence("BIQTITE")
99
+ >>> seq2 = ProteinSequence("TITANITE")
100
+ >>> seq3 = ProteinSequence("BISMITE")
101
+ >>> seq4 = ProteinSequence("IQLITE")
102
+ >>> # Run application without additional arguments
103
+ >>> app = ClustalOmegaApp([seq1, seq2, seq3, seq4])
104
+ >>> app.start()
105
+ >>> app.join()
106
+ >>> print(app.get_command())
107
+ clustalo --in ...fa --out ...fa --force --output-order=tree-order --seqtype Protein --guidetree-out ...tree
108
+ >>> # Run application with additional argument
109
+ >>> app = ClustalOmegaApp([seq1, seq2, seq3, seq4])
110
+ >>> app.add_additional_options(["--full"])
111
+ >>> app.start()
112
+ >>> app.join()
113
+ >>> print(app.get_command())
114
+ clustalo --full --in ...fa --out ...fa --force --output-order=tree-order --seqtype Protein --guidetree-out ...tree
115
+ """
116
+ self._options += options
117
+
118
+ @requires_state(
119
+ AppState.RUNNING | \
120
+ AppState.CANCELLED | \
121
+ AppState.FINISHED | \
122
+ AppState.JOINED
123
+ )
124
+ def get_command(self):
125
+ """
126
+ Get the executed command.
127
+
128
+ Cannot be called until the application has been started.
129
+
130
+ Returns
131
+ -------
132
+ command : str
133
+ The executed command.
134
+
135
+ Examples
136
+ --------
137
+
138
+ >>> seq1 = ProteinSequence("BIQTITE")
139
+ >>> seq2 = ProteinSequence("TITANITE")
140
+ >>> seq3 = ProteinSequence("BISMITE")
141
+ >>> seq4 = ProteinSequence("IQLITE")
142
+ >>> app = ClustalOmegaApp([seq1, seq2, seq3, seq4])
143
+ >>> app.start()
144
+ >>> print(app.get_command())
145
+ clustalo --in ...fa --out ...fa --force --output-order=tree-order --seqtype Protein --guidetree-out ...tree
146
+ """
147
+ return " ".join(self._command)
148
+
149
+
150
+ @requires_state(AppState.CREATED)
151
+ def set_exec_dir(self, exec_dir):
152
+ """
153
+ Set the directory where the application should be executed.
154
+ If not set, it will be executed in the working directory at the
155
+ time the application was created.
156
+
157
+ PROTECTED: Do not call from outside.
158
+
159
+ Parameters
160
+ ----------
161
+ exec_dir : str
162
+ The execution directory.
163
+ """
164
+ self._exec_dir = exec_dir
165
+
166
+ @requires_state(AppState.RUNNING | AppState.FINISHED)
167
+ def get_process(self):
168
+ """
169
+ Get the `Popen` instance.
170
+
171
+ PROTECTED: Do not call from outside.
172
+
173
+ Returns
174
+ -------
175
+ process : Popen
176
+ The `Popen` instance
177
+ """
178
+ return self._process
179
+
180
+ @requires_state(AppState.FINISHED | AppState.JOINED)
181
+ def get_exit_code(self):
182
+ """
183
+ Get the exit code of the process.
184
+
185
+ PROTECTED: Do not call from outside.
186
+
187
+ Returns
188
+ -------
189
+ code : int
190
+ The exit code.
191
+ """
192
+ return self._process.returncode
193
+
194
+ @requires_state(AppState.FINISHED | AppState.JOINED)
195
+ def get_stdout(self):
196
+ """
197
+ Get the STDOUT pipe content of the process.
198
+
199
+ PROTECTED: Do not call from outside.
200
+
201
+ Returns
202
+ -------
203
+ stdout : str
204
+ The standard output.
205
+ """
206
+ return self._stdout
207
+
208
+ @requires_state(AppState.FINISHED | AppState.JOINED)
209
+ def get_stderr(self):
210
+ """
211
+ Get the STDERR pipe content of the process.
212
+
213
+ PROTECTED: Do not call from outside.
214
+
215
+ Returns
216
+ -------
217
+ stdout : str
218
+ The standard error.
219
+ """
220
+ return self._stderr
221
+
222
+ def run(self):
223
+ cwd = getcwd()
224
+ chdir(self._exec_dir)
225
+ self._command = [self._bin_path] + self._options + self._arguments
226
+ self._process = Popen(
227
+ self._command, stdin=self._stdin_file, stdout=PIPE, stderr=PIPE,
228
+ encoding="UTF-8"
229
+ )
230
+ chdir(cwd)
231
+
232
+ def is_finished(self):
233
+ code = self._process.poll()
234
+ if code == None:
235
+ return False
236
+ else:
237
+ self._stdout, self._stderr = self._process.communicate()
238
+ return True
239
+
240
+ @requires_state(AppState.RUNNING | AppState.FINISHED)
241
+ def join(self, timeout=None):
242
+ # Override method as repetitive calls of 'is_finished()'
243
+ # are not necessary as 'communicate()' already waits for the
244
+ # finished application
245
+ try:
246
+ self._stdout, self._stderr = self._process.communicate(
247
+ timeout=timeout
248
+ )
249
+ except TimeoutExpired:
250
+ self.cancel()
251
+ raise TimeoutError(
252
+ f"The application expired its timeout ({timeout:.1f} s)"
253
+ )
254
+ self._state = AppState.FINISHED
255
+
256
+ try:
257
+ self.evaluate()
258
+ except AppStateError:
259
+ raise
260
+ except:
261
+ self._state = AppState.CANCELLED
262
+ raise
263
+ else:
264
+ self._state = AppState.JOINED
265
+ self.clean_up()
266
+
267
+
268
+ def wait_interval(self):
269
+ # Not used in this implementation of 'join()'
270
+ raise NotImplementedError()
271
+
272
+ def evaluate(self):
273
+ super().evaluate()
274
+ # Check if applicaion terminated correctly
275
+ exit_code = self.get_exit_code()
276
+ if exit_code != 0:
277
+ err_msg = self.get_stderr().replace("\n", " ")
278
+ raise SubprocessError(
279
+ f"'{self._bin_path}' returned with exit code {exit_code}: "
280
+ f"{err_msg}"
281
+ )
282
+
283
+ def clean_up(self):
284
+ if self.get_app_state() == AppState.CANCELLED:
285
+ self._process.kill()
286
+
287
+
288
+ def cleanup_tempfile(temp_file):
289
+ """
290
+ Close a :class:`NamedTemporaryFile` and delete it manually,
291
+ if `delete` is set to ``False``.
292
+ This function is a small helper function intended for usage in
293
+ `LocalApp` subclasses.
294
+
295
+ The manual deletion is necessary, as Windows does not allow to open
296
+ a :class:`NamedTemporaryFile` as second time
297
+ (e.g. by the file name), if `delete` is set to ``True``.
298
+
299
+ Parameters
300
+ ----------
301
+ temp_file : NamedTemporaryFile
302
+ The temporary file to be closed and deleted.
303
+ """
304
+ temp_file.close()
305
+ if not temp_file.delete:
306
+ remove(temp_file.name)
@@ -0,0 +1,12 @@
1
+ # This source code is part of the Biotite package and is distributed
2
+ # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further
3
+ # information.
4
+
5
+ """
6
+ A subpackage for multiple sequence alignments using MAFFT.
7
+ """
8
+
9
+ __name__ = "biotite.application.mafft"
10
+ __author__ = "Patrick Kunzmann"
11
+
12
+ from .app import *
@@ -0,0 +1,122 @@
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
+ __name__ = "biotite.application.mafft"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["MafftApp"]
8
+
9
+ import re
10
+ import os
11
+ from ..msaapp import MSAApp
12
+ from ..application import AppState, requires_state
13
+ from ...sequence.sequence import Sequence
14
+ from ...sequence.seqtypes import NucleotideSequence, ProteinSequence
15
+ from ...sequence.io.fasta.file import FastaFile
16
+ from ...sequence.align.alignment import Alignment
17
+ from ...sequence.phylo.tree import Tree
18
+
19
+
20
+ _prefix_pattern = re.compile(r"\d*_")
21
+
22
+
23
+
24
+ class MafftApp(MSAApp):
25
+ """
26
+ Perform a multiple sequence alignment using MAFFT.
27
+
28
+ Parameters
29
+ ----------
30
+ sequences : list of Sequence
31
+ The sequences to be aligned.
32
+ bin_path : str, optional
33
+ Path of the MUSCLE binary.
34
+ matrix : SubstitutionMatrix, optional
35
+ A custom substitution matrix.
36
+
37
+ Examples
38
+ --------
39
+
40
+ >>> seq1 = ProteinSequence("BIQTITE")
41
+ >>> seq2 = ProteinSequence("TITANITE")
42
+ >>> seq3 = ProteinSequence("BISMITE")
43
+ >>> seq4 = ProteinSequence("IQLITE")
44
+ >>> app = MafftApp([seq1, seq2, seq3, seq4])
45
+ >>> app.start()
46
+ >>> app.join()
47
+ >>> alignment = app.get_alignment()
48
+ >>> print(alignment)
49
+ -BIQTITE
50
+ TITANITE
51
+ -BISMITE
52
+ --IQLITE
53
+ """
54
+
55
+ def __init__(self, sequences, bin_path="mafft", matrix=None):
56
+ super().__init__(sequences, bin_path, matrix)
57
+ self._tree = None
58
+ self._out_tree_file_name = self.get_input_file_path() + ".tree"
59
+
60
+ def run(self):
61
+ args = [
62
+ "--quiet",
63
+ "--auto",
64
+ "--treeout",
65
+ # Get the reordered alignment in order for
66
+ # get_alignment_order() to work properly
67
+ "--reorder",
68
+ ]
69
+ if self.get_seqtype() == "protein":
70
+ args += ["--amino"]
71
+ else:
72
+ args += ["--nuc"]
73
+ if self.get_matrix_file_path() is not None:
74
+ args += ["--aamatrix", self.get_matrix_file_path()]
75
+ args += [self.get_input_file_path()]
76
+ self.set_arguments(args)
77
+ super().run()
78
+
79
+ def evaluate(self):
80
+ with open(self.get_output_file_path(), "w") as f:
81
+ # MAFFT outputs alignment to stdout
82
+ # -> write stdout to output file name
83
+ f.write(self.get_stdout())
84
+ super().evaluate()
85
+ with open(self._out_tree_file_name, "r") as file:
86
+ raw_newick = file.read().replace("\n", "")
87
+ # Mafft uses sequences label in the form '<n>_<seqname>'
88
+ # Only the <seqname> is required
89
+ # -> remove the '<n>_' prefix
90
+ newick = re.sub(_prefix_pattern, "", raw_newick)
91
+ self._tree = Tree.from_newick(newick)
92
+
93
+ def clean_up(self):
94
+ os.remove(self._out_tree_file_name)
95
+
96
+ @requires_state(AppState.JOINED)
97
+ def get_guide_tree(self):
98
+ """
99
+ Get the guide tree created for the progressive alignment.
100
+
101
+ Returns
102
+ -------
103
+ tree : Tree
104
+ The guide tree.
105
+ """
106
+ return self._tree
107
+
108
+ @staticmethod
109
+ def supports_nucleotide():
110
+ return True
111
+
112
+ @staticmethod
113
+ def supports_protein():
114
+ return True
115
+
116
+ @staticmethod
117
+ def supports_custom_nucleotide_matrix():
118
+ return True
119
+
120
+ @staticmethod
121
+ def supports_custom_protein_matrix():
122
+ return True