本文へ移動
cccskills
無料GitHub で公開

bio-retrosynthesis

Performs retrosynthetic planning using AiZynthFinder (MCTS, template-based), Chemformer (template-free transformer), ASKCOS, and emerging RetroSynFormer with explicit handling of route scoring, building-block availability (eMolecules, Enamine, Mcule), forward prediction validation (Molecular Transformer), and disconnection-aware multi-objective search (MO-MCTS). Use when assessing synthetic feasibility of generated or selected molecules, planning multi-step syntheses, building synthesis-aware design pipelines, or screening libraries for retro-route feasibility.

インストール方法を見る

含まれるファイル(3)

  • SKILL.md13.1 KB
  • examples/aizynth_batch.py2.8 KB
  • usage-guide.md2.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Version Compatibility

Reference examples tested with: AiZynthFinder 4.4+, Chemformer 1.3+, RDKit 2024.09+, RDChiral 1.1+, Aizynthtrain 1.0+, ASKCOS Lite 0.5+.

Before using code patterns, verify installed versions match. If versions differ:

  • Python: pip show <package> then help(module.function) to check signatures
  • CLI: aizynthcli --version

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Retrosynthesis

Plan synthetic routes from a target molecule back to commercially-available building blocks. AiZynthFinder 4.0 (Saigiridharan, Hassen, Lai, Torren-Peraire, Engkvist, Genheden 2024 J Cheminform 16:57, AstraZeneca) is the open-source production-grade tool: Monte Carlo Tree Search (MCTS) + template-based expansion + multi-objective scoring (MO-MCTS). Chemformer (Irwin 2022) is template-free transformer alternative. ASKCOS (MIT) is the academic reference. Modern best practice combines retrosynthesis with forward validation (the predicted route should also predict the target from starting materials via Molecular Transformer) and building-block availability (eMolecules, Enamine, Mcule, ZINC catalog).

For generative design pipelines that need synthetic feasibility, see chemoinformatics/generative-design. For reaction enumeration (forward direction), see chemoinformatics/reaction-enumeration.

Retrosynthesis Method Taxonomy

ToolApproachStrengthFails when
AiZynthFinder 4.0Template-based MCTSOpen, scalable, well-validatedBeyond template coverage
ChemformerTemplate-free transformerNovel disconnectionsLess interpretable; harder to debug
ASKCOSTemplate-based + neuralMIT-quality academic standardSetup complexity
Molecular TransformerForward + retro transformerSingle SMILES-to-SMILESLess robust to non-training distribution
RetroSynFormerDecision transformerModern methodLimited adoption
IBM RXNCloud serviceHigh quality, easy interfaceAPI access required
BKMS_MTHRO / RetroPathPathway-basedMetabolic / biochemicalNot for general medchem
SyntheMol (StanfordGarbage)Specialized for medchemPublic domain alternativeLimited tooling

Decision: For most users, AiZynthFinder 4.4 with USPTO + USPTO-50k templates is the open-source standard. For high-stakes routes, validate with Molecular Transformer forward prediction.

Decision Tree by Scenario

ScenarioToolNotes
Standard medchem targetAiZynthFinder default templatesUSPTO/Reaxys templates
Novel chemotypeAiZynthFinder + Chemformer template-free fallbackCombine both
Generated molecules (REINVENT output)AiZynthFinder batchFilter to feasible routes
Multi-step synthesis planningAiZynthFinder + manual reviewTop-K routes
Validate generated routeMolecular Transformer forwardCheck round-trip
Cost-aware synthesisAiZynthFinder + custom building-block pricingScore weight
Disconnection-aware design (DAD)AiZynthFinder MO-MCTSMulti-objective
Patent-aware routesCustom template exclusionSpecialized

AiZynthFinder Setup

Goal: Configure AiZynthFinder with USPTO templates + a building-block stock and run MCTS retrosynthesis planning on a target SMILES.

Approach: Build a configuration dict pointing to policy templates (ONNX + CSV) and a stock H5, instantiate AiZynthFinder, set the target SMILES, then call tree_search() followed by build_routes().

from aizynthfinder.aizynthfinder import AiZynthFinder

config_dict = {
    'policy': {
        'files': {
            'uspto': ['policy/uspto_model.onnx', 'templates/uspto_templates.csv'],
        }
    },
    'stock': {
        'files': {
            'zinc': 'stock/zinc.h5',
        }
    },
    'finder': {
        'algorithm': 'mcts',
        'iteration_limit': 100,
        'time_limit': 120,
    }
}

finder = AiZynthFinder(configdict=config_dict)
finder.target_smiles = 'CC(=O)Nc1ccc(C(=O)Nc2cccc(C(F)(F)F)c2)cc1'
finder.tree_search()
finder.build_routes()

Output: list of routes, each with depth, building blocks, score, leaf nodes.

Route Output Analysis

for route in finder.routes:
    print(f'Depth: {route.depth}, Score: {route.score:.2f}')
    print(f'In-stock: {sum(node.in_stock for node in route.leafs())}')
    print(f'Building blocks: {[node.smiles for node in route.leafs()]}')

Critical metrics:

  • Depth: number of synthetic steps. 1-3 typical for medchem.
  • Score: AiZynthFinder route score (0-1, higher = better)
  • In-stock: how many leaf nodes are commercially available
  • Stock origin: ZINC, Enamine, Mcule, eMolecules

Route Scoring (MO-MCTS)

AiZynthFinder 4.0 supports multi-objective scoring (Saigiridharan et al 2024 J Cheminform 16:57):

config_dict['finder']['algorithm'] = 'mo_mcts'
config_dict['finder']['mo_mcts'] = {
    'objectives': [
        {'name': 'state_score', 'weight': 0.5},  # default state score
        {'name': 'broken_bonds_score', 'weight': 0.3},  # complexity reduction
        {'name': 'route_length', 'weight': 0.2, 'maximize': False},  # shorter
    ]
}

State score: probability the current state can be solved. Broken bonds: each step should reduce molecular complexity. Route length: shorter is better.

Building Block Stocks

StockCompoundsSourceCost-tier
ZINC clean leads250kZINC22 catalogVarious commercial
Enamine Building Blocks200k+Enamine$$
Enamine REAL29B (make-on-demand)Enamine$$$
Mcule25MMcule$$
eMolecules16MeMolecules$$
ChemBridge1MChemBridge$$

AiZynthFinder accepts stocks as HDF5 (built via aizynthtrain):

aizynthtrain build-stock --input zinc_building_blocks.smi --output zinc.h5

Forward Validation with Molecular Transformer

AiZynthFinder predicts retrosynthesis (target -> precursors); Molecular Transformer predicts forward (precursors -> product). Validating the round-trip:

from molecular_transformer import predict_forward

precursors = route.leafs()  # building blocks from retro
predicted_product = predict_forward(precursors)
match = (Chem.CanonSmiles(predicted_product) == 
         Chem.CanonSmiles(finder.target_smiles))

Routes where the forward prediction reproduces the target are highest confidence. ~30-50% of AiZynthFinder routes pass forward validation (Saigiridharan, Genheden et al 2024 J Cheminform 16:57).

Template-Free with Chemformer

Chemformer uses a Transformer (BART) trained on USPTO reactions for SMILES-to-SMILES:

from chemformer import Chemformer

cf = Chemformer.load_pretrained('USPTO_RETROSYNTHESIS_TEMPLATE_FREE')
predictions = cf.predict('CC(=O)Nc1ccc(C(=O)Nc2cccc(C(F)(F)F)c2)cc1',
                         beam_search=10)

Output: 10 predicted precursor SMILES. No templates required; can predict novel disconnections.

Trade-off: Template-free is more flexible but harder to debug. Combining with AiZynthFinder template MCTS gives best of both.

Disconnection-Aware Design (DAD)

Modify generative design to also score retrosynthetic feasibility. AiZynthFinder batch mode for 1000+ molecules.

Goal: Add retrosynthetic feasibility scoring to generative design pipelines for hundreds-to-thousands of candidate molecules.

Approach: Batch-process generated SMILES through aizynthcli, classify each compound by route depth and in-stock leaf count, and feed feasibility back into the generative scoring function.

aizynthcli --smiles compounds.smi --output routes.json \
           --config config.yaml --policy uspto --stock zinc

For each compound, returns top-K routes. Score-feasibility for generative design:

  • "Synthesizable" = in-stock leaves >= 2 in best route
  • "Routable" = at least one route depth <= 5
  • "Easy" = at least one route depth <= 3 with all leaves in-stock

Cost-Aware Synthesis

Add building-block pricing as objective:

def route_cost(route, price_db):
    total = 0
    for leaf in route.leafs():
        smi = Chem.CanonSmiles(leaf.smiles)
        if smi in price_db:
            total += price_db[smi]
    return total

Combine with step-cost estimate (typical: ~$500-2000 per synthesis step).

Per-Tool Failure Modes

AiZynthFinder -- template coverage gap

Trigger: Target molecule uses bond formation not in training reactions.

Mechanism: USPTO templates are biased toward common transformations; novel chemistry (organometallics, exotic heterocycles) missing.

Symptom: No solved route or route uses unsuitable simplifications.

Fix: Augment templates from Reaxys; combine with Chemformer; manual review.

Chemformer -- non-canonical SMILES output

Trigger: Default Chemformer output.

Mechanism: Transformer can produce non-canonical SMILES variants.

Symptom: SMILES round-trip fails; validation tools confused.

Fix: Canonicalize Chemformer output via RDKit before comparing.

Route uses non-stock building block

Trigger: Leaf node not in stock database.

Mechanism: AiZynthFinder tree may end on non-purchasable molecules.

Symptom: Route "complete" but route has non-stock leaves.

Fix: Filter routes by in_stock_only=True; or expand stock to include theoretical building blocks (Enamine REAL).

MCTS iteration limit too low

Trigger: Complex target requiring deep tree search.

Mechanism: MCTS may not find route in default 100 iterations.

Symptom: No routes returned despite plausible target.

Fix: Increase iteration_limit=500 and time_limit=600; consider divide-and-conquer for complex targets.

Forward validation fails

Trigger: Retro route uses chemistry that doesn't actually work in forward.

Mechanism: Template-based retro lacks reaction conditions / catalysts; forward prediction more conservative.

Symptom: Forward predicts different product than target.

Fix: Use as confidence signal, not rejection; many routes don't round-trip but are still valid synthesis-wise.

Building block stock obsolete

Trigger: Old ZINC catalog used; building blocks no longer purchasable.

Mechanism: Commercial catalogs change quarterly.

Symptom: Routes recommend unavailable building blocks.

Fix: Use Enamine REAL or recent ZINC22 for current stock; verify with vendor before synthesis.

Reconciliation: AiZynthFinder vs Chemformer

AspectAiZynthFinderChemformer
ApproachTemplates + MCTSTransformer encoder-decoder
SpeedFast for shallow treesSingle-pass per target
InterpretabilityHigh (template + atom mapping)Low (black box)
Novel disconnectionsLimitedBetter
Production maturityHighMedium
CostCPUGPU recommended

For comprehensive coverage, run both and merge unique routes.

Common Errors

SymptomCauseFix
tree_search() returns no routesTarget outside template coverageIncrease iterations; try Chemformer
All routes depth > 8Complex targetLikely correct; review manually
Route says "solved" but leaves not in stockStock incompleteUpdate stock; or set in_stock_only=True
Building block price not foundCompound not in pricing DBUse Enamine quote or vendor inquiry
Chemformer truncates SMILESToken limitIncrease max_length
Forward prediction wrongOut-of-distribution reactionUse as confidence signal only
MCTS slow on simple targetDefault configReduce time_limit; use smaller template set

References

  • Saigiridharan L, Hassen AK, Lai J, Torren-Peraire P, Engkvist O, Genheden S 2024 J Cheminform 16:57 -- AiZynthFinder 4.0 (multi-objective MCTS retrosynthesis).
  • Irwin et al., Mach. Learn.: Sci. Technol. 3:015022 (2022) -- Chemformer.
  • Schwaller et al., ACS Cent. Sci. 5:1572 (2019) -- Molecular Transformer.
  • Coley et al., ACS Cent. Sci. 3:434 (2017) -- ASKCOS template extraction.
  • Digital Discovery (2026) -- RetroSynFormer decision transformer.

Related Skills

  • chemoinformatics/molecular-io - Parse target and route SMILES
  • chemoinformatics/molecular-standardization - Standardize before retrosynthesis
  • chemoinformatics/generative-design - Add synthetic feasibility to scoring
  • chemoinformatics/reaction-enumeration - Forward direction (template enumeration)
  • chemoinformatics/admet-prediction - Filter targets before retrosynthesis

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

生成图文并茂的分析报告/实验报告/质检报告(固定模版)。当用户要求"生成报告/总结报告/实验报告/质检报告/QC报告",或分析流程收尾需要交付报告时使用。报告必须基于真实分析输出,包含固定章节结构、关键指标表格和真实结果图。

日本語の概要は準備中です。原文の説明を表示しています。

peacezha/HPClaw32026年10月11日 更新

Predicts ADMET properties using ADMETlab 3.0 (119 endpoints with uncertainty), ADMET-AI, DeepChem MolNet, and chemprop D-MPNN with explicit handling of OECD QSAR principles, applicability domain assessment, calibration, hERG/CYP/AMES gold-standard endpoints, and PAINS / Lipinski / Ro5 / Veber / BBB druglikeness filters. Use when filtering compounds for drug-likeness, prioritizing leads by predicted safety, or building an in-house ADMET QSAR model.

日本語の概要は準備中です。原文の説明を表示しています。

peacezha/HPClaw32026年10月11日 更新

Trim PCR primers from aligned reads in amplicon-panel BAMs using samtools ampliconclip. Use when processing SARS-CoV-2 ARTIC, hereditary cancer panels, ctDNA hot-spot panels, or any amplicon assay where primer-derived bases would falsely confirm reference at primer footprints.

日本語の概要は準備中です。原文の説明を表示しています。

peacezha/HPClaw32026年10月11日 更新

Filter alignments by flags, mapping quality, and regions using samtools view and pysam. Use when extracting specific reads, removing low-quality alignments, or subsetting to target regions.

日本語の概要は準備中です。原文の説明を表示しています。

peacezha/HPClaw32026年10月11日 更新

Create and use BAI/CSI indices for BAM/CRAM files using samtools and pysam. Use when enabling random access to alignment files or fetching specific genomic regions.

日本語の概要は準備中です。原文の説明を表示しています。

peacezha/HPClaw32026年10月11日 更新

Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO. Supports Clustal, PHYLIP, Stockholm, FASTA, Nexus, and other alignment formats for phylogenetics and conservation analysis. Use when reading, writing, or converting alignment file formats.

日本語の概要は準備中です。原文の説明を表示しています。

peacezha/HPClaw32026年10月11日 更新

peacezha のスキルをすべて見る

このスキルの問題を報告する