The development of new drugs (molecules) can be extremely time-consuming and costly. The use of deep learning models can alleviate the search for good candidate drugs, by predicting properties of known molecules (e.g., solubility, toxicity, affinity to target protein, etc.).
As the number of possible molecules is astronomical, the space in which we search for/explore molecules is just a fraction of the entire space. Therefore, it's arguably desirable to implement generative models that can learn to generate novel molecules (which would otherwise have never been explored).
SMILES expresses the structure of a given molecule in the form of an ASCII string. The SMILES string is a compact encoding which, for smaller molecules, is relatively human-readable. Encoding molecules as a string both alleviates and facilitates database and/or web searching of a given molecule. RDKit uses algorithms to accurately transform a given SMILES to a molecule object, which can then be used to compute a great number of molecular properties/features.
Generative modelling has the potential of uncovering novel therapeutics that modulate targets and thereby affect the downwstream metabolism.
Aqueous solubility is a key factor in drug discovery, since if a molecule is not soluble. it will typically be poorly bioavailable, making it difficult to perform in-vivo studies with it, and hence deliver to patients.
The dataset used in this tutorial is a quantum mechanics dataset (QM9), obtained from MoleculeNet. Although many feature and label columns come with the dataset, we'll only focus on the SMILES column.
QM9 dataset is a good first dataset to work with for generating graphs, as the maximum number of heavy (non-hydrogen) atoms found in a molecule is only nine.
- ESOL
- AqSolDB
- [DSL-100] (https://risweb.st-andrews.ac.uk/portal/en/datasets/dls100-solubility-dataset(3a3a5abc-8458-4924-8e6c-b804347605e8).html)
Representing a molecular graph. Molecules can naturally be expressed as undirected graphs G = (V, E), where V is a set of vertices (atoms), and a set of edges (bonds). As for this implementation, each graph (molecule) will be represented as an adjacency tensor A, which encodes existence/non-existence of atom-pairs with their one-hot encoded bond types stretching an extra dimension, and a feature tensor H, which for each atom, one-hot encodes its atom type. Notice, as hydrogen atoms can be inferred by RDKit, hydrogen atoms are excluded from A and H for easier modeling.
We use easy to calculate RDKit descriptors, as described by Yalkowsky et al. . These descriptors are:
- Octanol-Water partition coefficient
- Molecular Weight
- Num. of Rotatable Bonds
- Aromatic Proportion = Num. Aromatic Atoms / Num Heavy Atoms
- Create your virtual environment
- Install libraries in the
requirements.txt
- Getting models
unzip models.zip
- Train Models:
- WGAN-GP: python main.py --wgan --name
name of database
- gVAE: python main.py --gvae --name
name of database
- WGAN-GP: python main.py --wgan --name
- Sample latent space:
- WGAN-GP: python main.py --sample_wgan --name
name of model
- gVAE: python main.py --sample_gvae --name
name of model
- WGAN-GP: python main.py --sample_wgan --name
- Visualize GVAE latent space
- python main.py --latent --name
name of model
- python main.py --latent --name
- Predict solubility
- python main.py --solubility --name
name of model
--smilessmiles string
- python main.py --solubility --name
- docker build . -t
docker-name-app
--no-cache - docker run -it -p 8501:8501
docker-app-name
- docker pull
adjon081/small-molecules:latest
- docker run -it -p 8501:8501
small-molecules-streamlit
streamlit run app.py
- WGAN-GP with R-GCN for the generation of small molecules graphs
- Relational Graph Convolutional Neural Network Variational AutoEncoder
- Mol-CycleGAN (Currently implementing)
- Random Forest solubility predictor
-
MolGAN: An implicit generative model for small molecular graphs
-
GraphVAE: Towards Generation of Small Graphs Using Variational AutoEncoders
-
Junction Tree Variational AutoEncoders for Molecular Graph Generation
-
ESOL: Estimating Aqueous Solubility Directly from Molecular Structure
- Implement Generative models (VAE and GAN) for small molecule design
- Add support for the latest diffusion models
- Sample generative models latent space
- Provide an API to use models
- Add a solubility and toxicity prediction models
What we've learned, and prospects. In this tutorial, a generative model for molecular graphs was succesfully implemented, which allowed us to generate novel molecules.
In the future, it would be interesting to implement generative models that can modify existing molecules (for instance, to optimize solubility or protein-binding of an existing molecule). For that however, a reconstruction loss would likely be needed, which is tricky to implement as there's no easy and obvious way to compute similarity between two molecular graphs.