From: Chitrak Gupta (chgupta_at_mix.wvu.edu)
Date: Wed Apr 18 2018 - 10:14:18 CDT

Hi Sandip,

So if I understand correctly, you simply want to write a PDB for the frame
123 (or whatever), correct? You don't need a loo for that. Also, for
writing pdb you don't need to open the file for writing the way you do for
writing regular text files. Simply do this.

set atoms [atomselect top "not water"]
$atoms frame 123
$atoms writepdb file.dpb

Hope this helps,
Chitrak.

On Wed, Apr 18, 2018 at 10:29 AM, Sandip Mondal <sandchem13_at_gmail.com>
wrote:

> Dear user,
>
> I am new in writing tcl script. I wrote a simple script for writing
> selected regions in pdb format from a dcd.
>
> The script is as follows
>
> set atoms [atomselect top "not water"]
> set nf [molinfo top get numframes]
> set out [open "file.pdb" w]
> for {set i 0} {$i < $nf} {incr i} {
> if {$i == 123} {
> $atoms frame $i
> $atoms writepdb $out
> }
> }
>
> Here 123th frame of a dcd is just for example. This script doesn't
> write anything in that $out file, however it creates a new file which I
> expect in $out file. Can you plz suggest the way.
>
> Thanking you,
> Sandip
>