rdkit.Chem.Recap module — The RDKit 2025.09.6 documentation

# rdkit.Chem.Recap module

Implementation of the RECAP algorithm from Lewell et al. JCICS 38 511-522 (1998)

The published algorithm is implemented more or less without modification. The results are returned as a hierarchy of nodes instead of just as a set of fragments. The hope is that this will allow a bit more flexibility in working with the results.

For example: >>> from rdkit import Chem >>> from rdkit.Chem import Recap >>> m = Chem.MolFromSmiles(‘C1CC1Oc1ccccc1-c1ncc(OC)cc1’) >>> res = Recap.RecapDecompose(m) >>> res <…Chem.Recap.RecapHierarchyNode object at …> >>> sorted(res.children.keys()) [’C1CC1’, ‘*c1ccc(OC)cn1’, ‘*c1ccccc1-c1ccc(OC)cn1’, ‘*c1ccccc1OC1CC1’] >>> sorted(res.GetAllChildren().keys()) [‘*C1CC1’, ‘*c1ccc(OC)cn1’, ‘*c1ccccc1’, ‘*c1ccccc1-c1ccc(OC)cn1’, ‘*c1ccccc1OC1CC1’]

To get the standard set of RECAP results, use GetLeaves(): >>> leaves=res.GetLeaves() >>> sorted(leaves.keys()) [’C1CC1’, ‘*c1ccc(OC)cn1’, ‘*c1ccccc1’] >>> leaf = leaves[’*C1CC1’] >>> leaf.mol <…Chem.rdchem.Mol object at …>

rdkit.Chem.Recap.RecapDecompose(mol, allNodes=None, minFragmentSize=0, onlyUseReactions=None)

  returns the recap decomposition for a molecule

class rdkit.Chem.Recap.RecapHierarchyNode(mol)

  Bases: `object`

  This class is used to hold the Recap hiearchy

  GetAllChildren()

    returns a dictionary, keyed by SMILES, of children

  GetLeaves()

    returns a dictionary, keyed by SMILES, of leaf (terminal) nodes

  children = None
  getUltimateParents()

    returns all the nodes in the hierarchy tree that contain this node as a child

  mol = None
  parents = None
  smiles = None

class rdkit.Chem.Recap.TestCase(methodName='runTest')

  Bases: `TestCase`

  Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

  test1()
  test2()
  test3()
  testAmideRxn()
  testAmineRxn()
  testAromCAromCRxn()
  testAromNAliphCRxn()
  testAromNAromCRxn()
  testEsterRxn()
  testEtherRxn()
  testLactamNAliphCRxn()
  testMinFragmentSize()
  testOlefinRxn()
  testSFNetIssue1801871()
  testSFNetIssue1804418()
  testSFNetIssue1881803()
  testSulfonamideRxn()
  testUreaRxn()