biotite 1.5.0__cp314-cp314-win_amd64.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.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/kmeralphabet.pyx +595 -0
- biotite/sequence/align/kmersimilarity.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/kmersimilarity.pyx +233 -0
- biotite/sequence/align/kmertable.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/kmertable.pyx +3411 -0
- biotite/sequence/align/localgapped.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/localgapped.pyx +892 -0
- biotite/sequence/align/localungapped.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/multiple.pyx +619 -0
- biotite/sequence/align/pairwise.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/pairwise.pyx +585 -0
- biotite/sequence/align/permutation.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/permutation.pyx +313 -0
- biotite/sequence/align/primes.txt +821 -0
- biotite/sequence/align/selector.cp314-win_amd64.pyd +0 -0
- biotite/sequence/align/selector.pyx +954 -0
- biotite/sequence/align/statistics.py +264 -0
- biotite/sequence/align/tracetable.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +0 -0
- biotite/sequence/phylo/nj.pyx +221 -0
- biotite/sequence/phylo/tree.cp314-win_amd64.pyd +0 -0
- biotite/sequence/phylo/tree.pyx +1169 -0
- biotite/sequence/phylo/upgma.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +0 -0
- biotite/structure/bonds.pyx +2036 -0
- biotite/structure/box.py +724 -0
- biotite/structure/celllist.cp314-win_amd64.pyd +0 -0
- biotite/structure/celllist.pyx +864 -0
- biotite/structure/chains.py +310 -0
- biotite/structure/charges.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +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.cp314-win_amd64.pyd +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 +4 -0
- biotite-1.5.0.dist-info/licenses/LICENSE.rst +30 -0
|
@@ -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 visualizing structure related objects.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__name__ = "biotite.structure.graphics"
|
|
10
|
+
__author__ = "Patrick Kunzmann, Tom David Müller"
|
|
11
|
+
|
|
12
|
+
from .atoms import *
|
|
13
|
+
from .rna import *
|
|
@@ -0,0 +1,243 @@
|
|
|
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.structure.graphics"
|
|
6
|
+
__author__ = "Patrick Kunzmann"
|
|
7
|
+
__all__ = ["plot_atoms", "plot_ball_and_stick_model"]
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
from mpl_toolkits.mplot3d import Axes3D
|
|
11
|
+
from mpl_toolkits.mplot3d.art3d import Line3DCollection
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def plot_atoms(
|
|
15
|
+
axes,
|
|
16
|
+
atoms,
|
|
17
|
+
colors,
|
|
18
|
+
line_width=1.0,
|
|
19
|
+
background_color=None,
|
|
20
|
+
center=None,
|
|
21
|
+
size=None,
|
|
22
|
+
zoom=1.0,
|
|
23
|
+
):
|
|
24
|
+
"""
|
|
25
|
+
Plot an :class:`AtomArray` as lines between bonded atoms.
|
|
26
|
+
|
|
27
|
+
The z-axis points into the screen plane.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
axes : Axes3D
|
|
32
|
+
The *Matplotlib* 3D-axes to plot the structure on.
|
|
33
|
+
atoms : AtomArray, shape=(n,)
|
|
34
|
+
The structure to be plotted.
|
|
35
|
+
The atom array must have an associated :class:`BondList`, i.e.
|
|
36
|
+
its ``bonds`` attribute must be defined.
|
|
37
|
+
One line for each bond is drawn.
|
|
38
|
+
colors : ndarray, shape=(n,3) or shape=(n,4), dtype=float
|
|
39
|
+
An array of RGB or RGBA colors for each atom in `atoms`.
|
|
40
|
+
The values for each color channel are in the range 0 to 1.
|
|
41
|
+
line_width : float, optional
|
|
42
|
+
The width of the lines to be drawn.
|
|
43
|
+
background_color : object
|
|
44
|
+
A *Matplotlib* compatible color (color name or RGB values).
|
|
45
|
+
If set, the background is colored with the given value.
|
|
46
|
+
center : tuple of (float, float, float), optional
|
|
47
|
+
The coordinates of the structure that are in the center of the
|
|
48
|
+
plot.
|
|
49
|
+
By default the complete molecule is centered.
|
|
50
|
+
size : float, optional
|
|
51
|
+
The size of each dimension in the plot.
|
|
52
|
+
The limits of the :class:`Axes3D` are set to
|
|
53
|
+
``(center - size/(2*zoom)), (center + size/(2*zoom))``.
|
|
54
|
+
zoom : float, optional
|
|
55
|
+
Zoom in or zoom out.
|
|
56
|
+
|
|
57
|
+
- ``> 1.0``: Zoom in.
|
|
58
|
+
- ``< 1.0``: Zoom out.
|
|
59
|
+
|
|
60
|
+
Notes
|
|
61
|
+
-----
|
|
62
|
+
This is a very simple visualization tools for quick visual analysis
|
|
63
|
+
of a structure.
|
|
64
|
+
For publication-ready molecular images the usage of a dedicated
|
|
65
|
+
molecular visualization tool is recommended.
|
|
66
|
+
"""
|
|
67
|
+
if not isinstance(axes, Axes3D):
|
|
68
|
+
raise ValueError("The given axes mut be an 'Axes3D'")
|
|
69
|
+
if atoms.bonds is None:
|
|
70
|
+
raise ValueError("The atom array must have an associated bond list")
|
|
71
|
+
|
|
72
|
+
# Calculating connections between atoms
|
|
73
|
+
line_coord = []
|
|
74
|
+
line_colors = []
|
|
75
|
+
for index1, index2 in atoms.bonds.as_array()[:, :2]:
|
|
76
|
+
# Every connection consist of two lines:
|
|
77
|
+
# One from the first atom to the center
|
|
78
|
+
# and from from the second atom to the center
|
|
79
|
+
line_start = atoms.coord[index1]
|
|
80
|
+
line_end = atoms.coord[index2]
|
|
81
|
+
line_center = (line_start + line_end) / 2
|
|
82
|
+
|
|
83
|
+
# Add line from first atom
|
|
84
|
+
line_coord.append((line_start, line_center))
|
|
85
|
+
line_colors.append(colors[index1])
|
|
86
|
+
|
|
87
|
+
# Add line from second atom
|
|
88
|
+
line_coord.append((line_end, line_center))
|
|
89
|
+
line_colors.append(colors[index2])
|
|
90
|
+
|
|
91
|
+
# Plot computed line coordinates and colors
|
|
92
|
+
# Use 'Line3DCollection' for higher efficiency
|
|
93
|
+
lines = Line3DCollection(
|
|
94
|
+
line_coord,
|
|
95
|
+
color=line_colors,
|
|
96
|
+
linewidths=line_width,
|
|
97
|
+
capstyle="round",
|
|
98
|
+
joinstyle="round",
|
|
99
|
+
)
|
|
100
|
+
axes.add_collection(lines)
|
|
101
|
+
|
|
102
|
+
# Set viewing angle
|
|
103
|
+
axes.azim = -90
|
|
104
|
+
axes.elev = 90
|
|
105
|
+
# Remove frame
|
|
106
|
+
axes.axis("off")
|
|
107
|
+
# Set background color
|
|
108
|
+
if background_color is not None:
|
|
109
|
+
axes.set_facecolor(background_color)
|
|
110
|
+
axes.get_figure().set_facecolor(background_color)
|
|
111
|
+
_set_box(axes, atoms.coord, center, size, zoom)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def plot_ball_and_stick_model(
|
|
115
|
+
axes,
|
|
116
|
+
atoms,
|
|
117
|
+
colors,
|
|
118
|
+
ball_size=200,
|
|
119
|
+
line_color="black",
|
|
120
|
+
line_width=1.0,
|
|
121
|
+
background_color=None,
|
|
122
|
+
center=None,
|
|
123
|
+
size=None,
|
|
124
|
+
zoom=1.0,
|
|
125
|
+
):
|
|
126
|
+
"""
|
|
127
|
+
Plot an :class:`AtomArray` as *ball-and-stick* model.
|
|
128
|
+
|
|
129
|
+
The z-axis points into the screen plane.
|
|
130
|
+
|
|
131
|
+
UNSTABLE: This function is probably subject to future changes.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
axes : Axes3D
|
|
136
|
+
The *Matplotlib* 3D-axes to plot the structure on.
|
|
137
|
+
atoms : AtomArray, length=n
|
|
138
|
+
The structure to be plotted.
|
|
139
|
+
The atom array must have an associated :class:`BondList`, i.e.
|
|
140
|
+
its ``bonds`` attribute must be defined.
|
|
141
|
+
One line for each bond is drawn.
|
|
142
|
+
colors : ndarray, shape=(n,3) or shape=(n,4), dtype=float
|
|
143
|
+
An array of RGB or RGBA colors for each atom in `atoms`, that
|
|
144
|
+
is used to color the *balls* of the model.
|
|
145
|
+
The values for each color channel are in the range 0 to 1.
|
|
146
|
+
ball_size : int or iterable of int, shape=(n,)
|
|
147
|
+
The size of the *balls* in the model in *pt*.
|
|
148
|
+
Either a single value for all atoms or an iterable object of
|
|
149
|
+
values for each atom.
|
|
150
|
+
line_color : object
|
|
151
|
+
A *Matplotlib* compatible color value for the *sticks* of the
|
|
152
|
+
model.
|
|
153
|
+
line_width : float, optional
|
|
154
|
+
The width of the *sticks* in the model in *pt*.
|
|
155
|
+
background_color : object
|
|
156
|
+
A *Matplotlib* compatible color (color name or RGB values).
|
|
157
|
+
If set, the background is colored with the given value.
|
|
158
|
+
center : tuple of (float, float, float), optional
|
|
159
|
+
The coordinates of the structure that are in the center of the
|
|
160
|
+
plot.
|
|
161
|
+
By default the complete molecule is centered.
|
|
162
|
+
size : float, optional
|
|
163
|
+
The size of each dimension in the plot.
|
|
164
|
+
The limits of the :class:`Axes3D` are set to
|
|
165
|
+
``(center - size/(2*zoom)), (center + size/(2*zoom))``.
|
|
166
|
+
zoom : float, optional
|
|
167
|
+
Zoom in or zoom out.
|
|
168
|
+
|
|
169
|
+
- ``> 1.0``: Zoom in.
|
|
170
|
+
- ``< 1.0``: Zoom out.
|
|
171
|
+
|
|
172
|
+
Notes
|
|
173
|
+
-----
|
|
174
|
+
This is a very simple visualization tools for quick visual analysis
|
|
175
|
+
of a structure.
|
|
176
|
+
For publication-ready molecular images the usage of a dedicated
|
|
177
|
+
molecular visualization tool is recommended.
|
|
178
|
+
"""
|
|
179
|
+
if not isinstance(axes, Axes3D):
|
|
180
|
+
raise ValueError("The given axes mut be an 'Axes3D'")
|
|
181
|
+
if atoms.bonds is None:
|
|
182
|
+
raise ValueError("The atom array must have an associated bond list")
|
|
183
|
+
|
|
184
|
+
# Calculating connections between atoms
|
|
185
|
+
line_coord = [
|
|
186
|
+
(atoms.coord[index1], atoms.coord[index2])
|
|
187
|
+
for index1, index2 in atoms.bonds.as_array()[:, :2]
|
|
188
|
+
]
|
|
189
|
+
|
|
190
|
+
# Plot sticks
|
|
191
|
+
# Use 'Line3DCollection' for higher efficiency
|
|
192
|
+
sticks = Line3DCollection(
|
|
193
|
+
line_coord,
|
|
194
|
+
color=line_color,
|
|
195
|
+
linewidths=line_width,
|
|
196
|
+
capstyle="round",
|
|
197
|
+
joinstyle="round",
|
|
198
|
+
)
|
|
199
|
+
axes.add_collection(sticks)
|
|
200
|
+
|
|
201
|
+
# Plot balls
|
|
202
|
+
axes.scatter(*atoms.coord.T, s=ball_size, c=colors, linewidth=0, alpha=1)
|
|
203
|
+
|
|
204
|
+
# Set viewing angle
|
|
205
|
+
axes.azim = -90
|
|
206
|
+
axes.elev = 90
|
|
207
|
+
# Remove frame
|
|
208
|
+
axes.axis("off")
|
|
209
|
+
# Set background color
|
|
210
|
+
if background_color is not None:
|
|
211
|
+
axes.set_facecolor(background_color)
|
|
212
|
+
axes.get_figure().set_facecolor(background_color)
|
|
213
|
+
_set_box(axes, atoms.coord, center, size, zoom)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def _set_box(axes, coord, center, size, zoom):
|
|
217
|
+
"""
|
|
218
|
+
This ensures an approximately equal aspect ratio in a 3D plot under
|
|
219
|
+
the condition, that the :class:`Axes` is quadratic on the display.
|
|
220
|
+
"""
|
|
221
|
+
if center is None:
|
|
222
|
+
center = (
|
|
223
|
+
(coord[:, 0].max() + coord[:, 0].min()) / 2,
|
|
224
|
+
(coord[:, 1].max() + coord[:, 1].min()) / 2,
|
|
225
|
+
(coord[:, 2].max() + coord[:, 2].min()) / 2,
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
if size is None:
|
|
229
|
+
size = np.array(
|
|
230
|
+
[
|
|
231
|
+
coord[:, 0].max() - coord[:, 0].min(),
|
|
232
|
+
coord[:, 1].max() - coord[:, 1].min(),
|
|
233
|
+
coord[:, 2].max() - coord[:, 2].min(),
|
|
234
|
+
]
|
|
235
|
+
).max()
|
|
236
|
+
|
|
237
|
+
axes.set_xlim(center[0] - size / (2 * zoom), center[0] + size / (2 * zoom))
|
|
238
|
+
axes.set_ylim(center[1] - size / (2 * zoom), center[1] + size / (2 * zoom))
|
|
239
|
+
axes.set_zlim(center[2] - size / (2 * zoom), center[2] + size / (2 * zoom))
|
|
240
|
+
|
|
241
|
+
# Make the axis lengths of the 'plot box' equal
|
|
242
|
+
# The 'plot box' is not visible due to 'axes.axis("off")'
|
|
243
|
+
axes.set_box_aspect([1, 1, 1])
|
|
@@ -0,0 +1,298 @@
|
|
|
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.structure.graphics"
|
|
6
|
+
__author__ = "Tom David Müller"
|
|
7
|
+
__all__ = ["plot_nucleotide_secondary_structure"]
|
|
8
|
+
|
|
9
|
+
import shutil
|
|
10
|
+
from itertools import repeat
|
|
11
|
+
import numpy as np
|
|
12
|
+
from biotite.application.viennarna import RNAplotApp
|
|
13
|
+
from biotite.structure import pseudoknots
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def plot_nucleotide_secondary_structure(
|
|
17
|
+
axes,
|
|
18
|
+
base_labels,
|
|
19
|
+
base_pairs,
|
|
20
|
+
length,
|
|
21
|
+
layout_type=RNAplotApp.Layout.NAVIEW,
|
|
22
|
+
draw_pseudoknots=True,
|
|
23
|
+
pseudoknot_order=None,
|
|
24
|
+
angle=0,
|
|
25
|
+
bond_linewidth=1,
|
|
26
|
+
bond_linestyle=None,
|
|
27
|
+
bond_color="black",
|
|
28
|
+
backbone_linewidth=1,
|
|
29
|
+
backbone_linestyle="solid",
|
|
30
|
+
backbone_color="grey",
|
|
31
|
+
base_text=None,
|
|
32
|
+
base_box=None,
|
|
33
|
+
annotation_positions=None,
|
|
34
|
+
annotation_offset=8.5,
|
|
35
|
+
annotation_text=None,
|
|
36
|
+
border=0.03,
|
|
37
|
+
bin_path="RNAplot",
|
|
38
|
+
):
|
|
39
|
+
"""
|
|
40
|
+
Generate 2D plots of nucleic acid secondary structures using the
|
|
41
|
+
interface to *RNAplot*, which is part of the *ViennaRNA* software
|
|
42
|
+
package.
|
|
43
|
+
|
|
44
|
+
Internally a :class:`biotite.application.viennarna.RNAplotApp`
|
|
45
|
+
instance is created to generate coordinates for each individual base
|
|
46
|
+
on a 2D plane. *ViennaRNA* must be installed in order to use this
|
|
47
|
+
function.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
axes : Axes
|
|
52
|
+
A *Matplotlib* axes, that is used as plotting area.
|
|
53
|
+
base_labels : iterable
|
|
54
|
+
The labels denoting the type of each base.
|
|
55
|
+
base_pairs : ndarray, shape=(n,2)
|
|
56
|
+
Each row corresponds to the positions of the bases in the
|
|
57
|
+
sequence. The positions are counted from zero.
|
|
58
|
+
length : int
|
|
59
|
+
The number of bases in the sequence.
|
|
60
|
+
layout_type : RNAplotApp.Layout, optional
|
|
61
|
+
The layout type according to the *RNAplot* documentation.
|
|
62
|
+
draw_pseudoknots : bool, optional
|
|
63
|
+
Whether pseudoknotted bonds should be drawn.
|
|
64
|
+
pseudoknot_order : iterable, optional
|
|
65
|
+
The pseudoknot order of each pair in the input `base_pairs`.
|
|
66
|
+
If no pseudoknot order is given, a solution determined by
|
|
67
|
+
:func:`biotite.structure.pseudoknots` is picked at random.
|
|
68
|
+
angle : int or float, optional
|
|
69
|
+
The angle the plot should be rotated.
|
|
70
|
+
bond_linewidth : float or int or iterable, optional
|
|
71
|
+
The linewidth of each bond. Provide a single value to set the
|
|
72
|
+
linewidth for all bonds or an iterable to set the linewidth for
|
|
73
|
+
each individual bond.
|
|
74
|
+
bond_linestyle : str or iterable, optional
|
|
75
|
+
The *Matplotlib* compatible linestyle of each bond. Provide a
|
|
76
|
+
single value to set the linewidth for all bonds or an iterable
|
|
77
|
+
to set the linewidth for each individual bond. By default, solid
|
|
78
|
+
lines are used for non-pseudoknotted bonds and dashed lines are
|
|
79
|
+
used for pseudoknotted bonds.
|
|
80
|
+
bond_color : str or ndarray, shape(n,) or shape(n,3) or shape(n,4), optional
|
|
81
|
+
The *Matplotlib* compatible color of each bond. Provide a single
|
|
82
|
+
string to set the color for all bonds or an array to set the
|
|
83
|
+
color for each individual bond.
|
|
84
|
+
backbone_linewidth : float, optional
|
|
85
|
+
The linewidth of the backbone.
|
|
86
|
+
backbone_linestyle : str, optional
|
|
87
|
+
The *Matplotlib* compatible linestyle of the backbone.
|
|
88
|
+
backbone_color : str or ndarray, shape=(3,) or shape=(4,), dtype=float, optional
|
|
89
|
+
The *Matplotlib* compatible color of the backbone.
|
|
90
|
+
base_text : dict or iterable, optional
|
|
91
|
+
The keyword parameters for the *Matplotlib* ``Text`` objects
|
|
92
|
+
denoting the type of each base. Provide a single value to set
|
|
93
|
+
the parameters for all labels or an iterable to set the
|
|
94
|
+
parameters for each individual label.
|
|
95
|
+
The default is ``{'size': 'small'}``.
|
|
96
|
+
base_box : dict or iterable, optional)
|
|
97
|
+
The *Matplotlib* compatible properties of the ``FancyBboxPatch``
|
|
98
|
+
surrounding the base labels. Provide a single dictionary to
|
|
99
|
+
set the properties of all base lables or an iterable to set the
|
|
100
|
+
properties for each individual label.
|
|
101
|
+
The default is ``{'pad'=0, 'color'='white'}``.
|
|
102
|
+
annotation_positions : iterable, optional
|
|
103
|
+
The positions of the bases to be numbered. By default every
|
|
104
|
+
second base is annotated. Please note that while the positions
|
|
105
|
+
in the sequence are counted from zero, they are displayed on the
|
|
106
|
+
graph counted from one.
|
|
107
|
+
annotation_offset : int or float, optional
|
|
108
|
+
The offset of the annotations from the base labels.
|
|
109
|
+
annotation_text : dict or iterable, optional
|
|
110
|
+
The keyword parameters for the *Matplotlib* ``Text`` objects
|
|
111
|
+
annotating the sequence. Provide a single value to set the
|
|
112
|
+
parameters for all annotations or an iterable to set the
|
|
113
|
+
parameters for each individual annotation.
|
|
114
|
+
The default is ``{'size': 'small'}``.
|
|
115
|
+
border : float, optional
|
|
116
|
+
The percentage of the coordinate range to be left as whitespace
|
|
117
|
+
to create a border around the plot.
|
|
118
|
+
bin_path : str, optional
|
|
119
|
+
Path to the *RNAplot* binary.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
# Check if RNAplot is installed
|
|
123
|
+
if shutil.which(bin_path) is None:
|
|
124
|
+
raise FileNotFoundError(
|
|
125
|
+
"RNAplot is not installed at the specified location, unable to "
|
|
126
|
+
"plot secondary structure."
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Get the unknotted base pairs
|
|
130
|
+
if pseudoknot_order is None:
|
|
131
|
+
# Get a random unknotted structure retaining the maximum number
|
|
132
|
+
# of base pairs.
|
|
133
|
+
pseudoknot_order = pseudoknots(base_pairs, max_pseudoknot_order=0)[0]
|
|
134
|
+
unknotted_base_pairs = base_pairs[pseudoknot_order == 0]
|
|
135
|
+
|
|
136
|
+
# If `bond_linewidth` is a single value, extrapolate
|
|
137
|
+
if isinstance(bond_linewidth, int) or isinstance(bond_linewidth, float):
|
|
138
|
+
bond_linewidth = np.full(base_pairs.shape[0], bond_linewidth)
|
|
139
|
+
|
|
140
|
+
# If `bond_color` is not an array, extrapolate
|
|
141
|
+
if not isinstance(bond_color, np.ndarray):
|
|
142
|
+
bond_color = np.full(base_pairs.shape[0], bond_color)
|
|
143
|
+
|
|
144
|
+
# Set the default properties of the Matplotlib `bbox` surrounding
|
|
145
|
+
# the base labels
|
|
146
|
+
if base_box is None:
|
|
147
|
+
base_box = np.full(length, {"pad": 0, "color": "white"})
|
|
148
|
+
# if `base_box` is a dictionary, extrapolate
|
|
149
|
+
elif isinstance(base_box, dict):
|
|
150
|
+
base_box = np.full(length, base_box)
|
|
151
|
+
|
|
152
|
+
# By default pseudoknotted bonds are denoted as dashed lines, while
|
|
153
|
+
# unknotted bonds are denoted as solid lines
|
|
154
|
+
if bond_linestyle is None:
|
|
155
|
+
bond_linestyle = np.full(base_pairs.shape[0], "solid", dtype="object")
|
|
156
|
+
bond_linestyle[pseudoknot_order != 0] = "dashed"
|
|
157
|
+
# If `bond_linestyle` is a string, extrapolate
|
|
158
|
+
elif isinstance(bond_linestyle, str):
|
|
159
|
+
bond_linestyle = np.full(base_pairs.shape[0], bond_linestyle, dtype="object")
|
|
160
|
+
|
|
161
|
+
# If pseudoknots are not to be drawn, remove pseudoknotted bonds,
|
|
162
|
+
# regardless of the given linestyles
|
|
163
|
+
if not draw_pseudoknots:
|
|
164
|
+
# Ensure that the array can hold the 'None' value
|
|
165
|
+
# (not possible with 'U1' dtype for example)
|
|
166
|
+
bond_linestyle = np.asarray(bond_linestyle, dtype="object")
|
|
167
|
+
bond_linestyle[pseudoknot_order != 0] = "None"
|
|
168
|
+
|
|
169
|
+
# Set the default properties of the base labels
|
|
170
|
+
if base_text is None:
|
|
171
|
+
base_text = np.full(length, {"size": "small"})
|
|
172
|
+
elif isinstance(base_text, dict):
|
|
173
|
+
base_text = np.full(length, base_text)
|
|
174
|
+
|
|
175
|
+
# If no specific annotation positions are given, annotate every
|
|
176
|
+
# second base pair
|
|
177
|
+
if annotation_positions is None:
|
|
178
|
+
annotation_positions = range(0, length, 2)
|
|
179
|
+
|
|
180
|
+
# Set the default font properties of the base annotations
|
|
181
|
+
if annotation_text is None:
|
|
182
|
+
annotation_text = repeat({"size": "small"})
|
|
183
|
+
elif isinstance(annotation_text, dict):
|
|
184
|
+
annotation_text = repeat(annotation_text)
|
|
185
|
+
|
|
186
|
+
# Get coordinates for secondary structure plot
|
|
187
|
+
coordinates = RNAplotApp.compute_coordinates(
|
|
188
|
+
base_pairs=unknotted_base_pairs,
|
|
189
|
+
length=length,
|
|
190
|
+
bin_path=bin_path,
|
|
191
|
+
layout_type=layout_type,
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# Rotate Coordinates
|
|
195
|
+
if angle != 0:
|
|
196
|
+
angle = np.deg2rad(angle)
|
|
197
|
+
rot_matrix = np.array(
|
|
198
|
+
[[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]]
|
|
199
|
+
)
|
|
200
|
+
for i, coord in enumerate(coordinates):
|
|
201
|
+
coordinates[i] = np.dot(rot_matrix, coord)
|
|
202
|
+
|
|
203
|
+
# Remove axes and frame
|
|
204
|
+
axes.set_xticks([])
|
|
205
|
+
axes.set_yticks([])
|
|
206
|
+
axes.xaxis.set_tick_params(
|
|
207
|
+
top=False, bottom=False, labeltop=False, labelbottom=False
|
|
208
|
+
)
|
|
209
|
+
axes.yaxis.set_tick_params(
|
|
210
|
+
top=False, bottom=False, labeltop=False, labelbottom=False
|
|
211
|
+
)
|
|
212
|
+
axes.set_frame_on(False)
|
|
213
|
+
|
|
214
|
+
# Define buffer area (Border)
|
|
215
|
+
coord_range = abs(np.max(coordinates)) + abs(np.min(coordinates))
|
|
216
|
+
buffer = border * coord_range
|
|
217
|
+
|
|
218
|
+
# Adjust display
|
|
219
|
+
axes.set_xlim(
|
|
220
|
+
np.min(coordinates[:, 0]) - buffer, np.max(coordinates[:, 0]) + buffer
|
|
221
|
+
)
|
|
222
|
+
axes.set_ylim(
|
|
223
|
+
np.min(coordinates[:, 1]) - buffer, np.max(coordinates[:, 1]) + buffer
|
|
224
|
+
)
|
|
225
|
+
axes.set_aspect(aspect="equal")
|
|
226
|
+
|
|
227
|
+
# Draw backbone
|
|
228
|
+
axes.plot(
|
|
229
|
+
coordinates[:, 0],
|
|
230
|
+
coordinates[:, 1],
|
|
231
|
+
color=backbone_color,
|
|
232
|
+
linestyle=backbone_linestyle,
|
|
233
|
+
linewidth=backbone_linewidth,
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
# Draw base labels
|
|
237
|
+
for coords, label, box, text in zip(coordinates, base_labels, base_box, base_text):
|
|
238
|
+
t = axes.text(
|
|
239
|
+
x=coords[0], y=coords[1], s=label, ha="center", va="center", **text
|
|
240
|
+
)
|
|
241
|
+
t.set_bbox(box)
|
|
242
|
+
|
|
243
|
+
# Draw bonds
|
|
244
|
+
for (base1, base2), color, style, width in zip(
|
|
245
|
+
base_pairs, bond_color, bond_linestyle, bond_linewidth
|
|
246
|
+
):
|
|
247
|
+
base1_coords = coordinates[base1]
|
|
248
|
+
base2_coords = coordinates[base2]
|
|
249
|
+
x = base1_coords[0], base2_coords[0]
|
|
250
|
+
y = base1_coords[1], base2_coords[1]
|
|
251
|
+
axes.plot(x, y, color=color, linestyle=style, linewidth=width)
|
|
252
|
+
|
|
253
|
+
# Draw annotations
|
|
254
|
+
for i, text in zip(annotation_positions, annotation_text):
|
|
255
|
+
if (i > 0) and ((i + 1) < length):
|
|
256
|
+
# Get the average of the direction vectors to the next and
|
|
257
|
+
# previous base
|
|
258
|
+
vector_to_previous = np.array(
|
|
259
|
+
[
|
|
260
|
+
coordinates[i - 1][0] - coordinates[i][0],
|
|
261
|
+
coordinates[i - 1][1] - coordinates[i][1],
|
|
262
|
+
]
|
|
263
|
+
)
|
|
264
|
+
vector_to_previous = vector_to_previous / np.linalg.norm(vector_to_previous)
|
|
265
|
+
vector_to_next = np.array(
|
|
266
|
+
[
|
|
267
|
+
coordinates[i][0] - coordinates[i + 1][0],
|
|
268
|
+
coordinates[i][1] - coordinates[i + 1][1],
|
|
269
|
+
]
|
|
270
|
+
)
|
|
271
|
+
vector_to_next = vector_to_next / np.linalg.norm(vector_to_next)
|
|
272
|
+
vector = (vector_to_next + vector_to_previous) / 2
|
|
273
|
+
elif i > 0:
|
|
274
|
+
# For the last base get the direction vector to the previous
|
|
275
|
+
# base
|
|
276
|
+
vector = np.array(
|
|
277
|
+
[
|
|
278
|
+
coordinates[i - 1][0] - coordinates[i][0],
|
|
279
|
+
coordinates[i - 1][1] - coordinates[i][1],
|
|
280
|
+
]
|
|
281
|
+
)
|
|
282
|
+
else:
|
|
283
|
+
# For the first base get the direction vector to the next
|
|
284
|
+
# base
|
|
285
|
+
vector = np.array(
|
|
286
|
+
[
|
|
287
|
+
coordinates[i][0] - coordinates[i + 1][0],
|
|
288
|
+
coordinates[i][1] - coordinates[i + 1][1],
|
|
289
|
+
]
|
|
290
|
+
)
|
|
291
|
+
# Normalize the vector
|
|
292
|
+
vector = vector / np.linalg.norm(vector)
|
|
293
|
+
# Get the perpendicular vector
|
|
294
|
+
vector = np.array([vector[1], -vector[0]])
|
|
295
|
+
# The annotations are offset in the direction of the
|
|
296
|
+
# perpendicular vector
|
|
297
|
+
x, y = coordinates[i] + (annotation_offset * vector)
|
|
298
|
+
axes.text(x=x, y=y, s=i + 1, ha="center", va="center", **text)
|