From: John Stone (johns_at_ks.uiuc.edu)
Date: Wed May 03 2006 - 18:12:04 CDT

Heh, one should never write scripts in a hurry, but I often have no choice
if I'm going to keep up with all of my email...

Here's another version that fixes a couple small bugs with the frame range:

##
## Write PDB files from a trajectory, using specified frame range
##
## Example:
## writepdbsfromtraj top all 0 -1 1 /tmp/mytraj%04d.pdb

proc writepdbsfromtraj { molid seltext first last step fileformat } {
  set numframes [molinfo $molid get numframes]
  set sel [atomselect $molid $seltext]

  if { $last < 0 } {
    set last [expr $numframes - 1]
  }

  for {set frame $first} {$frame < $last} {incr frame $step} {
    $sel frame $frame
    $sel update
    puts "Frame: $frame"

    set filename [format $fileformat $frame]
    $sel writepdb $filename
  }

  $sel delete
}

  

On Wed, May 03, 2006 at 05:52:21PM -0500, John Stone wrote:
> Hi,
> Try this script:
>
> ##
> ## Write PDB files from a trajectory, using specified frame range
> ##
> ## Example:
> ## writepdbsfromtraj top all 0 -1 1 /tmp/mytraj%04d.pdb
>
> proc writepdbsfromtraj { molid seltext first last step fileformat } {
> set numframes [molinfo $molid get numframes]
> set sel [atomselect $molid $seltext]
>
> if { $last < 0 } {
> set last $numframes
> }
>
> for {set frame $first} {$frame < $numframes} {incr frame $step} {
> $sel frame $frame
> $sel update
> puts "Frame: $frame"
>
> set filename [format $fileformat $frame]
> $sel writepdb $filename
> }
>
> $sel delete
> }
>
>
> On Wed, May 03, 2006 at 05:19:21PM -0400, Raul Araya Secchi wrote:
> >
> > Dear VMD users:
> >
> > This may sound trivial, but ....
> >
> > I have a dcd file with 600 frames, and I want to pick 50 frames and
> > save each one as an independent pdb file, but the only result I get is
> > one bif pdb file with all my selected frames in it. So how can I make
> > vmd save each frame in one pdb file??
> >
> > Please Help....
> >
> > Raul Araya
> > CGB_Universidad Catolica de Chile
>
> --
> NIH Resource for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> Email: johns_at_ks.uiuc.edu Phone: 217-244-3349
> WWW: http://www.ks.uiuc.edu/~johns/ Fax: 217-244-6078

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078