liveBook · Manning

SMARTS

As explained in Build AI Drug Discovery Pipelines

SMARTS is a chemical pattern language extending SMILES to represent molecular substructural queries.

SMARTS is a chemical pattern language extending SMILES to describe molecular substructures. Like regular expressions adapted to molecules, it lets RDKit search compound libraries for structural alerts. section 2.3.2

A practical SMARTS filtering workflow:

  • Load patterns with RDKit's MolFromSmarts, check for invalid patterns, and discard unusable entries. section 2.3.2
  • Test each molecule with HasSubstructMatch, record matching alerts, and retain compounds that pass the filter. section 2.3.2
  • Interpret hard filters as automatic rejection and soft filters as prompts for closer examination. section 2.3.2

Glaxo Wellcome structural alerts

Loading 55 SMARTS alerts and applying them to a screened library removed 135 compounds, leaving 105,495. Betalactams, nitroso groups, and crown ethers were among the most common matches. section 2.3.2

Listing 2.6 Loading SMARTS
from rdkit.Chem import Draw, MolFromSmarts
def load_glaxo_alerts():
    alerts_df = pd.read_csv("data/ch02/glaxo_structural_alerts.csv")
    alerts_df["ROMol"] = alerts_df.smarts.apply(MolFromSmarts)    #A
        
    invalid_count = alerts_df.ROMol.isnull().sum()
    if invalid_count > 0:    #B
        print(f"Warning: {invalid_count} invalid SMARTS patterns")
        alerts_df = alerts_df.dropna(subset=['ROMol'])
    print(f"Loaded {len(alerts_df)} Glaxo Wellcome structural alerts")
    return alerts_df
glaxo_alerts = load_glaxo_alerts()
>> Loaded 55 Glaxo Wellcome structural alerts

Inspect the RDKit code that loads SMARTS patterns, validates them, and reports invalid entries. section 2.3.2

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Defines SMARTS and demonstrates loading, validation, matching, and filtering, but does not detail the pattern syntax.
Examples
Uses Glaxo Wellcome alerts, PAINS and BRENK filters, and matched motifs including betalactams, nitroso groups, and crown ethers.
What it assumes
Assumes basic molecular structures and introduces SMARTS alongside SMILES and RDKit substructure matching.
What you can do after
Apply it via RDKit to load SMARTS patterns, detect molecular matches, and filter compounds.
How it connects
Connects SMARTS with SMILES, RDKit, substructure search, structural alerts, PAINS, BRENK, and REOS.

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.