schrodinger :: structutils :: measure :: DistanceCellIterator :: Class DistanceCellIterator
[hide private]
[frames] | no frames]

Class DistanceCellIterator

object --+
         |
        DistanceCellIterator

Iterate through neighbors of specified atoms. This class replaces the dist_cell_iterator function.

Instance Methods [hide private]
 
__init__(self, struc, dist, atoms=None)
Construct the distance cell to use for finding neighbors
 
__del__(self)
generator
iterateNeighboringAtoms(self, struc=None, atoms=None)
Iterate over neighboring atoms (atoms within dist Angstrom of each other)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, struc, dist, atoms=None)
(Constructor)

 

Construct the distance cell to use for finding neighbors

Parameters:
  • struc (schrodinger.structure.Structure) - The structure to use for building the distance cell
  • dist (float) - The distance cutoff for calculating neighbors
  • atoms (list) - A list of atom numbers for struc. If given, the distance cell will only contain the specified subset of atoms, so all other atoms will be ignored when calculating neighbors. If not given, all atoms will be used.
Overrides: object.__init__

iterateNeighboringAtoms(self, struc=None, atoms=None)

 

Iterate over neighboring atoms (atoms within dist Angstrom of each other)

Parameters:
  • struc (schrodinger.structure.Structure) - The query structure. Neighbors will be found for each atom of this structure. If not given, the structure passed to __init__ will be used as the query structure.
  • atoms (list) - A list of atom numbers for the query structure. If given, only the specified atoms will be examined. If not given, all atoms of the query structure will be used.
Returns: generator
A generator that iterates through neighbors. Each iteration will yield a tuple of:
  • An atom index from the query structure
  • A list of neighboring atom indices from the structure passed to __init__

Note: This method returns atom indices instead of atom object due to speed concerns. Profiling (using timeit) showed that:

  • returning atom indices instead of atom objects reduced runtime by ~25%
  • using coord = mm.mmct_atom_get_xyz(struc.handle, atom_num) in place of coord = struc.atom[atom_num].xyz also reduced runtime by ~25%