From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Thu Apr 19 2007 - 08:30:34 CDT

On Thu, 19 Apr 2007, Vlad Cojocaru wrote:

VC> Dear vmd users,
VC>
VC> It might be a stupid question but still I couldnt figure out the answer
VC> ... I am trying to do something like the following:
VC>
VC> set LEU_AT "name CD1 CD2"
VC> set VAL_AT "name CG1 CG2"
VC> foreach res {77 183 188 198} {
VC> set CA [atomselect 0 "name CA and resid $res"]
VC> set RESNAME [$CA get resname]
VC> set RES_SEL ?$${RESNAME_AT??
VC> set A [atomselect 0 "$RES_SEL and resid $res"]
VC> .............
VC> }
VC>
VC> The problem is at line 6 when defining $RES_SEL (see question marks) .

VC> $RESNAME would become VAL or LEU and I would like to select that
VC> selection corresponding to $RESNAME ... For that I would need to assign
VC> one variable name ($RES_SEL) using another variable ($RESNAME)
VC> Can anybody tell how to do this in tcl ?

not sure if this is the most elegant/simple solution, but this works.

eval [join [list {set RES_SEL $} "$RES" {_AT}] ""]

axel.

VC>
VC> If naybody has a better solution to do this ... I would appreciate ..
VC>
VC> Thanks
VC> Vlad
VC>
VC>
VC>
VC>

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