From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Thu Nov 24 2011 - 14:42:53 CST

2011/11/24 Andrés Morales <h.andres.m1986_at_gmail.com>:
> Hi Sajad!
>
> What do you mean with proper selection?

forget his comments. they are completely missing the point.

> I also tried with the following protocols (the first one is like the one
> suggested for moveby function in the VMD User's Guide):
>
> proc change {sel M} {
>
>     set newcoords {}
>     foreach coord [$sel get {x y z}] {
>     set new [coordtrans [transtranspose $M] $coord]
>     lvarpush newcoords $new

why lvarpush?? why not lappend?

>     }
>     $sel set $newcoords

this is wrong. "atomselectX set" works similar to
"atomselectX get", so you have to tell it which properties
you want to set and provide a matching list of lists.

>     }
>
> and
>
> proc chage {sel M} {
>
>     set newcoords {}
>     foreach atom [$sel get index] {

>      set coord [lindex [[atomselect top "index $atom"] get {x y z}] 0]

never *EVER* use this kind of construct. it is a bad idea
can easily lead to memory leaks, and creates needless
atom selections where they are not needed. the former loop
construct does the exact same thing and is much cleaner
and faster.

>     set new [coordtrans [transtranspose $M] $coord]
>     lvarpush newcoords $new
>     }
>     $sel set $newcoords

same error as above.

>     }
>
> But I get the error:
>
> atomselection: improper method: set
> usage: <atomselection> <command> [args...]

>
> I hope some one could help me.

you should learn to help yourself by not
just hacking together a complex function
that is difficult to decipher, but rather
"build" it step-by-step. few people have
a tcl interpreter "in their head", so they
can parse and see errors in such complex
functions or in few cases, is the error so
blatantly obvious. if you build your scripts
in stages, you can also easily tell where
the error is originating.

cheers,
    axel.

>
> Thank
>
> Andres
>
> 2011/11/24 sajad falsafi <sajad.falsafi_at_yahoo.com>
>>
>> Hi,
>>
>> this process can't get the atomic coordinates ({x y z}). maybe you didn't
>> use the proper selection.
>>
>>
>> Best of luck,
>> Sajad Falsafi
>> Dept. of Genetics, Shahid Chamran University of Ahvaz
>> Toxicology Research Center, Jondi-Shapour University of Medical Sciences
>>
>>
>>
>> --- On Thu, 11/24/11, Andrés Morales <h.andres.m1986_at_gmail.com> wrote:
>>
>> > From: Andrés Morales <h.andres.m1986_at_gmail.com>
>> > Subject: vmd-l: Change coordinates
>> > To: vmd-l_at_ks.uiuc.edu
>> > Date: Thursday, November 24, 2011, 11:44 AM
>> > Dear VMD users:
>> > I am trying to to replace  the coordinates of a
>> > selections with other coordinates I calculated before.  The
>> > new coordinates were calculated using an specific matrix I
>> > defined before.
>> > I am using the following protocol:
>> > proc change {sel M} {
>> >
>> >  foreach atom [$sel get index] {
>> >   set pos [lindex [[atomselect top "index
>> > $atom"] get {x y z}] 0]
>> >   lvarpush newpos [coordtrans [transtranspose $M] $pos]
>> >  }
>> >  $sel set $newpos
>> >
>> >  }
>> >
>> > When I use this protocol with somethin like : change $sel
>> > $A,
>> > I get the mistake: can't read "x": no
>> > such variable
>> >
>> > Does anybody know how can I solve it?
>> > Any suggestions?
>> >
>> > Thanks
>> >
>> >
>> > Andres
>> >
>> >
>
>

-- 
Dr. Axel Kohlmeyer
akohlmey_at_gmail.com  http://goo.gl/1wk0
College of Science and Technology
Temple University, Philadelphia PA, USA.