Hull
Convex hull construction and per-frame pocket volume computation.
This module contains the ConvexHull class used for two distinct
purposes in POVME:
- Pocket detection by building a convex hull around the protein so that grid points outside the protein surface can be discarded.
- Per-frame volume calculation that removes grid points that clash with receptor atoms, optionally excludes points outside the convex hull, enforces pocket contiguity, and computes the final pocket volume.
ConvexHull(pts)
¶
A class to handle convex-hull calculations.
seg_dict is a dictionary object that contains information about
segments within the convex hull.
- The keys are 2x3 tuples, which represent two ends of a segment in space.
- The values of
seg_dictare the number of times a segment has been part of a triangle, either1or2.0times would mean that the segment doesn't exist in the dictionary yet.
Initializes the ConvexHull class.
hull = self.gift_wrapping_3d(akl_toussaint_pts)
¶
akl_toussaint(points)
¶
The Akl-Toussaint Heuristic.
Given a set of points, this definition will create an octahedron whose corners are the extremes in x, y, and z directions. Every point within this octahedron will be removed because they are not part of the convex hull. This causes any expected running time for a convex hull algorithm to be reduced to linear time.
| PARAMETER | DESCRIPTION |
|---|---|
|
An nx3 array of x,y,z coordinates.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[float64]
|
All members of original set of points that fall outside the Akl-Toussaint octahedron. |
get_seg_dict_num(seg_dict, seg_index)
¶
This function looks up and returns the value of a seg_index from seg_dict.
| PARAMETER | DESCRIPTION |
|---|---|
|
The dictionary of segment 2x3 tuples as keys, integers as values.
TYPE:
|
|
the key of the dictionary member we are going to retrieve
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
If |
gift_wrapping_3d(raw_points)
¶
Gift wrapping for 3d convex hull.
| PARAMETER | DESCRIPTION |
|---|---|
|
A nx3 array of points, where each row corresponds to an x,y,z point coordinate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[NDArray[float64]]
|
A convex hull represented by a list of triangles. Each triangle is a 3x3 array, where each row is an x,y,z coordinate in space. The 3 rows describe the location of the 3 corners of the triangle. Each of the 3 points are arranged so that a cross product will point outwards from the hull. |
increment_seg_dict(seg_dict, seg_index)
¶
This function increments the values within seg_dict, or initiates them if they dont exist yet.
| PARAMETER | DESCRIPTION |
|---|---|
|
the dictionary of segment 2x3 tuples as keys, integers as values.
TYPE:
|
|
the key of the dictionary member we are going to increment.
TYPE:
|
inside_hull(our_point)
¶
Determines if a point is inside the hull
| PARAMETER | DESCRIPTION |
|---|---|
|
An x,y,z array
|
| RETURNS | DESCRIPTION |
|---|---|
|
A boolean, True if the point is inside the hull, False otherwise. |
outside_hull(point, triangles, epsilon=1e-05)
¶
Given the hull as defined by a list of triangles, this definition will return whether a point is within these or not.
| PARAMETER | DESCRIPTION |
|---|---|
|
an x,y,z array that is being tested to see whether it exists inside the hull or not.
TYPE:
|
|
a list of triangles that define the hull.
TYPE:
|
|
needed for imprecisions in the floating-point operations.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if our_point exists outside of the hull, False otherwise |
volume(frame_indx, pdb, pts, regions_contig, output_prefix, config)
¶
Compute the pocket volume for a single trajectory frame.
- Discard receptor atoms too far from the grid to matter.
- Build a
KDTreeon the remaining atom coordinates and usequery_ball_pointto identify grid points that clash with any atom's van der Waals sphere (plusconfig.distance_cutoff). - Optionally exclude points outside the convex hull of non-hydrogen receptor atoms.
- Optionally enforce contiguous-pocket constraints using a KD-tree-based BFS flood fill.
- Compute the volume as
N_surviving_points x grid_spacing^3.
| PARAMETER | DESCRIPTION |
|---|---|
|
1-based frame index within the trajectory.
|
|
A
|
|
An
|
|
A list of
|
|
Directory/filename prefix for output files.
|
|
A
|
| RETURNS | DESCRIPTION |
|---|---|
|
The input frame index (for bookkeeping). |
|
|
The pocket volume. |
|
|
A dict that may contain the key
|
TaskCalcVolume
¶
flood_fill_contiguous_kdtree(pts, contig_seed_pts, grid_spacing)
¶
Identify pocket points contiguous with a seed region using BFS.
- Builds a single
KDTreeover all surviving pocket points. - Pre-computes the full neighbor-list for every point in one
query_ball_pointcall, stored as a Python list of lists. - Finds which pocket points coincide with seed points using a second KD-tree query.
- Runs a breadth-first search (BFS) over the neighbor graph, expanding from the seed set.
| PARAMETER | DESCRIPTION |
|---|---|
|
An array of shape
TYPE:
|
|
An array of shape
TYPE:
|
|
The POVME grid spacing in Angstroms. Used to derive the neighbor cutoff (diagonal of a grid cell).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[float64]
|
An array of shape |