Skip to content

Commit 74706e4

Browse files
committed
Adding PAINS and other unwanted substructures filter and bumping version to 1.0.9
1 parent 3aee73f commit 74706e4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

chemfunc/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Contains the version information for chemfunc."""
22
# major, minor, patch
3-
version_info = 1, 0, 8
3+
version_info = 1, 0, 9
44

55
# Nice string for the version
66
__version__ = '.'.join(map(str, version_info))

chemfunc/molecular_properties.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from rdkit import Chem
66
from rdkit.Chem.Crippen import MolLogP
77
from rdkit.Chem.Descriptors import MolWt
8+
from rdkit.Chem.FilterCatalog import FilterCatalog, FilterCatalogParams
89
from rdkit.Chem.QED import qed
910

1011
from chemfunc.constants import Molecule
1112

12-
1313
PropertyFunction = Callable[[Molecule], float]
1414
PROPERTY_FUNCTION_REGISTRY = {}
1515

@@ -20,6 +20,7 @@ def register_property_function(property_type: str) -> Callable[[PropertyFunction
2020
:param property_type: The name to use to access the property function.
2121
:return: A decorator which will add a property function to the registry using the specified name.
2222
"""
23+
2324
def decorator(property_function: PropertyFunction) -> PropertyFunction:
2425
PROPERTY_FUNCTION_REGISTRY[property_type] = property_function
2526
return property_function
@@ -46,6 +47,7 @@ def get_available_property_functions() -> list[str]:
4647

4748
def smiles_to_mol_wrapper(property_function: PropertyFunction) -> PropertyFunction:
4849
"""A decorator which converts a SMILES to an RDKit molecule before passing it to a property function."""
50+
4951
@wraps(property_function)
5052
def wrapper(molecule: Molecule) -> float:
5153
if isinstance(molecule, str):
@@ -89,6 +91,27 @@ def compute_qed(molecule: Molecule) -> float:
8991
return qed(molecule)
9092

9193

94+
@register_property_function('pains_plus')
95+
@smiles_to_mol_wrapper
96+
def compute_pains_plus(molecule: Molecule) -> str:
97+
"""Checks a molecule for PAINS (pan-assay interference compounds) and other unwanted substructures.
98+
99+
:param molecule: A molecule, either a SMILES string or an RDKit molecule.
100+
:return: The PAINS and other unwanted substructure(s) found in the molecule.
101+
"""
102+
# Set up all unwanted substructures filters
103+
params = FilterCatalogParams()
104+
params.AddCatalog(FilterCatalogParams.FilterCatalogs.ALL)
105+
catalog = FilterCatalog(params)
106+
107+
# Check for unwanted substructures
108+
matches = " | ".join(
109+
f"{entry.GetProp('FilterSet')}: {entry.GetDescription()}" for entry in catalog.GetMatches(molecule)
110+
)
111+
112+
return matches
113+
114+
92115
try:
93116
import os
94117
import sys
@@ -99,6 +122,7 @@ def compute_qed(molecule: Molecule) -> float:
99122

100123
import sascorer
101124

125+
102126
@register_property_function('sa_score')
103127
@smiles_to_mol_wrapper
104128
def compute_sa_score(molecule: Molecule) -> float:

0 commit comments

Comments
 (0)