From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Wed Mar 09 2011 - 09:41:31 CST

On Wed, Mar 9, 2011 at 9:32 AM, menica dibenedetto
<domenica.dibenedetto_at_gmail.com> wrote:
> Dear all,
> I try to run this code to calculate same distance:
> cd /Users/domenica/Desktop/01_DOP
> mol load pdb 01_DOP_wat.pdb
> mol addfile new01.dcd type dcd
> set sel1 [atomselect top "resid 136"]
> set sel2 [atomselect top "resname DP0"]
> set fil [open distance_136-DOP_1f.dat w]
> for {set i 1} {$i < 50} {incr i} {
> $sel1 frame $i
> $sel2 frame $i
> set com1 [measure center $sel1 weight mass]
> set com2 [measure center $sel2 weight mass]
> set simdata($i.r) [veclength [vecsub $com1 $com2]]
> puts $fil  " $simdata($i.r)"
> }
> set sel3 [atomselect top "resid 125"]
> set sel4 [atomselect top "resname DP0"]
> set fil [open distance_125-DOP_1f.dat w]
> for {set i 1} {$i < 50} {incr i} {
> $sel3 frame $i
> $sel4 frame $i
> set com1 [measure center $sel1 weight mass]
> set com2 [measure center $sel2 weight mass]
> set simdata($i.r) [veclength [vecsub $com1 $com2]]
> puts $fil " $simdata($i.r)"
> }
> quit
> I run this code inside the TKconsole and it work even if it stopped before
> 50 frames.
> The problem is that I need to run it from command line, but from command
> line, the script don't work.
> In the output file it wrote only first three distances, and after is repeted
> until the and the same distance.
> Seems to appen that it don't recognize the different frames.

there are two problems with your script.

a) you don't close your files.
b) in the second loop you refer to $sel1 and $sel2,
but you update the frames for $sel3 and $sel4.

there are also several unneeded operations,
but they should have no impact on the result.

i also recommend to use syntactic indentation,
as that makes code much easier to read.

ciao,
   axel.

> Best regards,
> Domenica

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