Skip to content

ailab-bio/retrosynformer

 
 

Repository files navigation

retrosynformer

This repository contains the code for RetroSynformer [1].

The RetroSynFormer express the retrosynthesis task, iteratively breaking down a compound into building blocks, as a sequence-modeling problem and train a model based on the Decision Transformer. The synthesis routes are generated by iteratively predicting chemical reactions from a set of reaction templates that encode known transformations, and routes are scored during construction using a novel reward function. RetroSynFormer was trained on routes extracted from the PaRoutes dataset of patented experimental routes.

Installation

Start by cloning this repo. Then, create and activate the conda environment by executing the following commands at the root of the repository:

conda create -n retrosynformer-env python=3.11
conda activate myenv

Then install PyTorch with the appropriate CUDA version. For CUDA=11.7 run:

pip install torch==1.13 --index-url https://download.pytorch.org/whl/cu117

Finally, use pip to intall the requirements: pip install -r requirements.txt

User guide

  1. Download and preprocess the dataset (2 steps, see Data)
  2. Update the config file located in: /retrosynformer/results/config.yaml
  3. Train the data using: retrosynformer/train.py
  4. Use the trained model and retrosynformer/predict.py to predict retrosynthesis routes for the test targets.

Data

Downlowad the PaRoutes dataset [2] from https://zenodo.org/records/17177425 and place in a data folder.

Training

  • retrosynformer/train.py: Run to train the Decicion Transformer. See results/config.yaml for an example config file.

Inference

  • retrosynformer/predict.py: Run to predict routes for the testset and the N1 and N5 sets.

Evaluation

  • retrosynformer/utils/evaluation.py: Run to evaluate the results and calculate an average for multiple runs.

  • retrosynformer/utils/evalutaion_compare_aizy.py: Run to evaluate the results and compare predictions to routes generated by baseline (AiZynthFinder [3]).

Licence

The software is licensed under the Apache 2.0 license (see LICENSE file), and is free and provided as-is.

References

[1] Granqvist, et al. "RetroSynFormer: Planning multi-step chemical synthesis routes via a Decision Transformer" chemRxiv preprint DOI:https://doi.org/10.26434/chemrxiv-2025-kd6gb (2025).

[2] Genheden, S., and Bjerrum, E. "PaRoutes: towards a framework for benchmarking retrosynthesis route predictions." Digital Discovery 1.4 (2022).

[3] Genheden, Samuel, et al. "AiZynthFinder: a fast, robust and flexible open-source software for retrosynthetic planning." Journal of cheminformatics 12.1 (2020).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 65.5%
  • Jupyter Notebook 34.5%