From: Peter Freddolino (petefred_at_ks.uiuc.edu)
Date: Thu Apr 19 2007 - 09:38:53 CDT

Hi Vlad,
I may not properly understand what you're after, but if I do, then you
can do this using eval:
eval "set RES_SEL \$${RESNAME}_AT"

However, using eval is almost never the right answer; in your case you'd
probably be happier using a tcl array to store the selections, indexed
using the residue names:

array set SELARR {LEU "name CD1 CD2" VAL "name CG1 CG2"}

...

set RES_SEL $SELARR($RESNAME)

Peter

Vlad Cojocaru wrote:
> Dear vmd users,
>
> It might be a stupid question but still I couldnt figure out the
> answer ... I am trying to do something like the following:
>
> set LEU_AT "name CD1 CD2"
> set VAL_AT "name CG1 CG2"
> foreach res {77 183 188 198} {
> set CA [atomselect 0 "name CA and resid $res"]
> set RESNAME [$CA get resname]
> set RES_SEL ?$${RESNAME_AT??
> set A [atomselect 0 "$RES_SEL and resid $res"]
> .............
> }
>
> The problem is at line 6 when defining $RES_SEL (see question marks) .
> $RESNAME would become VAL or LEU and I would like to select that
> selection corresponding to $RESNAME ... For that I would need to
> assign one variable name ($RES_SEL) using another variable ($RESNAME)
> Can anybody tell how to do this in tcl ?
>
> If naybody has a better solution to do this ... I would appreciate ..
>
> Thanks
> Vlad
>
>
>