From: Mustafa Tekpinar (tekpinar_at_buffalo.edu)
Date: Tue Nov 27 2012 - 15:00:55 CST

Hi,
I am trying to produce an Elastic Network Model representation by using a
simple VMD script. However, each time I get the following error:
"vecsub: two vectors don't have the same size"

Here is the script I wrote:
//==========================================
#Select a CPK representation of CA atoms.

menu graphics off
menu graphics on
mol modselect 0 0 name CA
mol modstyle 0 0 CPK 1.000000 0.300000 10.000000 10.000000
menu graphics off

#R_c = Cutoff radius

set R_c 10.0
set ca_atoms [atomselect top "name CA"]
set total_ca [$ca_atoms num]
puts "Total number of CA atoms are $total_ca"
for { set i 1 } { $i <= $total_ca } { incr i } {
    set coord1 [lindex [[atomselect top "resid $i and name CA"] get {x y
z}] 0]
    for { set j 1 } { $j < $i} { incr j } {
        set coord2 [lindex [[atomselect top "resid $j and name CA"] get {x
y z}] 0]
        set dist [veclength [vecsub $coord1 $coord2]]
        if {$dist <= $R_c} {
            if {[expr ($i-$j)]==1 } {
                draw color red
                draw cylinder $coord1 $coord2 radius 0.2
            } else {
                draw color yellow
                draw cylinder $coord1 $coord2 radius 0.1
            }
        }
    }
}

//==========================================
I will really be glad if anybody can point me my mistake.
Mustafa Tekpinar