Pharmacophore Scoring#
PyTorch Implementation#
Pharmacophore scoring with PyTorch.
- shepherd_score.score.pharmacophore_scoring.tanimoto_func(VAB, VAA, VBB)[source]#
Computes Tanimoto similarity. Similarity(Tanimoto) = Overlap{1,2} / (Overlap{1,1} + Overlap{2,2} - Overlap{1,2})
- Parameters:
VAB (torch.Tensor)
VAA (torch.Tensor)
VBB (torch.Tensor)
- Return type:
torch.Tensor
- shepherd_score.score.pharmacophore_scoring.tversky_func(VAB, VAA, VBB, sigma)[source]#
Computes Tversky similarity -> clamped to be max of 1.0. sigma: [0,1]
Similarity(Tversky) = Overlap{1,2} / (sigma*Overlap{1,1} + (1-sigma)*Overlap{2,2})
- Parameters:
VAB (torch.Tensor)
VAA (torch.Tensor)
VBB (torch.Tensor)
sigma (float)
- Return type:
torch.Tensor
- shepherd_score.score.pharmacophore_scoring.get_vector_volume_overlap_score(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, allow_antiparallel)[source]#
Compute volumentric overlap score with cosine similarity of vectors. Handles batching.
- shepherd_score.score.pharmacophore_scoring.get_vector_volume_overlap_score_batch(ptype_str, ptype_1, ptype_2, cdist_21, cdist_22, cdist_11, vmm_21, vmm_22, vmm_11, allow_antiparallel=False)[source]#
Compute volumentric overlap score with cosine similarity of vectors. Only batching.
- shepherd_score.score.pharmacophore_scoring.get_volume_overlap_score(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2)[source]#
Computes volume overlap score single instance.
- shepherd_score.score.pharmacophore_scoring.get_volume_overlap_score_batch(ptype_str, ptype_1, ptype_2, cdist_21, cdist_22, cdist_11)[source]#
Compute volumentric overlap score with cosine similarity of vectors. Only batching.
- shepherd_score.score.pharmacophore_scoring.get_volume_overlap_score_extended_points(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, only_extended=False)[source]#
Score both the anchor and extended point volume overlap instead of a vector similarity.
- shepherd_score.score.pharmacophore_scoring.get_overlap_pharm(ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, similarity='tanimoto', extended_points=False, only_extended=False, precomputed_self_overlaps=None)[source]#
Compute pharmacophore score.
Accepts batching, but only if they are the same two molecules (or have the same number of features). Specifically used for alignment.
- Parameters:
ptype_1 (torch.Tensor) – Indices specifying the pharmacophore type based on order of P_TYPES, shape (N,) or (B, N).
ptype_2 (torch.Tensor) – Indices specifying the pharmacophore type based on order of P_TYPES, shape (M,) or (B, M).
anchors_1 (torch.Tensor) – Coordinates for the anchor points of each pharmacophore of molecule 1, shape (N, 3) or (B, N, 3).
anchors_2 (torch.Tensor) – Coordinates for the anchor points of each pharmacophore of molecule 2, shape (M, 3) or (B, M, 3).
vectors_1 (torch.Tensor) – Relative unit vectors of each pharmacophore of molecule 1, shape (N, 3) or (B, N, 3).
vectors_2 (torch.Tensor) – Relative unit vectors of each pharmacophore of molecule 2, shape (M, 3) or (B, M, 3).
similarity (str, optional) – Specifies what similarity function to use. Options are: ‘tanimoto’ (symmetric), ‘tversky’ (OpenEye’s 95% normalization by mol 1), ‘tversky_ref’ (Pharao’s 100% normalization by mol 1), ‘tversky_fit’ (Pharao’s 100% normalization by mol 2). Default is ‘tanimoto’.
extended_points (bool, optional) – Whether to score HBA/HBD with gaussian overlaps of extended points. Default is
False.only_extended (bool, optional) – When
extended_pointsisTrue, decide whether to only score the extended points (ignore anchor overlaps). Default isFalse.precomputed_self_overlaps (Optional[Tuple[torch.Tensor, torch.Tensor]], optional) – Pre-computed (total_VAA, total_VBB) self-overlaps. When provided (and
extended_pointsis False), the per-type self-overlap computation is skipped and only the cross-overlap VAB is computed each call. Used to avoid redundant self-overlap recomputation in optimization loops.
- Returns:
Score(s) with shape (1,) or (B,).
- Return type:
torch.Tensor
- shepherd_score.score.pharmacophore_scoring.get_pharm_combo_score(centers_1, centers_2, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, alpha=0.81, similarity='tanimoto', extended_points=False, only_extended=False)[source]#
Compute a combined shape and pharmacophore score.
- Parameters:
- Return type:
torch.Tensor
NumPy Implementation#
Pharmacophore scoring with NumPy.
- shepherd_score.score.pharmacophore_scoring_np.tanimoto_func_np(VAB, VAA, VBB)[source]#
Computes Tanimoto similarity. Similarity(Tanimoto) = Overlap{1,2} / (Overlap{1,1} + Overlap{2,2} - Overlap{1,2})
- shepherd_score.score.pharmacophore_scoring_np.tversky_func_np(VAB, VAA, VBB, sigma)[source]#
Computes Tversky similarity -> clamped to be max of 1.0. sigma: [0,1]
Similarity(Tversky) = Overlap{1,2} / (sigma*Overlap{1,1} + (1-sigma)*Overlap{2,2})
- shepherd_score.score.pharmacophore_scoring_np.get_vector_volume_overlap_score_np(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, allow_antiparallel)[source]#
Compute volumentric overlap score with cosine similarity of vectors.
- shepherd_score.score.pharmacophore_scoring_np.get_volume_overlap_score_np(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2)[source]#
Computes volume overlap score single instance.
- shepherd_score.score.pharmacophore_scoring_np.get_volume_overlap_score_extended_points_np(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, only_extended=False)[source]#
Score both the anchor and extended point volume overlap instead of a vector similarity.
- shepherd_score.score.pharmacophore_scoring_np.get_overlap_pharm_np(ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, similarity='tanimoto', extended_points=False, only_extended=False)[source]#
NumPy implementation to compute pharmacophore score. Single instance only
- Parameters:
ptype_1 (np.ndarray (N,)) – Indices specifying the pharmacophore type based on order of P_TYPES
ptype_2 (np.ndarray (M,)) – Indices specifying the pharmacophore type based on order of P_TYPES
anchors_1 (np.ndarray (N,3)) – Coordinates for the anchor points of each pharmacophore of molecule 1
anchors_2 (np.ndarray (M,3)) – Coordinates for the anchor points of each pharmacophore of molecule 2
vectors_1 (np.ndarray (N,3)) – Relative unit vectors of each pharmacophore of molecule 1
vectors_2 (np.ndarray (M,3)) – Relative unit vectors of each pharmacophore of molecule 2
similarity (str) – Specifies what similarity function to use. ‘tanimoto’ – symmetric scoring function ‘tversky’ – asymmetric -> Uses OpenEye’s formulation 95% normalization by molec 1 ‘tversky_ref’ – asymmetric -> Uses Pharao’s formulation 100% normalization by molec 1. ‘tversky_fit’ – asymmetric -> Uses Pharao’s formulation 100% normalization by molec 2.
extended_points (bool) – Whether to score HBA/HBD with gaussian overlaps of extended points.
only_extended (bool) –
- When extended_points is True, decide whether to only score the extended points (ignore
anchor overlaps)
- Return type:
np.ndarray (1,)
JAX Implementation#
Pharmacophore scoring with JAX.
This module may not be as fast as the NumPy version.
- shepherd_score.score.pharmacophore_scoring_jax.precompute_geometry(pos_ref, pos_fit, vec_ref, vec_fit, extended_points=False)#
Computes all necessary geometric matrices once per optimization step.
- shepherd_score.score.pharmacophore_scoring_jax.get_interaction_properties(ptype_idxs)#
Retrieves alpha and mode for given pharmacophore indices.
- shepherd_score.score.pharmacophore_scoring_jax.get_overlap_pharm_jax_vectorized(ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, extended_points=False, only_extended=False)#
Fully vectorized pharmacophore overlap.
- shepherd_score.score.pharmacophore_scoring_jax.get_overlap_pharm_jax_vectorized_mask(ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, mask_1, mask_2, extended_points=False, only_extended=False)#
Fully vectorized pharmacophore overlap with padding masks.
Identical to
get_overlap_pharm_jax_vectorizedbut multiplies by a padding mask so that padded entries (type=8/Dummy, coords=zeros) never contribute to the overlap.- Parameters:
ptype_1 (Array (N,))
ptype_2 (Array (M,))
anchors_1 (Array (N,3))
anchors_2 (Array (M,3))
vectors_1 (Array (N,3))
vectors_2 (Array (M,3))
mask_1 (Array (N,) — 1.0 for real entries, 0.0 for padding)
mask_2 (Array (M,) — 1.0 for real entries, 0.0 for padding)
extended_points (bool)
only_extended (bool)
- Returns:
score – Pharmacophore overlap score.
- Return type:
Array (1,)
- shepherd_score.score.pharmacophore_scoring_jax.tanimoto_func_jax(VAB, VAA, VBB)#
Computes Tanimoto similarity. Similarity(Tanimoto) = Overlap{1,2} / (Overlap{1,1} + Overlap{2,2} - Overlap{1,2})
- Parameters:
VAB (jax.Array)
VAA (jax.Array)
VBB (jax.Array)
- Return type:
jax.Array
- shepherd_score.score.pharmacophore_scoring_jax.tversky_func_jax(VAB, VAA, VBB, sigma)#
Computes Tversky similarity -> clamped to be max of 1.0. sigma: [0,1]
Similarity(Tversky) = Overlap{1,2} / (sigma*Overlap{1,1} + (1-sigma)*Overlap{2,2})
- Parameters:
VAB (jax.Array)
VAA (jax.Array)
VBB (jax.Array)
sigma (float)
- Return type:
jax.Array
- shepherd_score.score.pharmacophore_scoring_jax.get_vector_volume_overlap_score_jax(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, allow_antiparallel)[source]#
Compute volumentric overlap score with cosine similarity of vectors. JAX version.
- shepherd_score.score.pharmacophore_scoring_jax.get_volume_overlap_score_jax(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2)[source]#
Computes volume overlap score single instance. JAX version.
- shepherd_score.score.pharmacophore_scoring_jax.get_volume_overlap_score_extended_points_jax(ptype_str, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, only_extended=False)[source]#
Score both the anchor and extended point volume overlap instead of a vector similarity. JAX version.
- shepherd_score.score.pharmacophore_scoring_jax.get_overlap_pharm_jax(ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, similarity='tanimoto', extended_points=False, only_extended=False)#
JAX implementation to compute pharmacophore score. Single instance only.
- Parameters:
ptype_1 (Array (N,)) – Indices specifying the pharmacophore type based on order of P_TYPES
ptype_2 (Array (M,)) – Indices specifying the pharmacophore type based on order of P_TYPES
anchors_1 (Array (N,3)) – Coordinates for the anchor points of each pharmacophore of molecule 1
anchors_2 (Array (M,3)) – Coordinates for the anchor points of each pharmacophore of molecule 2
vectors_1 (Array (N,3)) – Relative unit vectors of each pharmacophore of molecule 1
vectors_2 (Array (M,3)) – Relative unit vectors of each pharmacophore of molecule 2
similarity (str) – Specifies what similarity function to use.
extended_points (bool) – Whether to score HBA/HBD with gaussian overlaps of extended points.
only_extended (bool) – When extended_points is True, decide whether to only score the extended points (ignore anchor overlaps)
- Return type:
Array (1,)
- shepherd_score.score.pharmacophore_scoring_jax.get_pharm_combo_score_jax(centers_1, centers_2, ptype_1, ptype_2, anchors_1, anchors_2, vectors_1, vectors_2, alpha=0.81, similarity='tanimoto', extended_points=False, only_extended=False)#
Compute a combined shape and pharmacophore score. JAX version.