| name | coot-essential-api |
| description | API documentation to be loaded at startup - when starting a Coot session, immediately call get_function_descriptions() with the functions listed in this skill. |
Coot Essential API Functions
This document contains the core Coot API functions needed for typical validation and model-building workflows.
Reading these function signatures at session start eliminates the need for searching.
Setup & Configuration
coot.set_refinement_immediate_replacement(1)
coot.set_imol_refinement_map(imol_map)
Molecule Management
coot.is_valid_model_molecule(imol) -> int
coot.is_valid_map_molecule(imol) -> int
coot.molecule_name(imol) -> str
coot.n_chains(imol) -> int
coot.coot_version() -> str
coot.load_tutorial_model_and_data()
coot.network_get_accession_code_entity(pdb_accession_code, mode)
Checkpoints - Model State Management
When experimenting with the various model building tools available to
address a particular model-building problem it is useful to create
backup checkpoints. This allows you to return to a particular state,
so that you can try alternative model-building parameters or
functions, or combinations of functions.
coot.make_backup_checkpoint(imol, description_string) -> int
checkpoint_idx = coot.make_backup_checkpoint(0, "before rotamer fix")
coot.auto_fit_best_rotamer(0, "A", 42, "", "", 1, 1, 0.01)
if not improved:
coot.restore_to_backup_checkpoint(0, checkpoint_idx)
coot.restore_to_backup_checkpoint(imol, checkpoint_index)
coot.compare_current_model_to_backup(imol, checkpoint_index) -> dict
Chain and Residue Information
coot_utils.chain_ids(imol) -> list
coot.chain_id_py(imol, chain_index) -> str
Secondary Structure Information
coot.get_header_secondary_structure_info(imol) -> dict
ss = coot.get_header_secondary_structure_info(0)
if 'strands' in ss:
for strand in ss['strands']:
print(f"Strand {strand['strandNo']}: {strand['initSeqNum']}-{strand['endSeqNum']}")
Navigation
coot.set_go_to_atom_chain_residue_atom_name(chain_id, resno, atom_name) -> int
coot.closest_atom_simple_py() -> list
coot.closest_atom_py(imol) -> list
coot.active_atom_spec_py() -> list
Residue Inspection
coot.residue_info_py(imol, chain_id, resno, ins_code) -> list
atoms = coot.residue_info_py(0, "A", 72, "")
atom_names = [a[0][0].strip() for a in atoms]
print(f"Atoms present: {atom_names}")
expected_atoms = {
'CYS': ['N', 'CA', 'CB', 'SG', 'C', 'O'],
'ILE': ['N', 'CA', 'CB', 'CG1', 'CG2', 'CD1', 'C', 'O'],
'GLY': ['N', 'CA', 'C', 'O'],
'PHE': ['N', 'CA', 'CB', 'CG', 'CD1', 'CD2', 'CE1', 'CE2', 'CZ', 'C', 'O'],
}
res_type = coot.residue_name_py(0, "A", 72, "")
if res_type in expected_atoms:
missing = [a for a in expected_atoms[res_type] if a not in atom_names]
if missing:
print(f"WARNING: Missing atoms in {res_type}: {missing}")
Validation - Density Fit
coot.map_to_model_correlation_stats_per_residue_range_py(
imol,
chain_id,
imol_map,
n_per_range,
exclude_NOC
) -> list
stats = coot.map_to_model_correlation_stats_per_residue_range_py(0, "A", 1, 1, 0)
all_atom = stats[0]
worst = sorted(all_atom, key=lambda x: x[1][1])[:5]
coot.map_to_model_correlation_py(imol, residue_specs, neighb_specs, atom_mask_mode, imol_map)
sigma = coot.map_sigma_py(imol_map)
d = coot.density_at_point(imol_map, x, y, z) / sigma
Validation - Geometry
coot.all_molecule_ramachandran_score_py(imol) -> list
coot.rotamer_graphs_py(imol) -> list
coot.molecule_atom_overlaps_py(imol, n_pairs) -> list
Validation - Unmodeled Density
coot.find_blobs_py(imol_model, imol_map, sigma_cutoff) -> list
Validation - Hydrogen Bonds
coot.get_hydrogen_bonds_py(imol, selection_1, selection_2, mcdonald_and_thornton) -> list
hbonds = coot.get_hydrogen_bonds_py(0, "//A/35", "//A", 0)
for hb in hbonds:
donor = hb[1]
acceptor = hb[2]
dist = hb[8]
d_str = donor['chain'] + " " + donor['residue_name'] + " " + donor['name'].strip()
a_str = acceptor['chain'] + " " + acceptor['residue_name'] + " " + acceptor['name'].strip()
print("H-bond: " + d_str + " -> " + a_str + " dist=" + str(dist))
Refinement
coot.refine_residues_py(imol, residue_specs) -> list
Model Building - Rotamers
coot.auto_fit_best_rotamer(
imol,
chain_id,
resno,
ins_code,
altloc,
imol_map,
clash_flag,
lowest_probability
) -> float
Model Building - Backbone
coot.pepflip(imol, chain_id, resno, ins_code, altloc)
CRITICAL: Always Render Validation Results as Interactive SVG Widgets
When presenting validation results, geometry analysis, per-atom density data, or any
tabular data about multiple residues, ALWAYS render an interactive SVG widget using
visualize:show_widget. Never just print a wall of text.
The user can click on each residue block to navigate directly to it in Coot or trigger
a fix. This is far more useful than stdout and makes results immediately actionable.
When to render a widget — trigger situations:
- After running full validation (Ramachandran, rotamers, density fit, clashes, geometry)
- After a per-atom backbone density probe scan
- After any survey comparing multiple residues or chains
- After a before/after fix comparison showing improvement
- Any time there are more than ~5 residues worth of results to show
Severity colour coding:
c-red — severe issues (Rama score < 0.001, rotamer 0%, corr < 0.3, omega > 20° off)
c-amber — moderate issues (Rama 0.001–0.01, rotamer < 5%, corr 0.3–0.65)
c-gray — informational / OK residues
c-teal — unmodelled density blobs / features to investigate
c-green — successfully fixed residues (before/after comparisons)
onclick patterns — make them actionable, not just informational:
onclick="sendPrompt('Go to A/41 GLU and show me the density')"
onclick="sendPrompt('Go to B/257 GLU and investigate — negative correlation')"
onclick="sendPrompt('Fix the clash between A/2 CA and A/89 CZ')"
onclick="sendPrompt('Try pepflip at B/262 and refine')"
onclick="sendPrompt('Fix rotamer A/32 GLN — 0% score')"
onclick="sendPrompt('Go to A/260 ALA — worst Ramachandran in chain A')"
The onclick prompt should describe the action to take, not just what the residue is.
A user clicking a red block should trigger the next useful step automatically.
Minimal widget template for validation results:
<svg width="100%" viewBox="0 0 680 [H]">
<text class="th" x="40" y="28">Ramachandran outliers</text>
<g class="node c-red" onclick="sendPrompt('Go to A/41 GLU and investigate Ramachandran outlier')">
<rect x="40" y="38" width="280" height="50" rx="8" stroke-width="0.5"/>
<text class="th" x="180" y="57" text-anchor="middle" dominant-baseline="central">A/41 GLU</text>
<text class="ts" x="180" y="74" text-anchor="middle" dominant-baseline="central">score 0.00004 phi=112°</text>
</g>
<g class="node c-amber" onclick="sendPrompt('Go to A/35 VAL and investigate')">
<rect x="340" y="38" width="280" height="50" rx="8" stroke-width="0.5"/>
<text class="th" x="480" y="57" text-anchor="middle" dominant-baseline="central">A/35 VAL</text>
<text class="ts" x="480" y="74" text-anchor="middle" dominant-baseline="central">score 0.006</text>
</g>
</svg>
Geometry widget — always include ideal, actual, Z score:
For bond/angle/omega distortions, display as rows with severity colour. Omega torsion
outliers (|omega − 180°| > 15°) are the most sensitive backbone diagnostic and should
always be highlighted — they identify misplaced backbone immediately.
<g class="node c-red" onclick="sendPrompt('Go to A/259 SER and investigate distorted backbone')">
<rect x="36" y="50" width="600" height="22" rx="4" stroke-width="0.5"/>
<text class="ts" x="40" y="65">A/258→A/259 omega</text>
<text class="ts" x="380" y="65">60.0° (ideal 180°)</text>
<text class="ts" x="510" y="65" style="fill:#A32D2D">+24.0σ distorted!</text>
</g>
Typical Validation & Fix Workflow
coot.set_refinement_immediate_replacement(1)
for i in range(10):
if coot.is_valid_model_molecule(i):
print(f"Model {i}: {coot.molecule_name(i)}")
if coot.is_valid_map_molecule(i):
print(f"Map {i}: {coot.molecule_name(i)}")
stats = coot.map_to_model_correlation_stats_per_residue_range_py(0, "A", 1, 1, 0)
worst = sorted(stats[0], key=lambda x: x[1][1])[:10]
overlaps = coot.molecule_atom_overlaps_py(0, 30)
severe = [o for o in overlaps if o['overlap-volume'] > 5.0]
coot.auto_fit_best_rotamer(0, "A", 89, "", "", 1, 1, 0.01)
coot.refine_residues_py(0, [["A", 89, ""]])
coot.pepflip(0, "A", 41, "", "")
coot.refine_residues_py(0, [["A", 40, ""], ["A", 41, ""], ["A", 42, ""]])
overlaps_after = coot.molecule_atom_overlaps_py(0, 10)
Important Notes
- Always call
set_refinement_immediate_replacement(1) first - makes refinement synchronous
- Use
coot.*_py() functions directly - faster than coot_utils wrappers
- Import coot_utils only when needed - for convenience functions like
chain_ids()
- The
coot module is auto-imported - no import statement needed