liveBook · Manning

Compound filter

As explained in Build AI Drug Discovery Pipelines

Compound filtering is the computational removal of molecules with undesirable properties or substructures from a screening collection.

A compound filter removes molecules with unwanted properties or substructures from a screening collection. Filtering is a low-cost first step: it reduces the number of candidates sent to more expensive methods such as molecular docking and molecular dynamics simulations. section 2.3 section 2.1.1

Two complementary kinds of filter are useful early in screening:

  • Property-based filters compare calculated molecular descriptors with chosen limits. For example, drug-likeness rules use molecular weight, lipophilicity, and hydrogen-bond counts. section 2.3 section 2.1.1
  • Substructure-based filters look for molecular patterns associated with problems such as assay interference or toxicity risk. A filter may reject any match or use a threshold on the number of alerts. section 2.3.2

Lipinski’s Rule of Five is a simple property filter for oral drug-likeness. The implementation counts violations when molecular weight exceeds 500, calculated logP exceeds 5, hydrogen-bond donors exceed 5, or hydrogen-bond acceptors exceed 10. It retains compounds with at most one violation. This is a crude guideline, not a guarantee of drug suitability. section 2.1.1 section 2.3.1

Listing 2.4 Applying an Ro5 Filter
def apply_lipinski_filter(df):
    def count_ro5_violations(row):
        violations = 0
        if row['ExactMolWt'] > 500: violations += 1
        if row['MolLogP'] > 5: violations += 1
        if row['NumHDonors'] > 5: violations += 1
        if row['NumHAcceptors'] > 10: violations += 1
        return violations
    
    df['ro5_violations'] = df.apply(count_ro5_violations, axis=1)
    df['ro5_compliant'] = (    #A
        df['ro5_violations'] <= 1
    )
    
    compliant_df = df[df['ro5_compliant']]
    violated_df = df[~df['ro5_compliant']]
    return df, compliant_df, violated_df
 
specs, specs_ro5_compliant, specs_ro5_violated = \
    apply_lipinski_filter(specs)

The Pandas implementation counts violations per row and returns both retained and rejected compounds. section 2.3.1

A substructure filter can use predefined RDKit catalogs. PAINS patterns flag compounds that may appear active because they interfere with assays or bind nonspecifically; BRENK patterns provide another set of structural alerts. Custom alerts can also be loaded as SMARTS patterns and matched against molecules. section 2.3.2 section 2.3.2

Listing 2.5 Applying PAINS & BRENK Filters
from rdkit.Chem import FilterCatalog
def apply_pains_brenk_filters(df, mol_col='mol'):
    df_copy = df.copy()
    filter_params = FilterCatalog.FilterCatalogParams()    #A
    filter_params.AddCatalog(filter_params.FilterCatalogs.PAINS)
    filter_params.AddCatalog(filter_params.FilterCatalogs.BRENK)
    catalog = FilterCatalog.FilterCatalog(filter_params)
    
    df_copy.loc[:, 'PAINS_BRENK_match'] = \
        df_copy[mol_col].apply(catalog.HasMatch)    #B
    df_copy.loc[:, 'PAINS_BRENK_compliant'] = ~df_copy['PAINS_BRENK_match']
    
    filtered_df = df_copy[df_copy['PAINS_BRENK_compliant']]
    
    print(f"Compounds before PAINS/BRENK filter: {len(df_copy)}")    #C
    return df_copy, filtered_df
 
specs_ro5_compliant, specs_ro5_pains_brenk_compliant = \
    apply_pains_brenk_filters(specs_ro5_compliant)

This listing combines the PAINS and BRENK catalogs, marks matching molecules, and retains nonmatches. section 2.3.2

Screening a commercial library

In an antimalarial screening workflow, a SPECS library starts with 212,670 molecules. The Rule of Five filter retains 199,640; the subsequent PAINS and BRENK filters retain 105,630. A custom Glaxo structural filter then retains 105,495. Recording counts at each step makes the effect of each filter visible. section 2.1.2 section 2.3.1 section 2.3.2

Treat alerts as signals, not definitive safety verdicts. A flagged substructure does not prove toxicity, and an unflagged molecule may still be toxic. Structural alerts derived from past observations can also miss new or understudied substructures; use them alongside other evidence and models. section 2.3.2

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Works through descriptor thresholds, catalog matching, custom SMARTS alerts, and successive filtering counts, while cautioning against definitive toxicity conclusions.
Examples
Uses a SPECS antimalarial screening library, Lipinski’s Rule of Five, PAINS and BRENK catalogs, and Glaxo structural alerts.
What it assumes
Assumes calculated molecular descriptors and molecule objects, while defining drug-likeness and structural alerts.
What you can do after
Apply compound filters using Pandas and RDKit, retain compliant molecules, and inspect filtering counts.
How it connects
Connects drug-likeness, structural alerts, assay interference, toxicity, and virtual screening.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.