From: srinivasa murthy (
Date: Tue Oct 07 2003 - 10:14:38 CDT

hi john,
        The script which you had given,works. But I
to generate sphere of radius more than 32 angstrom,
not working. I noted that, when radius exceeds 32
angstom, the water box created by the script contained
more than 27783 atoms(which is no. of atoms in wat.psf
and wat.pdb of ..plugins/noarch/tcl/solvate1.2).


--- John Stone <> wrote: >
> Hi,
> Your script is broken in several respects, here's
> a script I wrote
> that does what you had intended to do, but does it
> correctly, and uses
> solvate and psfgen to get the job done more or less
> as you had originally
> intended. Mine is written as several Tcl
> procedures, and you can specify
> your own radius and the center of the water sphere
> that you want to keep.
> The major problem with your script is that you
> assumed that the molecule
> loaded by VMD is the same structure that psfgen is
> operating on, but
> this is in fact not the case. You must explicitly
> tell psfgen what to
> load and work with, and this is done by writing your
> atom selection back
> out as a PDB file, as I do in my new version of your
> script. Take a look
> and let me know if you have questions. I did use
> one evil trick in my
> script, which is to load the topology file from the
> one that is included
> with the solvate script. Other than that, the rest
> of the script should
> be understandable.
> Enjoy,
> John Stone
proc drawselectionsphere { rad cx cy cz } {
  draw material Transparent
  set solvdraw [format "draw sphere { $cx $cy $cz }
radius $rad"]
  eval $solvdraw
  display update

proc makewatersphere { rad cx cy cz } {
  echo "generating water box of size [expr $rad * 2]
  package require solvate
  set solvcmd [format "solvate -o new -minmax {{ -$rad
-$rad -$rad} {$rad $rad
$rad}} -t 1.0"]
  puts $solvcmd
  # run the solvate command
  eval $solvcmd
mol new combine.psf
  mol addfile combine.pdb
  drawselectionsphere $rad $cx $cy $cz
  echo "generating water sphere of radius $rad from
box, in VMD"
  set r2 [expr $rad*$rad]
  set wat2keep [atomselect top "same residue as
((sqr(x-$cx)+sqr(y-$cy)+sqr(z-$cz)) <= $r2)"]
  $wat2keep writepdb watersphere.pdb
  $wat2keep delete
  mol delete top

proc makewaterspherepsf {} {
  package require psfgen
  set solversion [package require solvate]
  echo "generating water sphere PSF, via psfgen"
  set oldctx [psfcontext new]
  segment SOLV {
    auto none
    pdb watersphere.pdb

  coordpdb watersphere.pdb SOLV

  writepsf watersphere.psf
  writepdb watersphere.pdb
  psfcontext $oldctx delete

echo "deleting any old files"
file delete -force watersphere.psf
file delete -force watersphere.pdb
makewatersphere 10.0 20 20 20

mol new watersphere.pdb

mol delete top
mol new watersphere.psf
mol addfile watersphere.pdb


Yahoo! India Matrimony: Find your partner online.
Go to