From: Peter Freddolino (
Date: Mon Feb 01 2016 - 20:51:30 CST

Dear Monika,
The atom selections are not constructed on a frame by frame basis. You can update them with $sel update, but at the time that the animate write command is issued, only their current state will be considered. You can solve this easily enough just by looping over frames and writing a separate pdb file for each of them.

> On Feb 1, 2016, at 7:01 PM, Monika Madhavi <> wrote:
> Dear all,
> I want to create some atomselections, update them every frame and write the coordinates to a pdb file. I need to create a pdb file for each atom selection (which includes updated coordinates for all frames). Below is the code I wrote. The code works but, the selections are not updated. In the pdb files, there are coordinates of the same atom selection. Can you please suggest a way to correct this.
> Thank you.
> Best regards,
> Monika
> proc intermol1 {n} {
> #reading tracer atoms from a file
> set input [open "myout.dat" r]
> set atomlist [read $input]
> set len [llength $atomlist]
> #
> #select tracer atoms one by one
> for {set i 0} {$i < $len} {incr i} {
> set fname [format "interout%03d" $i]
> set ind1 [lindex $atomlist $i]
> set ind2 [expr $ind1+1]
> #
> #load trajectory frame by frame
> set mol [mol new my.psf type psf waitfor all]
> for {set frm 0} {$frm < $n} {incr frm} {
> mol addfile ../my.dcd type dcd first $frm last $frm waitfor all molid $mol
> #
> set centH1 [atomselect $mol "index $ind1" frame $frm]
> set coorH1 [lindex [$centH1 get {x y z }] 0]
> set x0 [lindex $coorH1 0]
> set y0 [lindex $coorH1 1]
> set z0 [lindex $coorH1 2]
> $centH1 delete
> #select H in a 5A sphere
> set sel1 [atomselect $mol "name H1 H2 and sqrt(sqr(x-x0)+sqr(y-y0)+sqr(z-z0))<5 and not index $ind2" frame $frm]
> $sel1 update
> }
> animate write pdb $fname.pdb beg 0 end [expr $n-1] waitfor all sel $sel1 $mol
> animate delete beg 0 $mol
> $sel1 delete
> }
> }
> --
> W.A.Monika Madhavi
> Lecturer (Probation),
> Department of Physics,
> University of Colombo.