From: Josh Vermaas (vermaas2_at_illinois.edu)
Date: Sat Sep 06 2014 - 11:53:40 CDT

Hi Eric,

Remember also that atomselection statements allow you to do math. So the
original:
(within X of EXP1 < 0) and
(within X of EXP1 > 0) and
(within X of EXP2 < 0) and
(within X of EXP2 > 0)

can logically become:

(within X of abs(EXP1) < 0) and
(within X of abs(EXP2) < 0)

Maybe I'm missing something, but won't your selection as written always
be empty? Atomselections operate on atoms, so in order for the "within"
statement to work, there needs to be some atom that fulfills the
criteria, and then the "within" operates on that selection and extends
it. The way I see it written your atomselection will always be empty, as
nothing has its absolute value less than zero, and the within selection
has nothing to operate on.

What you really want to do is define your region as a cylinder from the
get-go, and see which atoms fall within the cylinder. This is at the
heart of Ana's answer. If you need a bit more guidance, I answered a
similar question a while ago with some handy links:
http://www.ks.uiuc.edu/Research/vmd/mailing_list/vmd-l/23783.html

-Josh Vermaas

On 09/06/2014 03:39 AM, Ana Celia Vila Verde wrote:
> Hi Eric,
>
> I would do it in two steps:
>
> First, rotate your VMD molecule so that the line coincides with one of
> the axes. Use VMD's matrice routines.
>
> Then, assuming that your line now coincides with the z axis, you can
> select all atoms of type AAA within a certain distance R of that line
> at frame $frm with:
>
> set sel [atomselect top "(x**2 + y**2< R**2) and type AAA"]
> $sel frame $frm
> $sel update
>
> By the way, if type AAA is, for example, the water oxygen or some
> other atom type that's very abundant in your trajectory, it is more
> efficient to write
> set sel [atomselect top "(x**2 + y**2< R**2) and type AAA"]
> instead of
> set sel [atomselect top "type AAA and (x**2 + y**2< R**2) "]
>
> I hope it helps.
>
> Ana
>
> On 06/09/14 08:40, Eric Smoll wrote:
>> Hello VMD users,
>>
>> What is the best way to select all atoms a certain distance from a
>> line defined between two points?
>>
>> Toying with selections using a symmetric representation of the line,
>> I noticed that I cannot select atoms within a certain distance of a
>> plane. Only inequalities seem to work (greater-than or less-than the
>> plane). So, to achieve selection along a line, I have to resort to a
>> cumbersome expression like
>>
>> (within X of EXP1 < 0) and
>> (within X of EXP1 > 0) and
>> (within X of EXP2 < 0) and
>> (within X of EXP2 > 0)
>>
>> Is there a better way?
>>
>> Best,
>> Eric
>