From: Ashar Malik (asharjm_at_gmail.com)
Date: Thu Aug 16 2018 - 08:43:50 CDT

Interesting.

But if I understand your problem correctly, you are trying to save "a GRO"
file over every frame -- is that correct?

set zmin 30.3

set nf [molinfo top get numframes]
for {set i 0} {$i < $nf} {incr i} {

        set sel [atomselect top "resname SOL and z<$zmin" frame $i]
        $sel set resname den
        $sel writegro "water_interest$i.gro"
        $sel delete

}

I don't see any reason why the above shouldn't work.

On Thu, Aug 16, 2018 at 9:05 PM fan li <fanliqmul_at_gmail.com> wrote:

> Hi Malik
>
> I did that following this post
> http://www.ks.uiuc.edu/Research/vmd/mailing_list/vmd-l/6191.html .
>
> I want to select atoms in specific region for each frame. As the position
> selected condition changes over each frame, I can not put it outside the
> loop. But each atomselection will create a selection which will result in
> memory leakage. So I followed the post, I remove the "=" signal as there is
> a syntax error with the "=".
>
> Ashar Malik <asharjm_at_gmail.com> 于2018年8月16日周四 下午12:50写道:
>
>> I didn't know that one could play with variable names like that in TCL. !!
>> Perhaps you could explain the motivation behind appending $i to
>> $sel_water ??
>>
>>
>>
>> On Thu, Aug 16, 2018 at 7:18 PM fan li <fanliqmul_at_gmail.com> wrote:
>>
>>> Hi everyone
>>> I am trying to select atoms with specific region of SOL of each frame
>>> and change the selected atom's resname. I list part of my code below.
>>>
>>> ############################################
>>> set zmin 30.3
>>>
>>> set nf [molinfo top get numframes]
>>> for {set i 0} {$i < [expr (3-1)]} {incr i} {
>>>
>>> set sel_water($i) [atomselect top "resname SOL and z<$zmin"]
>>> $sel_water($i) frame $i
>>>
>>> #reset the resname of the selected water
>>> $sel_water($i) set resname den
>>>
>>> $sel_water($i) writegro "water_interest$i.gro"
>>>
>>> }
>>>
>>>
>>>
>>> ########################################
>>> This "set sel_water($i) [atomselect top "resname SOL and z<$zmin"]"
>>> selection is not working properly as the outcome is not the region I
>>> specified.
>>>
>>> Then I removed the "z<$zmin" and changed it to "set sel_water($i)
>>> [atomselect top "resname SOL"]", it woks fine as the entire water is
>>> selected.
>>>
>>> So could someone tell me why the selection is not working with the
>>> position selected condition is not working?
>>>
>>> As position selected condition changes over each frame in the actual
>>> code, so I can not put the selection outside the loop?
>>>
>>> Fan
>>>
>>
>>
>> --
>> Best,
>> /A
>>
>

-- 
Best,
/A