This project consists in using graph neural networks to produce generative models that generate realistic molecules with interesting properties. To this end, we rely on ZINC-250k, a publicly available dataset containing molecules. We train GNN models on ZINC-250k to extract latent representations for molecules, and use these latent representations to optimize properties of interest in the generated molecules.
This code was tested in Python 3.8.5, with PyTorch 1.8.1, DGL (Deep Graph Library) 0.6.1, and RDKit 2019.09.3.
-
prepare_data.py: this script splits the dataset in the folderdata/into training and validation datasets. In addition, it transforms the molecules represented as SMILES into graphs. -
model.py: this file contains the definition of the model, which is a Variational Graph Autoencoder (VGAE). -
train.ipynb: the training notebook. Use this to train the model defined inmodel.pyon the data generated byprepare_data.py. -
generate_molecules.py: this scripts uses the trained model to generate molecules. -
evaluate.py: this scripts evaluates the molecules generated bygenerate_molecules.py. Various evaluation metrics are computed. -
draw_molecules.py: this one is for vizualizing molecules. After executing this script, images of a sample of training and generated molecules can be found in the data folder. -
utils.py: this file contains various functions used throughout the repository.
First, run prepare_data.py to generate the training and validation data. Then, use the notebook train.ipynb to train the model. After that, run generate_molecules.py to generate molecules. Finally, run evaluate.py to compute evaluation metrics, or draw_molecules.py to visualize molecules.
