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 alertsInspect the RDKit code that loads SMARTS patterns, validates them, and reports invalid entries. section 2.3.2
