Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

coot-refinement

FreeNo executable scriptsNot checked

Best practices for protein structure refinement and validation in Coot. Use when performing (1) Residue refinement operations, (2) Model building and fitting…

pemsleyby pemsley★ 174 GitHub stars20 installs in other catalogs

About this skill

Coot Refinement Best Practices

This skill provides guidance for effective and safe structure refinement in Coot, based on lessons learned from crashes and workflow optimization.

Critical Configuration

Set Immediate Replacement Mode for Scripting

ALWAYS call these two before any refinement operations in scripts:

coot.set_refinement_immediate_replacement(1)
# Makes refinement synchronous — results are committed immediately.

coot.set_imol_refinement_map(imol_map)
# Tells Coot which map to refine against.
# CRITICAL: without this, refine_residues_py() silently fails (returns -2 with no atoms moved).
# Call once per session, or whenever the active map changes.

Why: Enables synchronous operation where refinement directly updates coordinates. Without this:

  • Refinement happens asynchronously in background threads
  • Need to call coot.set_refinement_immediate_replacement() before using refinement functions (just once is enough) which should remove the risk of threading conflicts and crashes, race conditions between refinement and rendering.

When to use: Any time you're scripting refinement operations (refine_residues_py, refine_zone, etc.)

Updating Maps

Rule: if a map has attached data (Fobs, sigFobs, rfree from an MTZ file) and the model is unambiguous, use updating maps. The difference map must be assigned too.

  • Test for attached data: coot.refmac_parameters_py(imol_map) returns [mtz, F, phi, weight, use_weights, is_diff, have_params, fobs, sigfobs, rfree, sensible], or [] if nothing is attached.
  • Make maps that carry the data: coot.make_and_draw_map_with_refmac_params(mtz, F, phi, weight, use_weights, is_diff, 1, fobs, sigfobs, rfree, 1). Do this for FWT/PHWT (2Fo-Fc) and for DELFWT/PHDELWT (difference).
  • Bind them: coot.set_auto_updating_sfcalc_genmaps(imol_model, imol_map_with_data, imol_2fofc, imol_diff).
  • Never pass a target map without refmac params to sfcalc_genmap (it crashed Coot).
  • Updating maps follow edits and checkpoint restores. To confirm an edit reached the maps, sample density_at_point in the difference map before and after, at the changed atoms. Do not rely on map_sigma_py changing.

CRITICAL: check the refinement map after creating maps

After maps were created, coot.imol_refinement_map() silently became the DIFFERENCE map. Refining against it degrades the fit, and every rotamer or peptide-flip trial run in that state is invalid.

  • Call coot.set_imol_refinement_map(imol_2fofc) after any map creation, and print coot.imol_refinement_map() before refining.
  • Sanity check: refining a well-fitted ligand against the right map moves its atoms only ~0.02 A. If a refinement lowers the density fit of something that fitted well, check the refinement map first.
  • Make a checkpoint before each trial and restore if the metric worsens.

Safe Refinement Workflow

# 1. Enable immediate replacement
coot.set_refinement_immediate_replacement(1)

# 2. Set the refinement map
coot.set_imol_refinement_map(imol_map)

# 3. Refine residues (preferred method)
# Pass a list of residue specs: [["A", 42, ""], ["A", 43, ""], ...]
residue_specs = [["A", resno, ""] for resno in range(start_resno, end_resno + 1)]
result = coot.refine_residues_py(imol, residue_specs)

# 4. so-called "sphere refine" is often useful because it allows movement/improvement
# of residues that are close in space but distant in sequence.
central_residue_spec = ['A', 12, '']
neighbours = coot.residues_near_residue_py(imol, central_residue_spec, 4.5)  # radius in Angstroms
residue_specs = neighbours + [central_residue_spec]
result = coot.refine_residues_py(imol, residue_specs)

Hard-Mode-Soft-Mode-Hard-Mode

Some problems are of the kind where the geometry restraints "get in the way" of the atoms moving to the correct minimum. In such cases, you can try letting the refinement "go soft" - ie.

o Mediocre Refinement o increase the map weight (weight_matrix) by a factor of 10 or so. o Refine the same residues again o Restore the previous map weight o Refine the same residues again

This can sometimes be helpful to remove bad geometry or bad fit - atom clashes in particular.

Additionally, or perhaps at the same time, you can try to reduce LJ epsilon using coot.set_refinement_lennard_jones_epsilon() by a factor of 100 or so. And then restore it and re-refine the same residues.

Zone Refinement

# Enable immediate replacement
coot.set_refinement_immediate_replacement(1)

# Refine zone
coot.refine_zone(
    imol,
    chain_id,
    start_resno,
    end_resno,
    ""  # alt conf
)

Validation and Correlation

Check Residue Quality

# Per-residue density correlation for a chain (1 residue per range, all atoms)
all_atom, _sidechain = coot.map_to_model_correlation_stats_per_residue_range_py(
    imol, chain_id, imol_map, 1, 0)
# Each entry is [[chain_id, resno, ins_code], [n_points, correlation]]

# Worst-fitting residues:
Full SKILL.md on GitHub

Install coot-refinement in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the coot-refinement skill do?

Best practices for protein structure refinement and validation in Coot. Use when performing (1) Residue refinement operations, (2) Model building and fitting, (3) Rotamer fixing, (4) Scripted/automated refinement workflows, (5) Validation and correlation checking.

How do I install the coot-refinement skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the coot-refinement skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare coot-refinement with