Cell list to facilitate neighbor searching.

class pdb2pqr.cells.Cells(cellsize)[source]

Accelerate the search for nearby atoms.

A pure all versus all search is O(n^2) - for every atom, every other atom must be searched. This is rather inefficient, especially for large biomolecules where cells may be tens of angstroms apart. The cell class breaks down the xyz biomolecule space into several 3-D cells of desired size - then by simply examining atoms that fall into the adjacent cells one can quickly find nearby cells.


Initialize the cells.

Parameters:cellsize (int) – the size of each cell (in Angstroms)

Add an atom to the cell.

Parameters:atom (Atom) – the atom to add

Place each atom in a virtual cell for easy neighbor comparison.

Parameters:biomolecule (Biomolecule) – biomolecule with atoms to assign to cells

Find all atoms in cells bordering an atom.

Parameters:atom (Atom) – the atom to test
Returns:a list of nearby atoms
Return type:[Atom]

Remove an atom from a cell.

Parameters:atom (Atom) – the atom to remove