From: John Stone (johns_at_ks.uiuc.edu)
Date: Wed Jul 23 2008 - 09:15:18 CDT

Hi,
  It's often easy to use the Tcl 'format' command to generate complex
atom selections involving variables if one doesn't want to do calculations
in multiple passes using the 'beta', 'user' etc.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Wed, Jul 23, 2008 at 07:36:25AM -0400, Axel Kohlmeyer wrote:
> On Wed, 23 Jul 2008, Ignacio Fernández Galván wrote:
>
> IFG> --- On Tue, 22/7/08, Eduardo Cruz-Chu <chucruz_at_ks.uiuc.edu> wrote:
> IFG>
> IFG> > you can use equations in your selection. For instance, to
> IFG> > select a cylindrical region of radius R around a point
> IFG> > (Xcenter,Ycenter) in the frame F
> IFG> >
> IFG> > set sel [ atomselect top "(x-$Xcenter)*(x-$Xcenter) +
> IFG> > (y-$Ycenter)*(y-$Ycenter) < $R*$R" frame $F ]
> IFG> >
> IFG> > you can limit the region of the cylinder adding extra
> IFG> > equations in the Z direction.
> IFG>
> IFG> Yes, that's what I tried as the "hard way", but somehow the variables are not evaluated inside the selection. The problem may be that I'm writing the selection formula in the GUI for representations (or in the "mol selection" line in a state file previously saved). So:
> IFG>
> IFG> set xA 2
> IFG> ...
> IFG> mol selection {x < $xA}
> IFG> ...
> IFG> mol addrep top
> IFG>
> IFG> but the selection comes out as if I had written "x < 0" instead of "x < 2". Of course, if I write "x < 2" directly, it works as it should, so at the end I could "hard code" the values in the state file, but I'd prefer to avoid that.
>
> yes. this cannot work. the selection parser does not have
> access to any tcl variables as it operates on a lower level.
>
> if you don't want to use the dummy atom option that i suggested,
> and compute everything explicitly, you can use the "user" field
> to store per-timestep information about each atom of your system.
> this can not only be used to color code atoms but to do selections
> (user > 0).
>
> cheers,
> axel.
>
> IFG>
> IFG> > If your benzene ring is moving, you should play with the
> IFG> > equations (find the center of the ring, can use the middle
> IFG> > point between 2 carbons, and the normal to the ring plane,
> IFG> > can use three carbons).
> IFG>
>
> IFG> Ok, in my case it is actually not moving, because I'm centering it
> IFG> at every frame. But if it were, how would I do it so that the
> IFG> selection would be updated at each frame? For doing analysis and
> IFG> calculations, I can use a foreach loop and get the coordinates each
> IFG> frame, but what can be done for a representation? The "update
> IFG> selection every frame" is not enough, because I'd need a way to
> IFG> define the xA variable every frame...
> IFG>
> IFG>
> IFG>
> IFG>
> IFG> __________________________________________________________
> IFG> Not happy with your email address?.
> IFG> Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html
> IFG>
>
> --
> =======================================================================
> 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