biotite 0.41.1__cp311-cp311-macosx_10_16_arm64.whl

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

Potentially problematic release.


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

Files changed (340) hide show
  1. biotite/__init__.py +19 -0
  2. biotite/application/__init__.py +43 -0
  3. biotite/application/application.py +265 -0
  4. biotite/application/autodock/__init__.py +12 -0
  5. biotite/application/autodock/app.py +505 -0
  6. biotite/application/blast/__init__.py +14 -0
  7. biotite/application/blast/alignment.py +83 -0
  8. biotite/application/blast/webapp.py +421 -0
  9. biotite/application/clustalo/__init__.py +12 -0
  10. biotite/application/clustalo/app.py +238 -0
  11. biotite/application/dssp/__init__.py +12 -0
  12. biotite/application/dssp/app.py +152 -0
  13. biotite/application/localapp.py +306 -0
  14. biotite/application/mafft/__init__.py +12 -0
  15. biotite/application/mafft/app.py +122 -0
  16. biotite/application/msaapp.py +374 -0
  17. biotite/application/muscle/__init__.py +13 -0
  18. biotite/application/muscle/app3.py +254 -0
  19. biotite/application/muscle/app5.py +171 -0
  20. biotite/application/sra/__init__.py +18 -0
  21. biotite/application/sra/app.py +456 -0
  22. biotite/application/tantan/__init__.py +12 -0
  23. biotite/application/tantan/app.py +222 -0
  24. biotite/application/util.py +59 -0
  25. biotite/application/viennarna/__init__.py +18 -0
  26. biotite/application/viennarna/rnaalifold.py +304 -0
  27. biotite/application/viennarna/rnafold.py +269 -0
  28. biotite/application/viennarna/rnaplot.py +187 -0
  29. biotite/application/viennarna/util.py +72 -0
  30. biotite/application/webapp.py +77 -0
  31. biotite/copyable.py +71 -0
  32. biotite/database/__init__.py +23 -0
  33. biotite/database/entrez/__init__.py +15 -0
  34. biotite/database/entrez/check.py +61 -0
  35. biotite/database/entrez/dbnames.py +89 -0
  36. biotite/database/entrez/download.py +223 -0
  37. biotite/database/entrez/key.py +44 -0
  38. biotite/database/entrez/query.py +223 -0
  39. biotite/database/error.py +15 -0
  40. biotite/database/pubchem/__init__.py +21 -0
  41. biotite/database/pubchem/download.py +260 -0
  42. biotite/database/pubchem/error.py +20 -0
  43. biotite/database/pubchem/query.py +827 -0
  44. biotite/database/pubchem/throttle.py +99 -0
  45. biotite/database/rcsb/__init__.py +13 -0
  46. biotite/database/rcsb/download.py +167 -0
  47. biotite/database/rcsb/query.py +959 -0
  48. biotite/database/uniprot/__init__.py +13 -0
  49. biotite/database/uniprot/check.py +32 -0
  50. biotite/database/uniprot/download.py +134 -0
  51. biotite/database/uniprot/query.py +209 -0
  52. biotite/file.py +251 -0
  53. biotite/sequence/__init__.py +73 -0
  54. biotite/sequence/align/__init__.py +49 -0
  55. biotite/sequence/align/alignment.py +658 -0
  56. biotite/sequence/align/banded.cpython-311-darwin.so +0 -0
  57. biotite/sequence/align/banded.pyx +652 -0
  58. biotite/sequence/align/buckets.py +69 -0
  59. biotite/sequence/align/cigar.py +434 -0
  60. biotite/sequence/align/kmeralphabet.cpython-311-darwin.so +0 -0
  61. biotite/sequence/align/kmeralphabet.pyx +574 -0
  62. biotite/sequence/align/kmersimilarity.cpython-311-darwin.so +0 -0
  63. biotite/sequence/align/kmersimilarity.pyx +233 -0
  64. biotite/sequence/align/kmertable.cpython-311-darwin.so +0 -0
  65. biotite/sequence/align/kmertable.pyx +3400 -0
  66. biotite/sequence/align/localgapped.cpython-311-darwin.so +0 -0
  67. biotite/sequence/align/localgapped.pyx +892 -0
  68. biotite/sequence/align/localungapped.cpython-311-darwin.so +0 -0
  69. biotite/sequence/align/localungapped.pyx +279 -0
  70. biotite/sequence/align/matrix.py +405 -0
  71. biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
  72. biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
  73. biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
  74. biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
  75. biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
  76. biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
  77. biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
  78. biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
  79. biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
  80. biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
  81. biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
  82. biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
  83. biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
  84. biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
  85. biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
  86. biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
  87. biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
  88. biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
  89. biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
  90. biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
  91. biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
  92. biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
  93. biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
  94. biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
  95. biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
  96. biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
  97. biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
  98. biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
  99. biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
  100. biotite/sequence/align/matrix_data/GONNET.mat +26 -0
  101. biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
  102. biotite/sequence/align/matrix_data/MATCH.mat +25 -0
  103. biotite/sequence/align/matrix_data/NUC.mat +25 -0
  104. biotite/sequence/align/matrix_data/PAM10.mat +34 -0
  105. biotite/sequence/align/matrix_data/PAM100.mat +34 -0
  106. biotite/sequence/align/matrix_data/PAM110.mat +34 -0
  107. biotite/sequence/align/matrix_data/PAM120.mat +34 -0
  108. biotite/sequence/align/matrix_data/PAM130.mat +34 -0
  109. biotite/sequence/align/matrix_data/PAM140.mat +34 -0
  110. biotite/sequence/align/matrix_data/PAM150.mat +34 -0
  111. biotite/sequence/align/matrix_data/PAM160.mat +34 -0
  112. biotite/sequence/align/matrix_data/PAM170.mat +34 -0
  113. biotite/sequence/align/matrix_data/PAM180.mat +34 -0
  114. biotite/sequence/align/matrix_data/PAM190.mat +34 -0
  115. biotite/sequence/align/matrix_data/PAM20.mat +34 -0
  116. biotite/sequence/align/matrix_data/PAM200.mat +34 -0
  117. biotite/sequence/align/matrix_data/PAM210.mat +34 -0
  118. biotite/sequence/align/matrix_data/PAM220.mat +34 -0
  119. biotite/sequence/align/matrix_data/PAM230.mat +34 -0
  120. biotite/sequence/align/matrix_data/PAM240.mat +34 -0
  121. biotite/sequence/align/matrix_data/PAM250.mat +34 -0
  122. biotite/sequence/align/matrix_data/PAM260.mat +34 -0
  123. biotite/sequence/align/matrix_data/PAM270.mat +34 -0
  124. biotite/sequence/align/matrix_data/PAM280.mat +34 -0
  125. biotite/sequence/align/matrix_data/PAM290.mat +34 -0
  126. biotite/sequence/align/matrix_data/PAM30.mat +34 -0
  127. biotite/sequence/align/matrix_data/PAM300.mat +34 -0
  128. biotite/sequence/align/matrix_data/PAM310.mat +34 -0
  129. biotite/sequence/align/matrix_data/PAM320.mat +34 -0
  130. biotite/sequence/align/matrix_data/PAM330.mat +34 -0
  131. biotite/sequence/align/matrix_data/PAM340.mat +34 -0
  132. biotite/sequence/align/matrix_data/PAM350.mat +34 -0
  133. biotite/sequence/align/matrix_data/PAM360.mat +34 -0
  134. biotite/sequence/align/matrix_data/PAM370.mat +34 -0
  135. biotite/sequence/align/matrix_data/PAM380.mat +34 -0
  136. biotite/sequence/align/matrix_data/PAM390.mat +34 -0
  137. biotite/sequence/align/matrix_data/PAM40.mat +34 -0
  138. biotite/sequence/align/matrix_data/PAM400.mat +34 -0
  139. biotite/sequence/align/matrix_data/PAM410.mat +34 -0
  140. biotite/sequence/align/matrix_data/PAM420.mat +34 -0
  141. biotite/sequence/align/matrix_data/PAM430.mat +34 -0
  142. biotite/sequence/align/matrix_data/PAM440.mat +34 -0
  143. biotite/sequence/align/matrix_data/PAM450.mat +34 -0
  144. biotite/sequence/align/matrix_data/PAM460.mat +34 -0
  145. biotite/sequence/align/matrix_data/PAM470.mat +34 -0
  146. biotite/sequence/align/matrix_data/PAM480.mat +34 -0
  147. biotite/sequence/align/matrix_data/PAM490.mat +34 -0
  148. biotite/sequence/align/matrix_data/PAM50.mat +34 -0
  149. biotite/sequence/align/matrix_data/PAM500.mat +34 -0
  150. biotite/sequence/align/matrix_data/PAM60.mat +34 -0
  151. biotite/sequence/align/matrix_data/PAM70.mat +34 -0
  152. biotite/sequence/align/matrix_data/PAM80.mat +34 -0
  153. biotite/sequence/align/matrix_data/PAM90.mat +34 -0
  154. biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
  155. biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
  156. biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
  157. biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
  158. biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
  159. biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
  160. biotite/sequence/align/multiple.cpython-311-darwin.so +0 -0
  161. biotite/sequence/align/multiple.pyx +620 -0
  162. biotite/sequence/align/pairwise.cpython-311-darwin.so +0 -0
  163. biotite/sequence/align/pairwise.pyx +587 -0
  164. biotite/sequence/align/permutation.cpython-311-darwin.so +0 -0
  165. biotite/sequence/align/permutation.pyx +305 -0
  166. biotite/sequence/align/primes.txt +821 -0
  167. biotite/sequence/align/selector.cpython-311-darwin.so +0 -0
  168. biotite/sequence/align/selector.pyx +956 -0
  169. biotite/sequence/align/statistics.py +265 -0
  170. biotite/sequence/align/tracetable.cpython-311-darwin.so +0 -0
  171. biotite/sequence/align/tracetable.pxd +64 -0
  172. biotite/sequence/align/tracetable.pyx +370 -0
  173. biotite/sequence/alphabet.py +566 -0
  174. biotite/sequence/annotation.py +829 -0
  175. biotite/sequence/codec.cpython-311-darwin.so +0 -0
  176. biotite/sequence/codec.pyx +155 -0
  177. biotite/sequence/codon.py +466 -0
  178. biotite/sequence/codon_tables.txt +202 -0
  179. biotite/sequence/graphics/__init__.py +33 -0
  180. biotite/sequence/graphics/alignment.py +1034 -0
  181. biotite/sequence/graphics/color_schemes/autumn.json +51 -0
  182. biotite/sequence/graphics/color_schemes/blossom.json +51 -0
  183. biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
  184. biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
  185. biotite/sequence/graphics/color_schemes/flower.json +51 -0
  186. biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
  187. biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
  188. biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
  189. biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
  190. biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
  191. biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
  192. biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
  193. biotite/sequence/graphics/color_schemes/ocean.json +51 -0
  194. biotite/sequence/graphics/color_schemes/pb_flower.json +39 -0
  195. biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
  196. biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
  197. biotite/sequence/graphics/color_schemes/spring.json +51 -0
  198. biotite/sequence/graphics/color_schemes/sunset.json +51 -0
  199. biotite/sequence/graphics/color_schemes/wither.json +51 -0
  200. biotite/sequence/graphics/colorschemes.py +139 -0
  201. biotite/sequence/graphics/dendrogram.py +184 -0
  202. biotite/sequence/graphics/features.py +510 -0
  203. biotite/sequence/graphics/logo.py +110 -0
  204. biotite/sequence/graphics/plasmid.py +661 -0
  205. biotite/sequence/io/__init__.py +12 -0
  206. biotite/sequence/io/fasta/__init__.py +22 -0
  207. biotite/sequence/io/fasta/convert.py +273 -0
  208. biotite/sequence/io/fasta/file.py +278 -0
  209. biotite/sequence/io/fastq/__init__.py +19 -0
  210. biotite/sequence/io/fastq/convert.py +120 -0
  211. biotite/sequence/io/fastq/file.py +551 -0
  212. biotite/sequence/io/genbank/__init__.py +17 -0
  213. biotite/sequence/io/genbank/annotation.py +277 -0
  214. biotite/sequence/io/genbank/file.py +575 -0
  215. biotite/sequence/io/genbank/metadata.py +324 -0
  216. biotite/sequence/io/genbank/sequence.py +172 -0
  217. biotite/sequence/io/general.py +192 -0
  218. biotite/sequence/io/gff/__init__.py +26 -0
  219. biotite/sequence/io/gff/convert.py +133 -0
  220. biotite/sequence/io/gff/file.py +434 -0
  221. biotite/sequence/phylo/__init__.py +36 -0
  222. biotite/sequence/phylo/nj.cpython-311-darwin.so +0 -0
  223. biotite/sequence/phylo/nj.pyx +221 -0
  224. biotite/sequence/phylo/tree.cpython-311-darwin.so +0 -0
  225. biotite/sequence/phylo/tree.pyx +1169 -0
  226. biotite/sequence/phylo/upgma.cpython-311-darwin.so +0 -0
  227. biotite/sequence/phylo/upgma.pyx +164 -0
  228. biotite/sequence/profile.py +456 -0
  229. biotite/sequence/search.py +116 -0
  230. biotite/sequence/seqtypes.py +556 -0
  231. biotite/sequence/sequence.py +374 -0
  232. biotite/structure/__init__.py +132 -0
  233. biotite/structure/atoms.py +1455 -0
  234. biotite/structure/basepairs.py +1415 -0
  235. biotite/structure/bonds.cpython-311-darwin.so +0 -0
  236. biotite/structure/bonds.pyx +1933 -0
  237. biotite/structure/box.py +592 -0
  238. biotite/structure/celllist.cpython-311-darwin.so +0 -0
  239. biotite/structure/celllist.pyx +849 -0
  240. biotite/structure/chains.py +298 -0
  241. biotite/structure/charges.cpython-311-darwin.so +0 -0
  242. biotite/structure/charges.pyx +520 -0
  243. biotite/structure/compare.py +274 -0
  244. biotite/structure/density.py +114 -0
  245. biotite/structure/dotbracket.py +216 -0
  246. biotite/structure/error.py +31 -0
  247. biotite/structure/filter.py +585 -0
  248. biotite/structure/geometry.py +697 -0
  249. biotite/structure/graphics/__init__.py +13 -0
  250. biotite/structure/graphics/atoms.py +226 -0
  251. biotite/structure/graphics/rna.py +282 -0
  252. biotite/structure/hbond.py +409 -0
  253. biotite/structure/info/__init__.py +25 -0
  254. biotite/structure/info/atom_masses.json +121 -0
  255. biotite/structure/info/atoms.py +82 -0
  256. biotite/structure/info/bonds.py +145 -0
  257. biotite/structure/info/ccd/README.rst +8 -0
  258. biotite/structure/info/ccd/amino_acids.txt +1663 -0
  259. biotite/structure/info/ccd/carbohydrates.txt +1135 -0
  260. biotite/structure/info/ccd/components.bcif +0 -0
  261. biotite/structure/info/ccd/nucleotides.txt +798 -0
  262. biotite/structure/info/ccd.py +95 -0
  263. biotite/structure/info/groups.py +90 -0
  264. biotite/structure/info/masses.py +123 -0
  265. biotite/structure/info/misc.py +144 -0
  266. biotite/structure/info/radii.py +197 -0
  267. biotite/structure/info/standardize.py +196 -0
  268. biotite/structure/integrity.py +268 -0
  269. biotite/structure/io/__init__.py +30 -0
  270. biotite/structure/io/ctab.py +72 -0
  271. biotite/structure/io/dcd/__init__.py +13 -0
  272. biotite/structure/io/dcd/file.py +65 -0
  273. biotite/structure/io/general.py +257 -0
  274. biotite/structure/io/gro/__init__.py +14 -0
  275. biotite/structure/io/gro/file.py +343 -0
  276. biotite/structure/io/mmtf/__init__.py +21 -0
  277. biotite/structure/io/mmtf/assembly.py +214 -0
  278. biotite/structure/io/mmtf/convertarray.cpython-311-darwin.so +0 -0
  279. biotite/structure/io/mmtf/convertarray.pyx +341 -0
  280. biotite/structure/io/mmtf/convertfile.cpython-311-darwin.so +0 -0
  281. biotite/structure/io/mmtf/convertfile.pyx +501 -0
  282. biotite/structure/io/mmtf/decode.cpython-311-darwin.so +0 -0
  283. biotite/structure/io/mmtf/decode.pyx +152 -0
  284. biotite/structure/io/mmtf/encode.cpython-311-darwin.so +0 -0
  285. biotite/structure/io/mmtf/encode.pyx +183 -0
  286. biotite/structure/io/mmtf/file.py +233 -0
  287. biotite/structure/io/mol/__init__.py +20 -0
  288. biotite/structure/io/mol/convert.py +115 -0
  289. biotite/structure/io/mol/ctab.py +414 -0
  290. biotite/structure/io/mol/header.py +116 -0
  291. biotite/structure/io/mol/mol.py +193 -0
  292. biotite/structure/io/mol/sdf.py +916 -0
  293. biotite/structure/io/netcdf/__init__.py +13 -0
  294. biotite/structure/io/netcdf/file.py +63 -0
  295. biotite/structure/io/npz/__init__.py +20 -0
  296. biotite/structure/io/npz/file.py +152 -0
  297. biotite/structure/io/pdb/__init__.py +20 -0
  298. biotite/structure/io/pdb/convert.py +293 -0
  299. biotite/structure/io/pdb/file.py +1240 -0
  300. biotite/structure/io/pdb/hybrid36.cpython-311-darwin.so +0 -0
  301. biotite/structure/io/pdb/hybrid36.pyx +242 -0
  302. biotite/structure/io/pdbqt/__init__.py +15 -0
  303. biotite/structure/io/pdbqt/convert.py +107 -0
  304. biotite/structure/io/pdbqt/file.py +640 -0
  305. biotite/structure/io/pdbx/__init__.py +23 -0
  306. biotite/structure/io/pdbx/bcif.py +648 -0
  307. biotite/structure/io/pdbx/cif.py +1032 -0
  308. biotite/structure/io/pdbx/component.py +246 -0
  309. biotite/structure/io/pdbx/convert.py +1597 -0
  310. biotite/structure/io/pdbx/encoding.cpython-311-darwin.so +0 -0
  311. biotite/structure/io/pdbx/encoding.pyx +950 -0
  312. biotite/structure/io/pdbx/legacy.py +267 -0
  313. biotite/structure/io/tng/__init__.py +13 -0
  314. biotite/structure/io/tng/file.py +46 -0
  315. biotite/structure/io/trajfile.py +710 -0
  316. biotite/structure/io/trr/__init__.py +13 -0
  317. biotite/structure/io/trr/file.py +46 -0
  318. biotite/structure/io/xtc/__init__.py +13 -0
  319. biotite/structure/io/xtc/file.py +46 -0
  320. biotite/structure/mechanics.py +75 -0
  321. biotite/structure/molecules.py +353 -0
  322. biotite/structure/pseudoknots.py +642 -0
  323. biotite/structure/rdf.py +243 -0
  324. biotite/structure/repair.py +253 -0
  325. biotite/structure/residues.py +562 -0
  326. biotite/structure/resutil.py +178 -0
  327. biotite/structure/sasa.cpython-311-darwin.so +0 -0
  328. biotite/structure/sasa.pyx +322 -0
  329. biotite/structure/sequence.py +112 -0
  330. biotite/structure/sse.py +327 -0
  331. biotite/structure/superimpose.py +727 -0
  332. biotite/structure/transform.py +504 -0
  333. biotite/structure/util.py +98 -0
  334. biotite/temp.py +86 -0
  335. biotite/version.py +16 -0
  336. biotite/visualize.py +251 -0
  337. biotite-0.41.1.dist-info/METADATA +187 -0
  338. biotite-0.41.1.dist-info/RECORD +340 -0
  339. biotite-0.41.1.dist-info/WHEEL +4 -0
  340. biotite-0.41.1.dist-info/licenses/LICENSE.rst +30 -0
@@ -0,0 +1,269 @@
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.viennarna"
6
+ __author__ = "Tom David Müller, Patrick Kunzmann"
7
+ __all__ = ["RNAfoldApp"]
8
+
9
+ import warnings
10
+ from tempfile import NamedTemporaryFile
11
+ import numpy as np
12
+ from ..application import AppState, requires_state
13
+ from ..localapp import LocalApp, cleanup_tempfile
14
+ from ...sequence.io.fasta import FastaFile, set_sequence
15
+ from ...structure.dotbracket import base_pairs_from_dot_bracket
16
+ from .util import build_constraint_string
17
+
18
+
19
+ class RNAfoldApp(LocalApp):
20
+ """
21
+ Compute the minimum free energy secondary structure of a ribonucleic
22
+ acid sequence using *ViennaRNA's* *RNAfold* software.
23
+
24
+ Internally this creates a :class:`Popen` instance, which handles
25
+ the execution.
26
+
27
+ Parameters
28
+ ----------
29
+ sequence : NucleotideSequence
30
+ The RNA sequence.
31
+ temperature : int, optional
32
+ The temperature (°C) to be assumed for the energy parameters.
33
+ bin_path : str, optional
34
+ Path of the *RNAfold* binary.
35
+
36
+ Examples
37
+ --------
38
+
39
+ >>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
40
+ >>> app = RNAfoldApp(sequence)
41
+ >>> app.start()
42
+ >>> app.join()
43
+ >>> print(app.get_free_energy())
44
+ -1.3
45
+ >>> print(app.get_dot_bracket())
46
+ (((.((((.......)).)))))....
47
+ """
48
+
49
+ def __init__(self, sequence, temperature=37, bin_path="RNAfold"):
50
+ self._sequence = sequence.copy()
51
+ self._temperature = str(temperature)
52
+ self._constraints = None
53
+ self._enforce = None
54
+ self._in_file = NamedTemporaryFile(
55
+ "w", suffix=".fa", delete=False
56
+ )
57
+ super().__init__(bin_path)
58
+
59
+ def run(self):
60
+ # Insert no line breaks
61
+ # -> Extremely high value for characters per line
62
+ fasta_file = FastaFile(chars_per_line=np.iinfo(np.int32).max)
63
+ set_sequence(fasta_file, self._sequence)
64
+ if self._constraints is not None:
65
+ fasta_file.lines.append(self._constraints)
66
+ fasta_file.write(self._in_file)
67
+ self._in_file.flush()
68
+
69
+ options = [
70
+ "--noPS",
71
+ "-T", self._temperature,
72
+ ]
73
+ if self._enforce is True:
74
+ options.append("--enforceConstraint")
75
+ if self._constraints is not None:
76
+ options.append("-C")
77
+
78
+ self.set_arguments(options + [self._in_file.name])
79
+ super().run()
80
+
81
+ def evaluate(self):
82
+ super().evaluate()
83
+ lines = self.get_stdout().splitlines()
84
+ content = lines[2]
85
+ dotbracket, free_energy = content.split(" ", maxsplit=1)
86
+ free_energy = float(free_energy[1:-1])
87
+
88
+ self._free_energy = free_energy
89
+ self._dotbracket = dotbracket
90
+
91
+ def clean_up(self):
92
+ super().clean_up()
93
+ cleanup_tempfile(self._in_file)
94
+
95
+ @requires_state(AppState.CREATED)
96
+ def set_temperature(self, temperature):
97
+ """
98
+ Adjust the energy parameters according to a temperature in
99
+ degrees Celsius.
100
+
101
+ Parameters
102
+ ----------
103
+ temperature : int
104
+ The temperature.
105
+ """
106
+ self._temperature = str(temperature)
107
+
108
+ @requires_state(AppState.CREATED)
109
+ def set_constraints(self, pairs=None, paired=None, unpaired=None,
110
+ downstream=None, upstream=None, enforce=False):
111
+ """
112
+ Add constraints of known paired or unpaired bases to the folding
113
+ algorithm.
114
+
115
+ Constraints forbid pairs conflicting with the respective
116
+ constraint.
117
+
118
+ Parameters
119
+ ----------
120
+ pairs : ndarray, shape=(n,2), dtype=int, optional
121
+ Positions of constrained base pairs.
122
+ paired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
123
+ Positions of bases that are paired with any other base.
124
+ unpaired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
125
+ Positions of bases that are unpaired.
126
+ downstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
127
+ Positions of bases that are paired with any downstream base.
128
+ upstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
129
+ Positions of bases that are paired with any upstream base.
130
+ enforce : bool, optional
131
+ If set to true, the given constraints are enforced, i.e. a
132
+ the respective base pairs must form.
133
+ By default (false), a constraint does only forbid formation
134
+ of a pair that would conflict with this constraint.
135
+ """
136
+ self._constraints = build_constraint_string(
137
+ len(self._sequence),
138
+ pairs, paired, unpaired, downstream, upstream
139
+ )
140
+ self._enforce = enforce
141
+
142
+ @requires_state(AppState.JOINED)
143
+ def get_free_energy(self):
144
+ """
145
+ Get the free energy (kcal/mol) of the suggested
146
+ secondary structure.
147
+
148
+ Returns
149
+ -------
150
+ free_energy : float
151
+ The free energy.
152
+
153
+ Examples
154
+ --------
155
+
156
+ >>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
157
+ >>> app = RNAfoldApp(sequence)
158
+ >>> app.start()
159
+ >>> app.join()
160
+ >>> print(app.get_free_energy())
161
+ -1.3
162
+ """
163
+ return self._free_energy
164
+
165
+ @requires_state(AppState.JOINED)
166
+ def get_mfe(self):
167
+ """
168
+ Get the free energy (kcal/mol) of the suggested
169
+ secondary structure.
170
+
171
+ DEPRECATED: Use :meth:`get_free_energy()` instead.
172
+
173
+ Returns
174
+ -------
175
+ mfe : float
176
+ The minimum free energy.
177
+ """
178
+ warnings.warn(
179
+ "'get_mfe()' is deprecated, use 'get_free_energy()' instead",
180
+ DeprecationWarning
181
+ )
182
+ return self.get_free_energy()
183
+
184
+ @requires_state(AppState.JOINED)
185
+ def get_dot_bracket(self):
186
+ """
187
+ Get the minimum free energy secondary structure of the input
188
+ sequence in dot bracket notation.
189
+
190
+ Returns
191
+ -------
192
+ dotbracket : str
193
+ The secondary structure in dot bracket notation.
194
+
195
+ Examples
196
+ --------
197
+
198
+ >>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
199
+ >>> app = RNAfoldApp(sequence)
200
+ >>> app.start()
201
+ >>> app.join()
202
+ >>> print(app.get_dot_bracket())
203
+ (((.((((.......)).)))))....
204
+ """
205
+ return self._dotbracket
206
+
207
+ @requires_state(AppState.JOINED)
208
+ def get_base_pairs(self):
209
+ """
210
+ Get the base pairs from the minimum free energy secondary
211
+ structure of the input sequence.
212
+
213
+ Returns
214
+ -------
215
+ base_pairs : ndarray, shape=(n,2)
216
+ Each row corresponds to the positions of the bases in the
217
+ sequence.
218
+
219
+ Examples
220
+ --------
221
+
222
+ >>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
223
+ >>> app = RNAfoldApp(sequence)
224
+ >>> app.start()
225
+ >>> app.join()
226
+ >>> print(app.get_base_pairs())
227
+ [[ 0 22]
228
+ [ 1 21]
229
+ [ 2 20]
230
+ [ 4 19]
231
+ [ 5 18]
232
+ [ 6 16]
233
+ [ 7 15]]
234
+
235
+ For reference, the corresponding dot bracket notation can be
236
+ displayed as below.
237
+
238
+ >>> print(app.get_dot_bracket())
239
+ (((.((((.......)).)))))....
240
+ """
241
+ return base_pairs_from_dot_bracket(self._dotbracket)
242
+
243
+ @staticmethod
244
+ def compute_secondary_structure(sequence, bin_path="RNAfold"):
245
+ """
246
+ Compute the minimum free energy secondary structure of a
247
+ ribonucleic acid sequence using *ViennaRNA's* *RNAfold* software.
248
+
249
+ This is a convenience function, that wraps the
250
+ :class:`RNAfoldApp` execution.
251
+
252
+ Parameters
253
+ ----------
254
+ sequence : NucleotideSequence
255
+ The RNA sequence.
256
+ bin_path : str, optional
257
+ Path of the *RNAfold* binary.
258
+
259
+ Returns
260
+ -------
261
+ dotbracket : str
262
+ The secondary structure in dot bracket notation.
263
+ free_energy : float
264
+ The free energy.
265
+ """
266
+ app = RNAfoldApp(sequence, bin_path=bin_path)
267
+ app.start()
268
+ app.join()
269
+ return app.get_dot_bracket(), app.get_free_energy()
@@ -0,0 +1,187 @@
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.viennarna"
6
+ __author__ = "Tom David Müller"
7
+ __all__ = ["RNAplotApp"]
8
+
9
+ import numpy as np
10
+ from tempfile import NamedTemporaryFile
11
+ from os import remove
12
+ from enum import IntEnum
13
+ from ..localapp import LocalApp, cleanup_tempfile
14
+ from ..application import AppState, requires_state
15
+ from ...structure.dotbracket import dot_bracket as dot_bracket_
16
+
17
+ class RNAplotApp(LocalApp):
18
+ """
19
+ Get coordinates for a 2D representation of any unknotted RNA
20
+ structure using *ViennaRNA's* *RNAplot*.
21
+
22
+ The structure has to be provided either in dot bracket notation or
23
+ as a ``ndarray`` of base pairs and the total sequence length.
24
+
25
+ Internally this creates a :class:`Popen` instance, which handles
26
+ the execution.
27
+
28
+ Parameters
29
+ ----------
30
+ dot_bracket : str, optional (default: None)
31
+ The structure in dot bracket notation.
32
+ base_pairs : ndarray, shape=(n,2), optional (default: None)
33
+ Each row corresponds to the positions of the bases in the
34
+ strand. This parameter is mutually exclusive to ``dot_bracket``.
35
+ length : int, optional (default: None)
36
+ The number of bases in the strand. This parameter is required if
37
+ ``base_pairs`` is given.
38
+ layout_type : RNAplotApp.Layout, optional (default: RNAplotApp.Layout.NAVIEW)
39
+ The layout type according to the *RNAplot* documentation.
40
+ bin_path : str, optional
41
+ Path of the *RNAplot* binary.
42
+
43
+ Examples
44
+ --------
45
+
46
+ >>> app = RNAplotApp('((..))')
47
+ >>> app.start()
48
+ >>> app.join()
49
+ >>> print(app.get_coordinates())
50
+ [[ -92.50 92.50]
51
+ [ -92.50 77.50]
52
+ [ -90.31 58.24]
53
+ [-109.69 58.24]
54
+ [-107.50 77.50]
55
+ [-107.50 92.50]]
56
+ """
57
+
58
+ class Layout(IntEnum):
59
+ """
60
+ This enum type represents the layout type of the plot according
61
+ to the official *RNAplot* orientation.
62
+ """
63
+ RADIAL = 0,
64
+ NAVIEW = 1,
65
+ CIRCULAR = 2,
66
+ RNATURTLE = 3,
67
+ RNAPUZZLER = 4
68
+
69
+ def __init__(self, dot_bracket=None, base_pairs=None, length=None,
70
+ layout_type=Layout.NAVIEW, bin_path="RNAplot"):
71
+ super().__init__(bin_path)
72
+
73
+ if dot_bracket is not None:
74
+ self._dot_bracket = dot_bracket
75
+ elif (base_pairs is not None) and (length is not None):
76
+ self._dot_bracket = dot_bracket_(
77
+ base_pairs, length, max_pseudoknot_order = 0
78
+ )[0]
79
+ else:
80
+ raise ValueError(
81
+ "Structure has to be provided in either dot bracket notation "
82
+ "or as base pairs and total sequence length"
83
+ )
84
+
85
+ # Get the value of the enum type
86
+ self._layout_type = str(int(layout_type))
87
+ self._in_file = NamedTemporaryFile("w", suffix=".fold", delete=False)
88
+
89
+ def run(self):
90
+ self._in_file.write("N"*len(self._dot_bracket) + "\n")
91
+ self._in_file.write(self._dot_bracket)
92
+ self._in_file.flush()
93
+ self.set_arguments(
94
+ ["-i", self._in_file.name, "-o", "xrna", "-t", self._layout_type]
95
+ )
96
+ super().run()
97
+
98
+ def evaluate(self):
99
+ super().evaluate()
100
+ self._coordinates = np.loadtxt("rna.ss", usecols=(2, 3))
101
+
102
+ def clean_up(self):
103
+ super().clean_up()
104
+ cleanup_tempfile(self._in_file)
105
+ remove("rna.ss")
106
+
107
+ @requires_state(AppState.CREATED)
108
+ def set_layout_type(self, layout_type):
109
+ """
110
+ Adjust the layout type for the plot according to the *RNAplot*
111
+ documentation.
112
+
113
+ Parameters
114
+ ----------
115
+ type : RNAplotApp.Layout
116
+ The layout type.
117
+ """
118
+ self._layout_type = str(layout_type)
119
+
120
+ @requires_state(AppState.JOINED)
121
+ def get_coordinates(self):
122
+ """
123
+ Get coordinates for a 2D representation of the input structure.
124
+
125
+ Returns
126
+ -------
127
+ coordinates : ndarray, shape=(n,2)
128
+ The 2D coordinates. Each row represents the *x* and *y*
129
+ coordinates for a total sequence length of *n*.
130
+
131
+ Examples
132
+ --------
133
+
134
+ >>> app = RNAplotApp('((..))')
135
+ >>> app.start()
136
+ >>> app.join()
137
+ >>> print(app.get_coordinates())
138
+ [[ -92.50 92.50]
139
+ [ -92.50 77.50]
140
+ [ -90.31 58.24]
141
+ [-109.69 58.24]
142
+ [-107.50 77.50]
143
+ [-107.50 92.50]]
144
+ """
145
+ return self._coordinates
146
+
147
+ @staticmethod
148
+ def compute_coordinates(
149
+ dot_bracket=None, base_pairs=None, length=None,
150
+ layout_type=Layout.NAVIEW, bin_path="RNAplot"
151
+ ):
152
+ """
153
+ Get coordinates for a 2D representation of any unknotted RNA
154
+ structure using *ViennaRNA's* *RNAplot*.
155
+
156
+ The structure has to be provided either in dot bracket notation
157
+ or as a ``ndarray`` of base pairs and the total sequence length.
158
+
159
+ This is a convenience function, that wraps the
160
+ :class:`RNAplotApp` execution.
161
+
162
+ Parameters
163
+ ----------
164
+ dot_bracket : str, optional (default: None)
165
+ The structure in dot bracket notation.
166
+ base_pairs : ndarray, shape=(n,2), optional (default: None)
167
+ Each row corresponds to the positions of the bases in the
168
+ strand. This parameter is mutually exclusive to
169
+ ``dot_bracket``.
170
+ length : int, optional (default: None)
171
+ The number of bases in the strand. This parameter is
172
+ required if ``base_pairs`` is given.
173
+ bin_path : str, optional
174
+ Path of the *RNAplot* binary.
175
+
176
+ Returns
177
+ -------
178
+ coordinates : ndarray, shape=(n,2)
179
+ The 2D coordinates. Each row represents the *x* and *y*
180
+ coordinates for a total sequence length of *n*.
181
+ """
182
+ app = RNAplotApp(dot_bracket=dot_bracket, base_pairs=base_pairs,
183
+ length=length, layout_type=layout_type,
184
+ bin_path=bin_path)
185
+ app.start()
186
+ app.join()
187
+ return app.get_coordinates()
@@ -0,0 +1,72 @@
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.viennarna"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["build_constraint_string"]
8
+
9
+ import numpy as np
10
+ from ...structure.pseudoknots import pseudoknots
11
+
12
+
13
+ def build_constraint_string(sequence_length,
14
+ pairs=None, paired=None, unpaired=None,
15
+ downstream=None, upstream=None):
16
+ """
17
+ Build a ViennaRNA constraint string.
18
+
19
+ Parameters
20
+ ----------
21
+ sequence_length : int
22
+ The length of the string to be built.
23
+ pairs : ndarray, shape=(n,2), dtype=int, optional
24
+ Positions of constrained base pairs.
25
+ paired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
26
+ Positions of bases that are paired with any other base.
27
+ unpaired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
28
+ Positions of bases that are unpaired.
29
+ downstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
30
+ Positions of bases that are paired with any downstream base.
31
+ upstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
32
+ Positions of bases that are paired with any upstream base.
33
+
34
+ Returns
35
+ -------
36
+ constraints : str
37
+ The constraint string
38
+ """
39
+ constraints = np.full(sequence_length, ".", dtype="U1")
40
+
41
+ if pairs is not None:
42
+ pairs = np.asarray(pairs)
43
+ # Ensure that pairs do not contain pseudoknots
44
+ if (pseudoknots(pairs, max_pseudoknot_order=1) == -1).any():
45
+ raise ValueError("Given pairs include pseudoknots")
46
+ # Ensure the lower base comes first for each pair
47
+ pairs = np.sort(pairs, axis=-1)
48
+ _set_constraints(constraints, pairs[:,0], "(")
49
+ _set_constraints(constraints, pairs[:,1], ")")
50
+
51
+ _set_constraints(constraints, paired, "|")
52
+ _set_constraints(constraints, unpaired, "x")
53
+ _set_constraints(constraints, downstream, "<")
54
+ _set_constraints(constraints, upstream, ">")
55
+
56
+ return "".join(constraints)
57
+
58
+
59
+ def _set_constraints(constraints, index, character):
60
+ if index is None:
61
+ return
62
+
63
+ # Search for conflicts with other constraints
64
+ potential_conflict_indices = np.where(constraints[index] != ".")[0]
65
+ if len(potential_conflict_indices) > 0:
66
+ conflict_i = index[potential_conflict_indices[0]]
67
+ raise ValueError(
68
+ f"Constraint '{character}' at position {conflict_i} "
69
+ f"conflicts with existing constraint '{constraints[conflict_i]}'"
70
+ )
71
+
72
+ constraints[index] = character
@@ -0,0 +1,77 @@
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__ = ["WebApp", "RuleViolationError"]
8
+
9
+ import abc
10
+ from .application import Application
11
+
12
+
13
+ class WebApp(Application, metaclass=abc.ABCMeta):
14
+ """
15
+ The base class for all web based applications.
16
+
17
+ It allows for getting and setting the URL of the app and raises
18
+ an :class:`RuleViolationError` when a subclass calls
19
+ :func:`violate_rule()`
20
+ (e.g. when the server was contacted too often.)
21
+
22
+ Be careful, when calling func:`get_app_state()`. This may involve a
23
+ server contact and therefore frequent calls may raise a
24
+ :class:`RuleViolationError`.
25
+
26
+ Parameters
27
+ ----------
28
+ app_url : str
29
+ URL of the web app.
30
+ obey_rules : bool, optional
31
+ If true, the application raises an :class:`RuleViolationError`, if
32
+ the server rules are violated. (Default: True)
33
+ """
34
+
35
+ def __init__(self, app_url, obey_rules=True):
36
+ super().__init__()
37
+ self._obey_rules = obey_rules
38
+ self._app_url = app_url
39
+
40
+ def violate_rule(self, msg=None):
41
+ """
42
+ Indicate that a server rule was violated, i.e. this raises a
43
+ :class:`RuleViolationError` unless `obey_rules` is false.
44
+
45
+ PROTECTED: Do not call from outside.
46
+
47
+ Parameters
48
+ ----------
49
+ msg : str, optional
50
+ A custom message for the :class:`RuleViolationError`.
51
+ """
52
+ if self._obey_rules:
53
+ if msg is None:
54
+ raise RuleViolationError(
55
+ "The user guidelines would be violated"
56
+ )
57
+ else:
58
+ raise RuleViolationError(msg)
59
+
60
+ def app_url(self):
61
+ """
62
+ Get the URL of the web app.
63
+
64
+ Returns
65
+ -------
66
+ url : str
67
+ URL of the web app.
68
+ """
69
+ return self._app_url
70
+
71
+
72
+ class RuleViolationError(Exception):
73
+ """
74
+ Indicates that the user guidelines of the web application would be
75
+ violated, if the program continued.
76
+ """
77
+ pass
biotite/copyable.py ADDED
@@ -0,0 +1,71 @@
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"
6
+ __author__ = "Patrick Kunzmann"
7
+ __all__ = ["Copyable"]
8
+
9
+ import abc
10
+
11
+
12
+ class Copyable(metaclass=abc.ABCMeta):
13
+ """
14
+ Base class for all objects, that should be copyable.
15
+
16
+ The public method `copy()` first creates a fresh instance of the
17
+ class of the instance, that is copied via the `__copy_create__()`
18
+ method. All variables, that could not be set via the constructor,
19
+ are then copied via `__copy_fill__()`, starting with the method in
20
+ the uppermost base class and ending with the class of the instance
21
+ to be copied.
22
+
23
+ This approach solves the problem of encapsulated variables in
24
+ superclasses.
25
+ """
26
+
27
+ def copy(self):
28
+ """
29
+ Create a deep copy of this object.
30
+
31
+ Returns
32
+ -------
33
+ copy
34
+ A copy of this object.
35
+ """
36
+ clone = self.__copy_create__()
37
+ self.__copy_fill__(clone)
38
+ return clone
39
+
40
+ def __copy_create__(self):
41
+ """
42
+ Instantiate a new object of this class.
43
+
44
+ Only the constructor should be called in this method.
45
+ All further attributes, that need to be copied are handled
46
+ in `__copy_fill__()`
47
+
48
+ Do not call the `super()` method here.
49
+
50
+ This method must be overridden, if the constructor takes
51
+ parameters.
52
+
53
+ Returns
54
+ -------
55
+ copy
56
+ A freshly instantiated copy of *self*.
57
+ """
58
+ return type(self)()
59
+
60
+ def __copy_fill__(self, clone):
61
+ """
62
+ Copy all necessary attributes to the new object.
63
+
64
+ Always call the `super()` method as first statement.
65
+
66
+ Parameters
67
+ ----------
68
+ clone
69
+ The freshly instantiated copy of *self*.
70
+ """
71
+ pass
@@ -0,0 +1,23 @@
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 fetching data from online databases.
7
+
8
+ Each subpackage of the database package contains an interface for a
9
+ specific database.
10
+
11
+ All subpackages provide at least two functions:
12
+ :func:`search()` is used to search for IDs (e.g. PDB ID) that match the
13
+ given search parameters.
14
+ The search parameters are usually abstracted by the respective
15
+ :class:`Query` objects.
16
+ Then the obtained IDs can be given to the :func:`fetch()` function to
17
+ download the associated files.
18
+ """
19
+
20
+ __name__ = "biotite.database"
21
+ __author__ = "Patrick Kunzmann"
22
+
23
+ from .error import *