科研 Skill

逆合成路线规划

retrosynthesis-route-planning

Generates candidate retrosynthesis routes for a target SMILES using AiZynthFinder’s template-based search. Use before literature or expert route review.

发布者 Codar安全审核通过v0.1.0更新于 2026-11-18

SKILL.md

Retrosynthesis Route Planning

Purpose

Given a target molecule, propose one or more candidate synthetic routes back to purchasable (or otherwise available) starting materials. This skill wraps AiZynthFinder, an open-source Monte Carlo tree search (MCTS) retrosynthesis tool that combines a neural one-step retrosynthesis policy with a stock of known building blocks to find routes automatically, without requiring a chemist to hand-enumerate disconnections.

This skill generates candidate routes. It does not judge whether a route is good, safe, or scalable — pass its output to review-routes (deterministic evidence review against literature precedent) or to a human expert before acting on it.

When to Use This Skill

  • A target molecule (drug candidate, ligand, probe, material precursor) needs candidate synthesis routes and no known route is on hand.
  • Comparing several algorithmically proposed routes by number of steps, route score, or availability of starting materials.
  • Pre-screening synthesizability for a virtual library before committing wet-lab resources (e.g., as a quick "can this be made from stock reagents in <=5 steps" filter during hit triage).
  • Feeding candidate routes into review-routes for evidence-based vetting, or into search-reactions to check whether proposed steps have literature precedent.

When Not to Use This Skill

  • When a known, literature-verified route already exists — search for it with search-reactions or the primary literature instead of re-deriving one.
  • For multi-component materials, polymers, or biologics without a well-defined small-molecule target graph — AiZynthFinder operates on single organic molecules expressible as SMILES.
  • As a final answer for "how do I make this" without expert review — see Limitations below.

Prerequisites

  • Python 3.9–3.11 (check current support in the AiZynthFinder release notes — supported versions change between releases).

  • pip install aizynthfinder (also installs rdkit, pandas, and the search engine itself). A GPU is not required; the expansion policy runs on CPU but a search can take tens of seconds to a few minutes per target.

  • Pre-trained public model files and a stock of purchasable building blocks, downloaded once:

    mkdir -p aizynthfinder_data
    python -m aizynthfinder.tools.download_public_data aizynthfinder_data
    

    This downloads (several hundred MB to a few GB) a trained one-step expansion policy, a filter policy, and a "ZINC"-derived stock of purchasable molecules published by the AiZynthFinder authors. Internet access is required once, at setup time; route search itself runs fully offline afterward.

  • A valid target SMILES string, ideally already passed through standardize-chemical-structures so it is sanitized and canonical.

Core Workflow

Step 1 — Configure the finder

# config.yml (paths point at files produced by download_public_data)
policy:
  files:
    uspto:
      - aizynthfinder_data/uspto_model.onnx
      - aizynthfinder_data/uspto_templates.csv.gz
filter:
  files:
    uspto: aizynthfinder_data/uspto_filter_model.onnx
stock:
  files:
    zinc: aizynthfinder_data/zinc_stock.hdf5

Step 2 — Run a search

from aizynthfinder.aizynthfinder import AiZynthFinder

finder = AiZynthFinder(configfile="config.yml")
finder.stock.select("zinc")
finder.expansion_policy.select("uspto")
finder.filter_policy.select("uspto")

finder.target_smiles = "COc1ccc2[nH]c(S(=O)Cc3ncc(C)c(OC)c3C)nc2c1"  # example: omeprazole
finder.tree_search()
finder.build_routes()

stats = finder.extract_statistics()
print(f"Solved: {stats['is_solved']}, routes found: {stats['number_of_routes']}")

routes = finder.routes
for i, route in enumerate(routes):
    print(f"\nRoute {i}: score={route['all_score']:.3f}, "
          f"steps={route['route'].get('children', [])}")

Step 3 — Inspect and rank routes

# Each route is scored on a mix of length, stock availability of the leaves,
# and model confidence in each retrosynthetic step. Export a readable summary:
for i, route in enumerate(routes):
    tree = route["route"]
    leaves = [n["smiles"] for n in route.get("stock_info", {}).get("leaves", [])] \
        if "stock_info" in route else []
    print(f"Route {i}: score={route.get('all_score'):.3f} "
          f"in_stock_leaves={route.get('in_stock', 'n/a')}")

# Save routes for downstream review (feed this file to review-routes)
import json
with open("candidate_routes.json", "w") as fh:
    json.dump(
        [{"rank": i, "score": r.get("all_score"), "tree": r["route"]}
         for i, r in enumerate(routes)],
        fh, indent=2,
    )

Step 4 — Hand off for evidence review

Do not treat a high AiZynthFinder score as proof a route works. Pass candidate_routes.json to the review-routes skill (or a domain chemist) to check each step against literature precedent, reagent availability, and reaction-condition feasibility before any wet-lab commitment.

Advanced Usage

Comparing multiple expansion policies

AiZynthFinder supports swapping in different trained expansion policies (e.g., a template-free model, or a custom in-house template library) via the same config.yml structure. Compare finder.extract_statistics() across policies to see which proposes shorter or higher-confidence routes for a given chemotype — do not assume the default USPTO-trained policy generalizes to chemistry far outside patent literature (e.g., organometallic, heterocyclic materials, or biocatalysis).

Custom stock files

Replace the default ZINC-derived stock with an in-house or vendor catalog (e.g., eMolecules, Enamine REAL) exported as SMILES and converted with AiZynthFinder's make_stock utility, so "in stock" reflects reagents actually available to the user rather than a generic public catalog.

python -m aizynthfinder.tools.make_stock --files my_catalog.smi --output my_stock.hdf5

Batch mode for virtual-library triage

import pandas as pd
from aizynthfinder.aizynthfinder import AiZynthFinder

finder = AiZynthFinder(configfile="config.yml")
finder.stock.select("zinc")
finder.expansion_policy.select("uspto")

results = []
for smi in pd.read_csv("candidates.csv")["smiles"]:
    finder.target_smiles = smi
    finder.tree_search()
    finder.build_routes()
    stats = finder.extract_statistics()
    results.append({"smiles": smi, "solved": stats["is_solved"],
                     "n_routes": stats["number_of_routes"],
                     "top_score": stats.get("top_score")})

pd.DataFrame(results).to_csv("synthesizability_triage.csv", index=False)

Common Failure Modes

SymptomLikely causeFix
is_solved: False for every targetTarget chemotype far from USPTO training distribution (e.g., novel heterocycle, organometallic)Try a different/larger stock, increase search.max_transforms/iteration budget, or accept the target needs expert/novel-reaction design beyond template-based search
Routes score well but steps look implausibleTemplate application without a reliability check on the proposed reagents/conditionsAlways cross-check top routes with search-reactions or primary literature before trusting a step
Very slow searchLarge max_transforms, big stock file loaded repeatedly, or no filter policy pruning bad expansionsLoad stock/policy objects once outside loops (as in Batch mode above), cap iteration budget, enable the filter policy
Only trivial 1-step "routes" returnedTarget itself (or a close analog) is already in the stock fileExpected behavior — check finder.target_smiles is the right final product, not an intermediate

Limitations

  • AiZynthFinder is template-based: the public USPTO-trained model and templates reflect reactions that appear in US patent literature. Coverage is biased toward pharmaceutical/fine-chemical organic synthesis and weak for novel transformations, organometallic chemistry, polymer/materials synthesis, and biocatalysis. A target outside this distribution may come back "unsolved" even when a real route exists.
  • A route being "solved" (all leaves in stock) and well-scored is a computational plausibility signal, not a verified synthesis. Reaction feasibility, yield, chemoselectivity, functional-group compatibility across steps, and scale-up hazards are not modeled and must be checked by a chemist.
  • The default public stock reflects a generic commercial catalog (ZINC-derived purchasable set) at the time it was published; it will not reflect what a specific lab or vendor actually has on the shelf today. Supply your own stock file for decisions that matter.
  • Search is stochastic (MCTS) — results can differ slightly between runs with the same target unless a random seed is fixed; always report the top few routes, not just the single best score, and re-run before concluding a target is "unsolvable."

Quality Checks Before Reporting Routes

  • Target SMILES was validated/standardized (see standardize-chemical-structures) before search.
  • Report route count, is_solved status, and top-N scores, not only the single best route.
  • Flag which stock file was used (public ZINC-derived vs. a custom catalog) since "in stock" is meaningless without that context.
  • Recommend review-routes or literature lookup (search-reactions) before any route is acted on experimentally.
  • Note model/template provenance (training corpus, AiZynthFinder version) alongside any reported route for reproducibility.

示例提示词

给定目标分子的SMILES,用AiZynthFinder生成候选逆合成路线供专家复核。

所属插件

化学面向化学研究:化学信息学、量子化学、分子模拟、反应检索与路线评审、谱学与质谱、催化剂检索与设计、电化学。

安装该插件会一并获得同领域的 32 个 Skill / MCP。

同插件的其他科研 Skill

常见问题

逆合成路线规划能做什么?

Generates candidate retrosynthesis routes for a target SMILES using AiZynthFinder’s template-based search. Use before literature or expert route review。

如何安装逆合成路线规划?

在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「逆合成路线规划」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。

逆合成路线规划需要哪些权限?

该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。

逆合成路线规划经过官方审核吗?

是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。