[Chimera-users] coloring seperate domains

Elaine Meng meng at cgl.ucsf.edu
Thu Oct 23 10:18:15 PDT 2008

On Oct 22, 2008, at 1:52 PM, Chin-Hsien (Emily) Tai wrote:
> We would like to use Chimera as a visualizing/figure drawing tool to  
> compare different domain parsing schemes and we are wondering how to  
> automate the process as much as possible.  The tasks are:
> 	1.fetch a PDB
> 	2.select  Chain (for example B)
> 	3.Invert (all models)
> 	4.Atoms/Bonds delete
> 	5.chain trace only
> 	6.backbone only
> 	7.Ribbon show rounded
> I am wondering if there is a simple way to combine step 1 to 4 to  
> display only specified chain in PDB?
> Then rotate the structure to minimize domain overlapped area.
> Then color each domain according to different parsing schemes, for  
> example:
> 	scheme1 "color red #0:1-38.A 150-190.A; color green #0:39-149.A;  
> color blue #0:192-347"
> 	scheme2 "color red #0:1-30.A 160-195.A; color green #0:31-159.A;  
> color blue #0:196-347"
> Can Chimera read a script and displays different domains in  
> different colors?
> Thanks for your advice in advance!
> Cheers,
> Emily,

Dear Emily,
You can definitely do all those steps in a script, except I'm not sure  
how to automatically orient the structure to best show the domains.   
I'll discuss the other parts first.

A Chimera command script is just a text file containing the same  
things you would enter at the command line.  If you name the file  
something.com or something.cmd it will automatically execute when  
opened in Chimera (with File... Open or the command "open").  Chimera  
can also execute python scripts (something.py) in the same way.

There are many possibilities for either type of script, but here are  
some example Chimera commands:

open 2mnr
delete ~ :.a
ribrep rounded
color red :3-132
color dodger blue :133-359
copy png file 2mnr.png

This set of commands fetches PDB structure 2mnr, deletes everything  
that is NOT chain A, displays ribbon, uses the rounded ribbon style,  
undisplays all atoms, colors the specified residue ranges, and saves  
an image in PNG format.  You don't have to specify the chain in the  
coloring command since there is only one chain left.  Each of these  
commands has a manual page if you want to see details (for example,  
there are other image formats such as TIFF).  You can try the commands  
in the Command Line  to see what works before putting them into a  

For saving images, you might want to make the background white (set  
bg_color white) before using the script, or after opening each  
structure use the ribbons preset  and then a publication preset  
(preset apply int 1; preset apply pub 1) instead of ribbon and ribrep  

There are some fancier approaches that may facilitate processing a  
large number of structures.   You can separate the structure-specific  
and general commands using aliases:

alias mypdb 2mnr
alias mychain :.a
alias dom1 :3-132
alias dom2 :133-359
~alias dom3
~alias dom4
alias output /Users/meng/Desktop/2mnr.png
#  the following general commands could be put in a separate file
open mypdb
delete ~ mychain
preset apply int 1
preset apply pub 1
color red dom1
color dodger blue dom2
color yellow dom3
color magenta dom4
copy png file output
close 0

This structure only has two domains, so I clear any previous dom3 and  
dom4 assignments from previous structures.  There will be error  
messages when commands refer to nonexistent aliases, but they can be  
ignored.  The reason you might want to separate the specific and  
general commands is that all of the general commands can then be put  
in a second command file (for example named "process.com" ) that is  
opened by the first script.  The second script file could be in the  
same directory (folder) as the first, or you could specify its whole  

alias mypdb 2mnr
alias mychain :.a
alias dom1 :3-132
alias dom2 :133-359
~alias dom3
~alias dom4
alias output /Users/meng/Desktop/2mnr.png
open /Users/meng/Desktop/process.com
#   now go to next structure
alias mypdb 4enl
alias mychain :.a
alias dom1 :1-141
alias dom2 :142-436
~alias dom3
~alias dom4
alias output /Users/meng/Desktop/4enl.png
open /Users/meng/Desktop/process.com
[... etc.]

Putting the general commands in a separate file minimizes the number  
of lines in the primary command file.  However, it may still be  
tedious if you are processing a very large number of structures.   
Since I don't know python, I would probably write a script or program  
(in some other language) to make the long main Chimera command file.   
If you know python, another approach is to make the main script python  
instead of Chimera commands, and have it cycle through multiple  
structures.  You could call the Chimera commands in my examples from  
inside the python script.

Finally, now about orienting the structure to best show the domains.   
The only way I can think of with Chimera commands is to use "align" to  
put domains 1 and 2 front and back, then rotate 90 degrees, for example:

align dom1 dom2
turn y 90

That worked pretty well in my tests.  Those commands could be in the  
general script (process.com in my example), assuming all the  
structures have at least two domains, before the image-saving  
command.  There are some other possibilities that require python; I'll  
get back to you if we come up with something good.

I hope this helps,
Elaine C. Meng, Ph.D.                          meng at cgl.ucsf.edu
UCSF Computer Graphics Lab (Chimera team) and Babbitt Lab
Department of Pharmaceutical Chemistry
University of California, San Francisco

More information about the Chimera-users mailing list