From: L. Michel Espinoza-Fonseca (mef_at_ddt.biochem.umn.edu)
Date: Thu Mar 20 2008 - 13:46:21 CDT

Lisa,

I forgot to mention one more thing. If you have a trajectory, you
should update your selections; thus, your script would look like this:

proc a2adist {A B} {
      set nf [molinfo top get numframes]
      set outfile [open adist.txt w]
      puts $outfile "Frame# A2A_Distance"
      for {set i 0} {$i < $nf } { incr i } {
              $posA frame $i
              $posB frame $i
              $posA update
              $posB update
              set posA [$A get {x y z}]
              set posB [$B get {x y z}]
              set dist [veclength [vecsub $posA $posB]]
              puts $outfile "$i $dist"
      }
      close $outfile
}

Cheers,
Michel

On Thu, Mar 20, 2008 at 1:35 PM, L. Michel Espinoza-Fonseca
<mef_at_ddt.biochem.umn.edu> wrote:
> On Thu, Mar 20, 2008 at 12:38 PM, Simpson, Lisa M <lmsimp_at_essex.ac.uk> wrote:
> >
> > Dear VMD users,
>
> Dear Lisa,
>
>
> >
> > A few years ago someone put a post out about a script called a2adist.tcl (see below)
> > http://www.ks.uiuc.edu/Research/vmd/mailing_list/vmd-l/2805.html
> >
> > I have tried running it but have had no luck. I keep a vecsub error when I execute-
> >
> > vmd > set A [atomselect top "index 1000"]
> > atomselect0
> > vmd > vmd > set B [atomselect top "index 3000"]
> > atomselect1
> > vmd > source a2adist.tcl
> > vmd > a2adist $A $B
> >
> > vecsub: non-numeric in first argument
> >
> > I don't suppose you know what I'm doing wrong?
> > Any help would be greatly appreciated.
>
> To make your script work, you should have something like:
>
>
> proc a2adist {A B} {
> set nf [molinfo top get numframes]
> set outfile [open adist.txt w]
> puts $outfile "Frame# A2A_Distance"
> for {set i 0} {$i < $nf } { incr i } {
> set posA [$A get {x y z}]
> set posB [$B get {x y z}]
> set dist [veclength [vecsub $posA $posB]]
>
> puts $outfile "$i $dist"
> }
> close $outfile
> }
>
> This will actually calculate the length of the vector between both selections.
>
> Cheers,
> Michel
>
>
> >
> > Thanks.
> >
> > Lisa.
> >
> > a2adist.tcl
> > ---------------------------------------------------------
> >
> > proc a2adist {A B} {
> > set nf [molinfo top get numframes]
> > set outfile [open adist.txt w]
> > puts $outfile "Frame# A2A_Distance"
> > for {set i 0} {$i < $nf } { incr i } {
> > set posA [$A get {x y z}]
> > set posB [$B get {x y z}]
> > set dist [vecdist $posA $posB]
> > puts $outfile "$i $dist"
> > }
> > close $outfile
> > }
> >
> > ---------------------------------------------------------
> >
> >
> > OLD POSTS:
> >
> > Hi Jerry,
> >
> > You can save below procedure into a file (i.e. a2adist.tcl) and call it vmd
> > tkon shell.
> >
> > To make it work type in vmd tkon shell:
> >
> > set atomA [atomselect top "index 555"]
> > set atomB [atomselect top "index 666"]
> > source a2adist.tcl
> > a2adist atomA atomB
> >
> > You can also make extra calculation within for loop.
> >
> > ----Procedure----
> > proc a2adist {A B} {
> > set nf [molinfo top get numframes]
> > set outfile [open adist.txt w]
> > puts $outfile "Frame# A2A_Distance"
> > for {set i 0} {$i < $nf } { incr i } {
> > set posA [$A get {x y z}]
> > set posB [$B get {x y z}]
> > set dist [vecdist $posA $posB]
> > puts $outfile "$i $dist"
> > }
> > close $outfile
> > }
> > ==========ABC==========
> > Ahmet Bakan
> > Chemistry, Junior
> > Koc University
> > abakan_at_ku.edu.tr
> > ICQ #86167698
> > http://home.ku.edu.tr/~abakan
> >
> > -----Original Message-----
> > From: owner-vmd-l_at_ks.uiuc.edu [mailto:owner-vmd-l_at_ks.uiuc.edu] On Behalf Of
> > Jerry Ebalunode
> > Sent: Thursday, May 06, 2004 11:18 PM
> > To: vmd-l_at_ks.uiuc.edu
> > Subject: vmd-l: measuring distances in vmd tkon
> >
> > Hi all,
> >
> > Which commands or set of commands could one use in measuring distances
> > between two atoms and if possible monitoring this property over a
> > trajectory
> > and writing it to disk for later examination, within the vmd tkon shell.
> >
> > Thanks for any help in advance.
> >
> >
> >
>