PyMOL Commands Cheat Sheet: The Essential Reference for Structural Biologists

PyMOL Commands Cheat Sheet: The Essential Reference for Structural Biologists

Every PyMOL command you’ll reach for regularly — organized by task, not alphabetically. Bookmark this page and keep it open alongside PyMOL while you work.

How to use this reference
All commands are entered in the PyMOL command line at the bottom of the External GUI window. Arguments in [ ] are optional. selection can be any named selection, object name, or selection expression like chain A or resi 100-150.

Loading & fetching

CommandWhat it does
fetch 4XYZDownload structure from RCSB PDB and load it
fetch 4XYZ, nameFetch and assign a custom object name
load protein.pdbLoad a local PDB file
load traj.xtc, proteinLoad an MD trajectory into an existing object
load_traj traj.dcd, proteinAlternative trajectory loading (DCD format)
delete allRemove all loaded objects
delete object_nameRemove a specific object
reinitializeReset PyMOL to a completely clean state
CommandWhat it does
zoom [selection]Fit the view to the selection (or everything)
orient [selection]Orient along principal axes of the selection
center [selection]Center the view on a selection without zooming
resetReset camera to default position
get_viewPrint the current view matrix — copy to reproduce later
set_view (matrix)Restore a previously saved view matrix
turn x, 90Rotate 90° around the x-axis (also y, z)
rotate x, 45, objectRotate a specific object by 45° around x
clip near, -5Adjust near clipping plane
clip far, 5Adjust far clipping plane

Selections

The backbone of everything in PyMOL. Every command operates on a selection.
Command / syntaxWhat it does
Creating selections
select name, expressionCreate a named selection from an expression
select site, chain A and resi 100-150Select residues 100–150 of chain A
select pocket, byres (LIG around 5)Select all residues within 5 Å of LIG
select iface, chain A and (byres chain B around 4)Interface residues of chain A near chain B
Selection keywords
chain AAll atoms in chain A
resi 100-150Residue numbers 100 through 150
resi 100+150+273Specific residue numbers (use + to list)
resn LYSAll lysine residues (3-letter code)
name CAAlpha carbon atoms only
elem CAll carbon atoms
hetatmHeteroatoms (ligands, waters, ions)
resn HOHWater molecules only
b > 70Atoms with B-factor above 70 (pLDDT for AF)
Boolean operators
chain A and resi 100Residue 100 in chain A specifically
chain A or chain BBoth chains A and B
not resn HOHEverything except water
sel1 within 5 of sel2Atoms in sel1 within 5 Å of sel2
byres (sel around 5)Complete residues with any atom within 5 Å

Display modes

CommandWhat it does
show — add a representation
show cartoon [, sel]Ribbon cartoon for protein backbone
show sticks [, sel]All bonds as sticks — for residues and ligands
show lines [, sel]Thin line bonds — lightweight background display
show spheres [, sel]Space-filling (van der Waals) representation
show surface [, sel]Molecular surface
show dots [, sel]Dot surface (accessible surface area)
show mesh [, sel]Wireframe mesh surface
show nb_spheres [, sel]Non-bonded atoms as small spheres (ions)
hide — remove a representation
hide everything [, sel]Remove all representations
hide cartoon [, sel]Remove cartoon only
hide everything, resn HOHRemove water molecules from view
as — show only this representation
as cartoonCartoon only — hides everything else
as sticks, selectionSticks only for the selection
as spheres, resn LIGSpace-filling for ligand only

Coloring

CommandWhat it does
color red [, sel]Single color — named colors: red, blue, green, white, slate, marine, wheat…
util.cbc [sel]Color by chain — each chain gets a distinct color
util.cbs [sel]Color by secondary structure (helix/sheet/loop)
util.cbaw [sel]Color by atom type — classic CPK scheme, white carbons
util.cbag [sel]Color by atom type — green carbons (ligand standard)
spectrum b, blue_redSpectrum by B-factor (pLDDT in AlphaFold structures)
spectrum b, blue_cyan_yellow_orange_red, min=50, max=100AlphaFold pLDDT color scale (blue=confident, red=disordered)
spectrum count, rainbowN→C terminus rainbow coloring
spectrum resi, blue_redGradient from first to last residue
set_color myblue, [0.1, 0.4, 0.8]Define a custom color with RGB values (0–1 scale)
color myblue, chain AApply custom color to a selection

Surfaces

CommandWhat it does
show surfaceDisplay molecular surface for all objects
set transparency, 0.5Make surface 50% transparent (0=opaque, 1=invisible)
set surface_quality, 1Higher quality surface (default 0; use 2 for publication)
set surface_color, whiteForce surface to a single color regardless of atom colors
set solvent_radius, 1.4Probe radius for surface (default 1.4 Å)
show surface, pocketSurface for a named selection only
hide surface, resn HOHRemove surface for water molecules

Analysis & measurements

CommandWhat it does
distance d1, atom1, atom2Draw and display distance between two atoms
distance hbonds, sel1, sel2, mode=2Show H-bonds between two selections
distance contacts, sel1, sel2, 4All contacts within 4 Å between selections
angle a1, atom1, atom2, atom3Measure bond angle
dihedral d1, a1, a2, a3, a4Measure dihedral angle between four atoms
hide labelsHide all distance/angle labels (keep the lines)
get_area selectionCalculate solvent-accessible surface area
iterate selection, print(resi, resn, b)Print per-residue data (B-factor, residue info)
centerofmass selectionCalculate and print center of mass coordinates

Alignment & RMSD

CommandWhat it does
align mobile, referenceSequence-aware alignment — best when sequences are similar
super mobile, referenceStructure-based alignment — ignores sequence, good for distant homologs
cealign mobile, referenceCE algorithm — best for different fold topologies
align mobile and chain A, reference and chain AAlign on specific chains only
rms_cur mobile and backbone, reference and backboneCalculate backbone RMSD without moving structures
pair_fit atom1, atom2, atom3, atom4Align based on specific atom pairs

Labels & annotations

CommandWhat it does
label selection, “text”Add a static text label to a selection
label selection, resn+resiLabel each residue with its name and number
label name CA, “%s%s” % (resn, resi)Label alpha carbons with residue identity
set label_size, 14Change label font size
set label_color, blackChange label color
hide labels [, sel]Hide all labels for a selection
set label_position, [0, 0, 2]Offset label position (x, y, z in Å)

Saving & export

CommandWhat it does
Saving images
ray [width, height]Ray trace the current view (high quality render)
ray 1200, 900Ray trace at 1200×900 pixels
png filename.png, dpi=300Export the ray-traced image at 300 DPI
png filename.png, width=1200, height=900, dpi=300, ray=1Ray trace and export in one command
set ray_opaque_background, 1White background (set before ray)
bg_color whiteSet background color to white
Saving sessions and structures
save session.pseSave full PyMOL session (all objects, views, settings)
load session.pseRestore a saved session
save output.pdb [, selection]Export coordinates as PDB (optionally, just a selection)
save output.cif [, selection]Export as mmCIF format
log_open commands.pmlStart recording all commands to a script file
log_closeStop recording commands
@script.pmlRun a saved .pml script file

Useful settings

Setting commandEffect
set cartoon_fancy_helices, 1Rounded ribbon helices — standard for publications
set cartoon_smooth_loops, 1Smooth loop interpolation
set cartoon_tube_radius, 0.4Thinner loop tubes (default 0.5)
set stick_radius, 0.15Thinner sticks (default 0.25) — useful for ligands
set sphere_scale, 0.25Smaller spheres (useful for ball-and-stick)
set ambient, 0.4Ambient light level — higher = softer shadows
set specular, 0.3Shininess — lower = more matte
set light_count, 4Number of lights — more = smoother shading
set depth_cue, 0Disable distance fog / depth cueing
set ray_shadow, 1Enable shadows during ray trace
set antialias, 2Anti-aliasing level for ray trace (1–4)

Quick workflows

New structure — starting sequence
fetch 4XYZ
as cartoon
hide everything, resn HOH
util.cbc
zoom
AlphaFold pLDDT coloring
load AF-P04637-F1-model_v4.pdb
as cartoon
spectrum b, blue_cyan_yellow_orange_red, minimum=50, maximum=100
bg_color white
Binding site figure
fetch 4XYZ
as cartoon
hide everything, resn HOH
color slate, protein
util.cbag LIG                   # green carbons for ligand
select site, byres (LIG around 5)
show sticks, site
show surface, site
set transparency, 0.4
zoom site
Publication figure export
bg_color white
set ray_opaque_background, 1
set cartoon_fancy_helices, 1
set ambient, 0.4
set specular, 0.3
ray 1200, 900
png figure1a.png, dpi=300
Align two structures and calculate RMSD
fetch 4XYZ
fetch 5ABC
align 5ABC, 4XYZ              # aligns and reports RMSD
zoom
Save every session before closing
PyMOL doesn’t auto-save. Before closing, run save session.pse — the PSE file captures everything: loaded structures, selections, colors, measurements, and the current view. Loading the PSE later restores the exact state. Get in the habit of saving PSE files the way you save documents.

The 10 commands you’ll use every day

fetch · as cartoon · hide everything, resn HOH · util.cbc · select · color · show sticks · zoom · get_view · ray + png. Learn these ten cold and every other PyMOL task becomes a variation on a pattern you already know.

Last updated on

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *