From: Norman Geist (norman.geist_at_uni-greifswald.de)
Date: Mon Mar 09 2015 - 06:08:36 CDT

Yes, you can write multiple frames for an atomselection to a single pdb file, but this only seems to make sense if you selection string doesn’t differ between frames.

 

example:

 

set myresids {}

for {whatever} {

                if {whatever} {

                               lappend myresids $resid

                }

}

set residlist [lrange $myresids 0 end]

set sel [atomselect top “resid $residlist”]

 

set lastframe [molinfo top get numframes]

animate write pdb my.pdb sel $sel beg 0 end [expr $lastframe-1]

 

$sel delete

 

If you need further help, it might be useful to know based on what criteria you build up our resid selection.

 

Norman Geist.

 

From: Monika Madhavi [mailto:monikamadhavi_at_gmail.com]
Sent: Monday, March 09, 2015 11:26 AM
To: Norman Geist
Cc: VMD Mailing List
Subject: Re: vmd-l: How to write coordinates to a pdb without replacing existing entries

 

Thanks Norman, your answer is exactly what I wanted. Is it possible to loop this around each frame also. Can I write the pdb entries for my atomselection ($sel here) for each frame in the same pdb?

Regards,

Monika

 

On Mon, Mar 9, 2015 at 3:12 PM, Norman Geist <norman.geist_at_uni-greifswald.de> wrote:

This is not the way it should be done. It is much easier and faster to just collect the resids you need 1st and write out the coordinates afterwards. You can easily collect the list of resids with “lappend”.

 

example:

 

set myresids {}

for {whatever} {

                if {whatever} {

                               lappend myresids $resid

                }

}

set residlist [lrange $myresids 0 end]

set sel [atomselect top “resid $residlist”]

$sel writepdb my.pdb

$sel delete

 

Norman Geist.

 

From: owner-vmd-l_at_ks.uiuc.edu [mailto:owner-vmd-l_at_ks.uiuc.edu] On Behalf Of Monika Madhavi
Sent: Monday, March 09, 2015 7:24 AM
To: Joaquim Rui de Castro Rodrigues
Cc: vmd-l_at_ks.uiuc.edu
Subject: Re: vmd-l: How to write coordinates to a pdb without replacing existing entries

 

Thanks Rui,
Actually I can select the residue ids I want to select but they are selected in a random manner and the number is large. Therefore I am wondering whether I can write coordinates of the selected molecule at the time it is selected without giving the whole list of ids at the end.

Regards,
Monika

Monika Madhavi
Department of Physics
University of Colombo

On Mar 8, 2015 11:03 PM, "Monika Madhavi" <monikamadhavi_at_gmail.com> wrote:

I want to achieve the result I would get if I write this command while looping around without writing line 2 as it is.

set residlist {1 2 3 4 5}

set sel [atomselect top "resid 1 2 3 4 5"]

$sel writepdb out.pdb

$sel delete

Regards,

Monik

 

 

On Sun, Mar 8, 2015 at 10:47 PM, Monika Madhavi <monikamadhavi_at_gmail.com> wrote:

Thanks Joaquim. Actually i set N outside the loop. What i want is to write all the coordinates in a single pdb file. As an example, something like

If my molecule is water,

Resid atomname coordinates
1 H1 .........
1 H2 ........
1 OH .........
2 H1 .........
2 H1 ..........
2 OH .........