From: maria goranovic (
Date: Tue Jun 07 2011 - 04:01:34 CDT

Dear All,

I have a vmd script (copied below) which I would expect to exit after
finishing, but it does not. Any ideas why? version 1.9, linux, amd64

mol load gro all.gro
source mybigdcd2.tcl

# closewater.tcl
# Justin Gullingsrud
# 8 November 2004

# This script processes a trajectory to create a new file containing just
# a selection of atoms and the N closest water to that selection. The N
# waters are recomputed for each timestep, and need not be the same waters
# in each timestep (in fact, they probably will not be); thus it is in
# meaningless to analyze the dynamics of individual waters. However, it
# may be useful for analyzing the distribution of waters around a relatively
# static protein or DNA chain.

# usage: closewater <molid> <selection text> <# waters> <filename prefix>

proc closewater {i} {

  set molid 0
  set seltext "protein"
  set nwat 2500
  set prefix "close"
  puts "now working in frame $i"
  set numinner 0
  set inner [list]
  set cut 1
  while {1} {
      set sel [atomselect $molid "name OW and within $cut of ($seltext)"]
      set outer [$sel list]
      $sel delete
      set numouter [llength $outer]
      if { $numouter < $nwat } {
        set inner $outer
        set numinner $numouter
        incr cut
  puts "Found $numouter waters at cutoff $cut"
  catch { unset ohash }
  foreach ind $outer { set ohash($ind) 1 }
  foreach ind $inner { unset ohash($ind) }
  set outer [lrange [array names ohash] 0 [expr $nwat - $numinner - 1]]
  set watind [concat $inner $outer]
  set sel [atomselect $molid "($seltext) or same residue as (index
  set j [format %06d $i]
  $sel writepdb [format $prefix-$j.pdb]
  exec editconf -f $prefix-$j.pdb -o $prefix-$j.gro -resnr 1 &
bigdcd closewater temp.xtc

Maria G.
Technical University of Denmark