From: John Stone (johns_at_ks.uiuc.edu)
Date: Tue May 02 2006 - 11:22:37 CDT

Oops, that's what I get for writing scripts in emails..
Yes, you'll want to $sel delete those :-)

  John

On Tue, May 02, 2006 at 12:22:22PM -0400, Axel Kohlmeyer wrote:
> On Tue, 2 May 2006, John Stone wrote:
>
> JS>
> JS> Enzo,
> JS> If you don't like writing the long expression below, you could
>
> enzo, can you please explain, what you want to do.
> there may be several solutions, but that depends
> very much on what and how you need the coordinates.
>
> JS> simply do something like:
> JS>
> JS> proc getatomcoords { index } {
> JS> return [lindex [[atomselect top "index $index"] get {x y z}] 0]
> JS> }
>
> please take care, that this subroutine creates a memory leak,
> as it allocates a selection, without deleting it.
>
> if you want to access coordinates from an array/list you can
> also do:
>
> set sel [atomselect top "all"]
> set coords [$sel get {x y z}]
> $sel delete
>
> and then access the coordinates via lindex from $coords.
>
> best regards,
> axel (happy that there is a wireless here during a boring talk).
>
>
> JS>
> JS> You could then write the much more compact expression:
> JS> getatomcoords 25
> JS>
> JS> If you want to be able to specify the atom in a 1-based indexing scheme, you
> JS> could use "serial" rather than index, if you prefer:
> JS> proc getatomcoords { serial } {
> JS> return [lindex [[atomselect top "serial $serial"] get {x y z}] 0]
> JS> }
> JS>
> JS> You could then write the same command with 1-based indices:
> JS> getatomcoords 26
> JS>
> JS> John Stone
> JS> vmd_at_ks.uiuc.edu
> JS>
> JS>
> JS> On Tue, May 02, 2006 at 04:39:10PM +0200, Enzo Vitale wrote:
> JS> > Dear VMD experts,
> JS> >
> JS> > I have another simple question, again related to scripting VMD by
> JS> > means of TCL: is there a predefined array variable holding the
> JS> > coordinates of all atoms of a given molecule ?
> JS> >
> JS> > So far, I get the coordinates via the following ugly expression:
> JS> >
> JS> > [lindex [[atomselect top "index 25"] get {x y z}] 0]
> JS> >
> JS> > when for instance I need the coordinates of the 26-th atom, but I
> JS> > guess there must be a simpler and more readable form for getting the
> JS> > same result.
> JS> >
> JS> > Thank you in advance,
> JS> > Enzo
> JS>
> JS>
>
> --
> =======================================================================
> Axel Kohlmeyer akohlmey_at_cmm.chem.upenn.edu http://www.cmm.upenn.edu
> Center for Molecular Modeling -- University of Pennsylvania
> Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
> tel: 1-215-898-1582, fax: 1-215-573-6233, office-tel: 1-215-898-5425
> =======================================================================
> If you make something idiot-proof, the universe creates a better idiot.

-- 
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