From: DCM CA (delcmca_at_gmail.com)
Date: Wed Jun 08 2011 - 20:57:17 CDT

Hello,

  I have written the following script to trace distances among atoms
through a MD simulation

  My problem is that I have to write explicitly the atom's ID's ...

==============================
==================
proc dist_atoms_over_time {{mol top} a1 a2 b1 b2} {

    set all [atomselect top all]
    #get the number of frames
    set num_steps [molinfo $mol get numframes]
    #open file for writing
    set fil [open dist_atoms.dat w]

    #loop over all frames in the trajectory
    for {set frame 0} {$frame < $num_steps} {incr frame} {

        # set dist_1 [measure bond {$a1 $b1 } molid $mol frame $frame
] <--- problem
        # set dist_1 [measure bond {$a2 $b2 } molid $mol frame $frame
] <---problem

            set dist_1 [measure bond {4115 7094 } molid $mol frame $frame
] <--replace with real ID's
            set dist_2 [measure bond {4129 7094 } molid $mol frame $frame ]
            set dist_3 [measure bond {4146 7094 } molid $mol frame $frame ]
            puts $fil " $frame \t $dist_1 $dist_2 $dist_3"
        }
     close $fil
    }
=======================================================
I would like to call this process simply as:

   dist_atoms_over_time { 0 a1 a2 b1 b2 },( as in the last line of the
script below)

and perform the task in the way of the two commented lines, i.e.:

# set dist_1 [measure bond {$a1 $b1 } molid $mol frame $frame ]
# set dist_1 [measure bond {$a2 $b2 } molid $mol frame $frame ]
in the program above...

 but the program would not run. It needs the replacement of $a1, $b1...
etc.,
with the real ID's, as shown in the following lines....
and this is cumbersome, since one would like to trace any two distances
through the simulation...

What I mean is that I have to run another script in order to get explicitly
the ID's,
and input from the keyboard the numbers as are shown above......!!!!

The program to get the ID's is the following.... it works just fine...

where a1, a2, b1, and b2 are the atomic ID's

==================================================
proc dist_atom { } {
# make the atom selections

    set sel1 [atomselect top "chain A and resid 255 and name CA"]
    set sel2 [atomselect top "chain B and resid 103 and name CA"]
    set a1 [$sel1 get index ]
    set b1 [$sel2 get index ]
    puts "atom1: $a1 atom2: $b1"

    set sel1 [atomselect top "chain A and resid 256 and name CA"]
    set sel2 [atomselect top "chain B and resid 103 and name CA"]
    set a2 [$sel1 get index ]
    set b2 [$sel2 get index ]
    puts "atom1: $a2: atom2: $b2 "

dist_atoms_over_time 0 a1 b1 a2 b2 <---- this is the problem line, I don't
know why it woudn't work
 }

================================================

Can any one tell me please, why is this happening... ?

 Thanks in advance:
                                        Carlos