GetRDKitFPGenerator() Method in RDKit

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

GetRDKitFPGenerator() method is located in the rdkit.Chem.rdFingerprintGenerator module of the RDKit library. It creates a Daylight fingerprint generator that uses the Daylight method to generate integer identifiers from subgraphs in the molecular.

Here is the definition of the method:

rdkit.Chem.rdFingerprintGenerator.GetRDKitFPGenerator([
  (int)minPath=1 [, 
  (int)maxPath=7 [, 
  (bool)useHs=True [, 
  (bool)branchedPaths=True [, 
  (bool)useBondOrder=True [, 
  (bool)countSimulation=False [, 
  (AtomPairsParameters)countBounds=None [, 
  (int)fpSize=2048 [, 
  (int)numBitsPerFeature=2 [, 
  (AtomPairsParameters)atomInvariantsGenerator=None]]]]]]]]]]) 
-> FingerprintGenerator

Descriptions of method arguments are:

Once a FingerprintGenerator object is created, you can call its instance methods to generate different types of Morgan fingerprints of a given molecule.

The above methods are actually providing same functionalities as Morgan fingerprint generation methods offered in the rdkit.Chem.rdMolDescriptors module as shown in the following tutorials.

1. GetRDKitFPGenerator().GetFingerprint() method is actually provides the same functionality as the rdkit.Chem.rdmolops.RDKFingerprint() method. For example:

from rdkit.Chem import AllChem
from rdkit.Chem import rdFingerprintGenerator
from rdkit.DataStructs import cDataStructs
mol = AllChem.MolFromSmiles('CCCC')
gen = rdFingerprintGenerator.GetRDKitFPGenerator(fpSize=64)
fp = gen.GetFingerprint(mol)
display(fp.ToBitString())

fp = AllChem.RDKFingerprint(mol, fpSize=64)
display(fp.ToBitString())

# output:
'0000010100000000000001000000100000000000000110000000000000000000'
'0000010100000000000001000000100000000000000110000000000000000000'

2. GetRDKitFPGenerator().GetSparseCountFingerprint() method is actually provides the same functionality as the rdkit.Chem.rdMolDescriptors.UnfoldedRDKFingerprintCountBased() method, except that GetRDKitFPGenerator() generates 2 identifiers per subgraph by default. But you can reduce it to 1 using the numBitsPerFeature=1 option. For example:

mol = AllChem.MolFromSmiles('CCCC')
gen = rdFingerprintGenerator.GetRDKitFPGenerator(numBitsPerFeature=1) 
fp = gen.GetSparseCountFingerprint(mol)
display(cDataStructs.ULongSparseIntVect.GetNonzeroElements(fp))

fp = AllChem.UnfoldedRDKFingerprintCountBased(mol)
display(cDataStructs.ULongSparseIntVect.GetNonzeroElements(fp))

# output: 
{1173125914: 2, 1244535424: 1, 2245384272: 2, 2246728737: 2, 3542456614: 2}
{1173125914: 2, 1244535424: 1, 2245384272: 2, 2246728737: 2, 3542456614: 2}

3. GetRDKitFPGenerator().GetCountFingerprint() method is actually provides the same functionality as the rdkit.Chem.rdMolDescriptors.RDKFingerprint() method, except that GetCountFingerprint() returns folded identifiers and their duplication counts. Those folded identifiers are ON (value of 1) bits locations in the bit string returned by RDKFingerprint(). For example:

mol = AllChem.MolFromSmiles('CCCC')
gen = rdFingerprintGenerator.GetRDKitFPGenerator(fpSize=64, 
  numBitsPerFeature=1) 
fp = gen.GetCountFingerprint(mol)
display(cDataStructs.UIntSparseIntVect.GetNonzeroElements(fp))

fp = AllChem.RDKFingerprint(mol, fpSize=64, nBitsPerHash=1)
display(fp.ToBitString())

# output: 
{21: 2, 28: 3, 43: 1}
'0000000000000000000001000000100000000000000100000000000000000000'
                      ^      ^              ^
                      21     28             43 

4. GetMorganGenerator().GetRDKitFPGenerator() method is actually provides the same functionality as the rdkit.Chem.rdMolDescriptors.UnfoldedRDKFingerprintCountBased() method, except that GetSparseFingerprint() returns identifiers in a SparseBitVect object. For example:

mol = AllChem.MolFromSmiles('CCCC')
gen = rdFingerprintGenerator.GetRDKitFPGenerator(numBitsPerFeature=1) 
fp = gen.GetSparseFingerprint(mol)
display(fp)
display(fp.GetNumBits())
display(fp.GetNumOnBits())
display(list(fp.GetOnBits()))

fp = AllChem.UnfoldedRDKFingerprintCountBased(mol)
display(fp)
display(cDataStructs.ULongSparseIntVect.GetNonzeroElements(fp))

# output:
<rdkit.DataStructs.cDataStructs.SparseBitVect at 0x7fcbd562ac40>
4294967295
3
[-1382976661, -19262180, 1940446997]
<rdkit.DataStructs.cDataStructs.ULongSparseIntVect at 0x7fcbd554ed60>
{1940446997: 2, 2911990635: 1, 4275705116: 3}

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

 What Is Daylight Fingerprint Generator in RDKit

 RDKFingerprint() Method in RDKit

 Impact of 'useBondOrder' on RDKFingerprint()

 Impact of 'branchedPaths' on RDKFingerprint()

 Impact of 'maxPath' on RDKFingerprint()

 Impact of 'fpSize' on RDKFingerprint()

 Impact of 'tgtDensity' on RDKFingerprint()

 Impact of 'nBitsPerHash' on RDKFingerprint()

 UnfoldedRDKFingerprintCountBased() Method in RDKit

GetRDKitFPGenerator() Method in RDKit

 Morgan Fingerprint Generator in RDKit

 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