HoloSpace#

class utils.ppseg.holo_descriptor.holo_space.HoloSpace(ply_path, num_of_frags=6, q=1.0, corrected=True)[source]#

Bases: object

HoloSpace class for estimating the fragment-binding (holo) space from the deep-learning semantic segmentation prediction of protein surface.

Parameters
  • ply_path (str, required) – Path to the PLY file (protein surface mesh). Required pred attribute.

  • num_of_frags (int) – Number of fragments to extract. (default: 6)

  • q (float) – Quantile value for fragment extraction. (default: 1.0, maximum value)

  • corrected (bool) – Whether to use corrected volume calculation. (default: True)

mesh#

The loaded mesh.

Type

pymesh.Mesh

pocket_frags#

List of pocket fragments.

Type

list

pocket#

The combined pocket mesh.

Type

pymesh.Mesh

Example

from holo_space import HoloSpace

# Initialize HoloSpace with a PLY file and parameters
holo_space = HoloSpace("path/to/mesh.ply", num_of_frags=6, q=1.0)

# Get the pocket volume
pocket_volume = holo_space.get_pocket_volume()
pocket_frag_volumes = holo_space.get_pocket_frag_volumes()
get_pocket_frag_volumes()[source]#

Returns the volumes of the pocket fragments.

get_pocket_volume()[source]#

Returns the volume of the pocket.

save_pocket(path)[source]#

Saves the pocket mesh to the specified path.

Parameters

path (str) – Path to save the pocket mesh.

utils.ppseg.holo_descriptor.holo_space.calculate_center(class_vertices)[source]#

Calculate the center of the class vertices.

Parameters

class_vertices (numpy.ndarray) – The vertices of the specified class.

Returns

The center of the class vertices.

Return type

numpy.ndarray

utils.ppseg.holo_descriptor.holo_space.combine_pocket_frags(pocket_frags)[source]#

Combine the pocket fragments into a single pocket mesh.

Parameters

pocket_frags (list) – List of pocket fragments.

Returns

Combined pocket mesh.

Return type

pymesh.Mesh

utils.ppseg.holo_descriptor.holo_space.extract_fragment_based_pocket(mesh, func, label, **kwargs)[source]#

Extract the pocket-based on the fragment (raw HoloSpace).

Parameters
  • mesh (pymesh.Mesh) – The input mesh.

  • func (function) – Function to calculate the radius.

  • label (int) – The fragment label.

  • **kwargs – Additional arguments for the function.

Returns

The extracted pocket mesh.

Return type

pymesh.Mesh

utils.ppseg.holo_descriptor.holo_space.extract_pocket(mesh, num_of_frags=6, q=1.0)[source]#

Extract the pocket from the mesh.

Parameters
  • mesh (pymesh.Mesh) – The input mesh.

  • num_of_frags (int) – Number of fragments to extract. (default: 6)

  • q (float) – Quantile value for fragment extraction. (default: 1.0)

Returns

The extracted pocket mesh.

Return type

pymesh.Mesh

utils.ppseg.holo_descriptor.holo_space.get_class_vertices(mesh, label=0, return_mask=False, feature='pred')[source]#

Get the vertices of a specific class from the mesh.

Parameters
  • mesh (pymesh.Mesh) – The input mesh.

  • label (int) – The class label. (default: 0)

  • return_mask (bool) – Whether to return the mask. (default: False)

  • feature (str) – The feature name. (default: pred)

Returns

The vertices of the specified class. If return_mask is True, also returns the mask (second element).

Return type

numpy.ndarray | (numpy.ndarray, numpy.ndarray)

utils.ppseg.holo_descriptor.holo_space.get_pocket_frags(mesh, num_of_frags=6, q=1.0)[source]#

Get the pocket fragments (raw HoloSpace for each fragment) from the mesh.

Parameters
  • mesh (pymesh.Mesh) – The input mesh.

  • num_of_frags (int) – Number of fragments to extract. (default: 6)

  • q (float) – Quantile value for fragment extraction. (default: 1.0)

Returns

List of pocket fragments.

Return type

list

utils.ppseg.holo_descriptor.holo_space.pairwise_intersection_volume(mesh_list)[source]#

Calculate the pairwise intersection volume of a list of meshes.

Parameters

mesh_list (list) – List of meshes.

Returns

Pairwise intersection volume matrix.

Return type

numpy.ndarray

utils.ppseg.holo_descriptor.holo_space.pocket_frag_volume(pocket_frags, corrected=False)[source]#

Corrected volume is calculated by subtracting the top 2 (with others) average intersection volume

Parameters
  • pocket_frags (list) – List of pocket fragments.

  • corrected (bool) – Whether to use corrected volume calculation.

Returns

List of pocket fragment volumes.

Return type

list

utils.ppseg.holo_descriptor.holo_space.radius_thres_from_distrib(class_vertices, center, func=<function amax>, **kwargs)[source]#

Calculate the radius threshold from the distribution of class vertices.

Parameters
  • class_vertices (numpy.ndarray) – The vertices of the specified class.

  • center (numpy.ndarray) – The center of the class vertices.

  • func (function) – Function to calculate the radius. (default: np.max)

  • **kwargs – Additional arguments for the function.

Returns

The radius threshold. 0.0 if class_vertices is empty.

Return type

float

utils.ppseg.holo_descriptor.holo_space.top_k_average(pIoV, k=2)[source]#

Calculate the average of the top k values in each row of pIoV.

Parameters
  • pIoV (numpy.ndarray) – Pairwise intersection volume matrix.

  • k (int) – Number of top values to average. (default: 2)

Returns

List of average values for each row.

Return type

list