13.2.3. Neighbor Search wrapper for MDAnalysis — MDAnalysis.lib.NeighborSearch

This module contains classes that allow neighbor searches directly with AtomGroup objects from MDAnalysis.

class MDAnalysis.lib.NeighborSearch.AtomNeighborSearch(atom_group: AtomGroup, box: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None)[source]

This class can be used to find all atoms/residues/segments within the radius of a given query position.

For the neighbor search, this class is a wrapper around capped_distance.

Parameters:
  • atom_list (AtomGroup) – list of atoms

  • box (array-like or None, optional, default None) – Simulation cell dimensions in the form of MDAnalysis.trajectory.timestep.Timestep.dimensions when periodic boundary conditions should be taken into account for the calculation of contacts.

search(atoms: AtomGroup, radius: float, level: str = 'A') AtomGroup | ResidueGroup | SegmentGroup | None[source]

Return all atoms/residues/segments that are within radius of the atoms in atoms.

Parameters:
Returns:

  • AtomGroup (AtomGroup) – When level='A', AtomGroup is being returned.

  • ResidueGroup (ResidueGroup) – When level='R', ResidueGroup is being returned.

  • SegmentGroup (SegmentGroup) – When level='S', SegmentGroup is being returned.

Changed in version 2.0.0: Now returns AtomGroup (when empty this is now an empty AtomGroup instead of an empty list), ResidueGroup, or a SegmentGroup