From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Fri Mar 11 2011 - 11:49:39 CST

On Fri, Mar 11, 2011 at 11:17 AM, Ajasja Ljubetič
<ajasja.ljubetic_at_gmail.com> wrote:
> Hi,
> you have to move the set A and set B calls inside the loop

...and delete the $sel# update calls.
the selection will not change and the update is time consuming.
without, the script will give the same result faster.

cheers,
    axel.

>  set mol [molinfo top]
>  set sel1 [atomselect $mol "resname UNK"]
>  set sel2 [atomselect $mol "resid 200"]
>  set frames [molinfo $mol get numframes]
>  for {set i 0} {$i < $frames} {incr i} {
>   $sel1 frame $i
>   $sel2 frame $i
>         $sel1 update
>         $sel2 update
>         set A [lindex [$sel1 get { x y z }] 0]
>         set B [lindex [$sel2 get { x y z }] 0]
>         set distAB [vecdist $A $B]
>         puts "$i $distAB"
>  }
> regards,
> Ajasja
> On Fri, Mar 11, 2011 at 16:06, ban arn <ban.arn_at_gmail.com> wrote:
>>
>> Dear VMD users
>>
>> I'm new to tcl scripting and i'm thankful to help or suggestion.
>>
>> In tcl script for calculating the distance between center of mass of
>> ligand and residues along the trajectory, I'm trying to loop over the
>> trajectory, but I couldn't able to update the frames along the time.
>>
>> Kindly find the script here:
>>
>>  set mol [molinfo top]
>>  set sel1 [atomselect $mol "resname UNK"]
>>  set sel2 [atomselect $mol "resid 200"]
>>  set A [lindex [$sel1 get { x y z }] 0]
>>  set B [lindex [$sel2 get { x y z }] 0]
>>  set distAB [vecdist $A $B]
>>  set frames [molinfo $mol get numframes]
>>  for {set i 0} {$i < $frames} {incr i} {
>>   $sel1 frame $i
>>   $sel2 frame $i
>>         $sel1 update
>>         $sel2 update
>>         set n [vecdist $A $B]
>>         puts "$i $n"
>>  }
>>
>> Kindly advice
>>
>> Many Thanks
>> Balaji
>
>

-- 
Dr. Axel Kohlmeyer
akohlmey_at_gmail.com  http://goo.gl/1wk0
Institute for Computational Molecular Science
Temple University, Philadelphia PA, USA.