From: Aravinda Munasinghe (
Date: Sun Jun 23 2019 - 11:48:15 CDT

I assume you have a selection of atoms and you want to pick atoms (i.e.,
solvent near a solute) within that selection (stays at least 80% of the
simulation time)?.
If so, I would loop the other way around, and addsomething like the
set outfile [open "output_name" w]
set num_frames [molinfo top get numframes]
for { set i 0 } { $i < $num_frames } { incr i } {
set atomenvirn [atomselect top "(exwithin $R of (selection_of_solute)) " ]
#exwithin does not count it self
puts $outfile $atomenvirn # this will write out all the indexes within the
previous selection
$atomenvirn delete #otherwise you will overload your mem
close $outfile

Then write a small python script to extract indexes which appears at least
80% during the simulation time.
You can customize this in fancy ways to get resid or other information.
Aravinda Munasinghe

On Fri, Jun 21, 2019 at 4:53 PM Amendra Fernando Hewa Dewage <> wrote:

> Hi
> I want to select atoms within certain distance (say 5 Angstrom) to an
> atom, where these atoms should be in that radius within 80% of the
> trajectory.
> ie. say you have two atoms, atom A and B, atom A is picked only if it is
> 80% of the time during the trajectory lies within 5 A of radius to atom B,
> part of the script is like this, here I am selecting side chains atoms
> within $R radius.
> foreach id $list {
> set sel1 [atomselect top "index $id" frame $iframe]
> set atomenvirn [atomselect top "(within $R of index $id) and
> (index $list and sidechain)" frame $iframe]
> I have large number of atoms.
> Thanks
> Aims

Aravinda Munasinghe,