Skip to content

Tiantao2000/Enzyformer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Enzyformer

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

🧪 Enzyformer - Colab Development Notebook

We have set up a simple ​Google Colab notebook​ to help users quickly get started with ​Enzyformer.

🔗 Notebook Link

👉 Open Enzyformer Colab Notebook

✅ What is this for?

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

License

  • Chemformer component: Apache License 2.0 (see Chemformer/LICENSE)
  • Other components: see LICENSE

Environment Setup

1. Enzymatic Retrosynthesis

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.git

2. EC number prediction

Create 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-reinstall

Original dataset

Our original dataset is available at zenodo .

Retrosynthesis Prediction (For random split)

Data Preparation

  1. Download dataset Google Drive Dataset
    Place all files in ./Retrosynthesis/data.

  2. Download pretrained checkpoints
    Google Drive Checkpoints
    Place all files in ./Retrosynthesis/ckpt.


Training and Inference

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

EC number prediction

Data preparation

  1. Download dataset
    Google Drive Dataset
    Place all files in ./Ec_assignment/data/distance_map.

    Google Drive Dataset
    Place all files in ./Ec_assignment/data.

  2. Download pretrained checkpoints
    Google Drive Checkpoints
    Place all files in ./Ec_assignment/data/model.

first ec level

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 rxnfp

second ec level

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

third ec level

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

prediction with a list of reactions

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

About

Enzyformer: Enhancing Enzymatic Retrosynthesis via Pretrained Transformers

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors