From: Myunggi Yi (myunggi_at_gmail.com)
Date: Thu Nov 16 2006 - 19:07:49 CST

Dear VMD users,

I'm trying to extract the closest atom and residue inforamtion.
The following is my script.

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

proc closest { sel1 sel2 file } {
    set fout [open $file w]
    set nf [molinfo [$sel1 molid] get numframes]
    set list1 [$sel1 list]
    set list2 [$sel2 list]

    # find distances between each pair
    for { set i 0 } { $i < 2 } { incr i } {
        $sel1 frame $i
        $sel2 frame $i
        set crd1 [$sel1 get {x y z}]
        set crd2 [$sel2 get {x y z}]
        set min 1000.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)]
                if {[expr $dist($id1,$id2) < $min]} {
                    set close [atomselect [molinfo $id2] "text"]
                }
            }
        }
        puts $fout "[expr ($i + 1)*10] [$close get resname] [$close get name]"
    }
    close $fout
}
++++++++++++++++++++++++++++

I've got the following error message.

"can't read "close": no such variable"

Please help me how to fix this script.

-- 
Best wishes,
MYUNGGI YI
==================================
KLB 419
Institute of Molecular Biophysics
Florida State University
Tallahassee, FL 32306
Office: (850) 645-1334
http://www.scs.fsu.edu/~myunggi