The silent page awaits the waking dawn.
# -*- coding: utf-8 -*-
set_map_radius(25)
set_map_radius_em(25) # 解决界面记不住 EM map 半径的问题
set_map_sampling_rate(3.0) # 提高密度采样率
set_smooth_scroll_steps(3) # 缩短跳转动画步长,移动更利落
set_nomenclature_errors_on_read("auto-correct") # 自动修正命名错误,不再弹窗询问add_key_binding("Refine Active Residue", "r", lambda: manual_refine_residues(0))
add_key_binding("Tandem Refinement", "t", lambda: refine_tandem_residues())
add_key_binding("Go To Blob", "g", lambda: blob_under_pointer_to_screen_centre())def _tkb_toggle_environment_distances():
if show_environment_distances_state():
set_show_environment_distances(0)
add_status_bar_text("Residue Environment: OFF")
else:
set_show_environment_distances(1)
add_status_bar_text("Residue Environment: ON")
graphics_draw()
add_key_binding("Toggle Residue Environment", "e", lambda: _tkb_toggle_environment_distances())coot_toolbar_button("Measure distance", "do_distance_define()", icon_name="geom.svg")
coot_toolbar_button("Merge Molecules", lambda: _tkb_open_merge_molecules(), icon_name="merge-molecules.svg")
coot_toolbar_button("Delete Hydrogens", lambda: _tkb_delete_hydrogens(), icon_name="Trash-hydrogens-Andy_Trash_Can.svg")
coot_toolbar_button("Ramachandran Plot", lambda: _tkb_open_rama_plot(), icon_name="ramachandran.png")
coot_toolbar_button("Rotamer Analysis", lambda: _tkb_open_rotamer_analysis(), icon_name="rotamers.svg")
coot_toolbar_button("Density Fit", lambda: _tkb_open_density_fit(), icon_name="density-fit.svg")
No matter how many tools help you build a protein model, you still end up in Coot, checking it against the density by hand, one residue at a time.
I didn’t start tinkering with Coot to add anything fancy. I just wanted large cryo-EM maps to stop lagging. They tend to be big, and on my Mac the frame rate would drop so low that dragging the view felt awful. Then I found that reducing the EM map display radius (map_radius_em) made the view noticeably smoother. The catch? Save Preferences only remembers the X-ray map radius, not the EM one. I had to adjust it every time I restarted Coot.
That one annoyance got me looking into Coot’s startup settings, and there turned out to be a lot more to them than I expected. Coot’s documentation isn’t exactly easy to navigate, so plenty of people use it every day without realizing that nearly the entire interface and most interactions are accessible from Python. I started with the official template_key_bindings and noticed that plenty of everyday operations, like mutate, had no keyboard shortcut at all. I had to click through the interface every time. Then I found olibclarke/coot-trimmings, and that’s when I realized how much else I could customize: toolbar buttons, menus, color schemes, even modeling tools.
But coot-trimmings is thousands of lines long, changes a lot of Coot’s default shortcuts, and packs in plenty of heavy-duty features I don’t use day to day. Rather than copy it wholesale, I took cues from it and the official template, put together a lighter setup that fits the way I work, and posted it on GitHub:
1. What you can customize in Coot
On macOS and Linux, every time Coot starts, it looks in ~/.coot-preferences/ and loads, in alphabetical order, all files ending in .py. When you click Save Preferences, Coot writes a fresh copy of coot_preferences.py, overwriting the old one. If you name your own script coot_z_shortcuts.py, it will load afterward, so your custom settings always take precedence.
The setup has four main parts: basic preferences, keyboard shortcuts, toolbar buttons, and menus. None of them is particularly hard to script.
Basic preferences: Keep the EM map radius and cut the lag
Put any settings the interface won’t remember, or that you keep changing for every new project, right at the top of the script. For instance, you can set the X-ray and EM map radii, use smaller animation steps for Go to Ligand / Blob, or have Coot fix naming errors when it reads a PDB file without popping up a dialog:
Keyboard shortcuts: Bind a built-in function or write a wrapper
There are two common ways to set up a shortcut. If Coot already has a function for what you want (like manual_refine_residues(0) for refining one residue or refine_tandem_residues() for refining seven consecutive residues), just bind it directly with add_key_binding:
If there’s no one-line function for the job, or you want to string a few steps together, write a short Python function. For example, I often toggle Show Residue Environment to check hydrogen bonds. There’s no default shortcut, but a little function that checks the current setting, toggles it, and refreshes the view does the job. There’s no default shortcut for Simple Mutate either, so I used PyGTK to build a quick picker for the 20 amino acids. After applying the mutation, it automatically calls refine_zone:
Toolbar: Pin frequently used validation plots and tools
Some tools don’t get used often enough to deserve their own key, but they’re buried deep enough in the menus to be annoying to reach. Validation plots, merging molecules, and deleting hydrogens are good examples. Use coot_toolbar_button to pin them to the top toolbar, where they’re a click away:
Menu bar: Running out of room on the toolbar? Use a menu
If you’d rather keep the toolbar uncluttered, you can add your own items to the menu bar or create a menu of your own. Coot provides coot_menubar_menu and add_simple_coot_menu_menuitem. The code looks much like it does for toolbar buttons:
Before AI assistants, tracking down these function names and their parameters meant digging through Coot’s source code. It was a pretty high bar. Now you can describe what you want, point an assistant at the Python and C++ interfaces in your local Coot installation, and get a setup that fits the way you work in a few minutes.
2. My keyboard shortcuts and toolbar buttons
I put my most-used refinement and modeling shortcuts within reach of my left hand, favoring lowercase keys so I don’t have to hold Shift. Where possible, I matched the rest to the first letter of the English command name so they’d be easy to remember.
Keyboard shortcuts
Category
Key
Action
What it does
Refinement
r
Refine Active Residue
Refines a single residue near the center of the view or the pointer
Refinement
R
Refine Zone
Click the first and last atoms in order to refine the entire stretch between them on the same chain
Refinement
s
Sphere Refinement
Refines all neighboring residues within a 4.5 Å sphere around the current residue
Refinement
t
Tandem Refinement
Refines seven consecutive residues centered on the current one
Modeling
a
Autofit Rotamer
Automatically fits the current residue’s side chain to the density using the best-fitting rotamer
Modeling
q
Flip Peptide
Flips the peptide plane at the current residue
Modeling
C
Simple Mutate + Refine
Opens a 20-amino-acid picker at the pointer and automatically refines the residue after mutation
Modeling
P
Place Atom at Pointer
Opens a dialog for placing an atom, such as a water oxygen or an ion, at the crosshairs
Modeling
y
Add Terminal Residue
Extends the chain by adding a residue after the active terminal residue
Modeling
k
Fill Partial Residue
Adds missing side-chain atoms to the current residue
Modeling
K
Delete Sidechain
Deletes the current residue’s side chain but keeps the backbone
Viewing and saving
e
Toggle Residue Environment
Shows or hides dashed lines for hydrogen bonds and nearby contacts around the current residue, then refreshes the view
Viewing and saving
v
Sequence View
Opens the sequence view for the active model, or the first model if no residue is active
Viewing and saving
g
Go To Blob
Centers the view on the blob of unmodeled density under the pointer
Viewing and saving
Q
Quicksave Active Model
Backs up the original file as .bak, then overwrites it with the current model coordinates
Top toolbar buttons
Appendix: Coot’s built-in shortcuts at a glance
While putting this setup together, I noticed that some useful built-in shortcuts (like Ctrl+d for deleting an atom or residue) don’t show up in Coot’s own shortcut list (std_key_bindings). I’ve included the bindings I found in the source code so you can avoid conflicts and see what already works out of the box.
Shortcuts in the standard list (std_key_bindings)
Category
Keys
Actions
Navigation and view
Ctrl+g / p / u / o
Go to residue / Center on nearest atom / Undo last jump / Switch NCS chains
Navigation and view
n / m / d / f
Zoom in / Zoom out / Decrease depth clipping / Increase depth clipping
Navigation and view
i / c / l
Toggle auto-rotation / Toggle crosshairs / Label nearest atom
Modeling and display
a / b / s
Auto-refine zone (deprecated) / Toggle baton rotation / Update skeleton display
Files and edit history
Ctrl+s / Ctrl+i / Ctrl+z / Ctrl+y
Save As / Residue Info / Undo / Redo
Lists
. / ,
Move up / down the button list
One thing to note: a, s, and b appear in the list above, but Coot doesn’t intercept them in normal modeling mode. If you remove them from std_key_bindings in your script, you can still bind them to whatever you like. For example, I use a and s for Autofit Rotamer and Sphere Refinement, respectively.
Hard-coded shortcuts not shown in the list
Keys
Actions
Ctrl+d
Delete the current atom or residue
+ / -
Raise / lower the map contour level (zoom in / out in the Ramachandran plot)
Space / Shift+Space
Jump to the next / previous residue in the sequence
Esc / Return (Enter)
Reject / Accept in the Refinement / Regularization dialog
1 / 2 / 3 / 4
Select chi angle 1–4 in Edit Chi Angles
F8
Render a high-resolution screenshot (Rendered snapshot)
One last tip: Let AI handle the implementation details
Everyone has their own rhythm when working on a structure in Coot. You usually find the shortcuts that feel right by tweaking them as you go, so think of my setup as a starting point you can adapt rather than a layout you need to copy.
Between figuring it out from scratch, trying things that didn’t work, and putting it all together, I spent most of an afternoon on this. You don’t have to do the same. Once you know how a Coot configuration is laid out—basic preferences, shortcuts, toolbar buttons, and menus—you can let an AI assistant look up function names, work out the arguments, and help troubleshoot errors.
The same goes for anything new you want to add. An AI assistant can check the source code in your local Coot installation to find the right built-in function. If there isn’t one, it can quickly put together a wrapper function or a small dialog. I’d rather spend the time I save on the part that actually needs my judgment: looking at the density and deciding what belongs there.