Class Grid
java.lang.Object
org.biojava.nbio.structure.contact.Grid
A grid to be used for calculating atom contacts through a spatial hashing algorithm.
The grid is composed of cells of size of the cutoff so that the distances that need to be calculated are reduced to those within each cell and to the neighbouring cells.
Usage, for generic 3D points:
Point3d[] points = ...; Grid grid = new Grid(8.0); grid.addCoords(points); List<Contact> contacts = getIndicesContacts();Usage, for atoms:
Atom[] atoms = ...; Grid grid = new Grid(8.0); grid.addCoords(atoms); AtomContactSet contacts = getAtomContacts();
- Author:
- Jose Duarte
-
Constructor Summary
ConstructorDescriptionGrid
(double cutoff) Creates aGrid
, the cutoff is in the same units as the coordinates (Angstroms if they are atom coordinates) and can be specified to a precision of 0.01. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a set of atoms, subsequent call togetIndicesContacts()
orgetAtomContacts()
will produce the interatomic contacts.void
Adds the i and j atoms and fills the grid.void
addAtoms
(Atom[] atoms, BoundingBox bounds) Adds a set of atoms, subsequent call togetIndicesContacts()
orgetAtomContacts()
will produce the interatomic contacts.void
addAtoms
(Atom[] iAtoms, BoundingBox icoordbounds, Atom[] jAtoms, BoundingBox jcoordbounds) Adds the i and j atoms and fills the grid, passing their bounds (array of size 6 with x,y,z minima and x,y,z maxima) This way the bounds don't need to be recomputed.void
addCoords
(javax.vecmath.Point3d[] atoms) Adds a set of coordinates, subsequent call togetIndicesContacts()
will produce the contacts, i.e. the set of points within distance cutoff.void
addCoords
(javax.vecmath.Point3d[] iAtoms, javax.vecmath.Point3d[] jAtoms) Adds the i and j coordinates and fills the grid.void
addCoords
(javax.vecmath.Point3d[] atoms, BoundingBox bounds) Adds a set of coordinates, subsequent call togetIndicesContacts()
will produce the contacts, i.e. the set of points within distance cutoff.void
addCoords
(javax.vecmath.Point3d[] iAtoms, BoundingBox icoordbounds, javax.vecmath.Point3d[] jAtoms, BoundingBox jcoordbounds) Adds the i and j coordinates and fills the grid, passing their bounds (array of size 6 with x,y,z minima and x,y,z maxima) This way the bounds don't need to be recomputed.Returns all contacts, i.e. all atoms that are within the cutoff distance.Deprecated.double
protected javax.vecmath.Point3d[]
Returns all contacts, i.e. all atoms that are within the cutoff distance, as simple Contact objects containing the atom indices pairs and the distance.protected javax.vecmath.Point3d[]
boolean
hasAnyContact
(Collection<javax.vecmath.Point3d> atoms) boolean
hasAnyContact
(javax.vecmath.Point3d[] atoms) Fast determination of whether any atoms from a given set fall within the cutoff of iAtoms.boolean
Tells whether (after having added atoms to grid) the i and j grids are not overlapping.
-
Constructor Details
-
Grid
Creates aGrid
, the cutoff is in the same units as the coordinates (Angstroms if they are atom coordinates) and can be specified to a precision of 0.01.- Parameters:
cutoff
-
-
-
Method Details
-
addAtoms
Adds the i and j atoms and fills the grid. Their bounds will be computed. Subsequent call togetIndicesContacts()
orgetAtomContacts()
will produce the interatomic contacts.- Parameters:
iAtoms
-jAtoms
-
-
addAtoms
public void addAtoms(Atom[] iAtoms, BoundingBox icoordbounds, Atom[] jAtoms, BoundingBox jcoordbounds) Adds the i and j atoms and fills the grid, passing their bounds (array of size 6 with x,y,z minima and x,y,z maxima) This way the bounds don't need to be recomputed. Subsequent call togetIndicesContacts()
orgetAtomContacts()
will produce the interatomic contacts.- Parameters:
iAtoms
-icoordbounds
-jAtoms
-jcoordbounds
-
-
addAtoms
Adds a set of atoms, subsequent call togetIndicesContacts()
orgetAtomContacts()
will produce the interatomic contacts. The bounding box of the atoms will be computed based on input array- Parameters:
atoms
-
-
addAtoms
Adds a set of atoms, subsequent call togetIndicesContacts()
orgetAtomContacts()
will produce the interatomic contacts. The bounds calculated elsewhere can be passed, or if null they are computed.- Parameters:
atoms
-bounds
-
-
addCoords
Adds the i and j coordinates and fills the grid. Their bounds will be computed. Subsequent call togetIndicesContacts()
will produce the contacts, i.e. the set of points within distance cutoff. Subsequent calls to methodgetAtomContacts()
will produce a NullPointerException since this only adds coordinates and no atom information.- Parameters:
iAtoms
-jAtoms
-
-
addCoords
public void addCoords(javax.vecmath.Point3d[] iAtoms, BoundingBox icoordbounds, javax.vecmath.Point3d[] jAtoms, BoundingBox jcoordbounds) Adds the i and j coordinates and fills the grid, passing their bounds (array of size 6 with x,y,z minima and x,y,z maxima) This way the bounds don't need to be recomputed. Subsequent call togetIndicesContacts()
will produce the contacts, i.e. the set of points within distance cutoff. Subsequent calls to methodgetAtomContacts()
will produce a NullPointerException since this only adds coordinates and no atom information.- Parameters:
iAtoms
-icoordbounds
-jAtoms
-jcoordbounds
-
-
addCoords
Adds a set of coordinates, subsequent call togetIndicesContacts()
will produce the contacts, i.e. the set of points within distance cutoff. The bounding box of the atoms will be computed based on input array. Subsequent calls to methodgetAtomContacts()
will produce a NullPointerException since this only adds coordinates and no atom information.- Parameters:
atoms
-
-
addCoords
Adds a set of coordinates, subsequent call togetIndicesContacts()
will produce the contacts, i.e. the set of points within distance cutoff. The bounds calculated elsewhere can be passed, or if null they are computed. Subsequent calls to methodgetAtomContacts()
will produce a NullPointerException since this only adds coordinates and no atom information.- Parameters:
atoms
-bounds
-
-
getAtomContacts
Returns all contacts, i.e. all atoms that are within the cutoff distance. If both iAtoms and jAtoms are defined then contacts are between iAtoms and jAtoms, if jAtoms is null, then contacts are within the iAtoms.- Returns:
-
getContacts
Deprecated.usegetAtomContacts()
insteadReturns all contacts, i.e. all atoms that are within the cutoff distance. If both iAtoms and jAtoms are defined then contacts are between iAtoms and jAtoms, if jAtoms is null, then contacts are within the iAtoms.- Returns:
-
getIndicesContacts
Returns all contacts, i.e. all atoms that are within the cutoff distance, as simple Contact objects containing the atom indices pairs and the distance. If both iAtoms and jAtoms are defined then contacts are between iAtoms and jAtoms, if jAtoms is null, then contacts are within the iAtoms.- Returns:
-
hasAnyContact
Fast determination of whether any atoms from a given set fall within the cutoff of iAtoms. IfaddAtoms(Atom[], Atom[])
was called with two sets of atoms, contacts to either set are considered.- Parameters:
atoms
-- Returns:
-
hasAnyContact
-
getCutoff
-
isNoOverlap
Tells whether (after having added atoms to grid) the i and j grids are not overlapping. Overlap is defined as enclosing bounds of the 2 grids being no more than one cell size apart.- Returns:
- true if the 2 grids don't overlap, false if they do
-
getIAtoms
-
getJAtoms
-
getAtomContacts()
instead