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

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.
>
>
>