AI Retrosynthesis 開源工具全景教學

為 lead optimization(先導化合物優化)產出的 analog(類似物)規劃最短、最可行的合成路線:6 大開源工具比較與實戰指南。

1. 背景與需求定義

什麼是 Retrosynthesis(逆合成分析)?

Retrosynthesis(逆合成分析)是有機化學的核心方法論,由 E.J. Corey 於 1960 年代提出並獲得 1990 年諾貝爾化學獎。其核心思路是:從目標分子出發,反向推導可能的合成路線,直到所有中間體都可以從商業可得的 building block(構建塊)出發合成。

你的 Use Case

1Lead Optimization Pipeline:
2  已有小分子藥物 → AI Lead Optimization → 新 Analog (SMILES)
34                                    Retrosynthesis Planning
56                                    合成路線(短步驟 + 可購買試劑)

關鍵需求:

  1. 合成步驟最小化(ideally 3-5 步)— 減少合成成本、時間與失敗風險
  2. Building block 商業可購買性(eMolecules / Enamine / ZINC / MolPort)— 確保路線可實際執行
  3. 批量處理— 同時評估多個 analog 的合成可行性
  4. 路線品質評分— 從多條路線中選出最佳方案

2. 6 大工具總覽與比較

工具定位矩陣


flowchart TD
    subgraph Tier1 ["Tier 1 — 端到端合成規劃平台"]
        A["aizynthfinder
AstraZeneca · 845⭐
MCTS + buyable stock"] B["ASKCOS
MIT · 265⭐
Web 平台 + 條件推薦"] C["SynPlanner
Strasbourg · 54⭐
6 種 MCTS + priority rules"] end subgraph Tier2 ["Tier 2 — 框架 / 模型層級"] D["syntheseus
Microsoft · 197⭐
模組化框架 · 4 種搜尋"] E["DeepRetro
DeepForest · 23⭐
LLM recursive + GUI"] F["RetroChimera
Microsoft · 25⭐
Ensemble single-step"] end A ---|最成熟| Tier1 D ---|可整合 RetroChimera| F E ---|內建 aizynthfinder| A

功能比較表

功能aizynthfinderASKCOSSynPlannersyntheseusDeepRetroRetroChimera
Multi-step planning✅ MCTS✅ MCTS✅ 6 種 MCTS✅ 4 種演算法✅ Recursive❌ Single-step
Buyable stock 檢查✅ ZINC/自訂✅ Pricer API✅ eMolecules✅ MolInventory✅ ZINC❌ 需整合
最大步驟數控制✅ max_transforms✅ max_depth✅ max_depth✅ max_expansion_depth✅ max_depth
路線評分✅ State Score✅ SCScore✅ Competing sites✅ 可自訂✅ Heuristic
Web UI⚠️ Jupyter✅ Django❌ CLI❌ CLI✅ D3.js GUI
API✅ Python✅ REST✅ Python✅ Python✅ REST✅ Python
反應條件推薦
Forward prediction✅ Filter
LLM 整合✅ Claude/DeepSeek
Docker 部署⚠️ 可選✅ 15+ services
安裝難度🟢 低🔴 高🟢 低🟢 低🟡 中🟢 低
活躍度🟢 活躍🟡 遷移中🟢 極活躍🟢 活躍🟢 活躍🟢 活躍
LicenseMITMPL-2.0MITMITApache-2.0MIT

資安掃描摘要

工具風險等級主要注意事項
aizynthfinder🟢 低pickle 載入 model(科學計算常見)
ASKCOS🟡 中Django SECRET_KEY / DB 密碼寫死(部署前須更換)
SynPlanner🟢 低pickle 僅在 test fixture
syntheseus🟢 低eval() 在 LocalRetro wrapper,輸入來自 model inference
DeepRetro🟢 低CORS 全開(production 需限縮)、simple token auth
RetroChimera🟢 低無硬編碼機密

3. 工具選擇決策樹


flowchart TD
    Start["我有 lead optimization 產出的 analog SMILES"] --> Q1{"需要什麼?"}
    
    Q1 -->|"完整合成規劃\n(最常見需求)"| Q2{"技術資源?"}
    Q1 -->|"只需 single-step\n反應預測"| RC["RetroChimera\n(最準的 single-step model)"]
    Q1 -->|"想用 LLM 探索\n創新路線"| DR["DeepRetro\n(LLM + template hybrid)"]
    
    Q2 -->|"Python 熟手\n快速開始"| AZ["aizynthfinder ⭐推薦\n(安裝簡單 + buyable stock)"]
    Q2 -->|"需要 Web UI\n團隊共用"| ASK["ASKCOS\n(功能最全但部署重)"]
    Q2 -->|"需要最新演算法\n學術研究"| Q3{"偏好?"}
    
    Q3 -->|"端到端工具"| SP["SynPlanner\n(6 種 MCTS + priority rules)"]
    Q3 -->|"模組化框架\n可插拔 model"| SYN["syntheseus\n(搭配 RetroChimera)"]
    
    AZ --> BatchQ{"需批量處理?"}
    BatchQ -->|"是"| Batch["aizynthfinder 內建\nbatch SMILES 處理"]
    BatchQ -->|"否"| Single["Jupyter notebook\n逐個分析"]

4. 推薦方案:Lead Optimization 工作流

首選方案:aizynthfinder

理由: 安裝最簡單、buyable stock 支援最完整、route scoring 成熟、AstraZeneca 藥廠實戰驗證。

1# 安裝
2pip install aizynthfinder[all]
3
4# 下載預訓練 model + ZINC building block stock
5download_public_data .
6
7# 快速跑一個 analog
8aizynthcli --smiles "CCO" --config config.yml --output result.json

關鍵設定(config.yml):

 1search:
 2  algorithm: mcts
 3  max_transforms: 4          # 限制最大合成步驟
 4  return_first: false         # 找所有路線再排序
 5  iteration_limit: 100
 6
 7stock:
 8  zinc:
 9    type: InMemoryMoleculeStock
10    path: zinc_stock.hdf5
11  # 自訂 building block 庫
12  internal:
13    type: InMemoryMoleculeStock
14    path: internal_bb.hdf5
15
16post_processing:
17  all_routes: true            # 提取所有 solved route

批量處理 analog:

1# 一行一個 SMILES
2cat analogs.smi | while read smi; do
3  aizynthcli --smiles "$smi" --config config.yml --output "results/${smi}.json"
4done

進階方案:aizynthfinder + RetroChimera

用 RetroChimera 做更準的 single-step prediction,再透過 syntheseus 框架做 multi-step planning:

1pip install syntheseus
2pip install retrochimera
3
4# RetroChimera 作為 single-step model
5# syntheseus 作為 multi-step search framework
6# 自訂 building block 作為 MolInventory

探索方案:DeepRetro(LLM-driven)

適合想探索「超越 template 限制」的新路線:

1git clone https://github.com/deepforestsci/DeepRetro.git
2cd DeepRetro && pip install -r requirements.txt
3
4# 需要 LLM API key(Claude / DeepSeek)
5export ANTHROPIC_API_KEY=...
6python -m deepretro.api  # 啟動 web GUI

5. Building Block 可購買性資源

主要資料庫

資料庫分子數量用途工具支援
ZINC~750M免費學術用,含 purchasable subsetaizynthfinder, DeepRetro
eMolecules~300K building blocks商業 building blocks,含價格SynPlanner
Enamine REAL~6.5B可合成化合物,building blocks ~300Kaizynthfinder(自訂 stock)
MolPort~8M聚合多供應商,含價格syntheseus
Sigma-Aldrich~300K常見化學試劑ASKCOS

自訂 Building Block 庫

如果你的實驗室有慣用的試劑供應商,可以建立自訂 building block 庫:

1# aizynthfinder 範例
2from aizynthfinder.utils.smiles2stock import smiles2stock
3
4# 從 SMILES 檔案建立 stock
5smiles2stock(files=["internal_building_blocks.smi"], output="internal_bb.hdf5")

6. 各工具教學索引

每個工具都有獨立的完整教學(11 章節 + mermaid 架構圖 + 資安掃描 + FAQ),以下為快速索引:

Tier 1 — 端到端合成規劃平台

工具教學重點檔案
aizynthfinderMCTS 搜尋策略、buyable stock 設定、max_transforms、route scoring、batch 處理2026-06-05-tutorial-aizynthfinder.md
ASKCOSWeb UI 操作、REST API、Pricer buyability 檢查、15+ Docker services 部署、條件推薦2026-06-05-tutorial-ASKCOS.md
SynPlanner6 種 MCTS 演算法、priority rules、eMolecules building blocks、route clustering、competing sites scoring2026-06-05-tutorial-SynPlanner.md

Tier 2 — 框架 / 模型層級

工具教學重點檔案
syntheseus模組化架構(Interface/Search/Prediction 三層)、4 種搜尋演算法、8 個 SOTA model wrapper、MolInventory2026-06-05-tutorial-syntheseus.md
DeepRetroLLM recursive approach、hallucination guard、D3.js GUI、protecting group awareness、prompt V4 CoT2026-06-05-tutorial-DeepRetro.md
RetroChimeraEdit + DeNovo ensemble、per-rank weight、syntheseus 整合、blind test 結果2026-06-05-tutorial-retrochimera.md

7. 實戰建議

7.1 快速可行性篩選(Triage)

用 aizynthfinder 的 return_first: true 快速篩選哪些 analog 有解:

 1from aizynthfinder.aizynthfinder import AiZynthFinder
 2
 3finder = AiZynthFinder(configfile="config.yml")
 4finder.config.search.return_first = True  # 找到第一條解即停
 5
 6results = {}
 7for smi in analog_smiles_list:
 8    finder.target_smiles = smi
 9    finder.tree_search()
10    finder.build_routes()
11    results[smi] = {
12        "solved": finder.routes.is_solved,
13        "n_steps": len(finder.routes[0]) if finder.routes.is_solved else None
14    }

7.2 深度路線分析

篩選通過的 analog 用完整搜尋分析:

1finder.config.search.return_first = False
2finder.config.search.iteration_limit = 500
3finder.config.search.max_transforms = 4
4
5# 跑完後取所有路線,按步驟數排序
6routes = finder.routes.scored_routes
7shortest = sorted(routes, key=lambda r: r.n_reactions)

7.3 路線視覺化

1# aizynthfinder 內建 route visualization
2from aizynthfinder.utils.image import RouteImageFactory
3
4factory = RouteImageFactory(finder.routes[0])
5factory.create_image().save("route.png")

7.4 合成可行性報告

建議產出格式:

AnalogSMILESSolved?StepsBuilding Blocks全部可購買?Score
A-001CCO…3BB1, BB2, BB30.92
A-002CCC…5BB1, BB4, BB5⚠️ BB5 不可購買0.71
A-003CC=…----

8. 工具間的搭配策略

策略 A:aizynthfinder 獨立使用(推薦起步)

最簡單,適合快速評估。

策略 B:aizynthfinder + SynPlanner 交叉驗證

兩個獨立工具跑同一組 analog,比較路線,提高信心度。

策略 C:syntheseus + RetroChimera(最佳 single-step)

用 RetroChimera 的高精度 single-step prediction 搭配 syntheseus 的 multi-step search。

策略 D:DeepRetro 探索 + aizynthfinder 驗證

先用 DeepRetro 的 LLM 探索創新路線(可能突破 template 限制),再用 aizynthfinder 驗證可行性。

9. 重點摘要 Checklist

  • 首選 aizynthfinder — 最成熟、安裝最簡、buyable stock 完整
  • 設定 max_transforms: 3-4 — 控制合成步驟數
  • 載入 ZINC stockdownload_public_data . 一鍵下載
  • 自訂 building block 庫smiles2stock 建立 .hdf5
  • 批量 triagereturn_first: true 快速篩選
  • 深度分析iteration_limit: 500 + all_routes: true
  • 交叉驗證 — 考慮 SynPlanner 或 ASKCOS 做第二意見
  • LLM 探索 — DeepRetro 用於突破 template 限制的新路線
  • 合成可行性報告 — 每個 analog 記錄 solved / steps / buyability / score
  • 6 份獨立教學 — 各工具有完整 11 章節教學可深入閱讀