biotite 1.5.0__cp314-cp314-macosx_10_13_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-darwin.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-darwin.so +0 -0
- biotite/sequence/align/kmeralphabet.pyx +595 -0
- biotite/sequence/align/kmersimilarity.cpython-314-darwin.so +0 -0
- biotite/sequence/align/kmersimilarity.pyx +233 -0
- biotite/sequence/align/kmertable.cpython-314-darwin.so +0 -0
- biotite/sequence/align/kmertable.pyx +3411 -0
- biotite/sequence/align/localgapped.cpython-314-darwin.so +0 -0
- biotite/sequence/align/localgapped.pyx +892 -0
- biotite/sequence/align/localungapped.cpython-314-darwin.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-darwin.so +0 -0
- biotite/sequence/align/multiple.pyx +619 -0
- biotite/sequence/align/pairwise.cpython-314-darwin.so +0 -0
- biotite/sequence/align/pairwise.pyx +585 -0
- biotite/sequence/align/permutation.cpython-314-darwin.so +0 -0
- biotite/sequence/align/permutation.pyx +313 -0
- biotite/sequence/align/primes.txt +821 -0
- biotite/sequence/align/selector.cpython-314-darwin.so +0 -0
- biotite/sequence/align/selector.pyx +954 -0
- biotite/sequence/align/statistics.py +264 -0
- biotite/sequence/align/tracetable.cpython-314-darwin.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-darwin.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-darwin.so +0 -0
- biotite/sequence/phylo/nj.pyx +221 -0
- biotite/sequence/phylo/tree.cpython-314-darwin.so +0 -0
- biotite/sequence/phylo/tree.pyx +1169 -0
- biotite/sequence/phylo/upgma.cpython-314-darwin.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-darwin.so +0 -0
- biotite/structure/bonds.pyx +2036 -0
- biotite/structure/box.py +724 -0
- biotite/structure/celllist.cpython-314-darwin.so +0 -0
- biotite/structure/celllist.pyx +864 -0
- biotite/structure/chains.py +310 -0
- biotite/structure/charges.cpython-314-darwin.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-darwin.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-darwin.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-darwin.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,1228 @@
|
|
|
1
|
+
__name__ = "biotite.interface.pymol"
|
|
2
|
+
__author__ = "Patrick Kunzmann"
|
|
3
|
+
__all__ = ["PyMOLObject", "NonexistentObjectError", "ModifiedObjectError"]
|
|
4
|
+
|
|
5
|
+
import numbers
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from functools import wraps
|
|
8
|
+
import numpy as np
|
|
9
|
+
import biotite.structure as struc
|
|
10
|
+
from biotite.interface.pymol.convert import (
|
|
11
|
+
from_model,
|
|
12
|
+
to_model,
|
|
13
|
+
)
|
|
14
|
+
from biotite.interface.pymol.startup import get_and_set_pymol_instance
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def validate(method):
|
|
18
|
+
"""
|
|
19
|
+
Check if the object name still exists and if the atom count has
|
|
20
|
+
been modified.
|
|
21
|
+
If this is the case, raise the appropriate exception.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
@wraps(method)
|
|
25
|
+
def wrapper(self, *args, **kwargs):
|
|
26
|
+
self._check_existence()
|
|
27
|
+
if self._type == PyMOLObject.Type.MOLECULE:
|
|
28
|
+
new_atom_count = self._cmd.count_atoms(f"model {self._name}")
|
|
29
|
+
if new_atom_count != self._atom_count:
|
|
30
|
+
raise ModifiedObjectError(
|
|
31
|
+
f"The number of atoms in the object changed "
|
|
32
|
+
f"from the original {self._atom_count} atoms "
|
|
33
|
+
f" to {new_atom_count} atoms"
|
|
34
|
+
)
|
|
35
|
+
return method(self, *args, **kwargs)
|
|
36
|
+
|
|
37
|
+
return wrapper
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class PyMOLObject:
|
|
41
|
+
"""
|
|
42
|
+
A handle to a *PyMOL object* (*PyMOL model*), usually created by the static
|
|
43
|
+
:meth:`from_structure()` method.
|
|
44
|
+
|
|
45
|
+
This class conveniently provides thin wrappers around *PyMOL* commands that
|
|
46
|
+
allows *NumPy*-style atom indices to select atoms instead of *PyMOL* selection
|
|
47
|
+
expressions.
|
|
48
|
+
The following *PyMOL* commands are supported:
|
|
49
|
+
|
|
50
|
+
- :meth:`alter()`
|
|
51
|
+
- :meth:`cartoon()`
|
|
52
|
+
- :meth:`center()`
|
|
53
|
+
- :meth:`clip()`
|
|
54
|
+
- :meth:`color()`
|
|
55
|
+
- :meth:`desaturate()`
|
|
56
|
+
- :meth:`disable()`
|
|
57
|
+
- :meth:`distance()`
|
|
58
|
+
- :meth:`dss()`
|
|
59
|
+
- :meth:`enable()`
|
|
60
|
+
- :meth:`hide()`
|
|
61
|
+
- :meth:`indicate()`
|
|
62
|
+
- :meth:`label()`
|
|
63
|
+
- :meth:`orient()`
|
|
64
|
+
- :meth:`origin()`
|
|
65
|
+
- :meth:`select()`
|
|
66
|
+
- :meth:`set()`
|
|
67
|
+
- :meth:`set_bond()`
|
|
68
|
+
- :meth:`show()`
|
|
69
|
+
- :meth:`show_as()`
|
|
70
|
+
- :meth:`smooth()`
|
|
71
|
+
- :meth:`unset()`
|
|
72
|
+
- :meth:`unset_bond()`
|
|
73
|
+
- :meth:`zoom()`
|
|
74
|
+
|
|
75
|
+
Instances of this class become invalid, when atoms are added to or
|
|
76
|
+
are deleted from the underlying *PyMOL* object.
|
|
77
|
+
Calling methods of such an an invalidated object raises an
|
|
78
|
+
:exc:`ModifiedObjectError`.
|
|
79
|
+
Likewise, calling methods of an object, of which the underlying
|
|
80
|
+
*PyMOL* object does not exist anymore, raises an
|
|
81
|
+
:exc:`NonexistentObjectError`.
|
|
82
|
+
|
|
83
|
+
Parameters
|
|
84
|
+
----------
|
|
85
|
+
name : str
|
|
86
|
+
The name of the *PyMOL* object.
|
|
87
|
+
pymol_instance : module or SingletonPyMOL or PyMOL, optional
|
|
88
|
+
If *PyMOL* is used in library mode, the :class:`PyMOL` or
|
|
89
|
+
:class:`SingletonPyMOL` object is given here.
|
|
90
|
+
If otherwise *PyMOL* is used in GUI mode, the :mod:`pymol` module is given.
|
|
91
|
+
By default the currently active *PyMOL* instance is used.
|
|
92
|
+
If no *PyMOL* instance is currently running, *PyMOL* is started in library mode.
|
|
93
|
+
delete : PyMOL, optional
|
|
94
|
+
If set to true, the underlying *PyMOL* object will be removed
|
|
95
|
+
from the *PyMOL* session, when this object is garbage collected.
|
|
96
|
+
|
|
97
|
+
Attributes
|
|
98
|
+
----------
|
|
99
|
+
name : str
|
|
100
|
+
The name of the *PyMOL* object.
|
|
101
|
+
object_type : PyMOLObject.Type
|
|
102
|
+
The type of this *PyMOL* object.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
class Type(Enum):
|
|
106
|
+
"""
|
|
107
|
+
Defines what this :class:`PyMOLObject` represents.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
MOLECULE = "object:molecule"
|
|
111
|
+
MAP = "object:map"
|
|
112
|
+
MESH = "object:mesh"
|
|
113
|
+
SLICE = "object:slice"
|
|
114
|
+
SURFACE = "object:surface"
|
|
115
|
+
MEASUREMENT = "object:measurement"
|
|
116
|
+
CGO = "object:cgo"
|
|
117
|
+
GROUP = "object:group"
|
|
118
|
+
VOLUME = "object:volume"
|
|
119
|
+
SELECTION = "selection"
|
|
120
|
+
|
|
121
|
+
_object_counter = 0
|
|
122
|
+
_color_counter = 0
|
|
123
|
+
|
|
124
|
+
def __init__(self, name, pymol_instance=None, delete=True):
|
|
125
|
+
self._name = name
|
|
126
|
+
self._pymol = get_and_set_pymol_instance(pymol_instance)
|
|
127
|
+
self._delete = delete
|
|
128
|
+
self._cmd = self._pymol.cmd
|
|
129
|
+
self._type = PyMOLObject.Type(self._cmd.get_type(self._name))
|
|
130
|
+
self._check_existence()
|
|
131
|
+
if self._type == PyMOLObject.Type.MOLECULE:
|
|
132
|
+
self._atom_count = self._cmd.count_atoms(f"%{self._name}")
|
|
133
|
+
|
|
134
|
+
def __del__(self):
|
|
135
|
+
if self._delete:
|
|
136
|
+
try:
|
|
137
|
+
# Try to delete this object from PyMOL
|
|
138
|
+
# Fails if PyMOL itself is already garbage collected
|
|
139
|
+
self._cmd.delete(self._name)
|
|
140
|
+
except Exception:
|
|
141
|
+
pass
|
|
142
|
+
|
|
143
|
+
@staticmethod
|
|
144
|
+
def from_structure(
|
|
145
|
+
atoms, name=None, pymol_instance=None, delete=True, delocalize_bonds=False
|
|
146
|
+
):
|
|
147
|
+
"""
|
|
148
|
+
Create a :class:`PyMOLObject` from an :class:`AtomArray` or
|
|
149
|
+
:class:`AtomArrayStack` and add it to the *PyMOL* session.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
atoms : AtomArray or AtomArrayStack
|
|
154
|
+
The structure to be converted.
|
|
155
|
+
name : str, optional
|
|
156
|
+
The name of the newly created *PyMOL* object.
|
|
157
|
+
If omitted, a unique name is generated.
|
|
158
|
+
pymol_instance : module or SingletonPyMOL or PyMOL, optional
|
|
159
|
+
If *PyMOL* is used in library mode, the :class:`PyMOL`
|
|
160
|
+
or :class:`SingletonPyMOL` object is given here.
|
|
161
|
+
If otherwise *PyMOL* is used in GUI mode, the :mod:`pymol`
|
|
162
|
+
module is given.
|
|
163
|
+
By default the currently active *PyMOL* instance is used.
|
|
164
|
+
If no *PyMOL* instance is currently running,
|
|
165
|
+
*PyMOL* is started in library mode.
|
|
166
|
+
delete : bool, optional
|
|
167
|
+
If set to true, the underlying *PyMOL* object will be
|
|
168
|
+
removed from the *PyMOL* session, when this object is
|
|
169
|
+
garbage collected.
|
|
170
|
+
delocalize_bonds : bool, optional
|
|
171
|
+
If set to true, use *PyMOL*'s delocalized bond order for aromatic bonds.
|
|
172
|
+
Otherwise, always use formal bond orders.
|
|
173
|
+
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
pymol_object : PyMOLObject
|
|
177
|
+
The :class:`PyMOLObject` representing the given structure.
|
|
178
|
+
"""
|
|
179
|
+
pymol_instance = get_and_set_pymol_instance(pymol_instance)
|
|
180
|
+
cmd = pymol_instance.cmd
|
|
181
|
+
|
|
182
|
+
if name is None:
|
|
183
|
+
name = f"biotite_{PyMOLObject._object_counter}"
|
|
184
|
+
PyMOLObject._object_counter += 1
|
|
185
|
+
|
|
186
|
+
if isinstance(atoms, struc.AtomArray) or (
|
|
187
|
+
isinstance(atoms, struc.AtomArrayStack) and atoms.stack_depth == 1
|
|
188
|
+
):
|
|
189
|
+
model = to_model(atoms, delocalize_bonds)
|
|
190
|
+
cmd.load_model(model, name)
|
|
191
|
+
elif isinstance(atoms, struc.AtomArrayStack):
|
|
192
|
+
# Use first model as template
|
|
193
|
+
model = to_model(atoms[0])
|
|
194
|
+
cmd.load_model(model, name)
|
|
195
|
+
# Append states corresponding to all following models
|
|
196
|
+
for coord in atoms.coord[1:]:
|
|
197
|
+
cmd.load_coordset(coord, name)
|
|
198
|
+
else:
|
|
199
|
+
raise TypeError("Expected 'AtomArray' or 'AtomArrayStack'")
|
|
200
|
+
|
|
201
|
+
return PyMOLObject(name, pymol_instance, delete)
|
|
202
|
+
|
|
203
|
+
def to_structure(self, state=None, altloc="first", include_bonds=False):
|
|
204
|
+
"""
|
|
205
|
+
Convert this object into an :class:`AtomArray` or
|
|
206
|
+
:class:`AtomArrayStack`.
|
|
207
|
+
|
|
208
|
+
The returned :class:`AtomArray` contains the optional annotation
|
|
209
|
+
categories ``b_factor``, ``occupancy`` and ``charge``.
|
|
210
|
+
|
|
211
|
+
Parameters
|
|
212
|
+
----------
|
|
213
|
+
state : int, optional
|
|
214
|
+
If this parameter is given, the function will return an
|
|
215
|
+
:class:`AtomArray` corresponding to the given state of the
|
|
216
|
+
*PyMOL* object.
|
|
217
|
+
If this parameter is omitted, an :class:`AtomArrayStack`
|
|
218
|
+
containing all states will be returned, even if the *PyMOL*
|
|
219
|
+
object contains only one state.
|
|
220
|
+
altloc : {'first', 'occupancy', 'all'}
|
|
221
|
+
This parameter defines how *altloc* IDs are handled:
|
|
222
|
+
|
|
223
|
+
- ``'first'`` - Use atoms that have the first
|
|
224
|
+
*altloc* ID appearing in a residue.
|
|
225
|
+
- ``'occupancy'`` - Use atoms that have the *altloc* ID
|
|
226
|
+
with the highest occupancy for a residue.
|
|
227
|
+
- ``'all'`` - Use all atoms.
|
|
228
|
+
Note that this leads to duplicate atoms.
|
|
229
|
+
When this option is chosen, the ``altloc_id``
|
|
230
|
+
annotation array is added to the returned structure.
|
|
231
|
+
|
|
232
|
+
include_bonds : bool, optional
|
|
233
|
+
If set to true, an associated :class:`BondList` will be created
|
|
234
|
+
for the returned structure.
|
|
235
|
+
|
|
236
|
+
Returns
|
|
237
|
+
-------
|
|
238
|
+
structure : AtomArray or AtomArrayStack
|
|
239
|
+
The converted structure.
|
|
240
|
+
Whether an :class:`AtomArray` or :class:`AtomArrayStack` is
|
|
241
|
+
returned depends on the `state` parameter.
|
|
242
|
+
"""
|
|
243
|
+
if state is None:
|
|
244
|
+
model = self._cmd.get_model(self._name, state=1)
|
|
245
|
+
template = from_model(model, include_bonds)
|
|
246
|
+
expected_length = None
|
|
247
|
+
coord = []
|
|
248
|
+
for i in range(self._cmd.count_states(self._name)):
|
|
249
|
+
state_coord = self._cmd.get_coordset(self._name, state=i + 1)
|
|
250
|
+
if expected_length is None:
|
|
251
|
+
expected_length = len(state_coord)
|
|
252
|
+
elif len(state_coord) != expected_length:
|
|
253
|
+
raise ValueError("The models have different numbers of atoms")
|
|
254
|
+
coord.append(state_coord)
|
|
255
|
+
coord = np.stack(coord)
|
|
256
|
+
structure = struc.from_template(template, coord)
|
|
257
|
+
|
|
258
|
+
else:
|
|
259
|
+
model = self._cmd.get_model(self._name, state=state)
|
|
260
|
+
structure = from_model(model, include_bonds)
|
|
261
|
+
|
|
262
|
+
# Filter altloc IDs and return
|
|
263
|
+
if altloc == "occupancy":
|
|
264
|
+
structure = structure[
|
|
265
|
+
...,
|
|
266
|
+
struc.filter_highest_occupancy_altloc(
|
|
267
|
+
structure, structure.altloc_id, structure.occupancy
|
|
268
|
+
),
|
|
269
|
+
]
|
|
270
|
+
structure.del_annotation("altloc_id")
|
|
271
|
+
return structure
|
|
272
|
+
elif altloc == "first":
|
|
273
|
+
structure = structure[
|
|
274
|
+
..., struc.filter_first_altloc(structure, structure.altloc_id)
|
|
275
|
+
]
|
|
276
|
+
structure.del_annotation("altloc_id")
|
|
277
|
+
return structure
|
|
278
|
+
elif altloc == "all":
|
|
279
|
+
return structure
|
|
280
|
+
else:
|
|
281
|
+
raise ValueError(f"'{altloc}' is not a valid 'altloc' option")
|
|
282
|
+
|
|
283
|
+
@property
|
|
284
|
+
def name(self):
|
|
285
|
+
return self._name
|
|
286
|
+
|
|
287
|
+
@property
|
|
288
|
+
def object_type(self):
|
|
289
|
+
return self._type
|
|
290
|
+
|
|
291
|
+
def exists(self):
|
|
292
|
+
"""
|
|
293
|
+
Check whether the underlying *PyMOL* object still exists.
|
|
294
|
+
|
|
295
|
+
Returns
|
|
296
|
+
-------
|
|
297
|
+
bool
|
|
298
|
+
True if the *PyMOL* session contains an object with the name
|
|
299
|
+
of this :class:`PyMOLObject`, false otherwise.
|
|
300
|
+
"""
|
|
301
|
+
return self._name in self._cmd.get_names("all", enabled_only=False)
|
|
302
|
+
|
|
303
|
+
def _check_existence(self):
|
|
304
|
+
if not self.exists():
|
|
305
|
+
raise NonexistentObjectError(
|
|
306
|
+
f"A PyMOL object with the name {self._name} does not exist anymore"
|
|
307
|
+
)
|
|
308
|
+
|
|
309
|
+
@validate
|
|
310
|
+
def where(self, index):
|
|
311
|
+
"""
|
|
312
|
+
Convert a *Biotite*-compatible atom selection index
|
|
313
|
+
(integer, slice, boolean mask, index array) into a *PyMOL*
|
|
314
|
+
selection expression.
|
|
315
|
+
|
|
316
|
+
Parameters
|
|
317
|
+
----------
|
|
318
|
+
index : int or slice or ndarray, dtype=bool or ndarray, dtype=int
|
|
319
|
+
The boolean mask to be converted into a selection string.
|
|
320
|
+
|
|
321
|
+
Returns
|
|
322
|
+
-------
|
|
323
|
+
expression : str
|
|
324
|
+
A *PyMOL* compatible selection expression.
|
|
325
|
+
"""
|
|
326
|
+
if self._type != PyMOLObject.Type.MOLECULE:
|
|
327
|
+
raise TypeError(
|
|
328
|
+
"Can only create atom selection strings "
|
|
329
|
+
"for PyMOL objects representing molecules"
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
if isinstance(index, numbers.Integral):
|
|
333
|
+
# PyMOLs indexing starts at 1
|
|
334
|
+
return f"%{self._name} and index {index}"
|
|
335
|
+
|
|
336
|
+
elif isinstance(index, np.ndarray) and index.dtype == bool:
|
|
337
|
+
mask = index
|
|
338
|
+
if len(mask) != self._atom_count:
|
|
339
|
+
raise IndexError(
|
|
340
|
+
f"Mask has length {len(mask)}, but the number of "
|
|
341
|
+
f"atoms in the PyMOL model is {self._atom_count}"
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
else:
|
|
345
|
+
# Convert any other index type into a boolean mask
|
|
346
|
+
mask = np.zeros(self._atom_count, dtype=bool)
|
|
347
|
+
mask[index] = True
|
|
348
|
+
|
|
349
|
+
# Indices where the mask changes from True to False
|
|
350
|
+
# or from False to True
|
|
351
|
+
# The '+1' makes each index refer to the position
|
|
352
|
+
# after the change i.e. the new value
|
|
353
|
+
changes = np.where(np.diff(mask))[0] + 1
|
|
354
|
+
# If first element is True, insert index 0 at start
|
|
355
|
+
# -> the first change is always from False to True
|
|
356
|
+
if mask[0]:
|
|
357
|
+
changes = np.concatenate(([0], changes))
|
|
358
|
+
# If the last element is True, insert append length of mask
|
|
359
|
+
# as exclusive stop index
|
|
360
|
+
# -> the last change is always from True to False
|
|
361
|
+
if mask[-1]:
|
|
362
|
+
changes = np.concatenate((changes, [len(mask)]))
|
|
363
|
+
# -> Changes are alternating (F->T, T->F, F->T, ..., F->T, T->F)
|
|
364
|
+
# Reshape into pairs ([F->T, T->F], [F->T, T->F], ...)
|
|
365
|
+
# -> these are the intervals where the mask is True
|
|
366
|
+
intervals = np.reshape(changes, (-1, 2))
|
|
367
|
+
|
|
368
|
+
if len(intervals) > 0:
|
|
369
|
+
# Convert interval into selection string
|
|
370
|
+
# Two things to note:
|
|
371
|
+
# - PyMOLs indexing starts at 1-> 'start+1'
|
|
372
|
+
# - Stop in 'intervals' is exclusive -> 'stop+1-1' -> 'stop'
|
|
373
|
+
index_selection = " or ".join(
|
|
374
|
+
[f"index {start + 1}-{stop}" for start, stop in intervals]
|
|
375
|
+
)
|
|
376
|
+
# Constrain the selection to given object name
|
|
377
|
+
return f"%{self._name} and ({index_selection})"
|
|
378
|
+
else:
|
|
379
|
+
return "none"
|
|
380
|
+
|
|
381
|
+
def _into_selection(self, selection, not_none=False):
|
|
382
|
+
"""
|
|
383
|
+
Turn a boolean mask into a *PyMOL* selection expression or
|
|
384
|
+
restrict an selection expression to the current *PyMOL* object.
|
|
385
|
+
"""
|
|
386
|
+
if selection is None:
|
|
387
|
+
return f"%{self._name}"
|
|
388
|
+
elif isinstance(selection, str):
|
|
389
|
+
return f"%{self._name} and ({selection})"
|
|
390
|
+
else:
|
|
391
|
+
if not isinstance(selection, slice):
|
|
392
|
+
selection = np.asarray(selection)
|
|
393
|
+
sel = self.where(selection)
|
|
394
|
+
if sel == "none" and not_none:
|
|
395
|
+
raise ValueError("Selection contains no atoms")
|
|
396
|
+
return sel
|
|
397
|
+
|
|
398
|
+
@validate
|
|
399
|
+
def alter(self, selection, expression):
|
|
400
|
+
"""
|
|
401
|
+
Change atomic properties using an expression evaluated
|
|
402
|
+
within a temporary namespace for each atom.
|
|
403
|
+
|
|
404
|
+
This method is a thin wrapper around the *PyMOL* ``alter()``
|
|
405
|
+
command.
|
|
406
|
+
|
|
407
|
+
Parameters
|
|
408
|
+
----------
|
|
409
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int
|
|
410
|
+
A *Biotite* compatible atom selection index,
|
|
411
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
412
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
413
|
+
command on.
|
|
414
|
+
expression : str
|
|
415
|
+
The properties of the selected atoms are changed based on
|
|
416
|
+
this expression.
|
|
417
|
+
"""
|
|
418
|
+
self._cmd.alter(self._into_selection(selection), expression)
|
|
419
|
+
|
|
420
|
+
@validate
|
|
421
|
+
def cartoon(self, type, selection=None):
|
|
422
|
+
"""
|
|
423
|
+
Change the default cartoon representation for a selection
|
|
424
|
+
of atoms.
|
|
425
|
+
|
|
426
|
+
This method is a thin wrapper around the *PyMOL* ``cartoon()``
|
|
427
|
+
command.
|
|
428
|
+
|
|
429
|
+
Parameters
|
|
430
|
+
----------
|
|
431
|
+
type : str
|
|
432
|
+
One of
|
|
433
|
+
|
|
434
|
+
- ``'automatic'``,
|
|
435
|
+
- ``'skip'``,
|
|
436
|
+
- ``'loop'``,
|
|
437
|
+
- ``'rectangle'``,
|
|
438
|
+
- ``'oval'``,
|
|
439
|
+
- ``'tube'``,
|
|
440
|
+
- ``'arrow'`` or
|
|
441
|
+
- ``'dumbbell'``.
|
|
442
|
+
|
|
443
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int
|
|
444
|
+
A *Biotite* compatible atom selection index,
|
|
445
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
446
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
447
|
+
command on.
|
|
448
|
+
By default, the command is applied on all atoms of this
|
|
449
|
+
*PyMOL* object.
|
|
450
|
+
"""
|
|
451
|
+
self._cmd.cartoon(type, self._into_selection(selection))
|
|
452
|
+
|
|
453
|
+
@validate
|
|
454
|
+
def center(self, selection=None, state=None, origin=True):
|
|
455
|
+
"""
|
|
456
|
+
Translate the window, the clipping slab, and the
|
|
457
|
+
origin to a point centered within the atom selection.
|
|
458
|
+
|
|
459
|
+
This method is a thin wrapper around the *PyMOL* ``center()``
|
|
460
|
+
command.
|
|
461
|
+
|
|
462
|
+
Parameters
|
|
463
|
+
----------
|
|
464
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
465
|
+
A *Biotite* compatible atom selection index,
|
|
466
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
467
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
468
|
+
command on.
|
|
469
|
+
By default, the command is applied on all atoms of this
|
|
470
|
+
*PyMOL* object.
|
|
471
|
+
state : int, optional
|
|
472
|
+
The state to apply the command on.
|
|
473
|
+
By default, the command is applied on all states of this
|
|
474
|
+
*PyMOL* object.
|
|
475
|
+
origin : bool, optional
|
|
476
|
+
If set to false, the origin is left unchanged.
|
|
477
|
+
"""
|
|
478
|
+
state = 0 if state is None else state
|
|
479
|
+
self._cmd.center(self._into_selection(selection), state, int(origin))
|
|
480
|
+
|
|
481
|
+
@validate
|
|
482
|
+
def clip(self, mode, distance, selection=None, state=None):
|
|
483
|
+
"""
|
|
484
|
+
Alter the positions of the near and far clipping planes.
|
|
485
|
+
|
|
486
|
+
This method is a thin wrapper around the *PyMOL* ``clip()``
|
|
487
|
+
command.
|
|
488
|
+
|
|
489
|
+
Parameters
|
|
490
|
+
----------
|
|
491
|
+
mode : {'near', 'far', 'move', 'slab', 'atoms'}
|
|
492
|
+
|
|
493
|
+
- ``near`` - Move the near plane
|
|
494
|
+
- ``far`` - Move the far plane
|
|
495
|
+
- ``move`` - Move slab
|
|
496
|
+
- ``slab`` - Set slab thickness
|
|
497
|
+
- ``atoms`` - clip selected atoms with the given buffer
|
|
498
|
+
|
|
499
|
+
distance : float
|
|
500
|
+
The meaning of this parameter depends on `mode`.
|
|
501
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
502
|
+
A *Biotite* compatible atom selection index,
|
|
503
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
504
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
505
|
+
command on.
|
|
506
|
+
By default, the command is applied on all atoms of this
|
|
507
|
+
*PyMOL* object.
|
|
508
|
+
state : int, optional
|
|
509
|
+
The state to apply the command on.
|
|
510
|
+
By default, the command is applied on all states of this
|
|
511
|
+
*PyMOL* object.
|
|
512
|
+
"""
|
|
513
|
+
state = 0 if state is None else state
|
|
514
|
+
self._cmd.clip(mode, distance, self._into_selection(selection), state)
|
|
515
|
+
|
|
516
|
+
@validate
|
|
517
|
+
def color(self, color, selection=None, representation=None):
|
|
518
|
+
"""
|
|
519
|
+
Change the color of atoms.
|
|
520
|
+
|
|
521
|
+
This method is a thin wrapper around the *PyMOL* ``color()``
|
|
522
|
+
or ``set("xxx_color")`` command.
|
|
523
|
+
|
|
524
|
+
Parameters
|
|
525
|
+
----------
|
|
526
|
+
color : str or tuple(float, float, float)
|
|
527
|
+
Either a *PyMOL* color name or a tuple containing an RGB
|
|
528
|
+
value (0.0 to 1.0).
|
|
529
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
530
|
+
A *Biotite* compatible atom selection index,
|
|
531
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
532
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
533
|
+
command on.
|
|
534
|
+
By default, the command is applied on all atoms of this
|
|
535
|
+
*PyMOL* object.
|
|
536
|
+
representation : {"sphere", "surface", "mesh", "dot", "cartoon", "ribbon"}, optional
|
|
537
|
+
Colors only the given representation by internally calling
|
|
538
|
+
``set("xxx_color")``.
|
|
539
|
+
By default, all representations are affected, i.e. ``color()``
|
|
540
|
+
is called internally.
|
|
541
|
+
|
|
542
|
+
Notes
|
|
543
|
+
-----
|
|
544
|
+
If an RGB color is given, the color is registered as a unique
|
|
545
|
+
named color via the ``set_color()`` command.
|
|
546
|
+
"""
|
|
547
|
+
if not isinstance(color, str):
|
|
548
|
+
color_name = f"biotite_color_{PyMOLObject._color_counter}"
|
|
549
|
+
PyMOLObject._color_counter += 1
|
|
550
|
+
self._cmd.set_color(color_name, tuple(color))
|
|
551
|
+
else:
|
|
552
|
+
color_name = color
|
|
553
|
+
registered = [name for name, _ in self._cmd.get_color_indices()]
|
|
554
|
+
if color_name not in registered:
|
|
555
|
+
raise ValueError(f"Unknown color '{color_name}'")
|
|
556
|
+
|
|
557
|
+
if representation is None:
|
|
558
|
+
self._cmd.color(color_name, self._into_selection(selection))
|
|
559
|
+
else:
|
|
560
|
+
if representation not in (
|
|
561
|
+
"sphere",
|
|
562
|
+
"surface",
|
|
563
|
+
"mesh",
|
|
564
|
+
"dot",
|
|
565
|
+
"cartoon",
|
|
566
|
+
"ribbon",
|
|
567
|
+
):
|
|
568
|
+
raise ValueError(
|
|
569
|
+
f"'{representation}' is not a supported representation"
|
|
570
|
+
)
|
|
571
|
+
self._cmd.set(
|
|
572
|
+
f"{representation}_color", color_name, self._into_selection(selection)
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
@validate
|
|
576
|
+
def surface_color(self, color, selection=None):
|
|
577
|
+
"""
|
|
578
|
+
Change the color of displayed surfaces.
|
|
579
|
+
|
|
580
|
+
This method is a thin wrapper around *PyMOL*
|
|
581
|
+
``set("surface_color")``.
|
|
582
|
+
|
|
583
|
+
Parameters
|
|
584
|
+
----------
|
|
585
|
+
color : str or tuple(float, float, float)
|
|
586
|
+
Either a *PyMOL* color name or a tuple containing an RGB
|
|
587
|
+
value (0.0 to 1.0).
|
|
588
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
589
|
+
A *Biotite* compatible atom selection index,
|
|
590
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
591
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
592
|
+
command on.
|
|
593
|
+
By default, the command is applied on all atoms of this
|
|
594
|
+
*PyMOL* object.
|
|
595
|
+
|
|
596
|
+
Notes
|
|
597
|
+
-----
|
|
598
|
+
If an RGB color is given, the color is registered as a unique
|
|
599
|
+
named color via the ``set_color()`` command.
|
|
600
|
+
"""
|
|
601
|
+
color_name = self._created_named_color(color)
|
|
602
|
+
self._cmd.set("surface_color", color_name, self._into_selection(selection))
|
|
603
|
+
|
|
604
|
+
@validate
|
|
605
|
+
def desaturate(self, selection=None, a=0.5):
|
|
606
|
+
"""
|
|
607
|
+
Desaturate the colors of the selected atoms.
|
|
608
|
+
|
|
609
|
+
This method is a thin wrapper around the *PyMOL*
|
|
610
|
+
``desaturate()`` command.
|
|
611
|
+
|
|
612
|
+
Parameters
|
|
613
|
+
----------
|
|
614
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
615
|
+
A *Biotite* compatible atom selection index,
|
|
616
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
617
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
618
|
+
command on.
|
|
619
|
+
By default, the command is applied on all atoms of this
|
|
620
|
+
*PyMOL* object.
|
|
621
|
+
a : float
|
|
622
|
+
A desaturation factor between 0.0 and 1.0.
|
|
623
|
+
"""
|
|
624
|
+
self._cmd.desaturate(self._into_selection(selection), a)
|
|
625
|
+
|
|
626
|
+
@validate
|
|
627
|
+
def disable(self, selection=None):
|
|
628
|
+
"""
|
|
629
|
+
Turn off display of the selected atoms.
|
|
630
|
+
|
|
631
|
+
This method is a thin wrapper around the *PyMOL* ``disable()``
|
|
632
|
+
command.
|
|
633
|
+
|
|
634
|
+
Parameters
|
|
635
|
+
----------
|
|
636
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
637
|
+
A *Biotite* compatible atom selection index,
|
|
638
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
639
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
640
|
+
command on.
|
|
641
|
+
By default, the command is applied on all atoms of this
|
|
642
|
+
*PyMOL* object.
|
|
643
|
+
"""
|
|
644
|
+
self._cmd.disable(self._into_selection(selection))
|
|
645
|
+
|
|
646
|
+
@validate
|
|
647
|
+
def distance(
|
|
648
|
+
self,
|
|
649
|
+
name,
|
|
650
|
+
selection1,
|
|
651
|
+
selection2,
|
|
652
|
+
cutoff=None,
|
|
653
|
+
mode=None,
|
|
654
|
+
show_label=True,
|
|
655
|
+
width=None,
|
|
656
|
+
length=None,
|
|
657
|
+
gap=None,
|
|
658
|
+
):
|
|
659
|
+
"""
|
|
660
|
+
Create a new distance object between two atom selections.
|
|
661
|
+
|
|
662
|
+
This method is a thin wrapper around the *PyMOL* ``distance()``
|
|
663
|
+
command.
|
|
664
|
+
|
|
665
|
+
Parameters
|
|
666
|
+
----------
|
|
667
|
+
name : str
|
|
668
|
+
Name of the distance object to create.
|
|
669
|
+
selection1, selection2 : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
670
|
+
A *Biotite* compatible atom selection index,
|
|
671
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
672
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
673
|
+
command on.
|
|
674
|
+
cutoff : float, optional
|
|
675
|
+
The longest distance to show.
|
|
676
|
+
mode : {0, 1, 2, 3, 4}, optional
|
|
677
|
+
|
|
678
|
+
- ``0`` - All interatomic distances
|
|
679
|
+
- ``1`` - Only bond distances
|
|
680
|
+
- ``2`` - Only polar contact distances
|
|
681
|
+
- ``3`` - All interatomic distances,
|
|
682
|
+
use distance_exclusion setting
|
|
683
|
+
- ``4`` - Distance between centroids
|
|
684
|
+
|
|
685
|
+
show_label : bool, optional
|
|
686
|
+
Whether to show the distance as label.
|
|
687
|
+
width, length, gap : float optional
|
|
688
|
+
The width and length of each dash and the gap length between
|
|
689
|
+
the dashes.
|
|
690
|
+
"""
|
|
691
|
+
self._cmd.distance(
|
|
692
|
+
name,
|
|
693
|
+
self._into_selection(selection1),
|
|
694
|
+
self._into_selection(selection2),
|
|
695
|
+
cutoff,
|
|
696
|
+
mode,
|
|
697
|
+
label=int(show_label),
|
|
698
|
+
width=width,
|
|
699
|
+
length=length,
|
|
700
|
+
gap=gap,
|
|
701
|
+
)
|
|
702
|
+
|
|
703
|
+
@validate
|
|
704
|
+
def dss(self, selection=None, state=None):
|
|
705
|
+
"""
|
|
706
|
+
Determine the secondary structure of the selected atoms.
|
|
707
|
+
|
|
708
|
+
This method is a thin wrapper around the *PyMOL* ``dss()``
|
|
709
|
+
command.
|
|
710
|
+
|
|
711
|
+
Parameters
|
|
712
|
+
----------
|
|
713
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
714
|
+
A *Biotite* compatible atom selection index,
|
|
715
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
716
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
717
|
+
command on.
|
|
718
|
+
By default, the command is applied on all atoms of this
|
|
719
|
+
*PyMOL* object.
|
|
720
|
+
state : int, optional
|
|
721
|
+
The state to apply the command on.
|
|
722
|
+
By default, the command is applied on all states of this
|
|
723
|
+
*PyMOL* object.
|
|
724
|
+
"""
|
|
725
|
+
state = 0 if state is None else state
|
|
726
|
+
self._cmd.dss(self._into_selection(selection), state)
|
|
727
|
+
|
|
728
|
+
@validate
|
|
729
|
+
def enable(self, selection=None):
|
|
730
|
+
"""
|
|
731
|
+
Turn on display of the selected atoms.
|
|
732
|
+
|
|
733
|
+
This method is a thin wrapper around the *PyMOL* ``enable()``
|
|
734
|
+
command.
|
|
735
|
+
|
|
736
|
+
Parameters
|
|
737
|
+
----------
|
|
738
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
739
|
+
A *Biotite* compatible atom selection index,
|
|
740
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
741
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
742
|
+
command on.
|
|
743
|
+
By default, the command is applied on all atoms of this
|
|
744
|
+
*PyMOL* object.
|
|
745
|
+
"""
|
|
746
|
+
self._cmd.enable(self._into_selection(selection))
|
|
747
|
+
|
|
748
|
+
@validate
|
|
749
|
+
def hide(self, representation, selection=None):
|
|
750
|
+
"""
|
|
751
|
+
Turn off an atom representation (e.g. sticks, spheres, etc.).
|
|
752
|
+
|
|
753
|
+
This method is a thin wrapper around the *PyMOL* ``hide()``
|
|
754
|
+
command.
|
|
755
|
+
|
|
756
|
+
Parameters
|
|
757
|
+
----------
|
|
758
|
+
representation : str
|
|
759
|
+
One of
|
|
760
|
+
|
|
761
|
+
- ``'lines'``,
|
|
762
|
+
- ``'spheres'``,
|
|
763
|
+
- ``'mesh'``,
|
|
764
|
+
- ``'ribbon'``,
|
|
765
|
+
- ``'cartoon'``,
|
|
766
|
+
- ``'sticks'``,
|
|
767
|
+
- ``'dots'``,
|
|
768
|
+
- ``'surface'``,
|
|
769
|
+
- ``'label'``,
|
|
770
|
+
- ``'extent'``,
|
|
771
|
+
- ``'nonbonded'``,
|
|
772
|
+
- ``'nb_spheres'``,
|
|
773
|
+
- ``'slice'`` or
|
|
774
|
+
- ``'cell'``.
|
|
775
|
+
|
|
776
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
777
|
+
A *Biotite* compatible atom selection index,
|
|
778
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
779
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
780
|
+
command on.
|
|
781
|
+
By default, the command is applied on all atoms of this
|
|
782
|
+
*PyMOL* object.
|
|
783
|
+
"""
|
|
784
|
+
self._cmd.hide(representation, self._into_selection(selection))
|
|
785
|
+
|
|
786
|
+
@validate
|
|
787
|
+
def indicate(self, selection=None):
|
|
788
|
+
"""
|
|
789
|
+
Show a visual representation of the selected atoms.
|
|
790
|
+
|
|
791
|
+
This method is a thin wrapper around the *PyMOL* ``indicate()``
|
|
792
|
+
command.
|
|
793
|
+
|
|
794
|
+
Parameters
|
|
795
|
+
----------
|
|
796
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
797
|
+
A *Biotite* compatible atom selection index,
|
|
798
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
799
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
800
|
+
command on.
|
|
801
|
+
By default, the command is applied on all atoms of this
|
|
802
|
+
*PyMOL* object.
|
|
803
|
+
"""
|
|
804
|
+
self._cmd.indicate(self._into_selection(selection))
|
|
805
|
+
|
|
806
|
+
@validate
|
|
807
|
+
def label(self, selection, text):
|
|
808
|
+
"""
|
|
809
|
+
Label the selected atoms.
|
|
810
|
+
|
|
811
|
+
This method is a thin wrapper around the *PyMOL* ``label()``
|
|
812
|
+
command.
|
|
813
|
+
|
|
814
|
+
Parameters
|
|
815
|
+
----------
|
|
816
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int
|
|
817
|
+
A *Biotite* compatible atom selection index,
|
|
818
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
819
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
820
|
+
command on.
|
|
821
|
+
text : str
|
|
822
|
+
The label text.
|
|
823
|
+
"""
|
|
824
|
+
self._cmd.label(self._into_selection(selection), f'"{text}"')
|
|
825
|
+
|
|
826
|
+
@validate
|
|
827
|
+
def orient(self, selection=None, state=None):
|
|
828
|
+
"""
|
|
829
|
+
Align the principal components of the selected atoms with the
|
|
830
|
+
*xyz* axes.
|
|
831
|
+
|
|
832
|
+
This method is a thin wrapper around the *PyMOL* ``orient()``
|
|
833
|
+
command.
|
|
834
|
+
|
|
835
|
+
Parameters
|
|
836
|
+
----------
|
|
837
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
838
|
+
A *Biotite* compatible atom selection index,
|
|
839
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
840
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
841
|
+
command on.
|
|
842
|
+
By default, the command is applied on all atoms of this
|
|
843
|
+
*PyMOL* object.
|
|
844
|
+
state : int, optional
|
|
845
|
+
The state to apply the command on.
|
|
846
|
+
By default, the command is applied on all states of this
|
|
847
|
+
*PyMOL* object.
|
|
848
|
+
"""
|
|
849
|
+
state = 0 if state is None else state
|
|
850
|
+
self._cmd.orient(self._into_selection(selection, True), state)
|
|
851
|
+
|
|
852
|
+
@validate
|
|
853
|
+
def origin(self, selection=None, state=None):
|
|
854
|
+
"""
|
|
855
|
+
Set the center of rotation about the selected atoms.
|
|
856
|
+
|
|
857
|
+
This method is a thin wrapper around the *PyMOL* ``origin()``
|
|
858
|
+
command.
|
|
859
|
+
|
|
860
|
+
Parameters
|
|
861
|
+
----------
|
|
862
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
863
|
+
A *Biotite* compatible atom selection index,
|
|
864
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
865
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
866
|
+
command on.
|
|
867
|
+
By default, the command is applied on all atoms of this
|
|
868
|
+
*PyMOL* object.
|
|
869
|
+
state : int, optional
|
|
870
|
+
The state to apply the command on.
|
|
871
|
+
By default, the command is applied on all states of this
|
|
872
|
+
*PyMOL* object.
|
|
873
|
+
"""
|
|
874
|
+
state = 0 if state is None else state
|
|
875
|
+
self._cmd.origin(selection=self._into_selection(selection), state=state)
|
|
876
|
+
|
|
877
|
+
@validate
|
|
878
|
+
def select(self, name, selection=None):
|
|
879
|
+
"""
|
|
880
|
+
Create a named selection object from the selected atoms.
|
|
881
|
+
|
|
882
|
+
This method is a thin wrapper around the *PyMOL* ``select()``
|
|
883
|
+
command.
|
|
884
|
+
|
|
885
|
+
Parameters
|
|
886
|
+
----------
|
|
887
|
+
name : str
|
|
888
|
+
Name of the selection object to create.
|
|
889
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
890
|
+
A *Biotite* compatible atom selection index,
|
|
891
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
892
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
893
|
+
command on.
|
|
894
|
+
By default, the command is applied on all atoms of this
|
|
895
|
+
*PyMOL* object.
|
|
896
|
+
"""
|
|
897
|
+
self._cmd.select(name, self._into_selection(selection))
|
|
898
|
+
|
|
899
|
+
@validate
|
|
900
|
+
def set(self, name, value, selection=None, state=None):
|
|
901
|
+
"""
|
|
902
|
+
Change per-atom settings.
|
|
903
|
+
|
|
904
|
+
This method is a thin wrapper around the *PyMOL* ``set()``
|
|
905
|
+
command.
|
|
906
|
+
|
|
907
|
+
Parameters
|
|
908
|
+
----------
|
|
909
|
+
name : str
|
|
910
|
+
The name of the setting to be changed.
|
|
911
|
+
One of
|
|
912
|
+
|
|
913
|
+
- ``'sphere_color'``,
|
|
914
|
+
- ``'surface_color'``,
|
|
915
|
+
- ``'mesh_color'``,
|
|
916
|
+
- ``'label_color'``,
|
|
917
|
+
- ``'dot_color'``,
|
|
918
|
+
- ``'cartoon_color'``,
|
|
919
|
+
- ``'ribbon_color'``,
|
|
920
|
+
- ``'transparency'`` (for surfaces) or
|
|
921
|
+
- ``'sphere_transparency'``.
|
|
922
|
+
|
|
923
|
+
value : object
|
|
924
|
+
The new value for the given setting name.
|
|
925
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
926
|
+
A *Biotite* compatible atom selection index,
|
|
927
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
928
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
929
|
+
command on.
|
|
930
|
+
By default, the command is applied on all atoms of this
|
|
931
|
+
*PyMOL* object.
|
|
932
|
+
state : int, optional
|
|
933
|
+
The state to apply the command on.
|
|
934
|
+
By default, the command is applied on all states of this
|
|
935
|
+
*PyMOL* object.
|
|
936
|
+
"""
|
|
937
|
+
state = 0 if state is None else state
|
|
938
|
+
self._cmd.set(name, value, self._into_selection(selection), state)
|
|
939
|
+
|
|
940
|
+
@validate
|
|
941
|
+
def set_bond(self, name, value, selection1=None, selection2=None, state=None):
|
|
942
|
+
"""
|
|
943
|
+
Change per-bond settings for all bonds which exist
|
|
944
|
+
between two atom selections.
|
|
945
|
+
|
|
946
|
+
This method is a thin wrapper around the *PyMOL* ``set_bond()``
|
|
947
|
+
command.
|
|
948
|
+
|
|
949
|
+
Parameters
|
|
950
|
+
----------
|
|
951
|
+
name : str
|
|
952
|
+
The name of the setting to be changed.
|
|
953
|
+
One of
|
|
954
|
+
|
|
955
|
+
- ``'valence'``,
|
|
956
|
+
- ``'line_width'``,
|
|
957
|
+
- ``'line_color'``,
|
|
958
|
+
- ``'stick_radius'``,
|
|
959
|
+
- ``'stick_color'`` or
|
|
960
|
+
- ``'stick_transparency'``.
|
|
961
|
+
|
|
962
|
+
value : object
|
|
963
|
+
The new value for the given setting name.
|
|
964
|
+
selection1, selection2 : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
965
|
+
A *Biotite* compatible atom selection index,
|
|
966
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
967
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
968
|
+
command on.
|
|
969
|
+
By default, `selection1` applies to all atoms of this
|
|
970
|
+
*PyMOL* object and `selection2` applies to the same atoms as
|
|
971
|
+
`selection1`.
|
|
972
|
+
state : int, optional
|
|
973
|
+
The state to apply the command on.
|
|
974
|
+
By default, the command is applied on all states of this
|
|
975
|
+
*PyMOL* object.
|
|
976
|
+
"""
|
|
977
|
+
state = 0 if state is None else state
|
|
978
|
+
selection2 = selection1 if selection2 is None else selection2
|
|
979
|
+
self._cmd.set_bond(
|
|
980
|
+
name,
|
|
981
|
+
value,
|
|
982
|
+
self._into_selection(selection1),
|
|
983
|
+
self._into_selection(selection2),
|
|
984
|
+
state,
|
|
985
|
+
)
|
|
986
|
+
|
|
987
|
+
@validate
|
|
988
|
+
def show(self, representation, selection=None):
|
|
989
|
+
"""
|
|
990
|
+
Turn on an atom representation (e.g. sticks, spheres, etc.).
|
|
991
|
+
|
|
992
|
+
This method is a thin wrapper around the *PyMOL* ``show()``
|
|
993
|
+
command.
|
|
994
|
+
|
|
995
|
+
Parameters
|
|
996
|
+
----------
|
|
997
|
+
representation : str
|
|
998
|
+
One of
|
|
999
|
+
|
|
1000
|
+
- ``'lines'``,
|
|
1001
|
+
- ``'spheres'``,
|
|
1002
|
+
- ``'mesh'``,
|
|
1003
|
+
- ``'ribbon'``,
|
|
1004
|
+
- ``'cartoon'``,
|
|
1005
|
+
- ``'sticks'``,
|
|
1006
|
+
- ``'dots'``,
|
|
1007
|
+
- ``'surface'``,
|
|
1008
|
+
- ``'label'``,
|
|
1009
|
+
- ``'extent'``,
|
|
1010
|
+
- ``'nonbonded'``,
|
|
1011
|
+
- ``'nb_spheres'``,
|
|
1012
|
+
- ``'slice'`` or
|
|
1013
|
+
- ``'cell'``.
|
|
1014
|
+
|
|
1015
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
1016
|
+
A *Biotite* compatible atom selection index,
|
|
1017
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
1018
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
1019
|
+
command on.
|
|
1020
|
+
By default, the command is applied on all atoms of this
|
|
1021
|
+
*PyMOL* object.
|
|
1022
|
+
"""
|
|
1023
|
+
self._cmd.show(representation, self._into_selection(selection))
|
|
1024
|
+
|
|
1025
|
+
@validate
|
|
1026
|
+
def show_as(self, representation, selection=None):
|
|
1027
|
+
"""
|
|
1028
|
+
Turn on a representation (e.g. sticks, spheres, etc.) and hide
|
|
1029
|
+
all other representations.
|
|
1030
|
+
|
|
1031
|
+
This method is a thin wrapper around the *PyMOL* ``show_as()``
|
|
1032
|
+
command.
|
|
1033
|
+
|
|
1034
|
+
Parameters
|
|
1035
|
+
----------
|
|
1036
|
+
representation : str
|
|
1037
|
+
One of
|
|
1038
|
+
|
|
1039
|
+
- ``'lines'``,
|
|
1040
|
+
- ``'spheres'``,
|
|
1041
|
+
- ``'mesh'``,
|
|
1042
|
+
- ``'ribbon'``,
|
|
1043
|
+
- ``'cartoon'``,
|
|
1044
|
+
- ``'sticks'``,
|
|
1045
|
+
- ``'dots'``,
|
|
1046
|
+
- ``'surface'``,
|
|
1047
|
+
- ``'label'``,
|
|
1048
|
+
- ``'extent'``,
|
|
1049
|
+
- ``'nonbonded'``,
|
|
1050
|
+
- ``'nb_spheres'``,
|
|
1051
|
+
- ``'slice'`` or
|
|
1052
|
+
- ``'cell'``.
|
|
1053
|
+
|
|
1054
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
1055
|
+
A *Biotite* compatible atom selection index,
|
|
1056
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
1057
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
1058
|
+
command on.
|
|
1059
|
+
By default, the command is applied on all atoms of this
|
|
1060
|
+
*PyMOL* object.
|
|
1061
|
+
"""
|
|
1062
|
+
self._cmd.show_as(representation, self._into_selection(selection))
|
|
1063
|
+
|
|
1064
|
+
@validate
|
|
1065
|
+
def smooth(self, selection=None, passes=1, window=5, first=1, last=0, ends=False):
|
|
1066
|
+
"""
|
|
1067
|
+
Perform a moving average over the coordinate states.
|
|
1068
|
+
|
|
1069
|
+
This method is a thin wrapper around the *PyMOL* ``smooth()``
|
|
1070
|
+
command.
|
|
1071
|
+
|
|
1072
|
+
Parameters
|
|
1073
|
+
----------
|
|
1074
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
1075
|
+
A *Biotite* compatible atom selection index,
|
|
1076
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
1077
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
1078
|
+
command on.
|
|
1079
|
+
By default, the command is applied on all atoms of this
|
|
1080
|
+
*PyMOL* object.
|
|
1081
|
+
passes : int, optional
|
|
1082
|
+
The number of smoothing passes.
|
|
1083
|
+
window : int, optional
|
|
1084
|
+
The size of the moving window.
|
|
1085
|
+
first, last : int, optional
|
|
1086
|
+
The interval of states to smooth.
|
|
1087
|
+
ends : bool, optional
|
|
1088
|
+
If set to true, the end states are also smoothed using a
|
|
1089
|
+
weighted asymmetric window.
|
|
1090
|
+
"""
|
|
1091
|
+
self._cmd.smooth(
|
|
1092
|
+
self._into_selection(selection), passes, window, first, last, int(ends)
|
|
1093
|
+
)
|
|
1094
|
+
|
|
1095
|
+
# TODO: def spectrum()
|
|
1096
|
+
|
|
1097
|
+
@validate
|
|
1098
|
+
def unset(self, name, selection=None, state=None):
|
|
1099
|
+
"""
|
|
1100
|
+
Clear per-atom settings.
|
|
1101
|
+
|
|
1102
|
+
This method is a thin wrapper around the *PyMOL* ``set()``
|
|
1103
|
+
command.
|
|
1104
|
+
|
|
1105
|
+
Parameters
|
|
1106
|
+
----------
|
|
1107
|
+
name : str
|
|
1108
|
+
The name of the setting to be cleared.
|
|
1109
|
+
One of
|
|
1110
|
+
|
|
1111
|
+
- ``'sphere_color'``,
|
|
1112
|
+
- ``'surface_color'``,
|
|
1113
|
+
- ``'mesh_color'``,
|
|
1114
|
+
- ``'label_color'``,
|
|
1115
|
+
- ``'dot_color'``,
|
|
1116
|
+
- ``'cartoon_color'``,
|
|
1117
|
+
- ``'ribbon_color'``,
|
|
1118
|
+
- ``'transparency'`` (for surfaces) or
|
|
1119
|
+
- ``'sphere_transparency'``.
|
|
1120
|
+
|
|
1121
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
1122
|
+
A *Biotite* compatible atom selection index,
|
|
1123
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
1124
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
1125
|
+
command on.
|
|
1126
|
+
By default, the command is applied on all atoms of this
|
|
1127
|
+
*PyMOL* object.
|
|
1128
|
+
state : int, optional
|
|
1129
|
+
The state to apply the command on.
|
|
1130
|
+
By default, the command is applied on all states of this
|
|
1131
|
+
*PyMOL* object.
|
|
1132
|
+
"""
|
|
1133
|
+
state = 0 if state is None else state
|
|
1134
|
+
self._cmd.unset(name, self._into_selection(selection), state)
|
|
1135
|
+
|
|
1136
|
+
@validate
|
|
1137
|
+
def unset_bond(self, name, selection1=None, selection2=None, state=None):
|
|
1138
|
+
"""
|
|
1139
|
+
Clear per-bond settings for all bonds which exist
|
|
1140
|
+
between two atom selections.
|
|
1141
|
+
|
|
1142
|
+
This method is a thin wrapper around the *PyMOL* ``unset_bond()``
|
|
1143
|
+
command.
|
|
1144
|
+
|
|
1145
|
+
Parameters
|
|
1146
|
+
----------
|
|
1147
|
+
name : str
|
|
1148
|
+
The name of the setting to be cleared.
|
|
1149
|
+
One of
|
|
1150
|
+
|
|
1151
|
+
- ``'valence'``,
|
|
1152
|
+
- ``'line_width'``,
|
|
1153
|
+
- ``'line_color'``,
|
|
1154
|
+
- ``'stick_radius'``,
|
|
1155
|
+
- ``'stick_color'`` or
|
|
1156
|
+
- ``'stick_transparency'``.
|
|
1157
|
+
|
|
1158
|
+
selection1, selection2 : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
1159
|
+
A *Biotite* compatible atom selection index,
|
|
1160
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
1161
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
1162
|
+
command on.
|
|
1163
|
+
By default, `selection1` applies to all atoms of this
|
|
1164
|
+
*PyMOL* object and `selection2` applies to the same atoms as
|
|
1165
|
+
`selection1`.
|
|
1166
|
+
state : int, optional
|
|
1167
|
+
The state to apply the command on.
|
|
1168
|
+
By default, the command is applied on all states of this
|
|
1169
|
+
*PyMOL* object.
|
|
1170
|
+
"""
|
|
1171
|
+
state = 0 if state is None else state
|
|
1172
|
+
selection2 = selection1 if selection2 is None else selection2
|
|
1173
|
+
self._cmd.unset_bond(
|
|
1174
|
+
name,
|
|
1175
|
+
self._into_selection(selection1),
|
|
1176
|
+
self._into_selection(selection2),
|
|
1177
|
+
state,
|
|
1178
|
+
)
|
|
1179
|
+
|
|
1180
|
+
@validate
|
|
1181
|
+
def zoom(self, selection=None, buffer=0.0, state=None, complete=False):
|
|
1182
|
+
"""
|
|
1183
|
+
Scale and translate the window and the origin to cover the
|
|
1184
|
+
selected atoms.
|
|
1185
|
+
|
|
1186
|
+
This method is a thin wrapper around the *PyMOL* ``zoom()``
|
|
1187
|
+
command.
|
|
1188
|
+
|
|
1189
|
+
Parameters
|
|
1190
|
+
----------
|
|
1191
|
+
selection : str or int or slice or ndarray, dtype=bool or ndarray, dtype=int, optional
|
|
1192
|
+
A *Biotite* compatible atom selection index,
|
|
1193
|
+
e.g. a boolean mask, or a *PyMOL* selection expression that
|
|
1194
|
+
selects the atoms of this *PyMOL* object to apply the
|
|
1195
|
+
command on.
|
|
1196
|
+
By default, the command is applied on all atoms of this
|
|
1197
|
+
*PyMOL* object.
|
|
1198
|
+
buffer : float, optional
|
|
1199
|
+
An additional distance to the calculated camera position.
|
|
1200
|
+
state : int, optional
|
|
1201
|
+
The state to apply the command on.
|
|
1202
|
+
By default, the command is applied on all states of this
|
|
1203
|
+
*PyMOL* object.
|
|
1204
|
+
complete : bool, optional
|
|
1205
|
+
If set to true, it is insured that no atoms centers are
|
|
1206
|
+
clipped.
|
|
1207
|
+
"""
|
|
1208
|
+
state = 0 if state is None else state
|
|
1209
|
+
self._cmd.zoom(
|
|
1210
|
+
self._into_selection(selection, True), buffer, state, int(complete)
|
|
1211
|
+
)
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
class NonexistentObjectError(Exception):
|
|
1215
|
+
"""
|
|
1216
|
+
Indicates that a *PyMOL* object with a given name does not exist.
|
|
1217
|
+
"""
|
|
1218
|
+
|
|
1219
|
+
pass
|
|
1220
|
+
|
|
1221
|
+
|
|
1222
|
+
class ModifiedObjectError(Exception):
|
|
1223
|
+
"""
|
|
1224
|
+
Indicates that a atoms were added to or removed from the *PyMOL*
|
|
1225
|
+
object after the corresponding :class:`PyMOLObject` was created.
|
|
1226
|
+
"""
|
|
1227
|
+
|
|
1228
|
+
pass
|