From: João Ribeiro (jribeiro_at_ks.uiuc.edu)
Date: Thu Aug 16 2018 - 08:23:51 CDT

Also, if you need to create atom selections inside the loop (e.g. if
zmin value changes), you should definitely delete the selection before the
next iteration ("$sel_water($i) delete"), unless you need the atom
selection for another operation outside the loop, or the selections don't
take that much memory.

Best

João

On Thu, Aug 16, 2018 at 8:14 AM Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:

>
>
> On Thu, Aug 16, 2018 at 7:17 AM 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?
>>
>
> that last statement is not correct something like this:
>
> $sel frame $i
> $sel update
>
> will re-evaluate the selection stored in $sel for the frame $i (that is,
> for as long as $zmin doesn't change, as the selection string will evaluate
> variables when the selection is defined and not re-evaluate it when
> updated).
>
> axel.
>
>
>
>>
>> Fan
>>
>
>
> --
> Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0
> College of Science & Technology, Temple University, Philadelphia PA, USA
> International Centre for Theoretical Physics, Trieste. Italy.
>

-- 
……………………………………………………...
João Vieira Ribeiro
Theoretical and Computational Biophysics Group
Beckman Institute, University of Illinois
http://www.ks.uiuc.edu/~jribeiro/
jribeiro_at_ks.uiuc.edu
+1 (217) 3005851