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] cubed" 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] topology $env(VMDDIR)/plugins/noarch/tcl/solvate$solversion/wat.top 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 makewaterspherepsf mol delete top mol new watersphere.psf mol addfile watersphere.pdb