Cheminformatics Tutorials - Herong's Tutorial Examples - v2.01, by Herong Yang
Impact of 'useCounts' on GetMorganFingerprint()
This section provides a tutorial example on impact of the 'useCounts' option on fingerprint generation with rdkit.Chem.rdMolDescriptors.GetMorganFingerprint() function.
The 'useCounts' option in the rdkit.Chem.rdMolDescriptors.GetMorganFingerprint() function call allows you to control whether or not counts of identifier duplications are included in the fingerprint. The default value is useCounts=True.
1. For example, molecule "CC" will produce 2 duplicate identifiers with useCounts=True in the fingerprint.
from rdkit.Chem import AllChem from rdkit.DataStructs.cDataStructs import UIntSparseIntVect radius = 0 bitInfo = {} mol = AllChem.MolFromSmiles('CC') fp = AllChem.GetMorganFingerprint(mol, radius, useCounts=True, 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))}
Output "GetNonzeroElements(fp)={2246728737: 2}" shows the count of duplications of identifier "2246728737" is 2 in the fingerprint.
2. If useCounts=False is used, "CC" will produce only a single identifier in the fingerprint.
radius = 0 bitInfo = {} mol = AllChem.MolFromSmiles('CC') fp = AllChem.GetMorganFingerprint(mol, radius, useCounts=False, bitInfo=bitInfo) display(UIntSparseIntVect.GetLength(fp)) display(UIntSparseIntVect.GetNonzeroElements(fp)) display(UIntSparseIntVect.GetTotalVal(fp)) print(bitInfo) # output: 4294967295 {2246728737: 1} 1 {2246728737: ((0, 0), (1, 0))}
But you can still use bitInfo to see which identifier is duplicated and how many times.
Conclusion: We should keep the default of useCounts=True to include the counts of identifier duplications in the fingerprint. This allows use to differentiate molecules with the same local substructure repeating with different times.
Table of Contents
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