| name | protein-structure-basics |
| description | Use when visualizing protein structures, showing secondary structure, coloring by B-factor, creating surface representations, or generating basic structural figures through PyMOL. |
| version | 0.1.0 |
Protein Structure Basics
Fundamental workflows for visualizing protein structures.
Send all cmd.* code via: ~/.pymol-agent-bridge/bin/pymol-agent-bridge exec "..." (or heredoc for multi-line). See @pymol-fundamentals for details.
Representations
Cartoon (Most Common)
cmd.hide("everything")
cmd.show("cartoon")
Surface
cmd.show("surface")
cmd.set("transparency", 0.5)
Sticks (Sidechains)
cmd.show("sticks", "resi 50-60")
cmd.show("cartoon")
cmd.show("sticks", "sidechain")
Spheres (CPK)
cmd.show("spheres")
cmd.set("sphere_scale", 0.3)
Ribbon
cmd.show("ribbon")
Coloring
By Secondary Structure
cmd.color("marine", "ss h")
cmd.color("tv_orange", "ss s")
cmd.color("gray70", "ss l+")
By Chain
cmd.util.cbc()
cmd.color("green", "chain A")
cmd.color("cyan", "chain B")
By B-factor (Flexibility/Disorder)
cmd.spectrum("b", "blue_white_red", "all")
By Residue Type
cmd.color("yellow", "resn ALA+VAL+LEU+ILE+MET+PHE+TRP+PRO")
cmd.color("cyan", "resn SER+THR+ASN+GLN+TYR+CYS")
cmd.color("blue", "resn ARG+LYS+HIS")
cmd.color("red", "resn ASP+GLU")
Rainbow (N to C terminus)
cmd.spectrum("count", "rainbow", "polymer.protein")
Structure Analysis
Count Residues by Secondary Structure
total = cmd.count_atoms("name CA")
helix = cmd.count_atoms("name CA and ss h")
sheet = cmd.count_atoms("name CA and ss s")
loop = cmd.count_atoms("name CA and ss l+")
print(f"Total: {total}")
print(f"Helix: {helix} ({100*helix/total:.1f}%)")
print(f"Sheet: {sheet} ({100*sheet/total:.1f}%)")
print(f"Loop: {loop} ({100*loop/total:.1f}%)")
List Chains
chains = cmd.get_chains()
for chain in chains:
count = cmd.count_atoms(f"chain {chain} and name CA")
print(f"Chain {chain}: {count} residues")
Publication Settings
cmd.bg_color("white")
cmd.set("ray_shadows", 0)
cmd.set("spec_reflect", 0.2)
cmd.set("ambient", 0.5)
cmd.set("antialias", 2)
cmd.set("ray_trace_mode", 1)
cmd.set("cartoon_fancy_helices", 1)
cmd.set("cartoon_smooth_loops", 1)
Complete Workflow
Standard Protein Figure Set
cmd.delete("all")
cmd.fetch("1ema")
cmd.remove("solvent")
cmd.hide("everything")
cmd.show("cartoon")
cmd.color("marine", "ss h")
cmd.color("tv_orange", "ss s")
cmd.color("gray70", "ss l+")
cmd.bg_color("white")
cmd.set("ray_shadows", 0)
cmd.set("spec_reflect", 0.2)
cmd.set("ambient", 0.5)
cmd.set("antialias", 2)
cmd.set("ray_trace_mode", 1)
cmd.set("cartoon_fancy_helices", 1)
cmd.orient()
cmd.ray(1200, 900)
cmd.png("protein_overview.png")
cmd.spectrum("b", "blue_white_red", "all")
cmd.ray(1200, 900)
cmd.png("protein_bfactor.png")
cmd.color("marine", "ss h")
cmd.color("tv_orange", "ss s")
cmd.color("gray70", "ss l+")
cmd.turn("y", 90)
cmd.ray(1200, 900)
cmd.png("protein_side.png")
Tips
- Always use
cmd.ray(w, h) then cmd.png(path) without dimensions
ss h = helix, ss s = sheet/strand, ss l+ = loop/coil
- B-factor visualization helps identify flexible regions and potential disorder
- Multiple views (front, side, top) tell a more complete story
- Consider showing key functional residues as sticks on top of cartoon