From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Thu Aug 16 2018 - 08:14:03 CDT

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.