Visualize Bio3D structure objects in PyMOL


# S3 method for pdbs
pymol(pdbs, col=NULL, as="ribbon", file=NULL, type="script",
                     exefile="pymol", user.vec=NULL, ...)

# S3 method for nma

# S3 method for pca

# S3 method for modes
pymol(modes, mode=NULL, file=NULL, scale=5, dual=FALSE,
                     type="script", exefile="pymol", ...)

# S3 method for dccm
pymol(dccm, pdb, file=NULL,
                     step=0.2, omit=0.2, radius = 0.15,
                     type="script", exefile="pymol", ...)



aligned C-alpha Cartesian coordinates as obtained with read.fasta.pdb or pdbaln.


a single element character vector specifying the coloring of the structures. Options are: ‘index’, ‘index2’, ‘gaps’, ‘rmsf’, ‘user’.

Special cases: Provide a ‘core’ object as obtained by core.find to color on the invariant core. Alternatively, provide a vector containing the color code for each structure in the ‘pdbs’ object.


User defined vector for coloring. Only used if col="user".


show as ‘ribbon’, ‘cartoon’, ‘lines’, ‘putty’.


a single element character vector specifying the file name of the PyMOL session/script file.


a single element character vector specifying the output type: ‘script’ generates a .pml script; ‘session’ generates a .pse session file; ‘launch’ launches pymol.


file path to the ‘PYMOL’ program on your system (i.e. how is ‘PYMOL’ invoked). If NULL, use OS-dependent default path to the program.


an object of class nma or pca as obtained from functions nma or


the mode number for which the vector field should be made.


global scaling factor.


logical, if TRUE mode vectors are also drawn in both direction.


an object of class dccm as obtained from function dccm.


an object of class pdb as obtained from function read.pdb or a numerical vector of Cartesian coordinates.


binning interval of cross-correlation coefficents.


correlation coefficents with values (0-omit, 0+omit) will be omitted from visualization.


numeric, radius of visualized correlation cylinders in PyMol. Alternatively, a matrix with the same dimesions as dccm can be provided, e.g. to draw cylinders with radii associated to the pairwise correlation value.


arguments passed to function pymol.modes for ‘nma’ and ‘pca’ objects.


These functions provides a convenient approach for the visualization of Bio3D objects in PyMOL. See examples for more details.

DCCM PyMOL visualization: This function generates a PyMOL (python) script that will draw colored lines between (anti)correlated residues. The PyMOL script file is stored in the working directory with filename “”. PyMOL will only be launched (and opened) when using argument ‘type='launch'’. Alternatively a PDB file with CONECT records will be generated (when argument type='pdb').

For the PyMOL version, PyMOL CGO objects are generated - each object representing a range of correlation values (corresponding to the actual correlation values as found in the correlation matrix). E.g. the PyMOL object with name “cor_-1_-08” would display all pairs of correlations with values between -1 and -0.8.

NMA / PCA PyMOL vector field visualization: This function generates a PyMOL (python) script for drawing mode vectors on a PDB structure. The PyMOL script file is stored in the working directory with filename “”.


Called for its action


Skjaerven, L. et al. (2014) BMC Bioinformatics 15, 399. Grant, B.J. et al. (2006) Bioinformatics 22, 2695--2696.


Lars Skjaerven

See also



if (FALSE) { ##- pymol with a 'pdbs' object attach(transducin) # build a pymol session containing all structures in the PDBs object pymol(pdbs) # color by invariant core ( # core <- core.find(pdbs) pymol(pdbs, col=core) # color by RMSF pymol(pdbs, col="rmsf") # color by a user defined vector # For example, colored by averaged contact density around each residue cm <- cmap(pdbs, binary=FALSE) vec <- rowSums(cm, na.rm=TRUE) pymol(pdbs, col="user", user.vec=vec) # color by clustering rd <- rmsd(pdbs$xyz) hc <- hclust(as.dist(rd)) grps <- cutree(hc, k=3) pymol(pdbs, col=grps) ##- pymol with a 'dccm' object ## Fetch stucture pdb <- read.pdb( system.file("examples/1hel.pdb", package="bio3d") ) ## Calculate normal modes modes <- nma(pdb) ## Calculate correlation matrix cm <- dccm.nma(modes) pymol(cm, modes$xyz) ##- pymol with a 'nma' or 'pca' object pymol(modes, mode=7) detach(transducin) }