Useful aliases and startup settings for UCSF ChimeraX (https://www.cgl.ucsf.edu/chimerax/). Add these to the "Startup" section of the "Preferences" pane and restart ChimeraX in order to have them take effect. (Note: Some of these will only work with recent builds of ChimeraX).
I would also recommend (if you are using a laptop) going through each tool in the "Tools" menu, launching it, right clicking on the relevant window and unchecking "Dockable tool" - this will ensure that each tool acts as a separate window and does not try to "snap" to the main GUI when you move it around, which I find undesirable on smaller screens (these settings will be persistent across restarts of ChimeraX).
This repository contains:
chimerax_trimmings.txt: Startup commands, aliases, keybindings, and Shortcut buttonpanel setup.chimerax_trimmings.py: Companion ChimeraX Python script for a couple of things that are difficult or not possible to implement in ChimeraX command language.map_salami.py: Experimental script that , if invoked via runscript, adds a commandmap_salami, which automates the generation of section-by-section map/model density fit figures (can run asmap_salami model #1 selection /A:100-220 map #2 zone 2 patches 3 movie true movie_resolution 1080p segment_size 40 image_height 2000 output_dir ~/Desktop/map_salami_panels, everything except for map & model is optional; patches controlsMaxComponentsof surface, defaults toNone;movie_resolutioncan be either 4k or 1080p, defaults to 1080p;zoneis the surface zone clipping offset, defaults to 2 Å;segment_sizeis the residue range chunk to use, defaults to 40 but will expand to include entire helix/strand or short terminal segments if needed.)- Caveat - I have re-organized, updated, and translated from the original
chimera-trimmingswith the help of an LLM (Codex). I have tried to carefully check for errors and unexpected behaviors, and inspect each ChimeraX command invoked, but if you notice anything broken or unexpected, please let me know and I will do my best to fix it.
- Make a local copy of
chimerax_startup.py(somewhere permanent). - Edit the first line of
chimerax_trimmings.txtso therunscriptpath points to your local copy ofchimerax_trimmings.py. - In ChimeraX on macOS, open
UCSF ChimeraX -> Preferences... -> Startup(I think under Favorites on Windows?) - Paste the contents of your edited
chimerax-trimmings.txtinto the startup commands box. - Restart ChimeraX.
The Python script registers:
nextmodelprevmodeltogglemapstogglemodelsreorient
togglemaps and togglemodels toggle the currently displayed maps/models on/off. reorient attempts to orient the view in a sensible direction - aligning the view to the shortest axis of an ellipsoid defined by the visible components - and repeated invocations of the command cycle through alignment to other axes of the ellipsoid.
F1: Previous modelF2: Next modelF3: Center selectionF4: View allF5: Toggle mapsF6: Toggle modelsF7: Cycle lighting presetsF8: Cycle model display optionsF9: Previous map (Ignores models)F10: Next map (Ignores models)
The startup file creates a Shortcuts button panel with quick access to commonly used tools/commands.
It currently includes buttons for:
Vol_Viewer: open the Volume Viewer toolModel_Panel: open the Model PanelLog: open the Log viewerdefault_disp: Set some nice defaults for model/map displaymap_sphere: Zone maps to a 15 A sphere around the center of rotationmap_unsphere: Undo map zoningcofron: Make sure the center of rotation is centered between the clip planes and show the center-of-rotation pivot markercofroff: Hide the center-of-rotation pivot marker while keeping the CoFR centered between the clip planes.cootmode: Apply a Coot-style display preset for models/mapsmark_cofr: Place a marker at the current center of rotationtogglemaps: Hide shown maps, then restore the same set on the next usetogglemodels: Hide shown atomic models, then restore the same set on the next usereset_mouse_and_help: Restore the default mouse bindings and open the mouse-mode help pageprevious_model: Step to the previous model in the Model Panelnext_model: Step to the next model in the Model Panel
Note: for all of these aliases, on the Chimerax command line you can type "help cofron" or "usage cofron" for example to get a short description of usage of the indicated alias in the Log
Centers the rotation point between the clip planes and shows the pivot marker.
Usage: cofron
alias cofron cofr centerofview showpivot 7,0.25
alias usage cofron synopsis "Centers the rotation point on the view and show the pivot"
Recenters the rotation point between the clip planes and hides the pivot marker.
Usage: cofroff
alias cofroff cofr centerofview showpivot false
alias usage cofroff synopsis "Recenter the rotation point on the view and hide the pivot marker"
Sets symmetric clip planes around the center of rotation.
Usage: symclip <half-distance>
alias symclip cofr centerofview; clip near -$1 far $1 position cofr
alias usage symclip synopsis "Set symmetric clip planes around the center of rotation" $1 "Half-width"
Selects all atomic models.
Usage: selmodel
alias selmodel sel ##num_residues
alias usage selmodel synopsis "Select atomic models"
Selects all non-atomic models such as maps.
Usage: selmap
alias selmap sel ~##num_residues
alias usage selmap synopsis "Select non-atomic models such as maps"
Applies a dark-background Coot-style display preset for model building.
Usage: cootmode
alias cootmode set bgColor black; surface cap false; surface style solid; nucleotides #* atoms; lighting flat; graphics silhouettes false; style stick; ~rib; color ##num_residues gold; color byhet ; disp; ~disp @H*; style ions sphere; style solvent ball; size ballscale 0.2; size stickradius 0.07; transparency 70; cofr centerofview; clip near -10 far 10 position cofr; color ~##num_residues cornflower blue
alias usage cootmode synopsis "Apply the dark-background Coot-style display preset"
Applies a white-background variant of cootmode.
Usage: cootmode_white
alias cootmode_white set bgColor white; surface cap false; surface style solid; nucleotides #* atoms; lighting flat; graphics silhouettes false; style stick; ~rib; color ##num_residues orange; color byhet ; disp; ~disp @H*; style ions sphere; style solvent ball; size ballscale 0.2; size stickradius 0.07; transparency 85; cofr centerofview; clip near -10 far 10 position cofr; color ~##num_residues medium blue
alias usage cootmode_white synopsis "Apply the white-background Coot-style display preset"
Applies a mesh-map variant of cootmode.
Usage: cootmode_mesh
alias cootmode_mesh surface cap false; surface style mesh; lighting flat; nucleotides #* atoms; graphics silhouettes false; style stick; ~rib; color ##num_residues gold; color byhet ; disp; ~disp @H*; style solvent ball; style ions sphere; size ballscale 0.2; size stickradius 0.07; cofr centerofview; clip near -10 far 10 position cofr; color ~##num_residues #3d60ffff; transparency 50
alias usage cootmode_mesh synopsis "Apply the mesh Coot-style display preset"
Shows a CA trace for proteins or phosphate backbone trace for nucleic acids, plus protein sidechains and nucleic-acid bases.
Usage: ca_and_sidechains <model-spec>
alias ca_and_sidechains ~rib $1; ~surf $1; ~disp $1; disp @CA&protein&$1; disp @P&nucleic&$1; style $1 stick; disp sidechain&$1; disp ~backbone&nucleic&$1; size stickradius 0.1; size pseudobondradius 0.1
alias usage ca_and_sidechains synopsis "Show CA or phosphate trace plus sidechains or bases" $1 "model-spec"
Shows a CA trace for proteins and a phosphate trace for nucleic acids.
Usage: ca_trace <model-spec>
alias ca_trace ~rib $1; ~surf $1; ~disp $1; disp @CA&protein&$1; disp @P&nucleic&$1; style $1 stick; size stickradius 0.1; size pseudobondradius 0.1
alias usage ca_trace synopsis "Show a CA or phosphate trace" $1 "model-spec"
Zones maps to a 15 A sphere around the center of rotation.
Usage: map_sphere_15
alias map_sphere_15 volume unzone ~##num_residues; sel; close #10000; marker #10000 position cofr; sel ~sel; volume zone ~##num_residues nearAtoms sel minimalBounds true range 15; close #10000
alias usage map_sphere_15 synopsis "Zone maps to a 15 A sphere around the center of rotation"
Creates a spherical mask map on a cubic grid.
Usage: cubic_map <sphere-radius>
alias cubic_map shape sphere radius $1 modelid #10000; volume onesmask #10000 spacing 1 border -0.5
alias usage cubic_map synopsis "Create a spherical mask map on a cubic grid" $1 "sphere radius"
Removes zoning from all maps.
Usage: map_unsphere
alias map_unsphere volume unzone ~##num_residues
alias usage map_unsphere synopsis "Remove map zoning from all maps"
Splits a model by chain, fits each chain independently into a map, then recombines the result.
Usage: fit_by_chain <model-spec> <map-spec>
alias fit_by_chain split $1; fitmap $1.* inmap $2 eachmodel true; combine $1.* close true
alias usage fit_by_chain synopsis "Split a model by chain, fit each chain into a map, and recombine" $1 "model-spec" $2 "map-spec"
Restores a default ribbon/cartoon molecular display with chain rainbow coloring.
Usage: default_mol_display
alias default_mol_display ~disp; rib; rainbow chain palette RdYlBu-5; lighting soft
alias usage default_mol_display synopsis "Restore the default cartoon molecular display"
Fits a model or map into a local zone cut from a target map around the center of rotation.
Usage: local_fitmap <model-or-map> <target-map> <zone-radius>
alias local_fitmap ~sel; close #10000-10001; marker #10000 position cofr; sel #10000; volume zone $2 nearAtoms sel range $3 newMap true modelid 10001 minimalbounds true; fitmap $1 inmap #10001 eachmodel true; close #10001; close sel; show $2
alias usage local_fitmap synopsis "Fit a model or map into a local zone around the center of rotation" $1 "model or map to fit" $2 "target map" $3 "zone radius"
Turns clipped surface caps off.
Usage: caps_off
alias caps_off surface cap false
alias usage caps_off synopsis "Turn clipped surface caps off"
Turns clipped surface caps on.
Usage: caps_on
alias caps_on surface cap true
alias usage caps_on synopsis "Turn clipped surface caps on"
Opens a file browser with volume-series mode enabled.
Usage: open_vseries
alias open_vseries "open browse vseries true"
alias usage open_vseries synopsis "Open a file browser with volume series enabled"
Selects residues between the current selection endpoints.
Usage: selbetween
alias selbetween ks ri
alias usage selbetween synopsis "Select residues between the current selection endpoints"
Marks selected residues as helix.
Usage: helix <residue-spec>
alias helix setattr $1 res is_helix true
alias usage helix synopsis "Mark residues as helix" $1 "residue-spec"
Marks selected residues as strand.
Usage: strand <residue-spec>
alias strand setattr $1 res is_strand true
alias usage strand synopsis "Mark residues as strand" $1 "residue-spec"
Clears helix and strand assignment for selected residues.
Usage: coil <residue-spec>
alias coil setattr $1 res is_strand false; setattr $1 res is_helix false
alias usage coil synopsis "Clear helix and strand assignment for residues" $1 "residue-spec"
Records a rocking movie to ~/Desktop/rock_movie.mp4.
Usage: rock_movie
alias rock_movie cofr showpivot false; movie record; rock y 50; wait 600; movie encode ~/Desktop/rock_movie.mp4; stop
alias usage rock_movie synopsis "Record a rocking movie and save it to the default Desktop file"
Centers on the current selection and applies local clipping around it.
Usage: centersel
alias centersel cofr sel; clip near 10 position cofr; clip far -10 position cofr; cofr centerOfView showpivot true; view sel
alias usage centersel synopsis "Center the view on the selection and apply local clipping"
Displays a map as a projected image volume.
Usage: volume_project <map-spec>
alias volume_project set bgColor black; volume $1 step 1 sd_level 0,0 sd_level 50,1 color white color white style image projection_mode auto maximum_intensity_projection true bt_correction true linear_interpolation true; lighting depth_cue false
alias usage volume_project synopsis "Display a map as a maximum-intensity projection" $1 "map-spec"
Replaces a map with a scaled positive/negative mesh difference map.
Usage: split_diff_map <input-map> <output-model-id>
alias split_diff_map volume scale $1 rms 1 modelId $2; close $1; volume $2 capFaces false meshLighting false squareMesh false level -3 color #da1200000000 level 3 color #0000bda00000; lighting depthCue true; volume $2 style mesh
alias usage split_diff_map synopsis "Replace a map with a scaled positive and negative mesh difference map" $1 "input map" $2 "output model-id"
Builds a local difference map from two maps around a model.
Usage: local_diff_map <model-spec> <first-map> <second-map>
Depends on: split_diff_map
alias local_diff_map view name tmp; close #1001,1002,1003,1004,1005; fitmap $1 inMap $2; vol zone $2 near $1 range 5 newMap true modelId 1000 minimalBounds true; fitmap $1 inMap $3; vol zone $3 near $1 range 5 newMap true modelId 1001 minimalBounds true; volume scale #1000 sd 0.1 modelId 1002; volume scale #1001 sd 0.1 modelId 1003; fitmap #1003 inMap #1002; volume resample #1003 onGrid #1002 modelId 1004; volume subtract #1002 #1004 modelId 1005 minRms true; volume #1005 step 1; split_diff_map #1005 #1006; close #1000,1001,1002,1003,1004,1005; view tmp
alias usage local_diff_map synopsis "Build a local difference map between two fitted maps around a model" $1 "model-spec" $2 "first map" $3 "second map"
Selects protein sidechains and nucleic-acid bases for the given atom specification.
Usage: selside <atom-spec>
alias selside sel sidechain & $1 | ~backbone & nucleic & $1
alias usage selside synopsis "Select protein sidechains and nucleic-acid bases" $1 "atom-spec"
Displays protein sidechains and nucleic-acid bases for the given atom specification.
Usage: dispside <atom-spec>
alias dispside sel sidechain & $1 | ~backbone & nucleic & $1; disp sel
alias usage dispside synopsis "Display protein sidechains and nucleic-acid bases" $1 "atom-spec"
Builds a local difference map from two maps around the center of rotation.
Usage: local_diff_map_sphere <first-map> <second-map> <radius>
Depends on: split_diff_map
alias local_diff_map_sphere ~sel; close #10000,#1001,#1002,#1003,#1004,#1005; marker #10000 position cofr; sel #10000; vol zone $1 near sel range $3 newMap true modelId 1000 minimalBounds true; vol zone $2 near sel range $3 newMap true modelId 1001 minimalBounds true; volume scale #1000 sd 0.1 modelId 1002; volume scale #1001 sd 0.1 modelId 1003; fitmap #1003 inMap #1002; volume resample #1003 onGrid #1002 modelId 1004; volume subtract #1002 #1004 modelId 1005 minRms true; volume #1005 step 1; split_diff_map #1005 #1006; close #10000,#1000,#1001,#1002,#1003,#1004,#1005
alias usage local_diff_map_sphere synopsis "Build a local difference map between two maps around the center of rotation" $1 "first map" $2 "second map" $3 "radius"
Creates a binary mask map at a chosen contour level.
Usage: binary_mask <map-spec> <contour-level>
alias binary_mask volume threshold $1 minimum $2 set 0 maximum $2 setMaximum 1 modelId 2000; volume #2000 level 0.5
alias usage binary_mask synopsis "Create a binary mask map at a chosen contour level" $1 "map-spec" $2 "contour level"
Creates a soft-edged mask map from a chosen contour level.
Usage: soft_mask <map-spec> <contour-level>
alias soft_mask volume threshold $1 minimum $2 set 0 maximum $2 setMaximum 1 modelId 2000; volume falloff #2000 iterations 20 modelId 2001; volume #2001 level 0.5; close #2000
alias usage soft_mask synopsis "Create a soft-edged mask map at a chosen contour level" $1 "map-spec" $2 "contour level"
Deletes all hydrogen atoms.
Usage: delh
alias delh delete @H*
alias usage delh synopsis "Delete all hydrogen atoms"
Deletes hydrogen atoms from the current selection.
Usage: delh_sel
alias delh_sel delete sel & @H*
alias usage delh_sel synopsis "Delete hydrogen atoms from the current selection"
Carves displayed map surfaces to the current selection by the given distance.
Usage: carve <distance>
alias carve surface zone ~##num_residues nearAtoms sel distance $1
alias usage carve synopsis "Carve displayed map surfaces to the current selection" $1 "distance"
Removes surface carving from displayed map surfaces.
Usage: uncarve
alias uncarve surface unzone ~##num_residues
alias usage uncarve synopsis "Remove surface carving from displayed map surfaces"
- The Python file is meant to be sourced inside ChimeraX with
runscript; it is not a standalone Python program. nextmodelandprevmodeluse the Model Panel tool and therefore depend on ChimeraX's current Model Panel implementation.- If you move the repository, update the
runscriptpath in the first line of your Startup preferences panel.
I prefer to operate ChimeraX with all panels undocked by default (except for this button panel!), as I find this is the best way to make use of screen real estate on a laptop (which is how I mostly work). So I have a button panel that allows me to quickly access the volume viewer, model panel and log, as well as other shortcuts that I find useful to have on hand. Here is what this looks like in practice:
And here is what it looks like in action: https://www.dropbox.com/scl/fi/cdi295s8h7vc5ijf9wr54/chimerax_example_nav.mov?rlkey=mbqn4uk4yodhj1346thyf86oo&dl=0