From: Manali Mehendale (
Date: Fri Dec 07 2007 - 13:15:59 CST


I am trying to calculate the length of multiple (thousands) small
molecules (upto 100 atom length).
My script works perfect for few molecules but when i try to process
thousands it takes up too much memory and freezes up the system.
Any help will be greatly appreciated.


The script is as follows:

set outfile1 [open length.dat w];
set m 0
foreach filename [lsort -dictionary [glob *.mol2]] {
puts $filename
mol new $filename type mol2 waitfor all
molinfo top set drawn 0
incr m 1

for {set k 0 } {$k < 4000 } { incr k} {

set distAB 0
set sel [atomselect $k all]
set s [$sel get index]
set length [llength $s]

for {set i 0 } {$i < $length } { incr i} {
for { set j 0 } { $j < $length} {incr j} {

set sel1 [atomselect $k "index $i"]
set sel2 [atomselect $k "index $j"]
set A [lindex [$sel1 get { x y z}] 0]
set B [lindex [$sel2 get { x y z}] 0]

lappend distAB [vecdist $A $B]
set result [lindex [lsort -decreasing $distAB] 0]
puts $outfile1 $result
close $outfile1