biotite 1.5.0__cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_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.
- biotite/__init__.py +18 -0
- biotite/application/__init__.py +69 -0
- biotite/application/application.py +276 -0
- biotite/application/autodock/__init__.py +12 -0
- biotite/application/autodock/app.py +500 -0
- biotite/application/blast/__init__.py +14 -0
- biotite/application/blast/alignment.py +92 -0
- biotite/application/blast/webapp.py +428 -0
- biotite/application/clustalo/__init__.py +12 -0
- biotite/application/clustalo/app.py +223 -0
- biotite/application/dssp/__init__.py +12 -0
- biotite/application/dssp/app.py +216 -0
- biotite/application/localapp.py +342 -0
- biotite/application/mafft/__init__.py +12 -0
- biotite/application/mafft/app.py +116 -0
- biotite/application/msaapp.py +363 -0
- biotite/application/muscle/__init__.py +13 -0
- biotite/application/muscle/app3.py +227 -0
- biotite/application/muscle/app5.py +163 -0
- biotite/application/sra/__init__.py +18 -0
- biotite/application/sra/app.py +447 -0
- biotite/application/tantan/__init__.py +12 -0
- biotite/application/tantan/app.py +199 -0
- biotite/application/util.py +77 -0
- biotite/application/viennarna/__init__.py +18 -0
- biotite/application/viennarna/rnaalifold.py +310 -0
- biotite/application/viennarna/rnafold.py +254 -0
- biotite/application/viennarna/rnaplot.py +208 -0
- biotite/application/viennarna/util.py +77 -0
- biotite/application/webapp.py +76 -0
- biotite/copyable.py +71 -0
- biotite/database/__init__.py +23 -0
- biotite/database/afdb/__init__.py +12 -0
- biotite/database/afdb/download.py +197 -0
- biotite/database/entrez/__init__.py +15 -0
- biotite/database/entrez/check.py +60 -0
- biotite/database/entrez/dbnames.py +101 -0
- biotite/database/entrez/download.py +228 -0
- biotite/database/entrez/key.py +44 -0
- biotite/database/entrez/query.py +263 -0
- biotite/database/error.py +16 -0
- biotite/database/pubchem/__init__.py +21 -0
- biotite/database/pubchem/download.py +258 -0
- biotite/database/pubchem/error.py +30 -0
- biotite/database/pubchem/query.py +819 -0
- biotite/database/pubchem/throttle.py +98 -0
- biotite/database/rcsb/__init__.py +13 -0
- biotite/database/rcsb/download.py +161 -0
- biotite/database/rcsb/query.py +963 -0
- biotite/database/uniprot/__init__.py +13 -0
- biotite/database/uniprot/check.py +40 -0
- biotite/database/uniprot/download.py +126 -0
- biotite/database/uniprot/query.py +292 -0
- biotite/file.py +244 -0
- biotite/interface/__init__.py +19 -0
- biotite/interface/openmm/__init__.py +20 -0
- biotite/interface/openmm/state.py +93 -0
- biotite/interface/openmm/system.py +227 -0
- biotite/interface/pymol/__init__.py +201 -0
- biotite/interface/pymol/cgo.py +346 -0
- biotite/interface/pymol/convert.py +185 -0
- biotite/interface/pymol/display.py +267 -0
- biotite/interface/pymol/object.py +1228 -0
- biotite/interface/pymol/shapes.py +178 -0
- biotite/interface/pymol/startup.py +169 -0
- biotite/interface/rdkit/__init__.py +19 -0
- biotite/interface/rdkit/mol.py +490 -0
- biotite/interface/version.py +94 -0
- biotite/interface/warning.py +19 -0
- biotite/sequence/__init__.py +84 -0
- biotite/sequence/align/__init__.py +199 -0
- biotite/sequence/align/alignment.py +702 -0
- biotite/sequence/align/banded.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/banded.pyx +652 -0
- biotite/sequence/align/buckets.py +71 -0
- biotite/sequence/align/cigar.py +425 -0
- biotite/sequence/align/kmeralphabet.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmeralphabet.pyx +595 -0
- biotite/sequence/align/kmersimilarity.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmersimilarity.pyx +233 -0
- biotite/sequence/align/kmertable.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmertable.pyx +3411 -0
- biotite/sequence/align/localgapped.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/localgapped.pyx +892 -0
- biotite/sequence/align/localungapped.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/localungapped.pyx +279 -0
- biotite/sequence/align/matrix.py +631 -0
- biotite/sequence/align/matrix_data/3Di.mat +24 -0
- biotite/sequence/align/matrix_data/BLOSUM100.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM30.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM35.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM40.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM45.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM50.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM50_13p.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM50_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM50_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM55.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM60.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM62.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM62_13p.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM62_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM62_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/BLOSUM65.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM70.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM75.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM80.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM85.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUM90.mat +31 -0
- biotite/sequence/align/matrix_data/BLOSUMN.mat +31 -0
- biotite/sequence/align/matrix_data/CorBLOSUM49_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM57_13p.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM57_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM61_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM66_13p.mat +25 -0
- biotite/sequence/align/matrix_data/CorBLOSUM67_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/DAYHOFF.mat +32 -0
- biotite/sequence/align/matrix_data/GONNET.mat +26 -0
- biotite/sequence/align/matrix_data/IDENTITY.mat +25 -0
- biotite/sequence/align/matrix_data/MATCH.mat +25 -0
- biotite/sequence/align/matrix_data/NUC.mat +25 -0
- biotite/sequence/align/matrix_data/PAM10.mat +34 -0
- biotite/sequence/align/matrix_data/PAM100.mat +34 -0
- biotite/sequence/align/matrix_data/PAM110.mat +34 -0
- biotite/sequence/align/matrix_data/PAM120.mat +34 -0
- biotite/sequence/align/matrix_data/PAM130.mat +34 -0
- biotite/sequence/align/matrix_data/PAM140.mat +34 -0
- biotite/sequence/align/matrix_data/PAM150.mat +34 -0
- biotite/sequence/align/matrix_data/PAM160.mat +34 -0
- biotite/sequence/align/matrix_data/PAM170.mat +34 -0
- biotite/sequence/align/matrix_data/PAM180.mat +34 -0
- biotite/sequence/align/matrix_data/PAM190.mat +34 -0
- biotite/sequence/align/matrix_data/PAM20.mat +34 -0
- biotite/sequence/align/matrix_data/PAM200.mat +34 -0
- biotite/sequence/align/matrix_data/PAM210.mat +34 -0
- biotite/sequence/align/matrix_data/PAM220.mat +34 -0
- biotite/sequence/align/matrix_data/PAM230.mat +34 -0
- biotite/sequence/align/matrix_data/PAM240.mat +34 -0
- biotite/sequence/align/matrix_data/PAM250.mat +34 -0
- biotite/sequence/align/matrix_data/PAM260.mat +34 -0
- biotite/sequence/align/matrix_data/PAM270.mat +34 -0
- biotite/sequence/align/matrix_data/PAM280.mat +34 -0
- biotite/sequence/align/matrix_data/PAM290.mat +34 -0
- biotite/sequence/align/matrix_data/PAM30.mat +34 -0
- biotite/sequence/align/matrix_data/PAM300.mat +34 -0
- biotite/sequence/align/matrix_data/PAM310.mat +34 -0
- biotite/sequence/align/matrix_data/PAM320.mat +34 -0
- biotite/sequence/align/matrix_data/PAM330.mat +34 -0
- biotite/sequence/align/matrix_data/PAM340.mat +34 -0
- biotite/sequence/align/matrix_data/PAM350.mat +34 -0
- biotite/sequence/align/matrix_data/PAM360.mat +34 -0
- biotite/sequence/align/matrix_data/PAM370.mat +34 -0
- biotite/sequence/align/matrix_data/PAM380.mat +34 -0
- biotite/sequence/align/matrix_data/PAM390.mat +34 -0
- biotite/sequence/align/matrix_data/PAM40.mat +34 -0
- biotite/sequence/align/matrix_data/PAM400.mat +34 -0
- biotite/sequence/align/matrix_data/PAM410.mat +34 -0
- biotite/sequence/align/matrix_data/PAM420.mat +34 -0
- biotite/sequence/align/matrix_data/PAM430.mat +34 -0
- biotite/sequence/align/matrix_data/PAM440.mat +34 -0
- biotite/sequence/align/matrix_data/PAM450.mat +34 -0
- biotite/sequence/align/matrix_data/PAM460.mat +34 -0
- biotite/sequence/align/matrix_data/PAM470.mat +34 -0
- biotite/sequence/align/matrix_data/PAM480.mat +34 -0
- biotite/sequence/align/matrix_data/PAM490.mat +34 -0
- biotite/sequence/align/matrix_data/PAM50.mat +34 -0
- biotite/sequence/align/matrix_data/PAM500.mat +34 -0
- biotite/sequence/align/matrix_data/PAM60.mat +34 -0
- biotite/sequence/align/matrix_data/PAM70.mat +34 -0
- biotite/sequence/align/matrix_data/PAM80.mat +34 -0
- biotite/sequence/align/matrix_data/PAM90.mat +34 -0
- biotite/sequence/align/matrix_data/PB.license +21 -0
- biotite/sequence/align/matrix_data/PB.mat +18 -0
- biotite/sequence/align/matrix_data/RBLOSUM52_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM59_13p.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM59_14.3.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM64_5.0.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM69_13p.mat +25 -0
- biotite/sequence/align/matrix_data/RBLOSUM69_14.3.mat +25 -0
- biotite/sequence/align/multiple.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/multiple.pyx +619 -0
- biotite/sequence/align/pairwise.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/pairwise.pyx +585 -0
- biotite/sequence/align/permutation.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/permutation.pyx +313 -0
- biotite/sequence/align/primes.txt +821 -0
- biotite/sequence/align/selector.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/selector.pyx +954 -0
- biotite/sequence/align/statistics.py +264 -0
- biotite/sequence/align/tracetable.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/tracetable.pxd +64 -0
- biotite/sequence/align/tracetable.pyx +370 -0
- biotite/sequence/alphabet.py +555 -0
- biotite/sequence/annotation.py +836 -0
- biotite/sequence/codec.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/codec.pyx +155 -0
- biotite/sequence/codon.py +476 -0
- biotite/sequence/codon_tables.txt +202 -0
- biotite/sequence/graphics/__init__.py +33 -0
- biotite/sequence/graphics/alignment.py +1101 -0
- biotite/sequence/graphics/color_schemes/3di_flower.json +48 -0
- biotite/sequence/graphics/color_schemes/autumn.json +51 -0
- biotite/sequence/graphics/color_schemes/blossom.json +51 -0
- biotite/sequence/graphics/color_schemes/clustalx_dna.json +11 -0
- biotite/sequence/graphics/color_schemes/clustalx_protein.json +28 -0
- biotite/sequence/graphics/color_schemes/flower.json +51 -0
- biotite/sequence/graphics/color_schemes/jalview_buried.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_hydrophobicity.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_prop_helix.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_prop_strand.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_prop_turn.json +31 -0
- biotite/sequence/graphics/color_schemes/jalview_taylor.json +28 -0
- biotite/sequence/graphics/color_schemes/jalview_zappo.json +28 -0
- biotite/sequence/graphics/color_schemes/ocean.json +51 -0
- biotite/sequence/graphics/color_schemes/pb_flower.json +40 -0
- biotite/sequence/graphics/color_schemes/rainbow_dna.json +11 -0
- biotite/sequence/graphics/color_schemes/rainbow_protein.json +30 -0
- biotite/sequence/graphics/color_schemes/spring.json +51 -0
- biotite/sequence/graphics/color_schemes/sunset.json +51 -0
- biotite/sequence/graphics/color_schemes/wither.json +51 -0
- biotite/sequence/graphics/colorschemes.py +170 -0
- biotite/sequence/graphics/dendrogram.py +231 -0
- biotite/sequence/graphics/features.py +544 -0
- biotite/sequence/graphics/logo.py +102 -0
- biotite/sequence/graphics/plasmid.py +712 -0
- biotite/sequence/io/__init__.py +12 -0
- biotite/sequence/io/fasta/__init__.py +22 -0
- biotite/sequence/io/fasta/convert.py +283 -0
- biotite/sequence/io/fasta/file.py +265 -0
- biotite/sequence/io/fastq/__init__.py +19 -0
- biotite/sequence/io/fastq/convert.py +117 -0
- biotite/sequence/io/fastq/file.py +507 -0
- biotite/sequence/io/genbank/__init__.py +17 -0
- biotite/sequence/io/genbank/annotation.py +269 -0
- biotite/sequence/io/genbank/file.py +573 -0
- biotite/sequence/io/genbank/metadata.py +336 -0
- biotite/sequence/io/genbank/sequence.py +173 -0
- biotite/sequence/io/general.py +201 -0
- biotite/sequence/io/gff/__init__.py +26 -0
- biotite/sequence/io/gff/convert.py +128 -0
- biotite/sequence/io/gff/file.py +449 -0
- biotite/sequence/phylo/__init__.py +36 -0
- biotite/sequence/phylo/nj.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/nj.pyx +221 -0
- biotite/sequence/phylo/tree.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/tree.pyx +1169 -0
- biotite/sequence/phylo/upgma.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/upgma.pyx +164 -0
- biotite/sequence/profile.py +561 -0
- biotite/sequence/search.py +117 -0
- biotite/sequence/seqtypes.py +720 -0
- biotite/sequence/sequence.py +373 -0
- biotite/setup_ccd.py +197 -0
- biotite/structure/__init__.py +135 -0
- biotite/structure/alphabet/__init__.py +25 -0
- biotite/structure/alphabet/encoder.py +332 -0
- biotite/structure/alphabet/encoder_weights_3di.kerasify +0 -0
- biotite/structure/alphabet/i3d.py +109 -0
- biotite/structure/alphabet/layers.py +86 -0
- biotite/structure/alphabet/pb.license +21 -0
- biotite/structure/alphabet/pb.py +170 -0
- biotite/structure/alphabet/unkerasify.py +128 -0
- biotite/structure/atoms.py +1562 -0
- biotite/structure/basepairs.py +1403 -0
- biotite/structure/bonds.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/bonds.pyx +2036 -0
- biotite/structure/box.py +724 -0
- biotite/structure/celllist.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/celllist.pyx +864 -0
- biotite/structure/chains.py +310 -0
- biotite/structure/charges.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/charges.pyx +520 -0
- biotite/structure/compare.py +683 -0
- biotite/structure/density.py +109 -0
- biotite/structure/dotbracket.py +213 -0
- biotite/structure/error.py +39 -0
- biotite/structure/filter.py +591 -0
- biotite/structure/geometry.py +817 -0
- biotite/structure/graphics/__init__.py +13 -0
- biotite/structure/graphics/atoms.py +243 -0
- biotite/structure/graphics/rna.py +298 -0
- biotite/structure/hbond.py +425 -0
- biotite/structure/info/__init__.py +24 -0
- biotite/structure/info/atom_masses.json +121 -0
- biotite/structure/info/atoms.py +98 -0
- biotite/structure/info/bonds.py +149 -0
- biotite/structure/info/ccd.py +200 -0
- biotite/structure/info/components.bcif +0 -0
- biotite/structure/info/groups.py +128 -0
- biotite/structure/info/masses.py +121 -0
- biotite/structure/info/misc.py +137 -0
- biotite/structure/info/radii.py +267 -0
- biotite/structure/info/standardize.py +185 -0
- biotite/structure/integrity.py +213 -0
- biotite/structure/io/__init__.py +29 -0
- biotite/structure/io/dcd/__init__.py +13 -0
- biotite/structure/io/dcd/file.py +67 -0
- biotite/structure/io/general.py +243 -0
- biotite/structure/io/gro/__init__.py +14 -0
- biotite/structure/io/gro/file.py +343 -0
- biotite/structure/io/mol/__init__.py +20 -0
- biotite/structure/io/mol/convert.py +112 -0
- biotite/structure/io/mol/ctab.py +420 -0
- biotite/structure/io/mol/header.py +120 -0
- biotite/structure/io/mol/mol.py +149 -0
- biotite/structure/io/mol/sdf.py +940 -0
- biotite/structure/io/netcdf/__init__.py +13 -0
- biotite/structure/io/netcdf/file.py +64 -0
- biotite/structure/io/pdb/__init__.py +20 -0
- biotite/structure/io/pdb/convert.py +389 -0
- biotite/structure/io/pdb/file.py +1380 -0
- biotite/structure/io/pdb/hybrid36.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/io/pdb/hybrid36.pyx +242 -0
- biotite/structure/io/pdbqt/__init__.py +15 -0
- biotite/structure/io/pdbqt/convert.py +113 -0
- biotite/structure/io/pdbqt/file.py +688 -0
- biotite/structure/io/pdbx/__init__.py +23 -0
- biotite/structure/io/pdbx/bcif.py +674 -0
- biotite/structure/io/pdbx/cif.py +1091 -0
- biotite/structure/io/pdbx/component.py +251 -0
- biotite/structure/io/pdbx/compress.py +362 -0
- biotite/structure/io/pdbx/convert.py +2113 -0
- biotite/structure/io/pdbx/encoding.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/io/pdbx/encoding.pyx +1078 -0
- biotite/structure/io/trajfile.py +696 -0
- biotite/structure/io/trr/__init__.py +13 -0
- biotite/structure/io/trr/file.py +43 -0
- biotite/structure/io/util.py +38 -0
- biotite/structure/io/xtc/__init__.py +13 -0
- biotite/structure/io/xtc/file.py +43 -0
- biotite/structure/mechanics.py +72 -0
- biotite/structure/molecules.py +337 -0
- biotite/structure/pseudoknots.py +622 -0
- biotite/structure/rdf.py +245 -0
- biotite/structure/repair.py +302 -0
- biotite/structure/residues.py +716 -0
- biotite/structure/rings.py +451 -0
- biotite/structure/sasa.cpython-312-x86_64-linux-gnu.so +0 -0
- biotite/structure/sasa.pyx +322 -0
- biotite/structure/segments.py +328 -0
- biotite/structure/sequence.py +110 -0
- biotite/structure/spacegroups.json +1567 -0
- biotite/structure/spacegroups.license +26 -0
- biotite/structure/sse.py +306 -0
- biotite/structure/superimpose.py +511 -0
- biotite/structure/tm.py +581 -0
- biotite/structure/transform.py +736 -0
- biotite/structure/util.py +160 -0
- biotite/version.py +34 -0
- biotite/visualize.py +375 -0
- biotite-1.5.0.dist-info/METADATA +162 -0
- biotite-1.5.0.dist-info/RECORD +354 -0
- biotite-1.5.0.dist-info/WHEEL +6 -0
- biotite-1.5.0.dist-info/licenses/LICENSE.rst +30 -0
|
@@ -0,0 +1,254 @@
|
|
|
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
|
+
from tempfile import NamedTemporaryFile
|
|
10
|
+
import numpy as np
|
|
11
|
+
from biotite.application.application import AppState, requires_state
|
|
12
|
+
from biotite.application.localapp import LocalApp, cleanup_tempfile
|
|
13
|
+
from biotite.application.viennarna.util import build_constraint_string
|
|
14
|
+
from biotite.sequence.io.fasta import FastaFile, set_sequence
|
|
15
|
+
from biotite.structure.dotbracket import base_pairs_from_dot_bracket
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class RNAfoldApp(LocalApp):
|
|
19
|
+
"""
|
|
20
|
+
Compute the minimum free energy secondary structure of a ribonucleic
|
|
21
|
+
acid sequence using *ViennaRNA's* *RNAfold* software.
|
|
22
|
+
|
|
23
|
+
Internally this creates a :class:`Popen` instance, which handles
|
|
24
|
+
the execution.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
sequence : NucleotideSequence
|
|
29
|
+
The RNA sequence.
|
|
30
|
+
temperature : int, optional
|
|
31
|
+
The temperature (°C) to be assumed for the energy parameters.
|
|
32
|
+
bin_path : str, optional
|
|
33
|
+
Path of the *RNAfold* binary.
|
|
34
|
+
|
|
35
|
+
Examples
|
|
36
|
+
--------
|
|
37
|
+
|
|
38
|
+
>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
|
|
39
|
+
>>> app = RNAfoldApp(sequence)
|
|
40
|
+
>>> app.start()
|
|
41
|
+
>>> app.join()
|
|
42
|
+
>>> print(app.get_free_energy())
|
|
43
|
+
-1.3
|
|
44
|
+
>>> print(app.get_dot_bracket())
|
|
45
|
+
(((.((((.......)).)))))....
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(self, sequence, temperature=37, bin_path="RNAfold"):
|
|
49
|
+
self._sequence = sequence.copy()
|
|
50
|
+
self._temperature = str(temperature)
|
|
51
|
+
self._constraints = None
|
|
52
|
+
self._enforce = None
|
|
53
|
+
self._in_file = NamedTemporaryFile("w", suffix=".fa", delete=False)
|
|
54
|
+
super().__init__(bin_path)
|
|
55
|
+
|
|
56
|
+
def run(self):
|
|
57
|
+
# Insert no line breaks
|
|
58
|
+
# -> Extremely high value for characters per line
|
|
59
|
+
fasta_file = FastaFile(chars_per_line=np.iinfo(np.int32).max)
|
|
60
|
+
set_sequence(fasta_file, self._sequence)
|
|
61
|
+
if self._constraints is not None:
|
|
62
|
+
fasta_file.lines.append(self._constraints)
|
|
63
|
+
fasta_file.write(self._in_file)
|
|
64
|
+
self._in_file.flush()
|
|
65
|
+
|
|
66
|
+
options = [
|
|
67
|
+
"--noPS",
|
|
68
|
+
"-T",
|
|
69
|
+
self._temperature,
|
|
70
|
+
]
|
|
71
|
+
if self._enforce is True:
|
|
72
|
+
options.append("--enforceConstraint")
|
|
73
|
+
if self._constraints is not None:
|
|
74
|
+
options.append("-C")
|
|
75
|
+
|
|
76
|
+
self.set_arguments(options + [self._in_file.name])
|
|
77
|
+
super().run()
|
|
78
|
+
|
|
79
|
+
def evaluate(self):
|
|
80
|
+
super().evaluate()
|
|
81
|
+
lines = self.get_stdout().splitlines()
|
|
82
|
+
content = lines[2]
|
|
83
|
+
dotbracket, free_energy = content.split(" ", maxsplit=1)
|
|
84
|
+
free_energy = float(free_energy[1:-1])
|
|
85
|
+
|
|
86
|
+
self._free_energy = free_energy
|
|
87
|
+
self._dotbracket = dotbracket
|
|
88
|
+
|
|
89
|
+
def clean_up(self):
|
|
90
|
+
super().clean_up()
|
|
91
|
+
cleanup_tempfile(self._in_file)
|
|
92
|
+
|
|
93
|
+
@requires_state(AppState.CREATED)
|
|
94
|
+
def set_temperature(self, temperature):
|
|
95
|
+
"""
|
|
96
|
+
Adjust the energy parameters according to a temperature in
|
|
97
|
+
degrees Celsius.
|
|
98
|
+
|
|
99
|
+
Parameters
|
|
100
|
+
----------
|
|
101
|
+
temperature : int
|
|
102
|
+
The temperature.
|
|
103
|
+
"""
|
|
104
|
+
self._temperature = str(temperature)
|
|
105
|
+
|
|
106
|
+
@requires_state(AppState.CREATED)
|
|
107
|
+
def set_constraints(
|
|
108
|
+
self,
|
|
109
|
+
pairs=None,
|
|
110
|
+
paired=None,
|
|
111
|
+
unpaired=None,
|
|
112
|
+
downstream=None,
|
|
113
|
+
upstream=None,
|
|
114
|
+
enforce=False,
|
|
115
|
+
):
|
|
116
|
+
"""
|
|
117
|
+
Add constraints of known paired or unpaired bases to the folding
|
|
118
|
+
algorithm.
|
|
119
|
+
|
|
120
|
+
Constraints forbid pairs conflicting with the respective
|
|
121
|
+
constraint.
|
|
122
|
+
|
|
123
|
+
Parameters
|
|
124
|
+
----------
|
|
125
|
+
pairs : ndarray, shape=(n,2), dtype=int, optional
|
|
126
|
+
Positions of constrained base pairs.
|
|
127
|
+
paired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
128
|
+
Positions of bases that are paired with any other base.
|
|
129
|
+
unpaired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
130
|
+
Positions of bases that are unpaired.
|
|
131
|
+
downstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
132
|
+
Positions of bases that are paired with any downstream base.
|
|
133
|
+
upstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
134
|
+
Positions of bases that are paired with any upstream base.
|
|
135
|
+
enforce : bool, optional
|
|
136
|
+
If set to true, the given constraints are enforced, i.e. a
|
|
137
|
+
the respective base pairs must form.
|
|
138
|
+
By default (false), a constraint does only forbid formation
|
|
139
|
+
of a pair that would conflict with this constraint.
|
|
140
|
+
"""
|
|
141
|
+
self._constraints = build_constraint_string(
|
|
142
|
+
len(self._sequence), pairs, paired, unpaired, downstream, upstream
|
|
143
|
+
)
|
|
144
|
+
self._enforce = enforce
|
|
145
|
+
|
|
146
|
+
@requires_state(AppState.JOINED)
|
|
147
|
+
def get_free_energy(self):
|
|
148
|
+
"""
|
|
149
|
+
Get the free energy (kcal/mol) of the suggested
|
|
150
|
+
secondary structure.
|
|
151
|
+
|
|
152
|
+
Returns
|
|
153
|
+
-------
|
|
154
|
+
free_energy : float
|
|
155
|
+
The free energy.
|
|
156
|
+
|
|
157
|
+
Examples
|
|
158
|
+
--------
|
|
159
|
+
|
|
160
|
+
>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
|
|
161
|
+
>>> app = RNAfoldApp(sequence)
|
|
162
|
+
>>> app.start()
|
|
163
|
+
>>> app.join()
|
|
164
|
+
>>> print(app.get_free_energy())
|
|
165
|
+
-1.3
|
|
166
|
+
"""
|
|
167
|
+
return self._free_energy
|
|
168
|
+
|
|
169
|
+
@requires_state(AppState.JOINED)
|
|
170
|
+
def get_dot_bracket(self):
|
|
171
|
+
"""
|
|
172
|
+
Get the minimum free energy secondary structure of the input
|
|
173
|
+
sequence in dot bracket notation.
|
|
174
|
+
|
|
175
|
+
Returns
|
|
176
|
+
-------
|
|
177
|
+
dotbracket : str
|
|
178
|
+
The secondary structure in dot bracket notation.
|
|
179
|
+
|
|
180
|
+
Examples
|
|
181
|
+
--------
|
|
182
|
+
|
|
183
|
+
>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
|
|
184
|
+
>>> app = RNAfoldApp(sequence)
|
|
185
|
+
>>> app.start()
|
|
186
|
+
>>> app.join()
|
|
187
|
+
>>> print(app.get_dot_bracket())
|
|
188
|
+
(((.((((.......)).)))))....
|
|
189
|
+
"""
|
|
190
|
+
return self._dotbracket
|
|
191
|
+
|
|
192
|
+
@requires_state(AppState.JOINED)
|
|
193
|
+
def get_base_pairs(self):
|
|
194
|
+
"""
|
|
195
|
+
Get the base pairs from the minimum free energy secondary
|
|
196
|
+
structure of the input sequence.
|
|
197
|
+
|
|
198
|
+
Returns
|
|
199
|
+
-------
|
|
200
|
+
base_pairs : ndarray, shape=(n,2)
|
|
201
|
+
Each row corresponds to the positions of the bases in the
|
|
202
|
+
sequence.
|
|
203
|
+
|
|
204
|
+
Examples
|
|
205
|
+
--------
|
|
206
|
+
|
|
207
|
+
>>> sequence = NucleotideSequence("CGACGTAGATGCTAGCTGACTCGATGC")
|
|
208
|
+
>>> app = RNAfoldApp(sequence)
|
|
209
|
+
>>> app.start()
|
|
210
|
+
>>> app.join()
|
|
211
|
+
>>> print(app.get_base_pairs())
|
|
212
|
+
[[ 0 22]
|
|
213
|
+
[ 1 21]
|
|
214
|
+
[ 2 20]
|
|
215
|
+
[ 4 19]
|
|
216
|
+
[ 5 18]
|
|
217
|
+
[ 6 16]
|
|
218
|
+
[ 7 15]]
|
|
219
|
+
|
|
220
|
+
For reference, the corresponding dot bracket notation can be
|
|
221
|
+
displayed as below.
|
|
222
|
+
|
|
223
|
+
>>> print(app.get_dot_bracket())
|
|
224
|
+
(((.((((.......)).)))))....
|
|
225
|
+
"""
|
|
226
|
+
return base_pairs_from_dot_bracket(self._dotbracket)
|
|
227
|
+
|
|
228
|
+
@staticmethod
|
|
229
|
+
def compute_secondary_structure(sequence, bin_path="RNAfold"):
|
|
230
|
+
"""
|
|
231
|
+
Compute the minimum free energy secondary structure of a
|
|
232
|
+
ribonucleic acid sequence using *ViennaRNA's* *RNAfold* software.
|
|
233
|
+
|
|
234
|
+
This is a convenience function, that wraps the
|
|
235
|
+
:class:`RNAfoldApp` execution.
|
|
236
|
+
|
|
237
|
+
Parameters
|
|
238
|
+
----------
|
|
239
|
+
sequence : NucleotideSequence
|
|
240
|
+
The RNA sequence.
|
|
241
|
+
bin_path : str, optional
|
|
242
|
+
Path of the *RNAfold* binary.
|
|
243
|
+
|
|
244
|
+
Returns
|
|
245
|
+
-------
|
|
246
|
+
dotbracket : str
|
|
247
|
+
The secondary structure in dot bracket notation.
|
|
248
|
+
free_energy : float
|
|
249
|
+
The free energy.
|
|
250
|
+
"""
|
|
251
|
+
app = RNAfoldApp(sequence, bin_path=bin_path)
|
|
252
|
+
app.start()
|
|
253
|
+
app.join()
|
|
254
|
+
return app.get_dot_bracket(), app.get_free_energy()
|
|
@@ -0,0 +1,208 @@
|
|
|
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
|
+
from enum import IntEnum
|
|
10
|
+
from os import remove
|
|
11
|
+
from tempfile import NamedTemporaryFile
|
|
12
|
+
import numpy as np
|
|
13
|
+
from biotite.application.application import AppState, requires_state
|
|
14
|
+
from biotite.application.localapp import LocalApp, cleanup_tempfile
|
|
15
|
+
from biotite.structure.dotbracket import dot_bracket as dot_bracket_
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class RNAplotApp(LocalApp):
|
|
19
|
+
"""
|
|
20
|
+
Get coordinates for a 2D representation of any unknotted RNA
|
|
21
|
+
structure using *ViennaRNA's* *RNAplot*.
|
|
22
|
+
|
|
23
|
+
The structure has to be provided either in dot bracket notation or
|
|
24
|
+
as a ``ndarray`` of base pairs and the total sequence length.
|
|
25
|
+
|
|
26
|
+
Internally this creates a :class:`Popen` instance, which handles
|
|
27
|
+
the execution.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
dot_bracket : str, optional
|
|
32
|
+
The structure in dot bracket notation.
|
|
33
|
+
base_pairs : ndarray, shape=(n,2), optional
|
|
34
|
+
Each row corresponds to the positions of the bases in the
|
|
35
|
+
strand. This parameter is mutually exclusive to ``dot_bracket``.
|
|
36
|
+
length : int, optional
|
|
37
|
+
The number of bases in the strand. This parameter is required if
|
|
38
|
+
``base_pairs`` is given.
|
|
39
|
+
layout_type : RNAplotApp.Layout, optional
|
|
40
|
+
The layout type according to the *RNAplot* documentation.
|
|
41
|
+
bin_path : str, optional
|
|
42
|
+
Path of the *RNAplot* binary.
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
--------
|
|
46
|
+
|
|
47
|
+
>>> app = RNAplotApp('((..))')
|
|
48
|
+
>>> app.start()
|
|
49
|
+
>>> app.join()
|
|
50
|
+
>>> print(app.get_coordinates())
|
|
51
|
+
[[ -92.50 92.50]
|
|
52
|
+
[ -92.50 77.50]
|
|
53
|
+
[ -90.31 58.24]
|
|
54
|
+
[-109.69 58.24]
|
|
55
|
+
[-107.50 77.50]
|
|
56
|
+
[-107.50 92.50]]
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
class Layout(IntEnum):
|
|
60
|
+
"""
|
|
61
|
+
This enum type represents the layout type of the plot according
|
|
62
|
+
to the official *RNAplot* orientation.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
RADIAL = (0,)
|
|
66
|
+
NAVIEW = (1,)
|
|
67
|
+
CIRCULAR = (2,)
|
|
68
|
+
RNATURTLE = (3,)
|
|
69
|
+
RNAPUZZLER = 4
|
|
70
|
+
|
|
71
|
+
def __init__(
|
|
72
|
+
self,
|
|
73
|
+
dot_bracket=None,
|
|
74
|
+
base_pairs=None,
|
|
75
|
+
length=None,
|
|
76
|
+
layout_type=Layout.NAVIEW,
|
|
77
|
+
bin_path="RNAplot",
|
|
78
|
+
):
|
|
79
|
+
super().__init__(bin_path)
|
|
80
|
+
|
|
81
|
+
if dot_bracket is not None:
|
|
82
|
+
self._dot_bracket = dot_bracket
|
|
83
|
+
elif (base_pairs is not None) and (length is not None):
|
|
84
|
+
self._dot_bracket = dot_bracket_(
|
|
85
|
+
base_pairs, length, max_pseudoknot_order=0
|
|
86
|
+
)[0]
|
|
87
|
+
else:
|
|
88
|
+
raise ValueError(
|
|
89
|
+
"Structure has to be provided in either dot bracket notation "
|
|
90
|
+
"or as base pairs and total sequence length"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
# Get the value of the enum type
|
|
94
|
+
self._layout_type = str(int(layout_type))
|
|
95
|
+
self._in_file = NamedTemporaryFile("w", suffix=".fold", delete=False)
|
|
96
|
+
|
|
97
|
+
def run(self):
|
|
98
|
+
self._in_file.write("N" * len(self._dot_bracket) + "\n")
|
|
99
|
+
self._in_file.write(self._dot_bracket)
|
|
100
|
+
self._in_file.flush()
|
|
101
|
+
self.set_arguments(
|
|
102
|
+
[
|
|
103
|
+
"-i", self._in_file.name,
|
|
104
|
+
"--output-format", "xrna",
|
|
105
|
+
"-t", self._layout_type,
|
|
106
|
+
]
|
|
107
|
+
) # fmt: skip
|
|
108
|
+
super().run()
|
|
109
|
+
|
|
110
|
+
def evaluate(self):
|
|
111
|
+
super().evaluate()
|
|
112
|
+
self._coordinates = np.loadtxt("rna.ss", usecols=(2, 3))
|
|
113
|
+
|
|
114
|
+
def clean_up(self):
|
|
115
|
+
super().clean_up()
|
|
116
|
+
cleanup_tempfile(self._in_file)
|
|
117
|
+
remove("rna.ss")
|
|
118
|
+
|
|
119
|
+
@requires_state(AppState.CREATED)
|
|
120
|
+
def set_layout_type(self, layout_type):
|
|
121
|
+
"""
|
|
122
|
+
Adjust the layout type for the plot according to the *RNAplot*
|
|
123
|
+
documentation.
|
|
124
|
+
|
|
125
|
+
Parameters
|
|
126
|
+
----------
|
|
127
|
+
layout_type : RNAplotApp.Layout
|
|
128
|
+
The layout type.
|
|
129
|
+
"""
|
|
130
|
+
self._layout_type = str(layout_type)
|
|
131
|
+
|
|
132
|
+
@requires_state(AppState.JOINED)
|
|
133
|
+
def get_coordinates(self):
|
|
134
|
+
"""
|
|
135
|
+
Get coordinates for a 2D representation of the input structure.
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
coordinates : ndarray, shape=(n,2)
|
|
140
|
+
The 2D coordinates. Each row represents the *x* and *y*
|
|
141
|
+
coordinates for a total sequence length of *n*.
|
|
142
|
+
|
|
143
|
+
Examples
|
|
144
|
+
--------
|
|
145
|
+
|
|
146
|
+
>>> app = RNAplotApp('((..))')
|
|
147
|
+
>>> app.start()
|
|
148
|
+
>>> app.join()
|
|
149
|
+
>>> print(app.get_coordinates())
|
|
150
|
+
[[ -92.50 92.50]
|
|
151
|
+
[ -92.50 77.50]
|
|
152
|
+
[ -90.31 58.24]
|
|
153
|
+
[-109.69 58.24]
|
|
154
|
+
[-107.50 77.50]
|
|
155
|
+
[-107.50 92.50]]
|
|
156
|
+
"""
|
|
157
|
+
return self._coordinates
|
|
158
|
+
|
|
159
|
+
@staticmethod
|
|
160
|
+
def compute_coordinates(
|
|
161
|
+
dot_bracket=None,
|
|
162
|
+
base_pairs=None,
|
|
163
|
+
length=None,
|
|
164
|
+
layout_type=Layout.NAVIEW,
|
|
165
|
+
bin_path="RNAplot",
|
|
166
|
+
):
|
|
167
|
+
"""
|
|
168
|
+
Get coordinates for a 2D representation of any unknotted RNA
|
|
169
|
+
structure using *ViennaRNA's* *RNAplot*.
|
|
170
|
+
|
|
171
|
+
The structure has to be provided either in dot bracket notation
|
|
172
|
+
or as a ``ndarray`` of base pairs and the total sequence length.
|
|
173
|
+
|
|
174
|
+
This is a convenience function, that wraps the
|
|
175
|
+
:class:`RNAplotApp` execution.
|
|
176
|
+
|
|
177
|
+
Parameters
|
|
178
|
+
----------
|
|
179
|
+
dot_bracket : str, optional
|
|
180
|
+
The structure in dot bracket notation.
|
|
181
|
+
base_pairs : ndarray, shape=(n,2), optional
|
|
182
|
+
Each row corresponds to the positions of the bases in the
|
|
183
|
+
strand. This parameter is mutually exclusive to
|
|
184
|
+
``dot_bracket``.
|
|
185
|
+
length : int, optional
|
|
186
|
+
The number of bases in the strand. This parameter is
|
|
187
|
+
required if ``base_pairs`` is given.
|
|
188
|
+
layout_type : Layout
|
|
189
|
+
The desired layout of the plot.
|
|
190
|
+
bin_path : str, optional
|
|
191
|
+
Path of the *RNAplot* binary.
|
|
192
|
+
|
|
193
|
+
Returns
|
|
194
|
+
-------
|
|
195
|
+
coordinates : ndarray, shape=(n,2)
|
|
196
|
+
The 2D coordinates. Each row represents the *x* and *y*
|
|
197
|
+
coordinates for a total sequence length of *n*.
|
|
198
|
+
"""
|
|
199
|
+
app = RNAplotApp(
|
|
200
|
+
dot_bracket=dot_bracket,
|
|
201
|
+
base_pairs=base_pairs,
|
|
202
|
+
length=length,
|
|
203
|
+
layout_type=layout_type,
|
|
204
|
+
bin_path=bin_path,
|
|
205
|
+
)
|
|
206
|
+
app.start()
|
|
207
|
+
app.join()
|
|
208
|
+
return app.get_coordinates()
|
|
@@ -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.viennarna"
|
|
6
|
+
__author__ = "Patrick Kunzmann"
|
|
7
|
+
__all__ = ["build_constraint_string"]
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
from biotite.structure.pseudoknots import pseudoknots
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def build_constraint_string(
|
|
14
|
+
sequence_length,
|
|
15
|
+
pairs=None,
|
|
16
|
+
paired=None,
|
|
17
|
+
unpaired=None,
|
|
18
|
+
downstream=None,
|
|
19
|
+
upstream=None,
|
|
20
|
+
):
|
|
21
|
+
"""
|
|
22
|
+
Build a ViennaRNA constraint string.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
sequence_length : int
|
|
27
|
+
The length of the string to be built.
|
|
28
|
+
pairs : ndarray, shape=(n,2), dtype=int, optional
|
|
29
|
+
Positions of constrained base pairs.
|
|
30
|
+
paired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
31
|
+
Positions of bases that are paired with any other base.
|
|
32
|
+
unpaired : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
33
|
+
Positions of bases that are unpaired.
|
|
34
|
+
downstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
35
|
+
Positions of bases that are paired with any downstream base.
|
|
36
|
+
upstream : ndarray, shape=(n,), dtype=int or dtype=bool, optional
|
|
37
|
+
Positions of bases that are paired with any upstream base.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
constraints : str
|
|
42
|
+
The constraint string.
|
|
43
|
+
"""
|
|
44
|
+
constraints = np.full(sequence_length, ".", dtype="U1")
|
|
45
|
+
|
|
46
|
+
if pairs is not None:
|
|
47
|
+
pairs = np.asarray(pairs)
|
|
48
|
+
# Ensure that pairs do not contain pseudoknots
|
|
49
|
+
if (pseudoknots(pairs, max_pseudoknot_order=1) == -1).any():
|
|
50
|
+
raise ValueError("Given pairs include pseudoknots")
|
|
51
|
+
# Ensure the lower base comes first for each pair
|
|
52
|
+
pairs = np.sort(pairs, axis=-1)
|
|
53
|
+
_set_constraints(constraints, pairs[:, 0], "(")
|
|
54
|
+
_set_constraints(constraints, pairs[:, 1], ")")
|
|
55
|
+
|
|
56
|
+
_set_constraints(constraints, paired, "|")
|
|
57
|
+
_set_constraints(constraints, unpaired, "x")
|
|
58
|
+
_set_constraints(constraints, downstream, "<")
|
|
59
|
+
_set_constraints(constraints, upstream, ">")
|
|
60
|
+
|
|
61
|
+
return "".join(constraints)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _set_constraints(constraints, index, character):
|
|
65
|
+
if index is None:
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
# Search for conflicts with other constraints
|
|
69
|
+
potential_conflict_indices = np.where(constraints[index] != ".")[0]
|
|
70
|
+
if len(potential_conflict_indices) > 0:
|
|
71
|
+
conflict_i = index[potential_conflict_indices[0]]
|
|
72
|
+
raise ValueError(
|
|
73
|
+
f"Constraint '{character}' at position {conflict_i} "
|
|
74
|
+
f"conflicts with existing constraint '{constraints[conflict_i]}'"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
constraints[index] = character
|
|
@@ -0,0 +1,76 @@
|
|
|
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 biotite.application.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.
|
|
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("The user guidelines would be violated")
|
|
55
|
+
else:
|
|
56
|
+
raise RuleViolationError(msg)
|
|
57
|
+
|
|
58
|
+
def app_url(self):
|
|
59
|
+
"""
|
|
60
|
+
Get the URL of the web app.
|
|
61
|
+
|
|
62
|
+
Returns
|
|
63
|
+
-------
|
|
64
|
+
url : str
|
|
65
|
+
URL of the web app.
|
|
66
|
+
"""
|
|
67
|
+
return self._app_url
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class RuleViolationError(Exception):
|
|
71
|
+
"""
|
|
72
|
+
Indicates that the user guidelines of the web application would be
|
|
73
|
+
violated, if the program continued.
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
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 *
|