From: Daniel Kennedy (kenne358_at_umn.edu)
Date: Tue Jul 17 2007 - 16:40:57 CDT

Hi,

I need to build a sphere of water around a myosin model. The file
prot_cent.psf and prot_cent.pdb correspond to a protein which has had its
center of mass moved to the center and is oriented such that the atom which
is farthest from the center of mass lies along the x-axis. I want to build a
cube 5A bigger than the x-coord of this farthest atom and then turn it into a
sphere. I am using a modified version of the script found in the NAMD
tutorial. However, when I try to delete atoms outside the radius of my
sphere, nothing happens. After trying each step interactively, the problem
seems to be that VMD doesn't recognize any of the segments or residues
corresponding to the water. What is wrong with my script?

script:

# change these for different mutants #
set struc fmv
set resid 270
set probe cmsl

# paths from which all others are relative #
set pathin /project/wrk/danieljk/structures/$struc$resid$probe
set pathout /project/wrk/danieljk/structures/$struc$resid$probe

# load the centered complex #
mol new $pathin/prot_cent.psf
mol addfile $pathin/prot_cent.pdb

# find the atoms furthest away in the x direction #
set all [atomselect top all]
set rmax 0
foreach x [$all get x] {
        set r [expr sqrt($x*$x)]
        if {$r > $rmax} {
                set rmax $r
        }
}

mol delete top

# build a 5A padded water box around the complex #
set rmax [expr $rmax + 5]
set rmin [expr $rmax * -1.0]
package require solvate
solvate $pathin/prot_cent.psf $pathin/prot_cent.pdb -minmax "{$rmin $rmin
$rmin} {$rmax $rmax $rmax}" -o $pathout/prot_h2o_cube

# mark h2o to be deleted #
set goodh2o [atomselect top "same residue as {water and ($x*$x + $y*$y +
$z*$z) < ($rmax * $rmax)}"]
set badh2o [atomselect top "water and not same residue as {water and (x*x +
y*y + z*$) < ($rmax * $rmax)}"]
set badseg [$badh2o get segid]
set badres [$badh2o get resid]
set badname [$badh2o get name]

# loop over h2o to be deleted #
set n [llength $badseg]
for {set i 0} {$i < $n} {incr i} {
        delatom [lindex $badseg $i] [lindex $badres $i] [lindex $badname $i]
}

# write the files #
resetpsf
writepdb $pathout/prot_h2o_sphere.pdb
mol delete top

package require psfgen

if {probe eq "cmsl"} {
        topology /project/wrk/danieljk/setup/ring.inp
}

segment U {
        pdb $pathin/prot_h2o_sphere.pdb
}

coordpdb $pathin/prot_h2o_sphere.pdb U
guesscoord
writepsf $pathout/prot_h2o_sphere.psf
resetpsf

Daniel J. Kennedy
Department of Physics and Astronomy
University of Minnesota