From: Vlad Cojocaru (Vlad.Cojocaru_at_eml-r.villa-bosch.de)
Date: Thu Apr 13 2006 - 11:48:08 CDT

Dear vmd users,

I am trying to write some intermediate pdb files for different
selections using the simple script below .. However, I noticed that each
of the pdb file contains the same atoms (which correspond to the last
selection from the foreach loop -- last atom id--)... So, there is
something wrong with the way writepdb acts within a foreach loop.... Can
somebody please give me a short hint how to get around this ?... There
must be something easy ..its just that I am running out of time for a
deadline ...I am using vmd-1.8.4b10

set mol [mol new {file.pdb} type pdb]
set pathsel [atomselect $mol {resname XXX}]

foreach atomid [$pathsel get index] {
   set proteinsel [atomselect $mol {protein within 5 of index $atomid}]
   $proteinsel writepdb "$atomid.pdb"
}

Cheers
vlad

-- 
Dr. Vlad Cojocaru
EML Research gGmbH
Molecular and Cellular Modeling Group
Schloss-Wolfsbrunnenweg 33
69118 Heidelberg, Germany
Phone: +49-6221-533266
Fax: +49-6221-533298
e-mail: Vlad.Cojocaru_at_eml-r.villa-bosch.de
http://projects.villa-bosch.de/mcm/people/cojocaru/