Claude
Skills
Sign in
Back

bio-retrosynthesis

Included with Lifetime
$97 forever

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.

Design

What this skill does


## 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

| Tool | Approach | Strength | Fails when |
|------|----------|----------|------------|
| AiZynthFinder 4.0 | Template-based MCTS | Open, scalable, well-validated | Beyond template coverage |
| Chemformer | Template-free transformer | Novel disconnections | Less interpretable; harder to debug |
| ASKCOS | Template-based + neural | MIT-quality academic standard | Setup complexity |
| Molecular Transformer | Forward + retro transformer | Single SMILES-to-SMILES | Less robust to non-training distribution |
| RetroSynFormer | Decision transformer | Modern method | Limited adoption |
| IBM RXN | Cloud service | High quality, easy interface | API access required |
| BKMS_MTHRO / RetroPath | Pathway-based | Metabolic / biochemical | Not for general medchem |
| SyntheMol (StanfordGarbage) | Specialized for medchem | Public domain alternative | Limited 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

| Scenario | Tool | Notes |
|----------|------|-------|
| Standard medchem target | AiZynthFinder default templates | USPTO/Reaxys templates |
| Novel chemotype | AiZynthFinder + Chemformer template-free fallback | Combine both |
| Generated molecules (REINVENT output) | AiZynthFinder batch | Filter to feasible routes |
| Multi-step synthesis planning | AiZynthFinder + manual review | Top-K routes |
| Validate generated route | Molecular Transformer forward | Check round-trip |
| Cost-aware synthesis | AiZynthFinder + custom building-block pricing | Score weight |
| Disconnection-aware design (DAD) | AiZynthFinder MO-MCTS | Multi-objective |
| Patent-aware routes | Custom template exclusion | Specialized |

## 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()`.

```python
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

```python
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):

```python
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

| Stock | Compounds | Source | Cost-tier |
|-------|-----------|--------|-----------|
| ZINC clean leads | 250k | ZINC22 catalog | Various commercial |
| Enamine Building Blocks | 200k+ | Enamine | $$ |
| Enamine REAL | 29B (make-on-demand) | Enamine | $$$ |
| Mcule | 25M | Mcule | $$ |
| eMolecules | 16M | eMolecules | $$ |
| ChemBridge | 1M | ChemBridge | $$ |

AiZynthFinder accepts stocks as HDF5 (built via `aizynthtrain`):
```bash
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:

```python
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:

```python
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.

```bash
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-sto
Files: 3
Size: 18.6 KB
Complexity: 34/100
Category: Design

Related in Design