MolecularDiffusion.utils.shepherd_score.generate_point_cloud¶
Module contains functions to generate point clouds of molecular surfaces.
- Surface generation workflow adapted from Open Drug Discovery Toolkit:
https://oddt.readthedocs.io/en/latest/_modules/oddt/surface.html
Attributes¶
Functions¶
|
Color the point cloud based on elecrostatic potential. Colors are only scaled to the molecule |
|
Get the coordinates of all atoms in a molecule using rdkit. |
|
Get the van der Waals radii of all atoms in a molecule using rdkit. |
|
Compute the Coulomb potential values at each point for a given molecule. |
|
Compute the Coulomb potential values at each point for a given set of charges at defined positions. |
|
Gets the point cloud representation of a molecule's van der Waals surface and outputs a |
|
Gets the point cloud representation of a molecule's van der Waals surface and outputs a |
Gets the point cloud representation of a molecule's van der Waals surface. Takes into account |
|
Gets the point cloud representation of a molecule's van der Waals surface. Takes into account |
|
|
Sample points uniformly from a molecule's volume. Does not include probe radius. |
|
Convert np.ndarray of points to a Open3D Point Cloud object. |
|
Sample points uniformly from a sphere. |
|
Samples points from the surface of vdW radius of atoms and combines it into one molecule (Vectorized). |
Samples points from the surface of vdW radius of atoms and combines it into one molecule (Vectorized). |
Module Contents¶
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.color_pcd_with_electrostatics(pcd: open3d.geometry.PointCloud, E_pot: numpy.ndarray) None¶
Color the point cloud based on elecrostatic potential. Colors are only scaled to the molecule itself (i.e., the colors are not comparable to different molecules). Red is positive, blue is negative, black is neutral.
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_atom_coords(mol: rdkit.Chem.Mol, MMFF_optimize: bool = True) Tuple[rdkit.Chem.Mol, numpy.ndarray]¶
Get the coordinates of all atoms in a molecule using rdkit. If the rdkit.Chem.mol object already has a conformer it just retrieves the coordinates without optimizing using MMFF.
- Parameters:
mol (rdkit.Chem.Mol object) – RDKit molecule object
MMFF_optimize (bool) – Whether or not to use MMFF to optimize geometry
- Returns:
- rdkit.Chem.Mol
Mol object. If the input mol did not have a conformer, it uses MMFF to optimize an embeded molecule and includes hydrogens.
- np.ndarray: shape = (N,3)
Positions of each atom’s center.
- Return type:
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_atomic_vdw_radii(mol: rdkit.Chem.Mol) numpy.ndarray¶
Get the van der Waals radii of all atoms in a molecule using rdkit.
- Parameters:
mol (rdkit.Chem.Mol object)
- Returns:
np.ndarray – vdW radii for each atom.
- Return type:
shape = (N,)
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_electrostatics(mol: rdkit.Chem.Mol, points: numpy.ndarray) numpy.ndarray¶
Compute the Coulomb potential values at each point for a given molecule. Assumes the input “mol” already has an optimized conformer. Gets partial charges from MMFF or Gasteiger.
- Parameters:
mol (rdkit.Chem.Mol object) – RDKit molecule object with an optimized geometry in conformers.
points (np.ndarray (N, 3)) – Coordinates of sampled points to compute Coulomb potential at.
- Returns:
Electrostatic potential values corresponding to each point.
- Return type:
np.ndarray (N)
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_electrostatics_given_point_charges(charges: numpy.ndarray, positions: numpy.ndarray, points: numpy.ndarray) numpy.ndarray¶
Compute the Coulomb potential values at each point for a given set of charges at defined positions.
- Parameters:
charges (np.ndarray (N,)) – Charges, with units [V]
positions (np.ndarray (N, 3)) – Coordinates of point charges, with units of A.
points (np.ndarray (M, 3)) – Coordinates of point cloud at which to compute electrostatic potential, with units of A.
- Returns:
Electrostatic potential values corresponding to each point.
- Return type:
np.ndarray (M,)
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_molecular_surface(centers: numpy.ndarray, radii: numpy.ndarray | List, num_points: int | None = None, num_samples_per_atom: int = 25, probe_radius: float = 1.2, ball_radii: List[float] = [1.2]) numpy.ndarray¶
Gets the point cloud representation of a molecule’s van der Waals surface and outputs a numpy array. Takes into account the vdW radii of different atoms. Removes overlapping points within vdW radii of neighboring atoms.
- Parameters:
centers (np.ndarray (N, 3)) – Cartesian coordinates of the atom centers of a molecule.
radii (np.ndarray (N,)) – van der Waals radii of each atom (in Angstrom) in the same order as the centers parameter.
num_points (int (default = None)) – The total number of points in the final point cloud. If None, it returns as many as what was left after cleaning up the atom-sampled surface point cloud.
num_samples_per_atom (int, optional) – Number of points to sample from the surface of each atom. Default is 25. Note that this value is scaled by a given atom’s relative vdW radius to a carbon and SQUARED. Typically choose a value between 15 and 35. For example, if set to 20, a carbon atom would have 400 sampled points.
probe_radius (float, optional) – The radius of a probe atom to act as a “solvent accessible surface”. Default is 1.2 angstroms which is the radius of a Hydrogen atom.
ball_radii (list, optional) – The radius of the ball(s) used in Open3D’s ball pivoting algorithm to generate a triangle mesh. Default is [1.2].
- Returns:
Coordinates of points representing the molecular surface.
- Return type:
np.ndarray
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_molecular_surface_const_density(centers: numpy.ndarray, radii: numpy.ndarray | List, density: float = 0.3, num_samples_per_atom: int = 25, probe_radius: float = 1.2, ball_radii: List[float] = [1.2]) numpy.ndarray¶
Gets the point cloud representation of a molecule’s van der Waals surface and outputs a numpy array. Takes into account the vdW radii of different atoms. Removes overlapping points within vdW radii of neighboring atoms.
- Parameters:
centers (np.ndarray (N, 3)) – Cartesian coordinates of the atom centers of a molecule.
radii (np.ndarray (N,)) – van der Waals radii of each atom (in Angstrom) in the same order as the centers parameter.
density (float (default = 0.3)) – The density of points on the surface. The number of points is calculated from the solvent accessible surface area approximately computed by the surface area of the generated mesh.
num_samples_per_atom (int, optional) – Number of points to sample from the surface of each atom. Default is 25. Note that this value is scaled by a given atom’s relative vdW radius to a carbon and SQUARED. Typically choose a value between 15 and 35. For example, if set to 20, a carbon atom would have 400 sampled points.
probe_radius (float, optional) – The radius of a probe atom to act as a “solvent accessible surface”. Default is 1.2 angstroms which is the radius of a Hydrogen atom.
ball_radii (list, optional) – The radius of the ball(s) used in Open3D’s ball pivoting algorithm to generate a triangle mesh. Default is [1.2].
- Returns:
Coordinates of points representing the molecular surface.
- Return type:
np.ndarray
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_molecular_surface_point_cloud(centers: numpy.ndarray, radii: numpy.ndarray | List, num_points: int | None = None, num_samples_per_atom: int = 25, probe_radius: float = 1.2, ball_radii: List[float] = [1.2], color: List[float] = [1.0, 0.0, 0.0]) open3d.geometry.PointCloud¶
Gets the point cloud representation of a molecule’s van der Waals surface. Takes into account the vdW radii of different atoms. Removes overlapping points within vdW radii of neighboring atoms.
- Parameters:
centers (np.ndarray (N, 3)) – Cartesian coordinates of the atom centers of a molecule.
radii (np.ndarray (N,)) – van der Waals radii of each atom (in Angstrom) in the same order as the centers parameter.
num_points (int (default = None)) – The total number of points in the final point cloud. If None, it returns as many as what was left after cleaning up the atom-sampled surface point cloud.
num_samples_per_atom (int, optional) – Number of points to sample from the surface of each atom. Default is 25. Note that this value is scaled by a given atom’s relative vdW radius to a carbon and SQUARED. Typically choose a value between 15 and 35. For example, if set to 20, a carbon atom would have 400 sampled points.
probe_radius (float, optional) – The radius of a probe atom to act as a “solvent accessible surface”. Default is 1.2 angstroms which is the radius of a Hydrogen atom.
ball_radii (list, optional) – The radius of the ball(s) used in Open3D’s ball pivoting algorithm to generate a triangle mesh. Default is [1.2].
color (list, optional) – RGB color values for the point cloud (default is [1., 0., 0.] red).
- Returns:
Point cloud object representation of the molecular surface.
- Return type:
o3d.geometry.PointCloud
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_molecular_surface_point_cloud_const_density(centers: numpy.ndarray, radii: numpy.ndarray | List, density: float = 0.3, num_samples_per_atom: int = 25, probe_radius: float = 1.2, ball_radii: List[float] = [1.2], color: List[float] = [1.0, 0.0, 0.0]) open3d.geometry.PointCloud¶
Gets the point cloud representation of a molecule’s van der Waals surface. Takes into account the vdW radii of different atoms. Removes overlapping points within vdW radii of neighboring atoms.
- Parameters:
centers (np.ndarray (N, 3)) – Cartesian coordinates of the atom centers of a molecule.
radii (np.ndarray (N,)) – van der Waals radii of each atom (in Angstrom) in the same order as the centers parameter.
density (float (default = 0.3)) – The density of points on the surface. The number of points is calculated from the solvent accessible surface area approximately computed by the surface area of the generated mesh.
num_samples_per_atom (int, optional) – Number of points to sample from the surface of each atom. Default is 25. Note that this value is scaled by a given atom’s relative vdW radius to a carbon and SQUARED. Typically choose a value between 15 and 35. For example, if set to 20, a carbon atom would have 400 sampled points.
probe_radius (float, optional) – The radius of a probe atom to act as a “solvent accessible surface”. Default is 1.2 angstroms which is the radius of a Hydrogen atom.
ball_radii (list, optional) – The radius of the ball(s) used in Open3D’s ball pivoting algorithm to generate a triangle mesh. Default is [1.2].
color (list, optional) – RGB color values for the point cloud (default is [1., 0., 0.] red).
- Returns:
Point cloud object representation of the molecular surface.
- Return type:
o3d.geometry.PointCloud
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_molecular_volume(centers: numpy.ndarray, radii: numpy.ndarray, num_samples: int = None, num_samples_per_atom: int = 15)¶
Sample points uniformly from a molecule’s volume. Does not include probe radius. Ignores possible overlap of vdW radius of atoms when randomly sub-selecting points for the volume.
- Parameters:
centers (np.ndarray (N, 3)) – Cartesian coordinates of the atom centers of a molecule.
radii (np.ndarray (N,)) – van der Waals radii of each atom (in Angstrom) in the same order as the centers parameter.
num_samples_per_atom (int, optional) – Number of points to sample from the surface of each atom. Default is 15. Note that this value is scaled by a given atom’s relative vdW radius to a carbon and CUBED. Typically choose a value between 10 and 20. For example, if set to 20, a carbon atom would have 8000 sampled points.
- Returns:
Coordinates of points representing the molecular surface.
- Return type:
np.ndarray
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_point_cloud(points: numpy.ndarray, color: List[float] = [0.0, 0.0, 0.0]) open3d.geometry.PointCloud¶
Convert np.ndarray of points to a Open3D Point Cloud object.
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.get_sample_atom_volume(R: float, num_samples: int) numpy.ndarray¶
Sample points uniformly from a sphere. https://stackoverflow.com/questions/5408276/sampling-uniformly-distributed-random-points-inside-a-spherical-volume
- Parameters:
- Return type:
np.ndarray (num_samples, 3)
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.sample_molecular_surface_with_radius(centers: numpy.ndarray, radii: numpy.ndarray | List, probe_radius: float = 1.2, num_samples_per_atom: int = 20) numpy.ndarray¶
Samples points from the surface of vdW radius of atoms and combines it into one molecule (Vectorized).
- Parameters:
centers (np.ndarray (N, 3)) – Cartesian coordinates of the atom centers of a molecule.
radii (np.ndarray (N,)) – van der Waals radii of each atom (in Angstrom) in the same order as the centers parameter.
probe_radius (float (default = 1.2)) – The radius of a probe atom to act as a “solvent accessible surface”. Default = 1.2 angstroms which is the radius of a Hydrogen atom.
num_samples_per_atom (int, optional) – Number of points to sample from the surface of each atom. Default is 20. Note that this value is scaled by a given atom’s relative vdW radius to a carbon and SQUARED. Typically choose a value between 15 and 35. For example, if set to 20, a carbon atom would have 400 sampled points.
- Returns:
Array of shape (N*num_points_per_atom, 3) containing the coordinates of each point sampled from each atom.
- Return type:
np.ndarray
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.sample_molecular_surface_with_radius_fibonacci(centers: numpy.ndarray, radii: numpy.ndarray | List, probe_radius: float = 1.2, num_samples_per_atom: int = 20) numpy.ndarray¶
Samples points from the surface of vdW radius of atoms and combines it into one molecule (Vectorized).
- Parameters:
centers (np.ndarray (N, 3)) – Cartesian coordinates of the atom centers of a molecule.
radii (np.ndarray (N,)) – van der Waals radii of each atom (in Angstrom) in the same order as the centers parameter.
probe_radius (float (default = 1.2)) – The radius of a probe atom to act as a “solvent accessible surface”. Default = 1.2 angstroms which is the radius of a Hydrogen atom.
num_samples_per_atom (int, optional) – Number of points to sample from the surface of each atom. Default is 20. Note that this value is scaled by a given atom’s relative vdW radius to a carbon and SQUARED. Typically choose a value between 15 and 35. For example, if set to 20, a carbon atom would have 400 sampled points.
- Returns:
Array of shape (N*num_points_per_atom, 3) containing the coordinates of each point sampled from each atom.
- Return type:
np.ndarray
- MolecularDiffusion.utils.shepherd_score.generate_point_cloud.PT¶