From: Monika Madhavi (
Date: Sun Mar 08 2015 - 09:33:03 CDT

Dear all,

I want to write coordinates of some selected molecules to a separate pdb
and I want to add the entries to the same pdb file for each molecule I
select in each iteration of the for loop.

I used this tcl command

set outfile [open out.pdb w]
for {set i 0} {$i<N} {incr i} {
set sel [atomselect top "resid $i"]
$sel writepdb out.pdb

this code keeps writing the coordinates of each selection to a new file at
each iteration so at the end I only have the coordinates of the last atom
selected. How can I keep writing the coordinates to the same pdb without
deleting the old entries. Any help is greatly appreciated.


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