From: Thomas C. Bishop (bishop_at_latech.edu)
Date: Fri Jan 23 2015 - 15:57:04 CST

exwithin was what I was looking for but it does not work for my  purpose

Maxim and Brian are on the right track
but maxim's code did not cut and paste ( bummer :-(... it's been too long a day to think now) but appears to do exactly what I want

fundamentally what I want to display are all pairs of Oxygens
that are w/in some cutoff of each other.


as stated in the current manual
(within 3 of protein) and not protein is equivalent to exwithin 3 of protein.
so  exwithin of name O 
eliminates is the oxygens I'm trying to catch


FYI:
The google page I found  was old so no mention of exwithin
http://www.ks.uiuc.edu/Research/vmd/vmd-1.3/ug/node142.html#SECTION001082000000000000000
the current manual spells things out though
http://www.ks.uiuc.edu/Research/vmd/current/ug/node97.html#5532


Thanks all.

Tom

On 01/23/2015 02:44 PM, Maxim Belkin wrote:

      
On Jan 23, 2015, at 2:05 PM, Axel Kohlmeyer <akohlmey@gmail.com> wrote:

On Fri, Jan 23, 2015 at 2:04 PM, Thomas C. Bishop <bishop@latech.edu> wrote:
Dear VMD,
I"m looking for a quick way to generate a list of atom pairs that are within
a specified distance of each other.
e.g find oxygen atoms that are within say 3A of each other.

I thought I could use the within command
set sel [atomselect top "within 3 of name O" ]

This selects all atoms within the specified distance (in Å) from a
selection,
BUT ALSO INCLUDES THE SELECTION ITSELF.

So the above sel includes ALL atoms named O b/c each oxygen is within 3 of
itself :-)

Maybe it's just Friday but I dont' see a simple solution here.
This selection is being used to highlight various pairs associated with a
radial distribution analysis.

Any tips,tricks or solutions greatly appreciated.
you want to use "exwithin" instead of "within".
.. and a little bit of coding.

For example, one could use a very (ultra?) slow script like this:

# result: pairlist with a list of pairs
#####################
set pairlist {}

set sel [atomselect top "name OH2"]
set sellist [$sel list]

foreach index $sellist {
	set selection [atomselect top "name OH2 and exwithin 3 of index $index"]
	set n [$selection num]
	if {$n > 0} {
		set selectionlist [$selection list]
		for {set i 0} {$i < $n} {incr i} {
			set idx [lindex $selectionlist $i]
			set pair [lsort [list $index $idx]]
			if {$pair ni $pairlist} {
				lappend pairlist $pair
			}
		}
	}
	$selection delete
}

$sel delete
#############################

Maxim

axel.

Is it worthwhile to suggest a " -self" option be added to the within command

Thanks in advance,
Tom.




--
*******************************
  Thomas C. Bishop
   Tel: 318-257-5209
   Fax: 318-257-3823
  www.latech.edu/~bishop
********************************


-- 
Dr. Axel Kohlmeyer  akohlmey@gmail.com  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.