MQS Search API - Part 3: Machine Learning with Quantum Chemistry Data
Introduction
Over the last decades researchers have developed quantum chemistry models ranging from ab-initio methods such as density functional theory (DFT) to semi-empirical methods such as PMx and GNFx-xTB. These methods can be used to calculate quantum properties of molecules. By using these methods to perform high-throughput screening over hundred thousands to millions of molecules, the results of these calculations have been collected into various datasets in recent years, for example the PubChemQC PM6 [1] which mined data from PubChem or QMugs based on the ChEMBL database [2]. This blog article presents how these quantum chemistry datasets can be leveraged in combination with machine learning (ML) methods to retrieve valuable insights.
Aryl hydrocarbon receptor (AhR, dioxin receptor)
The Aryl Hydrocarbon Receptor (AhR), commonly referred to as the dioxin receptor, is a vital protein encoded by the AHR gene in humans. It functions as a transcription factor, playing a crucial role in regulating gene expression. AhR belongs to the PAS (Per-Arnt-Sim) superfamily of receptors, which are responsible for responding to various environmental stresses like hypoxia and circadian rhythm. Moreover, they also exert control over fundamental physiological processes such as vascular development, learning, and neurogenesis, highlighting the receptor’s multifaceted functions [3].
AhR exhibits a remarkable capacity to integrate diverse signals from the environment, diet, microbiota, and metabolism to orchestrate complex transcriptional programs [4]. This integration occurs in a manner that is specific to the ligand, cell type, and overall context. Consequently, AhR’s regulatory activities are highly versatile and tailored to specific biological contexts. However, studying the effects of AhR agonists and other chemicals has traditionally relied on assays involving biomaterials, a process that can be time-consuming with in-vitro experiments.
To better understand the intricate workings of AhR and assess the toxicity of AhR agonists and other chemicals, researchers are actively exploring alternative methods that reduce the need of animal experiments and decrease research duration on biomaterial-based assays [5,6,7,8]. These advances have the potential to accelerate toxicological research, facilitating the development of safer and more environmentally friendly chemical compounds.
Polychlorinated biphenyls (PCBs)
Figure 1: 3D model of a polychlorinated biphenyl.
Polychlorinated biphenyls (PCBs; Figure 1) encompass a collection of synthetic organic chemicals that were once extensively utilized in both industrial and consumer products. However, their ban in the 1970s stemmed from their harmful effects on health and their ability to persist in the environment. The AhR, a protein found in various cell types throughout the body, plays a pivotal role in the metabolism of numerous drugs and environmental toxins, including PCBs. Activation of the AhR by PCBs initiates alterations in gene expression, which can elicit a broad range of physiological effects.
The toxicity of PCBs is contingent upon the arrangement of chlorine atoms substituted on the phenyl rings [5]. Within this group, there exists a subset of 12 PCBs called non-ortho- or mono-ortho-chlorinated PCBs, which exhibit AhR-related activities akin to those observed in dioxins.
Toxicity in similar molecules can be inferred by examining the energy gap between the highest occupied molecular orbital (HOMO) and the lowest unoccupied orbital (LUMO) [9]. A larger energy gap implies greater stability of the molecule concerning reactions with biomolecules.
The relative stability of highly chlorinated PCBs, coupled with their increased lipophilicity, leads to their widespread distribution across diverse environments, followed by prolonged accumulation within wildlife and human populations. Despite previous extensive studies, accurately determining the toxicity of PCBs remains a challenge. Consequently, PCBs serve as ideal candidates for testing models aimed at assessing the toxic and bioaccumulative behaviours of AhR agonists.
HOMO-LUMO gap as a toxicity indicator
Molecular orbitals, such as HOMO and LUMO, represent wave functions that describe the distribution of electrons within a molecule. Composed of atomic components derived from constituent atoms, the HOMO and LUMO exhibit distinct energy levels. The energy difference between these two orbitals is referred to as the HOMO-LUMO gap. The HOMO-LUMO gap is expressed in electronvolts (eV), a unit of energy commonly used to quantify small energy amounts. The magnitude of the energy gap can vary among different molecules. A small gap, below a certain threshold, is considered a necessary condition for molecules to possess significant potency.
The assessment of the HOMO-LUMO energy gap allows to determine the toxicity of PCBs. Below the threshold of 4.87 eV are the 12 dioxin-like PCBs, while above the threshold are non-dioxins. In the context of PCBs, the potency of AhR-mediated effects serves as a distinguishing factor between dioxin-like and non-dioxin-like molecules. However, it is important to note that the assessment of toxicity within the dioxin-like subgroup requires consideration of additional factors. While the HOMO-LUMO energy gap provides an overarching indicator of PCBs’ toxicity, it does not provide the sole determinant [5].
Torsional angle
The torsional angle (Figure 2) refers to the spatial configuration of atoms in a molecule, specifically the angle formed by the rotation of one group of atoms around a bond axis with respect to another group. The torsional angle, which is crucial in determining the overall shape and stability of a molecule, varies among different molecules depending on their structural arrangement, and play a significant role in understanding and predicting the behaviour of a molecule, as the magnitude of these angles directly affects molecular properties such as conformational stability, reactivity, and intermolecular interactions. Torsional angles arise due to the presence of rotatable bonds and can be quantified using the degree of rotation.
The torsional angle in a PCB molecule can impact their interaction with the aryl hydrocarbon receptor (AhR). The conformational change caused by the torsional angle can modulate the binding affinity and activation of AhR by PCBs, ultimately influencing their toxicological effects [5].
Figure 2: Torsional angle of a PCB molecule
PubchemQC PM6
The PubChemQC PM6 dataset is a collection of electronic properties of 221 million molecules with optimized molecular geometries [1]. The electronic properties were calculated using the PM6 method. The dataset covers 94.0% of the original PubChem dataset with respect to neutral molecules, making it a valuable resource for researchers in the field. How to access the dataset via the MQS Search UI and API can be read up on in the first Search API tutorial: MQS Search API Part 1 Tutorial.
QMugs dataset
The QMugs (Quantum-Mechanical Properties of Drug-like Molecules) dataset contains optimized molecular geometries calculated via density functional theory (DFT), thermodynamic data calculated with the semi-empirical method GFN2-xTB, atomic and molecular properties calculated with both DFT (ω B97X-D/def2-SVP) and GFN2-xTB.
The collection of QMugs consists of over 665,000 molecules that are biologically and pharmacologically significant. These molecules have been obtained from the ChEMBL database [8].
The dataset presented has multiple potential applications as highlighted in the QMugs research paper [8]:
- It can offer researchers a larger dataset that can be utilized to predict quantum chemical properties or establish correlations between the GFN2-xTB and ωB97X-D/def2-SVP levels of theory.
- It can aid in the advancement of machine learning techniques for generating molecular conformations and predicting molecular properties.
- It can support the development of deep learning frameworks that can predict quantum mechanical wave functions in atomic orbitals.
- It can facilitate research on quantum featurization in the context of pharmacologically relevant biological data.
The QMugs dataset features DFT-level properties and is found to have larger molecular samples and a larger number of distinct molecules than the QM9 (http://quantum-machine.org/datasets/) and ANI-1 (https://github.com/isayev/ANI1_dataset) datasets. It provides multiple conformers per molecule, enabling the training of QML models that can differentiate between molecular constitution and conformation. QMugs also provides a wide range of properties on multiple levels of theory and includes mostly compounds not previously reported in other DFT data collections.
Important to acknowledge is that the QMugs dataset holds a very limited number of PCBs compared to the PubchemQC PM6 dataset and has therefore implications for the machine learning model which is going to be presented in the next section. The Search API tutorial part 2 also holds some more information about the QMugs dataset: https://blog.mqs.dk/posts/getting_started_search_api_part2/
DelFTa toolbox
The DelFTa toolbox [9] is an open-source model that has been trained with the QMugs dataset to predict quantum-mechanical properties of drug-like molecules. The toolbox uses PyTorch modules and libraries, the Open Babel library, Numpy and JSON to define and run various models and tasks. The application provides a command-line interface in order to predict molecular properties from a SMILES string or a molecule file. The output results are provided either as JSON or CSV files.
DelFTa can predict a wide array of quantum observables on the molecular, atomic, and bond levels. Some of the properties that DelFTa can predict are:
- Formation energies: The energy required to form a molecule from its constituent atoms.
- Energies of HOMO and LUMO: Energies of the highest occupied and lowest unoccupied molecular orbital. These are important for understanding the electronic structure of molecules.
- HOMO/LUMO gaps: The energy difference between the HOMO and LUMO orbitals.
- Dipole moments: A measure of the separation of positive and negative charges in a molecule.
- Mulliken partial charges: A way to partition the electron density in a molecule among its constituent atoms.
- Wiberg bond orders: A measure of the strength of covalent and non-covalent chemical bonds.
The DelFTa toolbox applies an equivariant graph neural network with a message-passing layer.
Graph Neural Networks (GNNs) are neural networks specifically designed to operate on graph-structured data. Equivariant Graph Neural Networks (EGNNs) are an extension of GNNs that aim to capture and preserve symmetries present in the input graph data applying equivariant operations. In the context of graphs, symmetry refers to the invariance of the graph structure and its features under transformations such as rotations, translations, or permutations of the nodes. This can lead to several advantages, including better generalization to unseen data, improved robustness to noise and perturbations, and more efficient learning by leveraging the inherent structure and patterns of the data.
A message-passing layer facilitates information exchange and aggregation between connected nodes, enabling nodes to update their representations based on messages received from neighboring nodes. This enabling effective modeling of relational structures and improving the network’s ability to learn from graph-structured data.
The current version of the DelFTa toolbox only supports Python 3.8.X and 3.9.X versions of Linux builds.
The following points summarize the recommended installation steps for a conda environment:
-
The DelFTa toolbox can be cloned from its offical GitHub repository.
-
Create the Python environment with required installations using the
environment.yml
file. This can be done usingconda env create -f environment.yml
in the downloaded repository directory. After submitting this command, a conda environment nameddelfta
will be created. The environment can be activated by using theconda activate delfta
command. -
The DelFTa toolbox can also be installed on a prepared environment by running the
python setup.py install --user
command in the DelFTa repo directory. -
To get required files that include trained DelFTa model* and XTB utils, run: `python -c “from delfta.download import _download_required; _download_required()".
*To download additional models which were trained on different training set sizes, follow this download link provided by ETH Zurich.
In the following we are now going to compare the HOMO-LUMO gap data obtained from PubchemQC PM6, QMugs and via the DelFTa toolbox.
Get HOMO-LUMO gap data by using the MQS Search API
We are going to use the MQS Search API to get HOMO-LUMO gap data of PCBs stored in the PubchemQC PM6 dataset.
As explained in detail in the MQS Search API Part 1 Tutorial, we will start with getting our token to be able to reach the database via the Search API. The token can be obtained with your MQS Dashboard email and password as described in the Part 1 Tutorial.
On the molecule search page (Figure 3) we provide a documentation of the Search API.
Figure 3: “Search for chemicals (via API) tab on the molecule search page in the MQS Dashboard”
Now you can prepare a search query to search for the PCBs:
|
|
|
|
To select the HOMO-LUMO gap, we choose S0
as the molecule state and the alpha
register as the energy property. The 3d coordinates information is also being stored in a new array for later use:
|
|
We have now accessed specific data from QMugs and this is an example what the data for one PCB holds:
- PCB Name:
2,3,3’,5-Tetrachlorobiphenyl
- SMILES Code:
C1=CC(=CC(=C1)Cl)C2=CC(=CC(=C2Cl)Cl)Cl
- HOMO−LUMO Gap Value:
6.574814855781
- 3D Atom Coordinates:
Array(shape:(Number_of_Atoms, 3))
Predicting the HOMO-LUMO gap by using DelFTa
Now we are going to predict the HOMO-LUMO gap value of a PCB by applying the DelFTa toolbox with the SMILES strings and the 3D atom coordinates data that we have collected.
Create an Open Babel Molecule Object from the SMILES string of the PCB and add hydrogen atoms:
|
|
Pass 3D coordinates of atoms to the molecule object:
|
|
Predict the HOMO-LUMO gap via DelFTa:
|
|
The DelFTa prediction function will return a Python dictionary of the predicted values:
|
|
Convert the predicted HOMO-LUMO gap value from Hartree to Electronvolt (eV) unit (DelFTa returns HOMO-LUMO gap value as Hartree in a dictionary so we need to multiply by Hartree-eV constants):
|
|
Calculation of the torsional angle
To calculate the torsional angle of a PCB, we need to apply the following steps:
Create a molecule object from the SMILES string with RDKit:
|
|
Create a conformer object and pass atom coordinates to the object:
|
|
To find the torsional angle between two benzene rings of a PCB, we need to first locate the benzene rings in the molecule and determine the bond that connects the two rings. Then we need to identify the bond atoms consisting of two atoms and a neighbor atom on a ring for each bond atom. Finally, we have now defined the bond atoms between the rings and the benzene ring atoms as the two planes to calculate the torsional angle.
|
|
As an example atom1
, atom2
, atom3
, atom4
variables will be equal to atom indices 2, 1, 9, 10 on Figure: Benzene bridge of hexachlorobiphenyl.
|
|
As an example, angle
variable will be equal to 59.2896 degrees for the PCB molecule of Hexachlorobiphenyl.
Figure 4: Benzene bridge of Hexachlorobiphenyl
Counting PCB Ortho Configurations
Locating the number of ortho configurations of a PCB we need to match ortho substructures:
|
|
As an example, the num_orthos
variable (number of orthos) will be equal to 8 for the PCB molecule of Hexachlorobiphenyl.
In next section, we will call molecules without any ortho group non-ortho structures , molecules that only have one ortho group will be defined as mono-ortho PCBs, and molecules that have two or more ortho group will belong to the class of multi-ortho PCBs.
Comparison and Results
The comparison of HOMO-LUMO gap values from the PubchemQC PM6 dataset and DelFTa predictions, we prepared a figure with 100 different PCBs (Figure 5) and their respective HOMO-LUMO gap values.
Figure 5: Comparison of HOMO-LUMO gap calculations.
On this figure the x-axis represents different PCB molecules, y-axis represents HOMO-LUMO gap values as electronvolt (eV). Red dots represents DelFTa prediction and green dots represents PubchemQC PM6 dataset values of HOMO-LUMO gap of PCB projected on x-axis. Dark black lines between red and green dots represent the difference of HOMO-LUMO gap values of PubchemQC PM6 dataset and DelFTa predictions.
We did also plot HOMO-LUMO gap values of the PubchemQC PM6 dataset and DelFTa predictions for a HOMO-LUMO gap versus torsional angle representation (Figure 6 and 7) which allow to visualize the toxicity threshold together with torsional angle and the HOMO-LUMO gap values. In this way one can identify if a molecule lies below the toxicity threshold or above.
Figure 6: HOMO-LUMO gap - Torsional angle representation of PubchemQC PM6 PCBs with their ortho numbers.
Figure 7: HOMO-LUMO Gap - Torsional angle representation of DelFTa predicted PCBs with their ortho numbers.
On these figures the radius of a quarter circle represents the HOMO-LUMO gap values and the angle of a point to the (0,0) coordinate represents the torsional angle. Blue circles represent multi-ortho, yellow triangles represents mono-ortho, and red squares represent non-ortho PCBs. The small quarter circle represents the Dioxin threshold which is equal to 4.87 eV.
Figure 8: HOMO-LUMO gap outlier molecules with PCB indices.
Figure 8 depicts all outlier molecules and together with Table 1 we can differentiate between the outliers and see that most of the outliers are multi-ortho PCBs (9 out of 14), followed by non-ortho (3 out of 14) and mono-ortho (2 out of 14) PCBs. The outliers have been ordered by declining HOMO-LUMO gap difference values.
The highest HOMO-LUMO gap difference (3.1681) is observed for the multi-ortho PCB (PCB Index = 62) with a torsional angle of -90.12 degrees. This is the only PCB in the outlier set with a torsional angle around ±90 degrees. Most outlier PCBs exhibit torsional angles of around ±120 degrees (8 out of 14), followed by torsional angles of ±60 degrees (5 out of 14).
This analysis is valuable for re-training or fine-tuning purposes of the DelFTa model where more PCB structures with multi-ortho configuration and with a torsional angle of ±120 degrees could be added to the training set.
Table 1: HOMO-LUMO gap difference analysis between Delfta and PubchemQC PM6
PCB Index | HOMO-LUMO gap difference | Torsional angle | Ortho-configurations |
---|---|---|---|
62 | 3.1681 | -90.12 | multi-ortho |
79 | 2.9972 | -120.35 | multi-ortho |
30 | 2.9387 | 58.78 | non-ortho |
31 | 2.9309 | -121.09 | non-ortho |
44 | 2.8868 | 59.52 | mono-ortho |
94 | 2.4335 | 59.80 | multi-ortho |
51 | 2.4069 | -120.34 | multi-ortho |
15 | 2.2279 | 120.77 | multi-ortho |
80 | 2.1173 | -120.86 | non-ortho |
45 | 1.6816 | 59.04 | mono-ortho |
95 | 1.6462 | 59.65 | multi-ortho |
8 | 1.3525 | -120.77 | multi-ortho |
56 | 1.2610 | -120.20 | multi-ortho |
49 | 1.0624 | -120.25 | multi-ortho |
We hope we showed you that the datasets we have integrated into our database can be of value for interesting machine learning studies with molecular quantum information. You are always welcome to reach out if you have any feedback, questions, ideas or even collaboration projects to push this kind of work and research further (contact (at) mqs [dot] dk).
References
[1] M. Nakata, T. Shimazaki, M. Hashimoto, and T. Maeda; J. Chem. Inf. Model. 2020, 60, 12, 5891–5899; https://doi.org/10.1021/acs.jcim.0c00740
[2] C. Isert, K. Atz, J. Jiménez-Luna & G. Schneider; Sci Data 9, 273 (2022); https://doi.org/10.1038/s41597-022-01390-7
[3] J. Marlowe and A. Puga; Comprehensive Toxicology (Second Edition) Volume 2, 2010, Pages 93-115; https://doi.org/10.1016/B978-0-08-046884-6.00207-4
[4] V. Rothhammer and F. J. Quintana; Nature Reviews Immunology volume 19, pages 184–197 (2019); https://doi.org/10.1038/s41577-019-0125-8
[5] J. Forrest, P. Bazylewski, R. Bauer, S. Hong, C. Y. Kim, J. P. Giesy, J. S. Khim and G. S. Chang; Front. Mar. Sci., 06 August 2014; https://doi.org/10.3389/fmars.2014.00031
[6] S. Safe; Environmental Health Perspectives 100, 1993; https://doi.org/10.1289/ehp.93100259
[7] W., X. Liu, H. Liu, Y. Wu, J. P. Giesy, H. Yu; Environmental Toxicology and Chemistry, Volume 29, Issue 3, March 2010; https://doi.org/10.1002/etc.70
[8] W. Yang, Y. Mu, J. P. Giesy, A. Zhang, H. Yu; Chemosphere Volume 75, Issue 9, May 2009, Pages 1159-1164; https://doi.org/10.1016/j.chemosphere.2009.02.047
[9] M. M. Lynam, M. Kuty, J. Damborsky, J. Koca, P. Adriaens; Environmental Toxicology and Chemistry, Volume 17, Issue 6, June 1998, Pages 988-997; https://doi.org/10.1002/etc.5620170603