New finger print calculation method in RDKit #RDKit

It’s a good news for RDKitters!
New version of rdkit is released and it can be installed with Anaconda!
There are many implementations and enhancements. You can find details of that from URL below.

One of interesting feature is a fingerprint bit information rendering function.
There is nice blog post about that.

And I am interested in new finger print calculation method. This is a project of GSoc.
rdFingerprintGenerator can provide finger print generators. The generator can access directory to fingerprint methods.
I used the method and wrote some code…

from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import rdFingerprintGenerator
from rdkit import rdBase
from rdkit import RDPaths
import os

Load molecules.

mols = Chem.SDMolSupplier(os.path.join(RDPaths.RDDocsDir,'Book/data/cdk2.sdf'))
mols = [ mol for mol in mols if mol != None]

Get FP generator and calculate FP.

# Default radi of molecule is 3! (ECFP6 like)
morgan_fp_gen = rdFingerprintGenerator.GetMorganGenerator()
fp01 = morgan_fp_gen.GetFingerprint(mols[0])
fp02 = AllChem.GetMorganFingerprintAsBitVect(mols[0],3)

The generator returns molecular finger print as bit vect.
And the generator has several useful method listed below.

> 'GetFingerprint',
> 'GetInfoString',
> 'GetSparseCountFingerprint',

This example is limited to Morgan FP but the method can get other fingerprints as same manner, AtomPair FP, RDKit FP etc.

The official repository provides example code.
I think the code is written in python2 environments. If reader who want to run the code, I recommend replace ‘print xxx’ to ‘print(xxx)’

And I uploaded my snippet to my repo, ULR is below.


Published by iwatobipen

I'm medicinal chemist in mid size of pharmaceutical company. I love chemoinfo, cording, organic synthesis, my family.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: