Ch 1.a Handling Chemistry Data - aswalker-lab/AIChemBiochem GitHub Wiki
In this chapter we will discuss how to use RDkit to process chemical structure data.
SMILES are a string representation of molecules. If you are interested in the details of how to read SMILES, see: https://en.wikipedia.org/wiki/Simplified_Molecular_Input_Line_Entry_System One feature of SMILES is that there are multiple valid SMILES for many molecules (two different SMILES strings represent the same molecule). This is both an advantage and disadvantage depending on how SMILES are being used. There are have been alternatives to SMILES proposed, such as SELFIES (see: https://arxiv.org/abs/1905.13741 ). However, SMILES are still used more frequently. We will discuss SMILES vs SELFIES in more depth in future lessons on language models. RDkit stores molecules as Mol objects, which can be created from SMILES strings.
Molecular fingerprints are a vector of 0 and 1s that represent a molecule. There are many different types of fingerprints which work in different ways, but the basic idea for most methods is that each atom is given an identifier based on the atom itself and sometimes information about the atoms connected to that atom. These identifiers are then run through a hash function, which converts the atom information to a number. The corresponding position in the vector is then set to a 1. Then the atom identifier is updated based on the identifier of neighboring atoms and run through a hash function again, and the corresponding positions in the vector are again updated to a 1. This is repeated a set number of times, which is referred to as the radius, which essentially represents how "far away" in the structure each atom can see. Each entry in the vector then represents the presence (1) or absence (0) of certain substructures. Note that hash functions do not preserve similarity of the input, so two similar substructures will likely end up in very different positions in the vector. Hash functions are also designed to reduce collisions, which is where two inputs give the same hash function, but they do not eliminate them so it is possible that one position in the vector represents multiple substructures. For more a more detailed explanation see: https://towardsdatascience.com/a-practical-introduction-to-the-use-of-molecular-fingerprints-in-drug-discovery-7f15021be2b1/
Fingerprints can be used as a measure of how similar two molecules are. The most common way to do this is with Tanimoto similarity, which is the ratio of shared features between two fingerprints to the number of total features across the two fingerprints. Tanimoto similarity ranges from 0 to 1, with higher numbers representing more similar RDkit provides methods both for calculating various fingerprints and Tanimoto similarity.
Pandas is a module for managing data in python. Pandas can create dataframes which are tables of data. It can store different python objects, including strings for smiles and RDkit Mol objects.
You can find example code in the github repository or access through google colab:
Rdkit example code:
https://colab.research.google.com/github/aswalker-lab/AIChemBiochem/blob/main/1a_HandlingChemistryData/1a_1%20Intro%20to%20RdKit.ipynb
Pandas for chemistry data: https://colab.research.google.com/github/aswalker-lab/AIChemBiochem/blob/main/1a_HandlingChemistryData/1a_2%20Pandas%20and%20Chemistry%20Data.ipynb
If you choose to run this second notebook in Google Colab, you will need to upload the delaney.csv data, which is available from the main github page. To do that click on the folder icon on the left hand panel of the Colab interface and then click the upload button:
