GetMorganFingerprint() Method in RDKit

This section provides a quick introduction on the rdkit.Chem.rdMolDescriptors.GetMorganFingerprint() Method in the RDKit library.

GetMorganFingerprint(mol, radius) method is located in the rdkit.Chem.rdMolDescriptors module of the RDKit library. The same method is also packaged as rdkit.Chem.AllChem.GetMorganFingerprint() for easier access. It returns a collection of integer identifiers of atom node invariants updated with local structures at different radiuses.

Here is the definition of the method:

rdkit.Chem.rdMolDescriptors.GetMorganFingerprint((Mol)mol, 
  (int)radius[, 
  (AtomPairsParameters)invariants=[][, 
  (AtomPairsParameters)fromAtoms=[][, 
  (bool)useChirality=False[, 
  (bool)useBondTypes=True[, 
  (bool)useFeatures=False[, 
  (bool)useCounts=True[, 
  (AtomPairsParameters)bitInfo=None[, 
  (bool)includeRedundantEnvironments=False]]]]]]]]) 
-> UIntSparseIntVect

Descriptions of method arguments are:

By default, GetMorganFingerprint() uses the "useFeatures=False" option to provide an implementation of the ECFP (Extended Connectivity Fingerprint) method as described in the "ECFP (Extended Connectivity Fingerprint) Method - 2000" section in this book.

Note that GetMorganFingerprint() returns a collection of identifiers of all atom nodes generated at different radiuses as the fingerprint of a given molecule.

If you want the fingerprint to be returned as a bit string, you can call the GetMorganFingerprintAsBitVect() method, as described in the "GetMorganFingerprintAsBitVect() Method in RDKit" section in this chapter.

Now let's verify its ECFP implementation with some simple tests.

1. Molecule "C" has a single non-hydrogen atom. So a single identifier will be generated at radius=0.

from rdkit.Chem import AllChem
from rdkit.DataStructs.cDataStructs import UIntSparseIntVect
radius = 0
bitInfo = {}
mol = AllChem.MolFromSmiles('C')
fp = AllChem.GetMorganFingerprint(mol, radius, bitInfo=bitInfo)
display(UIntSparseIntVect.GetLength(fp))
display(UIntSparseIntVect.GetNonzeroElements(fp))
display(UIntSparseIntVect.GetTotalVal(fp))
print(bitInfo)

# output: 
4294967295
{2246733040: 1}
1
{2246733040: ((0, 0),)}

Notes on this test:

2. Molecule with a 2 identical atoms: "CC", expressed in SMILES.

radius = 0
bitInfo = {}
mol = AllChem.MolFromSmiles('CC')
fp = AllChem.GetMorganFingerprint(mol, radius, bitInfo=bitInfo)
display(UIntSparseIntVect.GetLength(fp))
display(UIntSparseIntVect.GetNonzeroElements(fp))
display(UIntSparseIntVect.GetTotalVal(fp))
print(bitInfo)

# output:
4294967295
{2246728737: 2}
2
{2246728737: ((0, 0), (1, 0))}

The output shows 2 identical identifiers: one for atom 0 with radius 0, and one for atom 1 with radius 0.

3. Molecule with a 2 different atoms: "CO".

radius = 0
bitInfo = {}
mol = AllChem.MolFromSmiles('CO')
fp = AllChem.GetMorganFingerprint(mol, radius, bitInfo=bitInfo)
display(UIntSparseIntVect.GetLength(fp))
display(UIntSparseIntVect.GetNonzeroElements(fp))
display(UIntSparseIntVect.GetTotalVal(fp))
print(bitInfo)

# output:
4294967295
{864662311: 1, 2246728737: 1}
2
{864662311: ((1, 0),), 2246728737: ((0, 0),)}

Now we have 2 different identifiers: the first one is for atom 1 with radius 0, and the second one is for atom 0 with radius 0.

As you can see, the atom C of "CO" molecule in this test and atom C of "CC" molecule in the previous test has the same identifier: 2246728737. It tells us that "2246728737" identifies atom C with a single bond connected in any molecule.

Table of Contents

 About This Book

 SMILES (Simplified Molecular-Input Line-Entry System)

 Open Babel: The Open Source Chemistry Toolbox

 Using Open Babel Command: "obabel"

 Generating SVG Pictures with Open Babel

 Substructure Search with Open Babel

 Similarity Search with Open Babel

 Fingerprint Index for Fastsearch with Open Babel

 Stereochemistry with Open Babel

 Command Line Tools Provided by Open Babel

 RDKit: Open-Source Cheminformatics Software

 rdkit.Chem.rdchem - The Core Module

 rdkit.Chem.rdmolfiles - Molecular File Module

 rdkit.Chem.rdDepictor - Compute 2D Coordinates

 rdkit.Chem.Draw - Handle Molecule Images

 Molecule Substructure Search with RDKit

 rdkit.Chem.rdmolops - Molecule Operations

 Daylight Fingerprint Generator in RDKit

Morgan Fingerprint Generator in RDKit

 What Is Morgan Fingerprint Generator in RDKit

GetMorganFingerprint() Method in RDKit

 Impact of 'radius' on GetMorganFingerprint()

 Impact of 'useCounts' on GetMorganFingerprint()

 Impact of 'invariants' on GetMorganFingerprint()

 Impact of 'useBondTypes' on GetMorganFingerprint()

 Impact of 'fromAtoms' on GetMorganFingerprint()

 GetMorganFingerprintAsBitVect() Method in RDKit

 Impact of 'nBits' on GetMorganFingerprintAsBitVect()

 GetHashedMorganFingerprint() Method in RDKit

 Impact of 'nBits' on GetHashedMorganFingerprint()

 GetMorganGenerator() Method in RDKit

 Morgan Fingerprint Generator in RDKit for FCFP

 RDKit Performance on Substructure Search

 Introduction to Molecular Fingerprints

 OCSR (Optical Chemical Structure Recognition)

 AlphaFold - Protein Structure Prediction

 Resources and Tools

 Cheminformatics Related Terminologies

 References

 Full Version in PDF/EPUB