[Chimera-users] Get xpos and ypos of selected residues automatically

Elaine Meng meng at cgl.ucsf.edu
Mon Jun 7 17:23:07 PDT 2010

Dear Wei,
You can create a custom "attribute" (a property with a name and values) and assign the values to atoms, then label the atoms with the attribute values.  The attribute definition is done with a simple text file that is read in with the "defattr" command or the Define Attribute tool.  The attribute file format is described here, and some example files are linked:


Attributes are also created by various tools in Chimera.  For example, the Add Charge tool creates the atom attribute named "charge".  After using Add Charge, to label residue 15 in chain A with charge values, you could use commands:

labelopt info charge
label :15.a

Or if you had created your own attribute named "stuff" it would be "labelopt info stuff" etc. 

Labelopt is used for atom labels.  If you had created a residue attribute, there is no command, but you could label the residue with the attribute value using the menu: Actions... Label... residue... custom...  If you want everything in a command script (not using the menu),  just create an atom attribute rather than a residue attribute with those calculated values and show the label of one atom in the residue.

The difficulty would be that your calculation would need to create the attribute definition file, but as mentioned above the format is pretty simple.  Finally, there is actually a command (setattr) 
to assign attributes without a separate file, but it only assigns one value at a time, so is probably not what you want in this case.   I hope this helps,
Elaine C. Meng, Ph.D. 
UCSF Computer Graphics Lab (Chimera team) and Babbitt Lab
Department of Pharmaceutical Chemistry
University of California, San Francisco

On Jun 3, 2010, at 8:56 PM, liwei0703 at nibs.ac.cn wrote:

> Dear Elaine,
> Thanks for your kindly providing useful information for me. I learned a lot about how to make a beautiful 3D labels in my figure. However my problem is that I have calculated some properties of this residue and I wanted to label this calculated value near the residue. But from your suggestion, it seems that it is impossible to automatically do this work. Maybe I could try some other methods.
> Thanks for your kind reply!
> Wei Li
> 2010-6-4
> -----原始邮件-----
> > 发件人: "Elaine Meng" <meng at cgl.ucsf.edu>
> > 发送时间: 2010-06-04 00:33:11
> > 收件人: "wei li" <liwei0703 at nibs.ac.cn>
> > 抄送: chimera-users at cgl.ucsf.edu
> > 主题: Re: [Chimera-users] Get xpos and ypos of selected residues automatically
> > 
> > Dear Wei,
> > You will probably need to use the regular (3D) labels instead, at least for the residues.  If you have some title or text that always goes in a particular place on the screen, for example across the top, it could be done with 2D labels.  However, if you want labels automatically near some atoms or residues but you don't know ahead of time where they will be in the window, use the regular labels.  I have been working on something similar myself...
> > 
> > How to make regular (3D) labels in figures look better:
> > 
> > (a)  use bigger font size, and perhaps bold font style.  
> > (b) use Z-offset to bring them forward so they will be in front, less likely to be blocked by other stuff.
> > 
> > More about each of these below...
> > 
> > (a) You can give each label a different color if you want (for example, with the color command), but the limitation with the regular labels is that they must all be in the same font size and style.  Another limitation is that currently you can't set the font size and style with commands;  you have to do it ahead of time (but only once):  choose Preferences from the Favorites menu, go to category: Background,  set label font size and style, click Save.
> > <http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/preferences.html#Background>
> > 
> > (b) In the label/rlabel commands, you can specify a Z-offset.  
> > <http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/label.html>
> > <http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/rlabel.html>
> > 
> > For example, these commands set the view to show some set of residues, label them with a Z-offset of 2.5 angstroms, change label colors:
> > 
> > windowsize 600 500
> > open 1add
> > ribscale licorice
> > alias motif :15.a,17.a,214.a,217.a,238.a,295.a,296.a
> > show motif
> > focus motif &~ @n,ca,c,o
> > rlabel offset 0,0,2.5 motif
> > color dodger blue,l
> > color red,l motif & :asp,glu
> > 
> > I hope this helps,
> > Elaine
> > ----------
> > Elaine C. Meng, Ph.D. 
> > UCSF Computer Graphics Lab (Chimera team) and Babbitt Lab
> > Department of Pharmaceutical Chemistry
> > University of California, San Francisco
> > 
> > 
> > On Jun 3, 2010, at 12:04 AM, wei li wrote:
> > 
> > > Dear all,
> > >    Here is my problem:
> > >    I need to write a cmd script to use 2dlables automatically assign some annotations to some selected residues for many different proteins. However, I did not know the xpos and ypos for these residues and for different proteins there will be different residues which need to be assigned.
> > >    So, is there any method to get the xpos and ypos via some commands when I only know the residue identifiers?
> > >    Thanks
> > >  
> > > Wei Li
> > > 2010-6-3
> > 

More information about the Chimera-users mailing list