Enzyformer: a Two-Stage Pretrained Model for Enzymatic Retrosynthesis.

We have set up a simple Google Colab notebook to help users quickly get started with Enzyformer.
👉 Open Enzyformer Colab Notebook
This Colab notebook provides a ready-to-run environment where you can:
- Use or experiment with the Enzyformer model
- Quickly test functionalities without needing to set up a local machine
- Ideal for quick prototyping, demos, or educational purposes
- Chemformer component: Apache License 2.0 (see
Chemformer/LICENSE) - Other components: see
LICENSE
mamba create -n enzymeformer_retro python=3.7
mamba activate enzymeformer_retro
pip install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
pip install rdkit-pypi==2022.9.4
pip install hydra-core --upgrade
pip install pandas
pip install pytorch-lightning==1.2.3
pip install git+https://github.com/MolecularAI/pysmilesutils.gitCreate a dedicated environment and install required packages:
# Create a Python 3.10 environment
mamba create -n enzymeformer_ec python=3.10
mamba activate enzymeformer_ec
# Install PyTorch and corresponding CUDA (adjust based on your GPU)
pip install torch==2.7.0 torchvision==0.22.0 torchaudio==2.7.0 \
--index-url https://download.pytorch.org/whl/cu128
# Install DGL (Deep Graph Library)
pip install dgl -f https://data.dgl.ai/wheels/torch-2.4/cu124/repo.html --no-deps
# Install rxnfp for reaction fingerprints
pip install rxnfp==0.1.0 --no-deps
# Install Hugging Face Transformers
pip install transformers
# Install Simple Transformers
pip install simpletransformers
pip install rdkit-pypi==2022.9.4
pip install drfp --no-deps
pip install "numpy<2" --force-reinstallOur original dataset is available at zenodo .
-
Download dataset Google Drive Dataset
Place all files in./Retrosynthesis/data. -
Download pretrained checkpoints
Google Drive Checkpoints
Place all files in./Retrosynthesis/ckpt.
Run the following commands for training the model if needed and direct inference on Enzyformer:
cd ./Chemformer
# Train the model (if needed)
bash ../Retrosynthesis/finetune-backward.sh
# Or directly run inference on Enzyformer
bash ../Retrosynthesis/finetune-direct.sh
# Score predictions
python score_predictions.py \
-mode 2 \
-beam_size 10 \
-n_best 10 \
-augmentation 1 \
-targets ./retrosyntheis/data/test.targets.txt \
-process_number 8 \
-score_alpha 1 \
-save_file ./retrosyntheis/otuputs/final_results_mode_5_wo.txt \
-detailed \
-source ./retrosyntheis/data/test.sources.txt-
Download dataset
Google Drive Dataset
Place all files in./Ec_assignment/data/distance_map.Google Drive Dataset
Place all files in./Ec_assignment/data. -
Download pretrained checkpoints
Google Drive Checkpoints
Place all files in./Ec_assignment/data/model.
cd Ec_assignment
python preprocess.py --rank first --fingerprint rxnfp
python train-triplet.py --training_data rxn_first --model_name rxn_first_triplet --epoch 2000000 --fingerprint rxnfp
python inference_rxn.py --rank first --infer_mode max --train_mode triplet --fingerprint rxnfppython preprocess.py --rank second --fingerprint rxnfp
python train-triplet.py --training_data rxn_second --model_name rxn_second_triplet --epoch 2000000 --fingerprint rxnfp
python inference_rxn.py --rank second --infer_mode max --train_mode triplet --fingerprint rxnfppython preprocess.py --rank third --fingerprint rxnfp
python train-triplet.py --training_data rxn_third --model_name rxn_third_triplet --epoch 2000000 --fingerprint rxnfp
python inference_rxn.py --rank third --infer_mode max --train_mode triplet --fingerprint rxnfppython inference_with_case.py -rxn "O=C1NC(CN1C2=CC=C(O)C=C2)=O>>NC(NC(C1=CC=C(O)C=C1)C(O)=O)=O" "CCO>>CC=O"