From: Monika Madhavi (
Date: Mon Feb 01 2016 - 18:01:41 CST

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,

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
animate delete beg 0 $mol
$sel1 delete

W.A.Monika Madhavi
Lecturer (Probation),
Department of Physics,
University of Colombo.