The truth is rarely pure and never simple

Detect sp2 hybridisation in RDKit

The default method of RDKit uses valence considerations to detect the hybridisation state of an atom, since geometries are optional for the molecular structures. While there are geometry criteria for hybridisation states, they are not implemented in rdkit. Here is an example how to use these criteria (number of bonded atoms = 3, all angles between 109 and 145 degrees in this case)

from rdkit import Chem
from rdkit.Chem import rdMolTransforms
# sanitize has to be False to avoid bond recalculation from the PDB file
mol = Chem.MolFromPDBFile('/tmp/hybtest.pdb', sanitize=False)

bonded = []
for bond in mol.GetAtoms()[0].GetBonds():
if len(bonded) != 3:
for a, b in ((0, 1), (1, 2), (2, 0)):
        angle = rdMolTransforms.GetAngleDeg(mol.GetConformer(),bonded[a],0,bonded[b])
        if not (angle > 109 and angle < 145):


Leave a comment

Your email address will not be published.