Gridmesh
Grid mesh construction and manipulation for pocket detection.
This module provides the GridMesh class, which represents a box of
equidistant 3D points used during POVME's pocket-detection phase. The class
supports:
- Generating a regular grid that encompasses a protein's bounding box.
- Removing points outside a convex hull.
- Removing points that clash with protein atoms.
- Filtering isolated points that lack sufficient neighbors.
- Expanding the grid to higher resolution around surviving points.
- Separating surviving points into distinct pockets.
GridMesh(box, res)
¶
A class representing a box of equidistant points.
Initialize the class.
| PARAMETER | DESCRIPTION |
|---|---|
|
A numpy array representing two 3D points, (min_x, min_y, min_z) and (max_x, max_y, max_z), that define a box.
TYPE:
|
|
The space between the points of the box, in the X, Y, and Z direction.
TYPE:
|
points = np.array(list(zip(x.ravel(), y.ravel(), z.ravel())))
¶
write_pdbs = write_pdbs()
¶
__snap_float(val, res)
¶
Snaps an arbitrary point to the nearest grid point.
| PARAMETER | DESCRIPTION |
|---|---|
|
A numpy array corresponding to a 3D point.
TYPE:
|
|
The resolution (distance in the X, Y, and Z directions between adjacent points) of the grid.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[float64]
|
A numpy array corresponding to a 3D point near val that is on a nearby grid point. |
__unique_points()
¶
Identifies unique points (rows) in an array of points.
| PARAMETER | DESCRIPTION |
|---|---|
|
A
|
| RETURNS | DESCRIPTION |
|---|---|
|
A |
expand_around_existing_points(num_pts, reso)
¶
Add points to the current box that surround existing points, essentially increasing the resolution of the box.
For each surviving grid point, new points are placed at all
integer multiples of reso within a cube of half-width
num_pts x reso centred on the original point. Duplicates are removed.
| PARAMETER | DESCRIPTION |
|---|---|
|
An int, the number of points to place on each side of the existing points, in the X, Y, and Z directions.
|
|
The distance between adjacent added points.
|
filter_isolated_points_until_no_change(reso, number_of_neighbors)
¶
Iteratively remove points with too few neighbors.
Points on the fringe of a pocket often have fewer grid neighbors
than points in the pocket interior. This method repeatedly
removes any point with fewer than number_of_neighbors neighbors
(counted within the diagonal distance of one grid cell) until the
point set stabilizes.
| PARAMETER | DESCRIPTION |
|---|---|
|
The grid spacing. The neighbor cutoff is derived
as
|
|
The minimum number of permissible neighbors.
|
remove_all_points_close_to_other_points(other_points, dist_cutoff, config)
¶
Remove grid points that are within a cutoff of protein atoms.
| PARAMETER | DESCRIPTION |
|---|---|
|
An
TYPE:
|
|
Grid points closer than this distance to any atom are removed.
TYPE:
|
|
Configuration object (
TYPE:
|
remove_points_outside_convex_hull(hull, config)
¶
separate_out_pockets()
¶
Partition surviving points into distinct pockets.
Two points belong to the same pocket if they are connected through a chain of grid neighbors (26-connectivity, i.e., including diagonal/kitty-corner neighbors).
- Points are mapped to integer
(i, j, k)indices by subtracting the grid minimum and dividing by the grid spacing. - A 3D boolean volume is constructed and filled at the appropriate indices.
scipy.ndimage.labelperforms connected-component labelling with 26-connectivity.- Each connected component is extracted as a separate pocket.
| RETURNS | DESCRIPTION |
|---|---|
list[NDArray[float64]]
|
A list of |
TaskRemovePointsOutsideHull
¶
Bases: RayTaskGeneral
A class to remove points outside a convex hull using multiple processors.
process_item(item)
¶
Removes points outside the convex hull.
| PARAMETER | DESCRIPTION |
|---|---|
|
A tuple containing: - hull: The convex hull object. - some_points: A numpy array of points to be tested.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[float64]
|
A numpy array of points that are inside the convex hull. |