From: Sadegh Faramarzi Ganjabad (
Date: Tue May 20 2014 - 22:40:59 CDT


I have some unwanted atoms located in center of coordinates in pdb and psf
files. Those atoms are not connected to other atoms. Is there any way to
delete them from pdb and psf files, without damaging psf?
I have found some commands in VMD user's guide, but it seems they are for
deleting residues rather than individual atoms. Followings are those

Thank you in advance

# Load a pdb and psf file into both psfgen and VMD.
readpsf myfile.psf
coordpdb myfile.pdb
mol load psf myfile.psf pdb myfile.pdb
# Select waters that are more than 10 Angstroms from the protein.
set badwater1 [atomselect top "name OH2 and not within 10 of protein"]
# Alternatively, select waters that are outside our periodic cell.
set badwater2 [atomselect top "name OH2 and (x<-30 or x>30 or y<-30 or>30
or z<-30 or z>30)"]
# Delete the residues corresponding to the atoms we selected.
foreach segid [$badwater1 get segid] resid [$badwater1 get resid] {
delatom $segid $resid
# Have psfgen write out the new psf and pdb file (VMD’s structure and
# coordinates are unmodified!).
writepsf myfile_chopwater.psf
writepdb myfile_chopwater.pdb