Skip to content

Instantly share code, notes, and snippets.

@emleddin
Last active February 22, 2022 17:17
Show Gist options
  • Save emleddin/f0ae964dbe0a5d0ed38038e60b561245 to your computer and use it in GitHub Desktop.
Save emleddin/f0ae964dbe0a5d0ed38038e60b561245 to your computer and use it in GitHub Desktop.
chmidasrc

Chimera Image Rendering

Chimera will source a ~/.chimera/midasrc or .chmidasrc file in the working directory. You often need to open the in-program command line (FavoritesCommand Line) before it is applied.

If a residue doesn't do what you would expect, it may be because Chimera named it differently. This can happen a lot with metals, where it appends a .het extension (meaning heteroatom). Any line starting with # is a comment (I just like using ##).

The following example is set up for PDBID 3WTG.

##------------------------ Set-Up
## Use an orthographic projection instead of perspective
set projection ortho

## Apply the publication preset
preset apply pub 1

## Change the lighting (more cartoony)
light contrast 0.3
light reflectivity 0.5

## Change the lighting (less cartoony, more shadowy)
#light contrast 0.5
#light reflectivity 0.8

## Remove nucleotide objects
nuc side atoms

##------------------------ Color Definitions
## Define colors (use X/255 for RGB). 4th number scaled 0=transparent/1=opaque
## You can get flag schemes from https://www.schemecolor.com/color/flags
## These are for the trans pride flag
colordef transblue  0.33 0.80 0.99 0.9
colordef transwhite 1.00 1.00 1.00 0.9
colordef transpink  0.97 0.66 0.72 0.9

## These are for the bi pride flag
colordef bipink   0.84 0.00 0.43 1
colordef bipurple 0.61 0.31 0.58 1
colordef biblue   0.00 0.22 0.65 1

## These are for the lesbian pride flag
colordef lesred     0.84 0.16 0.00 0.9
colordef lesorange  1.00 0.61 0.33 0.9
colordef leswhite   1.00 1.00 1.00 0.9
colordef lespink    0.83 0.38 0.65 0.9
colordef lesmagenta 0.65 0.00 0.38 0.9

## These are for the gay (rainbow) pride flag
colordef gayred    1.00 0.00 0.09 0.9
colordef gayorange 1.00 0.65 0.17 0.9
colordef gayyellow 1.00 1.00 0.25 0.9
colordef gaygreen  0.00 0.50 0.09 0.9
colordef gayblue   0.00 0.00 0.98 0.9
colordef gaypurple 0.53 0.00 0.49 0.9

## These are for the gay men flag                                               
colordef gmblue    0.24 0.10 0.47 0.9                                              
colordef gmindigo  0.31 0.29 0.80 0.9                                              
colordef gmltblue  0.48 0.67 0.88 0.9                                              
colordef gmltgreen 0.59 0.91 0.75 0.9                                              
colordef gmmint    0.15 0.80 0.66 0.9                                              
colordef gmdkgreen 0.37 0.55 0.44 0.9

## These are for the pansexual pride flag
colordef panpink   1.00 0.11 0.55 0.9
colordef panyellow 1.00 0.85 0.00 0.9
colordef panblue   0.11 0.70 1.00 0.9

## These are for the non-binary pride flag
colordef nbiyellow 1.00 0.96 0.19 0.9
colordef nbiwhite  1.00 1.00 1.00 0.9
colordef nbipurple 0.61 0.35 0.82 0.9
colordef nbiblack  0.00 0.00 0.00 0.9

## These are for the asexual pride flag
colordef aceblack  0.00 0.00 0.00 0.9
colordef acegray   0.64 0.64 0.64 0.9
colordef acewhite  1.00 1.00 1.00 0.9
colordef acepurple 0.51 0.00 0.51 0.9

## These are for the aromantic pride flag
colordef arodarkgreen  0.23 0.65 0.25 0.9
colordef arolightgreen 0.66 0.83 0.48 0.9
colordef arowhite      1.00 1.00 1.00 0.9
colordef arogray       0.67 0.67 0.67 0.9
colordef aroblack      0.00 0.00 0.00 0.9

##------------------------ Structural
## Hide the sidechains/linedraws of specific residues
~show #0:301-414
~show #0:1-141

## Show the sidechains of specific residues
disp #0:123 #0:222

## Color specific sections
## Subunit A
color gayred,r,s,a #0:1-146.A
## Subunit B
color gayyellow,r,s,a #0:1-146.B
## Subunit C
color gayblue,r,s,a #0:1-146.C
## Subunit D
color gaypurple,r,s,a #0:1-146.D
## Hemes
color gaygreen,r,s,a #0:201.A #0:201.B #0:201.C #0:201.D

## Explicitly color your metals how you want
## Color Mg2+
#color dark magenta,a #0:199 #0:199.het
## Color Zn2+
#color dim gray,a #0:200.het
## Color Fe2+
color firebrick,r,s,a #0:201.A@FE #0:201.B@FE #0:201.C@FE #0:201.D@FE

## Make the background transparent
set bgTransparency

## Fit the structure to the window
window

Moving the Structure

Once things are oriented how you want, you can use command-line commands such as move x 10 or move y -5 to center the structure in the Chimera window. For a rotation, do something like turn y 180.

Mapping Attributes

You can map attributes using the command line or the GUI. The GUI explanation is on my website.

## Define the colors to use                                                     
colordef botpurp #5e4b3c279992                                                  
colordef midwhite #f7fef7fef7fe                                                 
colordef toporange #e6fb616b0100

## Read in the specific attribute file                                          
defattr "WT_heatmap_values_chimera.txt"                                     
                                                                                
## Color the residues using a specified color key                               
## The attribute name is specified in the given text file                       
rangecol myWTheatmap key -1 botpurp 0 midwhite 1 toporange

Saving the Image

  1. Go to File --> Save Image
  2. Use a transparent background
  3. Increase the Image Width parameter to something like 2000. Increasing this will increase the DPI of the image.

If you want something with more shadows, you can opt to save it using POV-Ray instead of the Chimera renderer.

Command-Line Save with Set DPI

You can also save the image from the Chimera command-line.

copy file mychimerafigure.png png width 3 height 5 units inches dpi 600 supersample 4

The above command will save an image titled mychimerafigure.png as a 3x5in PNG using 600 DPI.

@krithravi
Copy link

10/10 stunning!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment