psfgen is currently distributed in two forms. One form is as a standalone program implemented as a Tcl interpreter which reads commands from standard output. You may use loops, variables, etc. as you would in a VMD or NAMD script. You may use psfgen interactively, but we expect it to be run most often with a script file redirected to standard input. The second form is as a Tcl package which can be imported into any Tcl application, including VMD. All the commands available to the standalone version of psfgen are available to the Tcl package; using psfgen within VMD lets you harness VMD's powerful atom selection capability, as well as instantly view the result of your structure building scripts. Examples of using psfgen both with and without VMD are provided in this document.
Generating PSF and PDB files for use with NAMD will typically consist of the following steps:
Chains can be split up into their own PDB files using your favorite text editor and/or Unix shell commands, as illustrated in the BPTI example below. If you are using VMD you can also use atom selections to write pieces of the structure to separate files:
# Split a file containing protein and water into separate segments. # Creates files named myfile_water.pdb, myfile_frag0.pdb, myfile_frag1.pdb,... # Requires VMD. mol load pdb myfile.pdb set water [atomselect top water] $water writepdb myfile_water.pdb set protein [atomselect top protein] set chains [lsort -unique [$protein get pfrag]] foreach chain $chains { set sel [atomselect top "pfrag $chain"] $sel writepdb myfile_frag${chain}.pdb }
Very often the atoms you want to delete are water molecules that are either too far from the solute, or else outside of the periodic box you are trying to prepare. In either case VMD atom selections can be used to select the waters you want to delete. For example:
# Load a pdb and psf file into both psfgen and VMD. resetpsf 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