Publication Protein Figure Illustration (Flat-Silhouette Style)
Produces multi-panel, flat-shaded, silhouette-outlined structural biology
figures (like Larsen et al., PNAS 2026, 10.1073/pnas.2529505123, Panels E, F,
and G) using headless PyMOL (pymol-open-source-whl via uv run) and a
Matplotlib vector-annotation layer that exports both 300 DPI PNG and editable
SVG.
Prerequisites
uvinstalled and onPATH.- PyMOL License Notice: If
.licenses/pymol_LICENSE.txtdoes not exist in the project root, notify the user to check the PyMOL license at https://www.pymol.org/ and create.licenses/pymol_LICENSE.txtwith the notice and timestamp. Always mention PyMOL when used. - A local
.pdbor.cifstructure file (fetch first usingpdb-databaseoralphafold-database-fetch-and-analyzeif needed), and optionally a CSV table of per-residue scores (such as DMS effects, antibody escape, conservation, or pLDDT).
Core Visual System
Read references/STYLE_GUIDE.md for the exact
PyMOL settings, multi-chain color palettes, and equivalent ChimeraX .cxc
commands. Summary of the visual rules:
- Lighting: Flat, bright, shadowless (
ambient = 0.94,direct = 0.16,specular = 0,ray_shadows = 0,orthoscopic = 1,depth_cue = 0). - Outlines: Crisp dark charcoal silhouettes (
ray_trace_mode = 1,ray_trace_color = 0x242424,ray_trace_gain = 0.004,antialias = 2). Render panels between900 pxand1200 pxwide so outline thickness stays balanced at 300 DPI. - Per-chain white-to-hue ramps: Assign each chain its own sequential palette
where neutral or tolerant values map cleanly to
#FFFFFF(starting around 78% to 85% of the range) so hotspots stand out clearly. - Interface close-ups:
- Background partner: Molecular surface (either opaque flat-shaded or softly translucent via two-pass compositing so silhouettes stay crisp).
- Foreground motif: Uniform cylindrical tube (
cartoon tube,cartoon_tube_radius = 0.52,cartoon_discrete_colors = 1) plus sidechain-only sticks (cartoon_side_chain_helper = 1,stick_radius = 0.16).
- Vector overlays: Rounded color-coded pill badges (bold white sans-serif
text, no border), thin
0.8 ptstraight charcoal leader lines anchored to mathematically projected 3D residue centroids, bracketed grouped domain callouts, stacked horizontal multi-chain colorbar legends,90°rotation glyphs, and white-silhouette context mini-maps with black zoom frames.
Workflow
Step 1: Inspect Structure and Score Data
Verify the structure file exists, inspect its chain IDs, residue numbering, and
score range (vmin, vmax), and identify the key residues or domain interfaces
to call out. Remove waters, hydrogens, and irrelevant heteroatoms unless a
bound ligand or glycan is part of the figure.
Step 2: Render Panels and Project 3D Anchors
Import helpers from scripts/render_protein_panels.py
in a PEP 0723 PyMOL script run via uv run:
- Initialize headless PyMOL (
PYOPENGL_PLATFORM=osmesa,pymol.pymol_argv = ["pymol", "-cq"],pymol.finish_launching()). - Load structure and verify
cmd.count_atoms("all") > 0. - Call
apply_goodsell_flat_style(cmd)andcolor_chains_from_scores(cmd, obj, scores, chain_ramps, vmin, vmax). - Align symmetry or principal axes cleanly (for symmetric oligomers, align the
symmetry axis to
+ZsoTop viewandSide vieware exact 90-degree rotations). - Render each panel as a transparent PNG (
ray=1) and record projected 2D anchors withget_projected_anchors(cmd, targets, width, height)intoanchors.json:- Full-structure views: Opaque
surfacewithray_trace_mode = 1. - Translucent pocket + opaque motif zoom: Use
render_two_pass_translucent_interface(...)so the translucent surface keeps crisp silhouette outlines. - Context mini-map: Color bystander chains
white(outline-only silhouette), keep interacting chains colored, and compute the projected zoom bounding box of the interface residues.
- Full-structure views: Opaque
- Save a
.psesession file (and optionally export a matching.cxcscript withwrite_chimerax_cxc(...)) and callcmd.quit().
Step 3: Compose Publication Figure (PNG + Editable SVG)
Import vector helpers from
scripts/compose_protein_figure.py in a
Matplotlib script run via uv run:
draw_stacked_legend(...)for compact multi-chain horizontal colorbars.draw_rotation_90(...)for clean 90-degree rotation glyphs between views.load_image_in_ax(...)to place transparent renders and obtainuv_to_ax.draw_pill(...)anddraw_grouped_pills(...)for chain-colored rounded pill callouts and bracketed domain lists.place_noncrossing_perimeter_pills(...)for automatic angular sorting around zoomed interface panels so leader lines never cross.draw_zoom_box(...)to overlay the exact projected zoom rectangle onto the context mini-map.
Save both *.png (300 DPI) and *.svg (editable in Illustrator or Inkscape).
Step 4: Visual Verification and Iteration
Always open the rendered panels and the final composed PNG with read_file to
check:
- Color contrast (tolerant regions stay clean white; hotspots pop vividly).
- Camera framing (no clipped surfaces or awkward helix-on-end angles).
- Leader lines (zero unintended crossings; every line lands on its exact named
residue and on a camera-facing, unoccluded surface atom rather than a buried
back-face residue; verify
zcamera depth inanchors.jsonand audit every residue name/number against the PDB/CIF file). - Label spacing (no overlapping pills, headers, or terminus numbers).
Iterate on camera vectors, ramp stops, or pill coordinates until the composed figure is clean and balanced.