VMD atomselect help

Hi All,

I know this is a VMD question but I was unable to get registered for their mailing list. I’ve been trying to learn some Tcl so I can use Topotools (Thanks Axel!). When using atomselect I would like to do something like this:

set polyRes [atomselect top {index 1 3 5 7 9 11}]

The index list could be longer so I don’t want to hand enter each number so is it possible to use a list as an index? I tried:

set aList [list 1 3 5 7 9 11]
set polyRes [atomselect top {index $aList}] --> did not work

and I tried:
set polyRes [atomselect top {index aList}] --> also did not work

So how could I generate a list, maybe using a for/while loop and use the resulting list as the “index” input?

Thanks for your help and again sorry for submitting a VMD question to the LAMMPS mailing list,

Casey

hi casey,

Hi All,

I know this is a VMD question but I was unable to get registered for their

actually, it is neither a VMD nor a LAMMPS but a Tcl question.

mailing list. I've been trying to learn some Tcl so I can use Topotools

please have a close look at:
http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html

this is a _very_ well written self-study tutorial, that takes
you through many of the simple and not so simple steps
of writing Tcl scripts.

(Thanks Axel!). When using atomselect I would like to do something like
this:

set polyRes [atomselect top {index 1 3 5 7 9 11}]

The index list could be longer so I don't want to hand enter each number so
is it possible to use a list as an index? I tried:

set aList [list 1 3 5 7 9 11]
set polyRes [atomselect top {index $aList}] --> did not work

it certainly doesn't, since any string contained in curly braces
is not expanded, but taken as a literal string.

and I tried:
set polyRes [atomselect top {index aList}] --> also did not work

sure. you are not handing over a variable, but a word. and again,
due to the curly braces, it is handed over literally.

So how could I generate a list, maybe using a for/while loop and use the
resulting list as the "index" input?

strings embedded in double quotes _are_ expanded, so your command
would become:

set aList [list 1 3 5 7 9 11]
set polyRes [atomselect top "index $aList"]

Thanks for your help and again sorry for submitting a VMD question to the
LAMMPS mailing list,

please contact [email protected] with a detailed explanation
of what happened when registering for the vmd list. the mailing
list software hasn't changed for ages, and i don't recall any
persistent problem for people to subscribe.

axel.