biotite 1.5.0__cp314-cp314-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-314-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-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmeralphabet.pyx +595 -0
- biotite/sequence/align/kmersimilarity.cpython-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmersimilarity.pyx +233 -0
- biotite/sequence/align/kmertable.cpython-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/kmertable.pyx +3411 -0
- biotite/sequence/align/localgapped.cpython-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/localgapped.pyx +892 -0
- biotite/sequence/align/localungapped.cpython-314-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-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/multiple.pyx +619 -0
- biotite/sequence/align/pairwise.cpython-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/align/pairwise.pyx +585 -0
- biotite/sequence/align/permutation.cpython-314-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-314-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-314-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-314-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-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/nj.pyx +221 -0
- biotite/sequence/phylo/tree.cpython-314-x86_64-linux-gnu.so +0 -0
- biotite/sequence/phylo/tree.pyx +1169 -0
- biotite/sequence/phylo/upgma.cpython-314-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-314-x86_64-linux-gnu.so +0 -0
- biotite/structure/bonds.pyx +2036 -0
- biotite/structure/box.py +724 -0
- biotite/structure/celllist.cpython-314-x86_64-linux-gnu.so +0 -0
- biotite/structure/celllist.pyx +864 -0
- biotite/structure/chains.py +310 -0
- biotite/structure/charges.cpython-314-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-314-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-314-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-314-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,98 @@
|
|
|
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.database.pubchem"
|
|
6
|
+
__author__ = "Patrick Kunzmann"
|
|
7
|
+
__all__ = ["ThrottleStatus"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
import time
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class ThrottleStatus:
|
|
16
|
+
"""
|
|
17
|
+
This class gives information about the dynamic request throttling
|
|
18
|
+
of *Pubchem*.
|
|
19
|
+
|
|
20
|
+
Typically, objects of this class are created from responses of
|
|
21
|
+
the *Pubchem* sever using :meth:`from_response()`, so that
|
|
22
|
+
the the throttle statuses can be read from that object.
|
|
23
|
+
|
|
24
|
+
Furthermore, this class provides the :meth:`wait_if_busy()` method,
|
|
25
|
+
that halts the execution for a short time at high loads to ensure
|
|
26
|
+
adherence to *Pubchem* usage policies.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
count : float
|
|
31
|
+
A value between 0 and (typically) 1 that indicates the current
|
|
32
|
+
load of this user due to the number of requests.
|
|
33
|
+
If the value exceeds 1, server requests will be blocked.
|
|
34
|
+
time : float
|
|
35
|
+
A value between 0 and (typically) 1 that indicates the current
|
|
36
|
+
load of this user due to the running time of requests.
|
|
37
|
+
If the value exceeds 1, server requests will be blocked.
|
|
38
|
+
service : float
|
|
39
|
+
A value between 0 and (typically) 1 that indicates the current
|
|
40
|
+
general load of the server.
|
|
41
|
+
If the value exceeds 1, the server is overloaded.
|
|
42
|
+
|
|
43
|
+
Attributes
|
|
44
|
+
----------
|
|
45
|
+
count, time, service : float
|
|
46
|
+
Read-only attributes for the parameters given above.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
count: ...
|
|
50
|
+
time: ...
|
|
51
|
+
service: ...
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def from_response(response):
|
|
55
|
+
"""
|
|
56
|
+
Extract the throttle status from a *Pubchem* server response.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
response : requests.Response
|
|
61
|
+
The response from the request to the *Pubchem* server.
|
|
62
|
+
|
|
63
|
+
Returns
|
|
64
|
+
-------
|
|
65
|
+
throttle_status : ThrottleStatus
|
|
66
|
+
The extracted throttle status.
|
|
67
|
+
"""
|
|
68
|
+
throttle_control = response.headers["X-Throttling-Control"]
|
|
69
|
+
throttle_status = [
|
|
70
|
+
substring.split(")")[0] for substring in throttle_control.split("(")[1:]
|
|
71
|
+
]
|
|
72
|
+
# Remove '%' sign and convert to int
|
|
73
|
+
count_status, time_status, service_status = [
|
|
74
|
+
int(status[:-1]) for status in throttle_status
|
|
75
|
+
]
|
|
76
|
+
# Convert from percent
|
|
77
|
+
count_status /= 100
|
|
78
|
+
time_status /= 100
|
|
79
|
+
service_status /= 100
|
|
80
|
+
return ThrottleStatus(count_status, time_status, service_status)
|
|
81
|
+
|
|
82
|
+
def wait_if_busy(self, threshold=0.5, wait_time=1.0):
|
|
83
|
+
"""
|
|
84
|
+
Halt the execution for a given number of seconds, if the current
|
|
85
|
+
request time or count of this user exceeds the given threshold.
|
|
86
|
+
|
|
87
|
+
Parameters
|
|
88
|
+
----------
|
|
89
|
+
threshold : float, optional
|
|
90
|
+
A value between 0 and 1.
|
|
91
|
+
If the load of either the request time or count exceeds this
|
|
92
|
+
value the execution is halted.
|
|
93
|
+
wait_time : float, optional
|
|
94
|
+
The time in seconds the execution will halt, if the
|
|
95
|
+
threshold is exceeded.
|
|
96
|
+
"""
|
|
97
|
+
if self.count > threshold or self.time > threshold:
|
|
98
|
+
time.sleep(wait_time)
|
|
@@ -0,0 +1,13 @@
|
|
|
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 downloading files from the RCSB PDB.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__name__ = "biotite.database.rcsb"
|
|
10
|
+
__author__ = "Patrick Kunzmann"
|
|
11
|
+
|
|
12
|
+
from .download import *
|
|
13
|
+
from .query import *
|
|
@@ -0,0 +1,161 @@
|
|
|
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.database.rcsb"
|
|
6
|
+
__author__ = "Patrick Kunzmann"
|
|
7
|
+
__all__ = ["fetch"]
|
|
8
|
+
|
|
9
|
+
import io
|
|
10
|
+
import os
|
|
11
|
+
from os.path import getsize, isfile, join
|
|
12
|
+
import requests
|
|
13
|
+
from biotite.database.error import RequestError
|
|
14
|
+
|
|
15
|
+
_standard_url = "https://files.rcsb.org/download/"
|
|
16
|
+
_bcif_url = "https://models.rcsb.org/"
|
|
17
|
+
_fasta_url = "https://www.rcsb.org/fasta/entry/"
|
|
18
|
+
|
|
19
|
+
_binary_formats = ["bcif"]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def fetch(pdb_ids, format, target_path=None, overwrite=False, verbose=False):
|
|
23
|
+
"""
|
|
24
|
+
Download structure files (or sequence files) from the RCSB PDB in
|
|
25
|
+
various formats.
|
|
26
|
+
|
|
27
|
+
This function requires an internet connection.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
pdb_ids : str or iterable object of str
|
|
32
|
+
A single PDB ID or a list of PDB IDs of the structure(s)
|
|
33
|
+
to be downloaded.
|
|
34
|
+
format : {'pdb', 'pdbx', 'cif', 'mmcif', 'bcif', 'fasta'}
|
|
35
|
+
The format of the files to be downloaded.
|
|
36
|
+
``'pdbx'``, ``'cif'`` and ``'mmcif'`` are synonyms for
|
|
37
|
+
the same format.
|
|
38
|
+
target_path : str, optional
|
|
39
|
+
The target directory of the downloaded files.
|
|
40
|
+
By default, the file content is stored in a file-like object
|
|
41
|
+
(:class:`StringIO` or :class:`BytesIO`, respectively).
|
|
42
|
+
overwrite : bool, optional
|
|
43
|
+
If true, existing files will be overwritten.
|
|
44
|
+
Otherwise the respective file will only be downloaded, if the
|
|
45
|
+
file does not exist yet in the specified target directory or if
|
|
46
|
+
the file is empty.
|
|
47
|
+
verbose : bool, optional
|
|
48
|
+
If set to true, the function will output the download progress.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
files : str or StringIO or BytesIO or list of (str or StringIO or BytesIO)
|
|
53
|
+
The file path(s) to the downloaded files.
|
|
54
|
+
If a single PDB ID was given in `pdb_ids`,
|
|
55
|
+
a single string is returned. If a list (or other iterable
|
|
56
|
+
object) was given, a list of strings is returned.
|
|
57
|
+
If no `target_path` was given, the file contents are stored in
|
|
58
|
+
either :class:`StringIO` or :class:`BytesIO` objects.
|
|
59
|
+
|
|
60
|
+
Warnings
|
|
61
|
+
--------
|
|
62
|
+
Even if you give valid input to this function, in rare cases the
|
|
63
|
+
database might return no or malformed data to you.
|
|
64
|
+
In these cases the request should be retried.
|
|
65
|
+
When the issue occurs repeatedly, the error is probably in your
|
|
66
|
+
input.
|
|
67
|
+
|
|
68
|
+
Examples
|
|
69
|
+
--------
|
|
70
|
+
|
|
71
|
+
>>> import os.path
|
|
72
|
+
>>> file = fetch("1l2y", "cif", path_to_directory)
|
|
73
|
+
>>> print(os.path.basename(file))
|
|
74
|
+
1l2y.cif
|
|
75
|
+
>>> files = fetch(["1l2y", "3o5r"], "cif", path_to_directory)
|
|
76
|
+
>>> print([os.path.basename(file) for file in files])
|
|
77
|
+
['1l2y.cif', '3o5r.cif']
|
|
78
|
+
"""
|
|
79
|
+
# If only a single PDB ID is present,
|
|
80
|
+
# put it into a single element list
|
|
81
|
+
if isinstance(pdb_ids, str):
|
|
82
|
+
pdb_ids = [pdb_ids]
|
|
83
|
+
single_element = True
|
|
84
|
+
else:
|
|
85
|
+
single_element = False
|
|
86
|
+
# Create the target folder, if not existing
|
|
87
|
+
if target_path is not None and not os.path.isdir(target_path):
|
|
88
|
+
os.makedirs(target_path)
|
|
89
|
+
|
|
90
|
+
files = []
|
|
91
|
+
for i, id in enumerate(pdb_ids):
|
|
92
|
+
# Verbose output
|
|
93
|
+
if verbose:
|
|
94
|
+
print(f"Fetching file {i + 1:d} / {len(pdb_ids):d} ({id})...", end="\r")
|
|
95
|
+
|
|
96
|
+
# Fetch file from database
|
|
97
|
+
if target_path is not None:
|
|
98
|
+
file = join(target_path, id + "." + format)
|
|
99
|
+
else:
|
|
100
|
+
# 'file = None' -> store content in a file-like object
|
|
101
|
+
file = None
|
|
102
|
+
|
|
103
|
+
if file is None or not isfile(file) or getsize(file) == 0 or overwrite:
|
|
104
|
+
if format == "pdb":
|
|
105
|
+
r = requests.get(_standard_url + id + ".pdb")
|
|
106
|
+
content = r.text
|
|
107
|
+
_assert_valid_file(content, id)
|
|
108
|
+
elif format in ["cif", "mmcif", "pdbx"]:
|
|
109
|
+
r = requests.get(_standard_url + id + ".cif")
|
|
110
|
+
content = r.text
|
|
111
|
+
_assert_valid_file(content, id)
|
|
112
|
+
elif format in ["bcif"]:
|
|
113
|
+
r = requests.get(_bcif_url + id + ".bcif")
|
|
114
|
+
content = r.content
|
|
115
|
+
_assert_valid_file(r.text, id)
|
|
116
|
+
elif format == "fasta":
|
|
117
|
+
r = requests.get(_fasta_url + id)
|
|
118
|
+
content = r.text
|
|
119
|
+
_assert_valid_file(content, id)
|
|
120
|
+
else:
|
|
121
|
+
raise ValueError(f"Format '{format}' is not supported")
|
|
122
|
+
|
|
123
|
+
if file is None:
|
|
124
|
+
if format in _binary_formats:
|
|
125
|
+
file = io.BytesIO(content)
|
|
126
|
+
else:
|
|
127
|
+
file = io.StringIO(content)
|
|
128
|
+
else:
|
|
129
|
+
mode = "wb+" if format in _binary_formats else "w+"
|
|
130
|
+
with open(file, mode) as f:
|
|
131
|
+
f.write(content)
|
|
132
|
+
|
|
133
|
+
files.append(file)
|
|
134
|
+
if verbose:
|
|
135
|
+
print("\nDone")
|
|
136
|
+
# If input was a single ID, return only a single path
|
|
137
|
+
if single_element:
|
|
138
|
+
return files[0]
|
|
139
|
+
else:
|
|
140
|
+
return files
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _assert_valid_file(response_text, pdb_id):
|
|
144
|
+
"""
|
|
145
|
+
Checks whether the response is an actual structure file
|
|
146
|
+
or the response a *404* error due to invalid PDB ID.
|
|
147
|
+
"""
|
|
148
|
+
# Structure file and FASTA file retrieval
|
|
149
|
+
# have different error messages
|
|
150
|
+
if len(response_text) == 0 or any(
|
|
151
|
+
err_msg in response_text
|
|
152
|
+
for err_msg in [
|
|
153
|
+
"404 Not Found",
|
|
154
|
+
"<title>RCSB Protein Data Bank Error Page</title>",
|
|
155
|
+
"<title>PDB Archive over AWS</title>",
|
|
156
|
+
"No fasta files were found.",
|
|
157
|
+
"No valid PDB IDs were submitted.",
|
|
158
|
+
"The requested URL was incorrect, too long or otherwise malformed.",
|
|
159
|
+
]
|
|
160
|
+
):
|
|
161
|
+
raise RequestError("PDB ID {:} is invalid".format(pdb_id))
|