Applies medicinal-chemistry filters using the medchem library: drug-likeness rules (Lipinski, Veber), PAINS filters, structural alerts, and molecular complexity metrics for compound prioritization and library cleanup.
Ships in alterlab-cheminformatics. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Medchem (datamol-io/medchem) is a Python library for molecular filtering and prioritization in drug-discovery workflows: medicinal-chemistry rules, structural alerts (ChEMBL/NIBR/PAINS), chemical-group detection, complexity metrics, and a query DSL. Rules and filters are context-specific guidelines, not hard truth — combine with domain expertise.
Verified against medchem==2.1.0 (current as of 2026-09; Python ≥ 3.11, RDKit 2026.03). API names below are checked against this version; earlier docs/blog posts described a different surface.
This skill should be used when:
| Scenario | Use Instead |
|---|---|
| Just computing descriptors (MW, cLogP, TPSA, HBD/HBA) or standardizing structures, no rule/alert filtering | alterlab-datamol |
| Writing custom SMARTS queries or substructure logic outside the curated catalogs | alterlab-rdkit |
| Fetching a labeled toxicity/ADMET benchmark (e.g. hERG, AMES) with scaffold splits | alterlab-pytdc |
| Retrieving measured bioactivity (IC50/Ki) for compounds or targets | alterlab-chembl |
Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-datamol) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.
No install step — run install-free with uv (it resolves medchem, rdkit and datamol into an ephemeral environment on first use):
uv run --python ">=3.11" --with medchem python your_script.py # pulls rdkit + datamol
Pin the interpreter: uv's default Python here is 3.9, but medchem needs ≥ 3.11. (If you prefer a persistent environment, uv pip install medchem works too.)
Two features need extra native deps that PyPI cannot provide:
lilly_demerit_filter) shells out to the compiled Lilly MedChem Rules tools. Since medchem 2.1, medchem install-lilly downloads the checksum-pinned upstream release (2.1.0) and builds it next to the active Python — it needs make, a C++ compiler, and zlib (plus Ruby for the regression tests, or pass --no-test), and native Windows is unsupported (use WSL). The old conda-forge lilly-medchem-rules 1.0.1 build is obsolete. Without the tools, the call raises ImportError. 2.1 also changed the default Lilly atom-count limits (soft 25 / hard 40 / minimum 7; previously 30 / 50 / 1).rule_of_chemaxon_druglikeness) needs a licensed ChemAxon install.Everything else (RuleFilters, CommonAlerts, NIBR, complexity, groups, query) works from the PyPI wheel alone.
Conventions that hold across medchem. Filters take
mols(a sequence of SMILES strings or RDKit mols), default ton_jobs=-1(all cores), and acceptprogress=True. Themedchem.structural/medchem.rulesfilter classes return a pandas DataFrame (one row per input mol); themedchem.functional.*helpers return a NumPy boolean array whereTrue= the molecule passes / is kept. Get the canonical rule and alert names frommc.rules.RuleFilters.list_available_rules()andmc.structural.CommonAlertsFilters.list_default_available_alerts()rather than guessing.
medchem.rulesSingle rule — medchem.rules.basic_rules.* functions take one mol (SMILES or RDKit) and return a plain bool:
import medchem as mc
smi = "CC(=O)OC1=CC=CC=C1C(=O)O" # aspirin
mc.rules.basic_rules.rule_of_five(smi) # -> True
mc.rules.basic_rules.rule_of_veber(smi) # -> True
mc.rules.basic_rules.rule_of_cns(smi)
Available rules (full list via mc.rules.RuleFilters.list_available_rules()): rule_of_five, rule_of_five_beyond, rule_of_four, rule_of_three, rule_of_three_extended, rule_of_two, rule_of_ghose, rule_of_veber, rule_of_reos, rule_of_egan, rule_of_pfizer_3_75, rule_of_gsk_4_400, rule_of_oprea, rule_of_xu, rule_of_cns, rule_of_respiratory, rule_of_zinc, rule_of_leadlike_soft, rule_of_druglike_soft, rule_of_generative_design, rule_of_generative_design_strict, rule_of_chemaxon_druglikeness (needs ChemAxon).
There is no
rule_of_drug,rule_of_leadlike_strict,golden_triangle, orpains_filterfunction (checked in 2.1.0). PAINS lives in the alert system (HASALERT("pains")orCommonAlertsFilters(alerts_set=["PAINS"])). For lead-likeness userule_of_leadlike_softorrule_of_oprea.
Multiple rules — RuleFilters returns a DataFrame with columns mol, pass_all, pass_any, and one boolean column per rule:
import datamol as dm
import medchem as mc
mols = [dm.to_mol(s) for s in smiles_list]
rfilter = mc.rules.RuleFilters(rule_list=["rule_of_five", "rule_of_veber", "rule_of_cns"])
df = rfilter(mols=mols, n_jobs=-1, progress=True)
# df["pass_all"] -> bool per molecule; df["rule_of_five"] -> per-rule bool
clean = [m for m, ok in zip(mols, df["pass_all"]) if ok]
Property windows — there is no all-in-one "Constraints(mw_range=...)" object (see note in section 7). Build custom property cutoffs with mc.rules.in_range over descriptor names from mc.rules.list_descriptors() (mw, clogp, tpsa, n_lipinski_hbd, n_lipinski_hba, n_rotatable_bonds, n_rings, ...), or use the query DSL (HASPROP, section 8).
medchem.structuralTwo filter classes ship in medchem.structural: CommonAlertsFilters and NIBRFilters. (Lilly demerits is reached through medchem.functional, see section 3 — its class lives under medchem.structural.lilly_demerits and needs external binaries.)
Common alerts — curated alert sets from ChEMBL (Glaxo, Dundee, BMS, PAINS, SureChEMBL, ...). Returns a DataFrame with mol, pass_filter (bool), status (ok/exclude), reasons (matched alert names, ;-joined):
import medchem as mc
caf = mc.structural.CommonAlertsFilters() # all default sets
caf_pains = mc.structural.CommonAlertsFilters(alerts_set=["PAINS"]) # PAINS only
df = caf(mols=mol_list, n_jobs=-1, progress=True)
clean = df[df["pass_filter"]]
# discover sets: mc.structural.CommonAlertsFilters.list_default_available_alerts()
NIBR filters — Novartis filter set. Returns a DataFrame including mol, pass_filter, severity, status, reasons:
nibr = mc.structural.NIBRFilters()
df = nibr(mols=mol_list, n_jobs=-1)
medchem.functionalOne-call helpers that return a NumPy boolean array (True = keep). Pass return_idx=True to get indices of passing mols instead:
import medchem as mc
mc.functional.rules_filter(mol_list, rules=["rule_of_five", "rule_of_veber"], n_jobs=-1)
mc.functional.alert_filter(mol_list, alerts=["pains"], n_jobs=-1) # alert names are lowercase here
mc.functional.nibr_filter(mol_list, max_severity=10, n_jobs=-1)
mc.functional.complexity_filter(mol_list, complexity_metric="bertz", limit="99", n_jobs=-1)
mc.functional.chemical_group_filter(mol_list, chemical_group=mc.groups.ChemicalGroup(groups=["hinge_binders"]))
Lilly demerits — requires the Lilly tools (medchem install-lilly, see Installation); raises ImportError if missing. Molecules above max_demerits (default 160) are rejected:
keep = mc.functional.lilly_demerit_filter(mol_list, max_demerits=160, n_jobs=-1) # NumPy bool array
medchem.groupsChemicalGroup matches curated group catalogs. List valid catalog names with mc.groups.list_default_chemical_groups() (e.g. hinge_binders, electrophilic_warheads_for_kinases, common_warhead_covalent_inhibitors, privileged_kinase_inhibitor_scaffolds, aggregator). Per-mol functional-group names (for the query DSL HASGROUP) come from mc.groups.list_functional_group_names().
import medchem as mc
group = mc.groups.ChemicalGroup(groups=["hinge_binders"])
group.has_match(mol) # bool for one mol
group.get_matches(mol) # detailed matches
# batch: mc.functional.chemical_group_filter(mols, chemical_group=group)
phosphate_binders,michael_acceptors, andreactive_groupsare not default catalog names. For reactive/electrophilic motifs useelectrophilic_warheads_for_kinases/common_warhead_covalent_inhibitors, the alert filters (section 2), or a custom SMARTS catalog (mc.catalogs.catalog_from_smarts).
medchem.catalogsimport medchem as mc
mc.catalogs.list_named_catalogs() # available catalog names
cat = mc.catalogs.NamedCatalogs.pains() # e.g. a PAINS RDKit FilterCatalog
mc.catalogs.catalog_from_smarts(...) # build a catalog from custom SMARTS
medchem.complexityComplexityFilter flags molecules whose complexity exceeds a percentile threshold derived from a reference set (default ZINC). It is called per molecule and returns a bool (True = within limit / keep). Metrics: bertz, whitlock (WhitlockCT), barone (BaroneCT), smcm (SMCM), twc (TWC), plus sas/qed/clogp. New in 2.1: mc.complexity.SPS(mol) (normalized SpacialScore, Krzyzanowski et al., J. Med. Chem. 2023); as a ComplexityFilter metric ("spacialscore") it needs your own threshold_stats_file.
import medchem as mc
cflt = mc.complexity.ComplexityFilter(limit="99", complexity_metric="bertz")
keep = [cflt(m) for m in mol_list]
# or batch: mc.functional.complexity_filter(mol_list, complexity_metric="bertz", limit="99")
There is no
mc.complexity.calculate_complexity(...)andComplexityFiltertakeslimit/complexity_metric/threshold_stats_file, notmax_complexity. For a raw score use the metric classes directly (mc.complexity.TWC, etc.).
medchem.constraintsmc.constraints.Constraints(core, constraint_fns, prop_name="query") enforces substructure / R-group constraints around a query core (via has_match / validate) — it is not a physchem property-window filter. For MW/logP/TPSA windows, use RuleFilters + in_range (section 1) or the query DSL HASPROP (section 8).
medchem.queryQueryFilter evaluates a boolean expression over rules, properties, alerts, and groups. Operators: AND, OR, NOT, comparisons < > <= >= == !=. Primitives: MATCHRULE("..."), HASPROP("<descriptor>" < value), HASALERT("<lowercase set>"), HASGROUP("..."), HASSUBSTRUCTURE/HASSUPERSTRUCTURE, LIKE.
import medchem as mc
qf = mc.query.QueryFilter('MATCHRULE("rule_of_five") AND HASPROP("mw" < 500) AND NOT HASALERT("pains")')
keep = qf(mol_list, n_jobs=-1) # NumPy bool array
The syntax is the structured DSL above — not free-form text like
"rule_of_five AND NOT common_alerts". There is nomc.query.parse(); constructmc.query.QueryFilter(query_string)and call it on the mols. Alert names insideHASALERTare lowercase (pains,tox,nih, ...).
Filter a large collection to drug-like candidates, dropping anything with structural alerts.
import datamol as dm
import medchem as mc
import pandas as pd
df = pd.read_csv("compounds.csv")
mols = [dm.to_mol(smi) for smi in df["smiles"]]
# Rule filter -> DataFrame with pass_all + per-rule columns
rule_df = mc.rules.RuleFilters(rule_list=["rule_of_five", "rule_of_veber"])(
mols=mols, n_jobs=-1, progress=True
)
# Structural alerts -> DataFrame with pass_filter (True = clean)
alert_df = mc.structural.CommonAlertsFilters()(mols=mols, n_jobs=-1, progress=True)
df["passes_rules"] = rule_df["pass_all"].to_numpy()
df["no_alerts"] = alert_df["pass_filter"].to_numpy()
df["drug_like"] = df["passes_rules"] & df["no_alerts"]
df[df["drug_like"]].to_csv("filtered_compounds.csv", index=False)
Stack stricter filters and keep only molecules passing every stage. The functional.* helpers all return aligned NumPy bool arrays, so intersecting them is straightforward.
import numpy as np
import medchem as mc
f = mc.functional
keep = (
f.rules_filter(candidate_mols, rules=["rule_of_oprea"], n_jobs=-1)
& f.nibr_filter(candidate_mols, n_jobs=-1)
& f.complexity_filter(candidate_mols, complexity_metric="bertz", limit="99", n_jobs=-1)
)
# Add lilly_demerit_filter(...) too if the Lilly binaries are installed.
survivors = [m for m, ok in zip(candidate_mols, keep) if ok]
Flag molecules containing a target scaffold/motif (validate names with mc.groups.list_default_chemical_groups()).
import medchem as mc
group = mc.groups.ChemicalGroup(groups=["hinge_binders"])
keep = mc.functional.chemical_group_filter(mol_list, chemical_group=group)
with_group = [m for m, ok in zip(mol_list, keep) if ok]
Context Matters: Don't blindly apply filters. Understand the biological target and chemical space.
Combine Multiple Filters: Use rules, structural alerts, and domain knowledge together for better decisions.
Use Parallelization: For large datasets (>1000 molecules), always use n_jobs=-1 for parallel processing.
Iterative Refinement: Start with broad filters (Ro5), then apply more specific criteria (CNS, leadlike) as needed.
Document Filtering Decisions: Track which molecules were filtered out and why for reproducibility.
Validate Results: Remember that marketed drugs often fail standard filters—use these as guidelines, not absolute rules.
Consider Prodrugs: Molecules designed as prodrugs may intentionally violate standard medicinal chemistry rules.
Comprehensive API reference covering all medchem modules with detailed function signatures, parameters, and return types.
Complete catalog of available rules, filters, and alerts with descriptions, thresholds, and literature references.
Batch filtering CLI. Supports CSV/TSV, SDF, and plain-SMILES .txt input, configurable filter combinations, and a summary report.
Usage (install-free; pin the interpreter so medchem resolves):
uv run --python ">=3.11" --with medchem python scripts/filter_molecules.py input.csv \
--rules rule_of_five,rule_of_cns --nibr --output filtered.csv
Flags are individual switches (--nibr, --common-alerts, --lilly, --pains), not --alerts <name>. --lilly needs the Lilly tools (medchem install-lilly).
Official documentation: https://medchem-docs.datamol.io/ GitHub repository: https://github.com/datamol-io/medchem
Part of the AlterLab Academic Skills suite.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
12 skills in this plugin
/alterlab-datamolWraps RDKit in a high-level, pandas-friendly datamol interface with sensible defaults for everyday drug discovery — SMILES/SDF loading into DataFrames, molecule standardization, descriptors, fingerprints, Butina clustering, 3D conformer generation, scaffold analysis, and parallel batch processing, returning native rdkit.Chem.Mol objects. Use when running standard cheminformatics pipelines on molecule tables with minimal boilerplate; for low-level control, custom sanitization, or specialized algorithms prefer alterlab-rdkit. Part of the AlterLab Academic Skills suite./alterlab-deepchemRuns molecular machine learning with DeepChem — diverse featurizers, pre-built MoleculeNet benchmark datasets, and pre-trained models (ChemBERTa, GROVER) for property prediction (ADMET, toxicity, solubility) via traditional ML or graph neural networks. Use when running end-to-end molecular ML experiments that need MoleculeNet benchmarks, scaffold splitting, or ready-made models with minimal setup; for building custom PyTorch graph architectures prefer alterlab-torch-geometric, and for standalone molecule-to-feature-vector generation prefer alterlab-molfeat. Part of the AlterLab Academic Skills suite./alterlab-diffdockPredicts protein-ligand binding poses with DiffDock diffusion-based molecular docking from PDB structures and SMILES, producing pose confidence scores for virtual screening and structure-based drug design. Use when docking ligands into a protein, generating binding poses, or screening compounds against a target; not for binding affinity prediction. Part of the AlterLab Academic Skills suite./alterlab-matchmsComputes mass-spectral similarity and identifies compounds for metabolomics with matchms — comparing mass spectra, scoring similarity (cosine, modified cosine), and searching spectral libraries to annotate unknowns. Use when matching MS/MS spectra, identifying metabolites, or library searching; for full LC-MS/MS proteomics pipelines use alterlab-pyopenms. Part of the AlterLab Academic Skills suite./alterlab-molecular-dynamicsRuns and analyzes molecular dynamics simulations with OpenMM and MDAnalysis — setting up protein and small-molecule systems, assigning force fields, running energy minimization and production MD, and analyzing trajectories (RMSD, RMSF, contact maps, free energy surfaces). Use when simulating protein or ligand dynamics, equilibrating a system, or computing trajectory metrics for structural biology, drug binding, or biophysics. Part of the AlterLab Academic Skills suite./alterlab-molfeatFeaturizes molecules for machine learning with molfeat — ECFP/MACCS/MAP4 fingerprints, RDKit and Mordred physicochemical descriptors, pharmacophore and shape descriptors, and pretrained embeddings (ChemBERTa, ChemGPT, CheMeleon) exposed as scikit-learn transformers that convert SMILES into feature vectors. Use when turning molecules into ML-ready feature matrices for QSAR/QSPR or virtual screening, or benchmarking fingerprint against descriptor and embedding representations; for training models and MoleculeNet benchmarks on those features prefer alterlab-deepchem, and for low-level fingerprint or descriptor primitives prefer alterlab-rdkit. Part of the AlterLab Academic Skills suite./alterlab-cheminformatics:alterlab-medchemfrom alterlab-cheminformatics
npx claudepluginhub alterlab-ieu/alterlab-academic-skills --plugin alterlab-cheminformatics2 plugins in one repository ship this exact skill · first indexed Nov 9, 2026
Other plugins' skills for the same job