Home

Awesome

Macformer

This repo implements macrocyclization of linear molecules to generate macrocycles with chemical diversity and structural novelty.

Setup

Install Macformer from the .yaml file

conda env create -f Macformer_env.yaml  
conda activate Macformer  

Quick Start

1. Data processing

The acyclic-macrocyclic SMILES pairs extracted from ChEMBL and ZINC database, respectively, can be found in the data/ folder. Or researcher can process their own macrocyclic compounds from scratch using scripts in the utils/ folder.

fragmentation.py:  generate unique acyclic-macrocyclic SMILES pairs  
data_split.py:  split the acyclic-macrocyclic SMILES pairs into train, validation, and test datasets 
data_augmentation.py:  implement substructure-aligned data augmentation  

2. Input files generation

The preprocessing.sh script will generate following input files necessary to train the model.

*.train.pt: serialized PyTorch file containing training data  
*.valid.pt: serialized PyTorch file containing validation data  
*.vocab.pt: serialized PyTorch file containing vocabulary data  

3. Model training

Run the training.sh script to start model training.
The saved checkpoints can be averaged by running the average_models.sh script.

4. Model evaluation

Run the testing_beam_search.sh script to obtain predicted molecules.
The utils/model_evaluation.py script can be used to calculate the evaluation metrics, including recovery, validity, uniqueness, novelty, and macrocyclization.

To compare our model with previously reported non-deep learning approaches, we proposed a pipeline to construct macrocycles from three-dimensional (3D) structures of linear compounds through linker database searching (termed as MacLS). The detailed script can be found in the MacLS.py of the Utils fold. For internal ChEMBL and external ZINC test datasets, the conformations of the linear chemical structures were obtained in two ways, one was generated de novo from the SMILES strings (termed as MacLS_self) and the other was extracted from the 3D structures of corresponding target macrocycles (termed as MacLS_extra).

5. Pre-trained models and results reproduction

The models pretrained with ChEMBL dataset can be found in the models/ folder.
The metrics can be reproduced by the pre-trained models using internal ChEMBL test dataset (data/ChEMBL/a10/src-testa10) and external ZINC test dataset (data/ZINC/src-external-zinc-a10).

Tabel 1. Comparison of Macformer with different augmentation numbers and MacLS on ChEMBL test dataset.

MethodTraining data augmentationRecovery(%)Validity(%)Uniqueness(%)Novelty(mol,%)Novelty(linker,%)Macrocyclization(%)
MacformerNone54.85±14.2866.74±2.2963.18±6.3889.30±1.9440.56±2.3395.00±0.74
Macformer×296.09±0.6180.34±1.3864.43±0.2391.58±0.1558.91±0.3698.62±0.17
Macformer×597.54±0.1681.94±1.4265.36±0.1391.79±0.1662.11±0.6598.80±0.11
Macformer×1097.02±0.0582.59±1.5764.44±0.4691.76±0.2260.27±0.9698.46±0.04
MacLS_self/0.01±0.0117.05±0.2995.33±0.01100±0.000.00±0.00100±0.00
MacLS_extra/4.16±0.2089.65±0.0396.32±0.0699.65±0.020.00±0.00100±0.00

Tabel 2. Comparison of Macformer with different augmentation numbers and MacLS on ZINC test dataset.

MethodTraining data augmentationRecovery(%)Validity(%)Uniqueness(%)Novelty(mol,%)Novelty(linker,%)Macrocyclization(%)
MacformerNone2.70±1.3172.91±2.0547.74±8.9896.10±0.8144.24±2.0596.39±0.71
Macformer×276.37±3.2381.97±1.2044.99±5.3799.31±0.1953.03±0.6599.48±0.08
Macformer×581.86±0.75684.73±1.0145.14±4.6099.39±0.0953.98±1.0099.53±0.05
Macformer×1084.25±0.84585.35±1.3345.26±0.4699.43±0.0950.00±0.9599.27±0.07
MacLS_self/0.00±0.0013.02±0.7983.68±0.74100±0.000.00±0.00100±0.00
MacLS_extra/4.52±0.2089.67±0.0795.04±0.1499.99±0.000.00±0.00100±0.00