dimchris / mdanalysis

Automatically exported from code.google.com/p/mdanalysis
0 stars 0 forks source link

distance selections from AtomGroups do not work #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
 from MDAnalysis import Universe
 u = Universe(psf,dcd)
 w_ok = u.selectAtoms('name OH2 and around 4.0 protein') # select solvation
shell
 water = u.selectAtoms('name OH2')
 w_bad = water.selectAtoms('around 4.0 protein')

What is the expected output? 
 w_ok == w_bad 
 --> True

What do you see instead?
 w_ok == w_bad
 --> False
(In fact, w_bad == []) 

Original issue reported on code.google.com by orbeckst on 28 Aug 2008 at 12:55

GoogleCodeExporter commented 9 years ago
There exists a workaround if you know your selections. Then you can explicitly
construct the KDTree NeighborSearch from atom selection. (In fact, this is 
faster
than MDAnalysis selection parsing and may be rather useful when iterating over a
whole trajectory):

  import MDAnalysis.KDTree.NeighborSearch as kdNS

  u = Universe(psf,dcd)
  water = u.selectAtoms('name OH2')
  protein = u.selectAtoms('protein')

  # The following has to be done every time step:   
  ns_w = kdNS.AtomNeighborSearch(water)
  solvation_shell = ns_w.search_list(protein,4.0)  # water oxygens within 4A of 
protein

(see also the doc strings for MDAnalysis.KDTree.NeighborSearch)

Original comment by orbeckst on 28 Aug 2008 at 1:00

GoogleCodeExporter commented 9 years ago
Changed the title because the problem is really that selectAtoms() from Universe
behaves different from seletAtoms() from a arbitrary AtomSelection. In the code 
the
problem is that the atom selection does not know about any other atoms than 
itself.
Hence any selection that references atoms outside the AtomGroup fails.

Original comment by orbeckst on 2 Sep 2008 at 4:15

GoogleCodeExporter commented 9 years ago
changed title (removed 'UNSTABLE') because this issue is also present in 0.6.0

Original comment by orbeckst on 1 Apr 2010 at 11:27

GoogleCodeExporter commented 9 years ago
i'm going to give this one and issue 42 a look.

Original comment by jan...@gmail.com on 3 Jul 2011 at 6:25

GoogleCodeExporter commented 9 years ago
This is the simplest solution i could think of: when a selection is applied to 
an existing AtomGroup, it is in fact applied to its universe. Then, a common 
set of the starting Atoms and the newly selected ones is returned.

A common parent class to AtomGroup and Universe would probably be a better idea.

Original comment by jan...@gmail.com on 3 Jul 2011 at 8:39

Attachments:

GoogleCodeExporter commented 9 years ago
@jandom: The patch is probably to costly for most cases. I can't really think 
of a good way to change the underlying code to make this work except 
introducing "named selections" as proposed in Issue 42. I'll close it for the 
time being as wontfix.

Anyone, feel free to re-open.

Original comment by orbeckst on 13 Sep 2011 at 3:33