PyMOL Selections: A Complete Guide with Examples
Selections are the foundation of everything in PyMOL. Every command — coloring, showing, hiding, measuring, labeling — targets a selection. Master the selection syntax and every other PyMOL task becomes straightforward.
Anatomy of a selection command
Every PyMOL selection has the same structure: a command, an optional name for the selection, and a selection expression that describes which atoms to include.
select — creates a named selection. Other commands like color, show, hide use the same expression syntax.
The selection expression is the part that varies. It can be as simple as chain A or as complex as byres ((chain A and resi 200-300) within 5 of chain B). Everything else is just combinations of the keywords and operators covered in this guide.
Core selection keywords
resi 100+150+273resn LIG for ligands, resn HOH for watername CA = alpha carbons, name N+CA+C+O = backboneelem N = all nitrogens, elem S = all sulfursh=helix, s=sheet, l=loop (or "" for unassigned)polymer*Selecting by chain
Chain selections are the most common starting point for any multi-chain structure. Chain identifiers are case-sensitive — chain A and chain a are different.
# Single chain
select receptor, chain A
# Multiple chains (use or)
select both_chains, chain A or chain B
# Everything except a specific chain
select not_water_chain, not chain W
# Chain + residue range combined
select domain, chain A and resi 50-200
# Color directly without creating a named selection
color slate, chain A
color salmon, chain B
Selecting by residue
Residue selections target specific positions in the sequence. resi takes residue numbers; resn takes three-letter residue names.
# Contiguous range
select loop, resi 100-120
# Non-contiguous list (use +)
select active_site, resi 175+248+249+273
# By residue name (3-letter code)
select all_lys, resn LYS
select charged, resn LYS+ARG+ASP+GLU
# Waters
select waters, resn HOH
hide everything, resn HOH # common: remove waters from view
# Combine residue number and name for precision
select key_arg, resn ARG and resi 273 and chain A
resi selects by residue number (position in the sequence). resn selects by residue name (amino acid type). resi 100 picks the 100th residue regardless of what it is. resn LYS picks every lysine regardless of where it is. Combine them when you need one specific residue at one specific position.
Selecting by atom type and element
Atom-level selections are useful for showing specific parts of residues — the backbone only, just the side chains, or specific functional groups in a ligand.
# Backbone atoms only
select backbone, name N+CA+C+O
# Alpha carbons only (lightest representation of structure)
select ca_only, name CA
# Side chains only (exclude backbone)
select sidechains, not name N+CA+C+O and polymer
# Heteroatoms (non-hydrogen atoms in ligands)
select ligand_heavy, hetatm and not resn HOH
# By element
select all_sulfurs, elem S
select metals, elem ZN+MG+CA+FE+MN
# B-factor threshold (pLDDT in AlphaFold)
select confident, b > 70
select disordered, b < 50
Distance-based selections
Distance selections are among PyMOL's most powerful features. They let you select atoms based on their spatial proximity to other atoms — essential for binding site analysis, interface identification, and contact mapping.
# All atoms within 5 Å of the ligand
select near_lig, ligand around 5
# Complete residues with any atom within 5 Å of ligand
select binding_site, byres (ligand around 5)
# Interface residues: chain A atoms within 4 Å of chain B
select iface_A, chain A and (byres chain B around 4)
select iface_B, chain B and (byres chain A around 4)
# within syntax (equivalent to around, preferred in some contexts)
select close, protein within 5 of ligand
# Expand an existing selection by a radius
select expanded, byres (active_site expand 3)
around N and within N of select individual atoms within N ångströms. byres (...) expands the result to include complete residues if any atom from that residue is within range. For binding site analysis, always use byres — showing partial residues in a binding site figure looks wrong and makes measuring interactions harder.
Boolean operators — and, or, not
chain A and resi 100 = only residue 100 in chain A.chain A or chain B = all atoms in A and B combined.not resn HOH = everything except water molecules.# AND: must satisfy both conditions
select specific, chain A and resi 100-200 and ss h
# OR: satisfies either condition
select both_ends, resi 1-20 or resi 380-400
# NOT: everything except the condition
select no_water, not resn HOH
select no_backbone, polymer and not name N+CA+C+O
# Combining all three
select complex, (chain A or chain B) and not resn HOH and b > 50
# Parentheses control evaluation order
select interface, (chain A and byres chain B around 5) or \
(chain B and byres chain A around 5)
Named selections
Named selections — created with the select command — appear in the PyMOL object list as pink dashed outlines on the structure and can be reused in any subsequent command by name. This is the key workflow for complex figures: define your selections once, then reference them repeatedly.
# Create named selections for a binding site workflow
select LIG, resn LIG # the ligand
select pocket, byres (LIG around 5) # binding site residues
select h_donors, pocket and (elem N or elem O) # H-bond donors/acceptors
# Now use the named selections in commands
color slate, pocket
show sticks, pocket
util.cbag LIG
distance hbonds, LIG, pocket, mode=2
# Update an existing named selection
select pocket, byres (LIG around 6) # redefine with larger radius
# Delete a named selection
delete pocket
select vs show — what's the difference
# Use select when you'll reuse the set of atoms multiple times
select active_site, resi 175+248+273 and chain A
color red, active_site
show sticks, active_site
label active_site and name CA, resn+resi # reuse 3× — worth naming
# Use show directly for one-off display (no selection needed)
show sticks, resi 100 and chain A # one-off — just show it
color green, resi 100 and chain A
Real-world examples
fetch 4XYZ
as cartoon
hide everything, resn HOH
select LIG, hetatm and not resn HOH
select pocket, byres (LIG around 5)
show sticks, pocket
show sticks, LIG
color slate, pocket
util.cbag LIG
zoom pocket
load AF-P04637-F1-model_v4.pdb
as cartoon
select confident, b > 70
select uncertain, b >= 50 and b <= 70
select disordered, b < 50
color blue, confident
color yellow, uncertain
color red, disordered
fetch 1ACB
as cartoon
util.cbc
select iface_E, chain E and byres (chain I around 4)
select iface_I, chain I and byres (chain E around 4)
show sticks, iface_E or iface_I
distance contacts, iface_E, iface_I, 4
color tv_red, iface_E
color tv_blue, iface_I
zoom iface_E or iface_I
Selections in one paragraph
Every PyMOL command targets a selection expression. The six keywords you'll use in 90% of cases are chain, resi, resn, name, hetatm, and b. Combine them with and, or, and not to narrow, broaden, or exclude. Use byres (...around N) for binding sites — it returns complete residues rather than partial ones. Create named selections with select when you'll reuse the same set of atoms multiple times. Use the selection expression directly in show, color, hide, or distance for one-off commands. That's the entire selection system — everything else is combinations of these patterns.