From: John Stone (johns_at_ks.uiuc.edu)
Date: Thu Mar 06 2003 - 10:05:37 CST

Hi Jim,
  This is easily doable with some Tcl scripting. To add atom labels
via the command interface, one just uses "label add Atoms $molid/$atomid"
where molid and atomid are integers specifying the molecule and atom
you want the label toggled on/off. That's pretty easy to understand.
The next thing is to get the list of atoms from the atom selection you're
interested in, which can be done using the "list" feature of the
atomselect command. Using these two commands and a foreach loop, you
can very easily process all of the atoms in any selection you like.

Here's a simple Tcl proc that does this. You can use this same
technique to do various things with atom selections you're interested in.

To call this routine, you'd do something like:
label_atoms 0 "within 3 of resid 1"

Here's the Tcl code:
proc label_atoms { molid seltext } {
  set sel [atomselect $molid $seltext]
  set atomlist [$sel list]
  foreach {atom} $atomlist {
    set atomlabel [format "%d/%d" $molid $atom]
    label add Atoms $atomlabel
  }
  $sel delete
}

Enjoy,
  John Stone
  vmd_at_ks.uiuc.edu
 

On Wed, Mar 05, 2003 at 04:59:03PM -0800, Jim Caldwell wrote:
>
> Hi,
>
> I'd like to label the O atoms of the water residues within "x" of my solute
> automatically. I've been thru the manual several times and nothing looks
> obvious in the same vein as the select "within 3 of resid 1" for displaying
> residues. Any suggestions?
>
> thanks,
> jim
>
> James W. Caldwell
> Department of Pharmaceutical Chemistry
> UCSF
> San Francisco, CA 94143-2240

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349              
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078