From: Myunggi Yi (myunggi_at_gmail.com)
Date: Thu Oct 19 2006 - 22:30:48 CDT

Dear vmd users,

I'm trying to calculate minimum distance b/w two selections
using vecsub. (I'm not familiar with tcl.)

I have modified the ca-dist matrix script from the archive.
The following is my script.

++++++++++++++++++++++++++++++++++++++++++++
proc mymin { a b } {
    if {[expr $a < $b]} {
        return $a
    } else {
        return $b
    }
}

set fout [open file w]
set nf [molinfo 0 get numframes]

# selections
set sel1 [atomselect 0 "name CA and resid 185 to 190"]
set sel2 [atomselect 0 "name CA and resid 367 to 376"]

# find distances between each pair
for { set i 0 } { $i < $nf } { incr i } {
    $sel1 frame $i
    $sel2 frame $i
    set crd1 [$sel1 get {x y z}]
    set crd2 [$sel2 get {x y z}]
    set list1 [$sel1 list]
    set list2 [$sel2 list]
    set min 100.0

    foreach atom1 $crd1 id1 $list1 {
        foreach atom2 $crd2 id2 $list2 {
            set dist($id1,$id2) [veclength [vecsub $atom2 $atom1]]
            set min [mymin $min $dist($id1,$id2)]
        }
        # delete variables
        lvarpop crd1
        lvarpop crd2
    }
    puts $fout "[expr ($i + 1)*10] $min"

    lvarpop list1
    lvarpop list2
}
close $fout
++++++++++++++++++++++++++++++++++++++++++++++++

I've got the following error message.

vecsub: two vectors don't have the same size

What's wrong in the script?
Any help will be appreciated.

-- 
Best wishes,
MYUNGGI YI