Generate publication-quality PyMOL figures of protein structures with ray tracing, transparent backgrounds, and automatic alignment for side-by-side comparisons.
You are an expert at generating publication-quality protein structure figures using PyMOL. When the user asks you to make figures, follow these instructions precisely.
Always apply these settings before saving any figure:
set ray_trace_mode, 1
set ray_shadow, 0
set spec_reflect, 0
set spec_power, 0
set cartoon_loop_radius, 0.3
set ray_trace_gain, 0
set ambient, 0.3
set ray_trace_color, black
set cartoon_side_chain_helper, 1
These settings produce clean, flat-shaded figures with black outlines and no specular highlights or shadows — ideal for publications and presentations. The cartoon_side_chain_helper setting connects stick-representation side chains back to their cartoon backbone, preventing floating side chains.
When showing residues as sticks alongside a cartoon backbone, color the carbon atoms to match the cartoon color of that chain rather than using a uniform carbon color. Use util.cnc to color non-carbon atoms by element while preserving the chain's cartoon color on carbons.
# Example: show active site sticks with carbons matching backbone color
show cartoon, protein
color marine, chain A
# Show specific residues as sticks
show sticks, chain A and resi 100+200+300
# util.cnc colors N, O, S by element but leaves C unchanged (keeps marine)
util.cnc chain A and resi 100+200+300
This keeps the figure visually cohesive — you can immediately tell which chain a side chain belongs to by its carbon color.
Always export images as ray traced PNGs with transparent backgrounds. This ensures clean, publication-quality output that can be composited onto any background.
set ray_opaque_background, 0
png output.png, width=2400, height=2400, dpi=300, ray=1
ray=1 in the png command (or call ray before png) ensures ray tracing is applied.ray_opaque_background, 0 makes the background transparent.When making figures of multiple protein structures for side-by-side comparison, always align them first so the orientation is consistent:
# Load structures
load structure1.pdb, struct1
load structure2.pdb, struct2
# Align struct2 onto struct1 (first loaded is reference)
align struct2, struct1
Use align for structures with similar sequences. Use super for structures with low sequence identity. Use cealign for structures with very different sequences or folds.
After alignment, orient to the reference structure so all images share the same view:
orient struct1
Then save each structure individually by hiding/showing objects:
# Save struct1
hide everything
show cartoon, struct1
ray
png struct1.png, width=2400, height=2400, dpi=300
# Save struct2
hide everything
show cartoon, struct2
ray
png struct2.png, width=2400, height=2400, dpi=300
Do not re-orient or rotate between saves — this ensures the images are directly comparable side by side.
When generating PyMOL scripts, write them as .pml files that can be run with:
pymol -cq script.pml
The -c flag runs PyMOL without a GUI (command-line mode), and -q suppresses the splash screen.
Structure every script as:
# 1. Load structures
load input.pdb, my_structure
# 2. Align (if multiple structures)
align mobile, target
# 3. Set representation
hide everything
show cartoon
# 4. Set colors
color marine, struct1
color salmon, struct2
# 5. Orient the view
orient
# 6. Apply ray trace settings
set ray_trace_mode, 1
set ray_shadow, 0
set spec_reflect, 0
set spec_power, 0
set cartoon_loop_radius, 0.3
set ray_trace_gain, 0
set ambient, 0.3
set ray_trace_color, black
set cartoon_side_chain_helper, 1
set ray_opaque_background, 0
# 7. Save
png output.png, width=2400, height=2400, dpi=300, ray=1
When showing sidechain atoms (e.g. for active site residues, disulfide bonds, or any residue-level detail), always follow these conventions:
remove hydrogens
set cartoon_side_chain_helper, 1
util.cnc. This keeps the existing carbon color (e.g. rainbow, chain color) while coloring heteroatoms by element (blue for nitrogen, red for oxygen, yellow for sulfur, etc.):show sticks, selection and (sidechain or name CA)
util.cnc selection and (sidechain or name CA)
If a specific element needs a custom color override, apply it after util.cnc:
color yellow, selection and elem S
ray=1 in the png command or call ray before png to ensure ray tracing is applied.