From: Monika Madhavi (monikamadhavi_at_gmail.com)
Date: Mon Mar 09 2015 - 01:24:11 CDT

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 .........
>> .
>> .
>> .
>>
>> Regards,
>> Monika
>>
>> Monika Madhavi
>> Department of Physics
>> University of Colombo
>> On Mar 8, 2015 10:11 PM, "Joaquim Rui de Castro Rodrigues" <
>> joaquim.rodrigues_at_ipleiria.pt> wrote:
>>
>>> Dear Monika,
>>>
>>> I don't quite get what you are trying to achieve... Do you want to get
>>> separate PDB files for each resid?
>>> Anyhow, I see a few problems with your script:
>>> - the for loop contains a strange comparison: $i<N. I just tested this
>>> and it results in an infinite loop. You must set N outside of the loop.
>>> - you're looping over resid's, but always writing to same the same file
>>> (out.pdb)
>>> - you're building atomselections at each iterations without deleting
>>> them. Your script should crash vmd at some point.
>>>
>>> The following script should write resid's to separate files:
>>>
>>> set N 10
>>> for {set i 0} {$i<$N} {incr i} {
>>> set sel [atomselect top "resid $i"]
>>> $sel writepdb [format out.%05d.pdb $i]
>>> $sel delete
>>> }
>>>
>>> Hope this helps,
>>> J Rui Rodrigues
>>>
>>>
>>> ________________________________________
>>> De: owner-vmd-l_at_ks.uiuc.edu [owner-vmd-l_at_ks.uiuc.edu] Em Nome De Monika
>>> Madhavi [monikamadhavi_at_gmail.com]
>>> Enviado: domingo, 8 de Março de 2015 14:33
>>> Para: vmd-l_at_ks.uiuc.edu
>>> Assunto: vmd-l: How to write coordinates to a pdb without replacing
>>> existing entries
>>>
>>> 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.
>>>
>>> Regards,
>>> Monika
>>> --
>>> W.A.Monika Madhavi
>>> Lecturer (Probation),
>>> Department of Physics,
>>> University of Colombo.
>>
>>
>
>
> --
> W.A.Monika Madhavi
> Lecturer (Probation),
> Department of Physics,
> University of Colombo.
>