medchem – skill Dữ liệu & Khoa học cho agent AI
Áp dụng bộ lọc hóa dược để sàng lọc hợp chất, dùng các quy tắc drug-likeness (Lipinski, Veber, CNS), danh mục cảnh báo cấu trúc (PAINS, NIBR, ChEMBL), chỉ số độ phức tạp, và ngôn ngữ truy vấn medchem để lọc thư viện hợp chất.
Cài skill medchem bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/medchem-7d165.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /medchem – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/medchem-7d165.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $medchem – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/medchem-7d165.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /medchem – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/medchem-7d165.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /medchem – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Medchem
Overview
Medchem is a Python library from [datamol-io](https://github.com/datamol-io/medchem) for molecular filtering and prioritization in drug discovery. Apply literature-derived drug-likeness rules, named alert catalogs, complexity thresholds, chemical-group detection, and a custom query language to triage compound libraries at scale. Filters are context-specific guidelines — combine with domain expertise and target knowledge.
Verified runtime: medchem 2.1.1, datamol 0.13.0, RDKit 2026.3.6; Python 3.11+. RuleFilters and structural classes return pandas DataFrames. Filters run locally; installation and documentation lookup need network access. Lilly native execution was not tested in this review.
When to Use This Skill
This skill should be used when:
- Applying drug-likeness rules (Lipinski, Veber, CNS, lead-like) to compound libraries
- Filtering molecules by structural alerts, PAINS, or NIBR screening-deck rules
- Prioritizing compounds for hit-to-lead or lead optimization
- Calculating complexity metrics against ZINC-derived thresholds
- Detecting functional groups or named substructure catalogs
- Building multi-criteria filters with the medchem query language
Installation
uv pip install "medchem==2.1.1" "datamol==0.13.0" "rdkit==2026.3.6"Optional Lilly integration: install the upstream checksum-pinned native tools beside the active Python. This downloads source, builds executables, and runs native regression tests (C++ compiler, make, zlib, Ruby; WSL on Windows). This installation command is documented upstream, not executed here:
medchem install-lillyCore Capabilities
1. Medicinal Chemistry Rules
Apply established drug-likeness rules via medchem.rules.
List available rules:
import medchem as mc
mc.rules.RuleFilters.list_available_rules_names()
# ['rule_of_five', 'rule_of_five_beyond', 'rule_of_four', 'rule_of_three', ...]Single rule on one molecule:
import datamol as dm
import medchem as mc
smiles = "CC(=O)OC1=CC=CC=C1C(=O)O" # aspirin
mc.rules.basic_rules.rule_of_five(smiles) # True
mc.rules.basic_rules.rule_of_cns(smiles) # True
mc.rules.basic_rules.rule_of_veber(smiles) # TrueMultiple rules with RuleFilters (returns a DataFrame):
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_oprea", "rule_of_cns", "rule_of_leadlike_soft"]
)
df = rfilter(mols=mols, n_jobs=-1, progress=True, keep_props=False)
# Columns: mol, pass_all, pass_any, rule_of_five, rule_of_oprea, ...
passing = df[df["pass_all"]]Examples below use already parsed mol_list, smiles_list, and candidates supplied by the caller; reject missing/empty structures before filtering. Use keep_props=True to include computed descriptors (mw, clogp, tpsa, etc.) in the result.
2. Structural Alert Filters
Detect problematic patterns with medchem.structural. Both classes return DataFrames with pass_filter, status, and reasons columns.
Common alerts (ChEMBL-derived rule sets):
import medchem as mc
alert_filter = mc.structural.CommonAlertsFilters(alerts_set=["BMS", "Dundee", "Glaxo"])
df = alert_filter(mols=mol_list, n_jobs=-1, progress=True)
# df columns: mol, pass_filter, status, reasons
clean = df[df["pass_filter"]]NIBR filters (Novartis screening-deck curation):
nibr_filter = mc.structural.NIBRFilters()
df = nibr_filter(mols=mol_list, n_jobs=-1, progress=True)
# df columns: mol, pass_filter, status, severity, reasons, n_covalent_motif, special_molThe class rejects explicit exclusion alerts. To also reject accumulated flag severity ≥10, use df["pass_filter"] & (df["severity"] < 10), or mc.functional.nibr_filter(..., max_severity=10). The functional cutoff is strict < 10 and assumes valid molecules: it checks severity alone and can admit parse failures with severity zero. Prevalidate inputs.
3. Named Catalog Filters (PAINS, Brenk, etc.)
Use medchem.catalogs.NamedCatalogs for RDKit FilterCatalog instances, or the functional API:
import medchem as mc
# List available named catalogs
mc.catalogs.list_named_catalogs()
# ['tox', 'pains', 'pains_a', 'brenk', 'nibr', 'zinc', ...]
# Functional API — True means molecule passes (no alert match)
passes = mc.functional.catalog_filter(mols=mol_list, catalogs=["pains"], n_jobs=-1)
# Or via catalog objects
passes = mc.functional.catalog_filter(
mols=mol_list,
catalogs=[mc.catalogs.NamedCatalogs.pains()],
n_jobs=-1,
)alert_filter is a different API: it uses the ChEMBL common-alert collection names from CommonAlertsFilters.list_default_available_alerts(), not every NamedCatalogs name. For example, brenk and pains_a belong in catalog_filter. Set common-alert sets explicitly; the current class implementation defaults to BMS only. catalog_filter rejects the string names nibr and bredt; use their dedicated functional filters. Raw NIBR catalog matches include annotations, regardless of severity.
4. Functional API
medchem.functional provides one-call wrappers that return boolean masks (True = passes):
import medchem as mc
mc.functional.rules_filter(mols=mol_list, rules=["rule_of_five", "rule_of_cns"], n_jobs=-1)
mc.functional.nibr_filter(mols=mol_list, max_severity=10, n_jobs=-1)
mc.functional.catalog_filter(mols=mol_list, catalogs=["pains", "brenk"], n_jobs=-1)
mc.functional.complexity_filter(mols=mol_list, complexity_metric="bertz", limit="99", n_jobs=-1)Other helpers: catalog_filter, chemical_group_filter, lilly_demerit_filter (requires optional binaries), macrocycle_filter, bredt_filter, protecting_groups_filter, and more. Pass copies to bredt_filter ([Chem.Mol(m) for m in mol_list], after from rdkit import Chem): its in-place kekulization changes later aromatic alert matches in 2.1.1.
5. Chemical Groups
Detect functional groups and curated pattern collections via medchem.groups:
import medchem as mc
# Browse available group collections
mc.groups.list_default_chemical_groups()
# ['privileged_scaffolds', 'common_warhead_covalent_inhibitors', 'rings_in_drugs', ...]
group = mc.groups.ChemicalGroup(groups=["privileged_scaffolds"])
group.has_match(mol) # bool
group.get_matches(mol) # DataFrame, including a matches column
matching_mols = [mol for mol in mol_list if group.has_match(mol)]
# group.filter(names=[...]) narrows pattern names in place; it does not filter molecules.
# Returns a boolean mask: True means the molecule does NOT match the group
mc.functional.chemical_group_filter(mols=mol_list, chemical_group=group, n_jobs=-1)Custom groups use groups_db CSV with both smiles and smarts, plus name and group columns. SMILES and SMARTS matching can differ; record the representation and exact_match setting.
6. Molecular Complexity
Compare complexity metrics to precomputed, molecular-weight-binned ZINC-15 thresholds. Valid default limit labels are median, 90, 99, 999 (99.9th percentile), and max; 95 is not provided. spacialscore needs a custom threshold file. All metrics use an upper cutoff, including QED; do not interpret that as selecting high QED.
import medchem as mc
# Single molecule
cf = mc.complexity.ComplexityFilter(limit="99", complexity_metric="bertz")
cf(mol) # True if below 99th-percentile threshold
# Batch via functional API
mc.functional.complexity_filter(
mols=mol_list,
complexity_metric="bertz", # also: sas, qed, whitlock, barone, smcm, twc
limit="99",
n_jobs=-1,
)
# Direct metric functions
mc.complexity.WhitlockCT(mol)
mc.complexity.BaroneCT(mol)7. Scaffold Constraints
medchem.constraints.Constraints matches a core scaffold and applies per-atom constraint functions — not simple MW/LogP ranges. For property bounds, use RuleFilters, descriptors via mc.rules.list_descriptors(), or the query language.
import datamol as dm
import medchem as mc
core = dm.from_smarts("c1cncc([*:1])c1")
for atom in core.GetAtoms():
if atom.GetAtomMapNum() == 1:
atom.SetProp("query", "aromatic_sidechain")
constraints = mc.constraints.Constraints(
core=core,
constraint_fns={"aromatic_sidechain": lambda fragment: dm.descriptors.n_aromatic_atoms(fragment) > 0},
)
assert not constraints(dm.to_mol("CN(C)C(=O)c1cncc(C)c1"))
assert constraints(dm.to_mol("c1ccc(cc1)-c1cccnc1"))8. Medchem Query Language
Build multi-criteria filters with medchem.query.QueryFilter:
import medchem as mc
# Rule + alert combination
qf = mc.query.QueryFilter('MATCHRULE("rule_of_five") AND NOT HASALERT("pains")')
mask = qf(mols=mol_list, n_jobs=-1) # list[bool]
# CNS-like with property bounds
qf = mc.query.QueryFilter('MATCHRULE("r… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- molecular-dynamics – Chạy và phân tích mô phỏng động lực học phân tử bằng OpenMM và MDAnalysis. Thiết lập hệ…
- ml-pipeline-workflow – Xây dựng pipeline MLOps đầu cuối, từ chuẩn bị dữ liệu, huấn luyện mô hình, kiểm định đến…
- molfeat – Trích xuất đặc trưng phân tử nhỏ bằng Molfeat cho QSAR/QSPR, độ tương đồng hóa học, sàng…
- neurokit2 – Xây dựng và kiểm tra quy trình nghiên cứu NeuroKit2 có thể tái lập cho tiền xử lý chuỗi…
- hyperliquid – Dữ liệu thị trường Hyperliquid, lịch sử tài khoản, đánh giá giao dịch.
- neuropixels-analysis – Phân tích toàn bộ quy trình dữ liệu ghi điện ngoại bào Neuropixels với SpikeInterface…
- data-quality-auditor – Kiểm tra dữ liệu về độ đầy đủ, tính nhất quán, độ chính xác và tính hợp lệ. Lập hồ sơ…
- database-designer – Dùng khi người dùng yêu cầu thiết kế schema cơ sở dữ liệu, lập kế hoạch migration dữ…