rdkit.Chem.rdFMCS module — The RDKit 2025.09.6 documentation

# rdkit.Chem.rdFMCS module

Module containing a C++ implementation of the FMCS algorithm

class rdkit.Chem.rdFMCS.AtomCompare

  Bases: `enum`

  CompareAny = rdkit.Chem.rdFMCS.AtomCompare.CompareAny
  CompareAnyHeavyAtom = rdkit.Chem.rdFMCS.AtomCompare.CompareAnyHeavyAtom
  CompareElements = rdkit.Chem.rdFMCS.AtomCompare.CompareElements
  CompareIsotopes = rdkit.Chem.rdFMCS.AtomCompare.CompareIsotopes
  names = {'CompareAny': rdkit.Chem.rdFMCS.AtomCompare.CompareAny, 'CompareAnyHeavyAtom': rdkit.Chem.rdFMCS.AtomCompare.CompareAnyHeavyAtom, 'CompareElements': rdkit.Chem.rdFMCS.AtomCompare.CompareElements, 'CompareIsotopes': rdkit.Chem.rdFMCS.AtomCompare.CompareIsotopes}
  values = {0: rdkit.Chem.rdFMCS.AtomCompare.CompareAny, 1: rdkit.Chem.rdFMCS.AtomCompare.CompareElements, 2: rdkit.Chem.rdFMCS.AtomCompare.CompareIsotopes, 3: rdkit.Chem.rdFMCS.AtomCompare.CompareAnyHeavyAtom}

class rdkit.Chem.rdFMCS.BondCompare

  Bases: `enum`

  CompareAny = rdkit.Chem.rdFMCS.BondCompare.CompareAny
  CompareOrder = rdkit.Chem.rdFMCS.BondCompare.CompareOrder
  CompareOrderExact = rdkit.Chem.rdFMCS.BondCompare.CompareOrderExact
  names = {'CompareAny': rdkit.Chem.rdFMCS.BondCompare.CompareAny, 'CompareOrder': rdkit.Chem.rdFMCS.BondCompare.CompareOrder, 'CompareOrderExact': rdkit.Chem.rdFMCS.BondCompare.CompareOrderExact}
  values = {0: rdkit.Chem.rdFMCS.BondCompare.CompareAny, 1: rdkit.Chem.rdFMCS.BondCompare.CompareOrder, 2: rdkit.Chem.rdFMCS.BondCompare.CompareOrderExact}

rdkit.Chem.rdFMCS.FindMCS((object)mols[, (bool)maximizeBonds=True[, (float)threshold=1.0[, (int)timeout=3600[, (bool)verbose=False[, (bool)matchValences=False[, (bool)ringMatchesRingOnly=False[, (bool)completeRingsOnly=False[, (bool)matchChiralTag=False[, (AtomCompare)atomCompare=rdkit.Chem.rdFMCS.AtomCompare.CompareElements[, (BondCompare)bondCompare=rdkit.Chem.rdFMCS.BondCompare.CompareOrder[, (RingCompare)ringCompare=rdkit.Chem.rdFMCS.RingCompare.IgnoreRingFusion[, (str)seedSmarts='']]]]]]]]]]]]) → MCSResult :

  Find the MCS for a set of molecules

  > C++ signature :

  >   RDKit::MCSResult* FindMCS(boost::python::api::object [,bool=True [,double=1.0 [,unsigned int=3600 [,bool=False [,bool=False [,bool=False [,bool=False [,bool=False [,RDKit::AtomComparator=rdkit.Chem.rdFMCS.AtomCompare.CompareElements [,RDKit::BondComparator=rdkit.Chem.rdFMCS.BondCompare.CompareOrder [,RDKit::RingComparator=rdkit.Chem.rdFMCS.RingCompare.IgnoreRingFusion [,std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >=’’]]]]]]]]]]]])

  FindMCS( (object)mols, (MCSParameters)parameters) -> MCSResult :

    Find the MCS for a set of molecules

    C++ signature :

      RDKit::MCSResult* FindMCS(boost::python::api::object,RDKit::PyMCSParameters {lvalue})

class rdkit.Chem.rdFMCS.MCSAcceptance((object)arg1) → None :

  Bases: `instance`

  Base class. Subclass and override MCSAcceptance.__call__() to define a custom boolean callback function. Returning True will cause the MCS candidate to be accepted, False to be rejected

  C++ signature :

    void __init__(_object*)

class rdkit.Chem.rdFMCS.MCSAtomCompare((object)arg1) → None :

  Bases: `instance`

  Base class. Subclass and override MCSAtomCompare.__call__() to define custom atom compare functions, then set MCSParameters.AtomTyper to an instance of the subclass

  C++ signature :

    void __init__(_object*)

  CheckAtomCharge((MCSAtomCompare)self, (MCSAtomCompareParameters)parameters, (rdkit.Chem.rdchem.Mol)mol1, (int)atom1, (rdkit.Chem.rdchem.Mol)mol2, (int)atom2) → bool :

    Return True if both atoms have the same formal charge

    C++ signature :

      bool CheckAtomCharge(RDKit::PyMCSAtomCompare {lvalue},RDKit::MCSAtomCompareParameters,RDKit::ROMol,unsigned int,RDKit::ROMol,unsigned int)

  CheckAtomChirality((MCSAtomCompare)self, (MCSAtomCompareParameters)parameters, (rdkit.Chem.rdchem.Mol)mol1, (int)atom1, (rdkit.Chem.rdchem.Mol)mol2, (int)atom2) → bool :

    Return True if both atoms have, or have not, a chiral tag

    C++ signature :

      bool CheckAtomChirality(RDKit::PyMCSAtomCompare {lvalue},RDKit::MCSAtomCompareParameters,RDKit::ROMol,unsigned int,RDKit::ROMol,unsigned int)

  CheckAtomRingMatch((MCSAtomCompare)self, (MCSAtomCompareParameters)parameters, (rdkit.Chem.rdchem.Mol)mol1, (int)atom1, (rdkit.Chem.rdchem.Mol)mol2, (int)atom2) → bool :

    Return True if both atoms are, or are not, in a ring

    C++ signature :

      bool CheckAtomRingMatch(RDKit::PyMCSAtomCompare {lvalue},RDKit::MCSAtomCompareParameters,RDKit::ROMol,unsigned int,RDKit::ROMol,unsigned int)

class rdkit.Chem.rdFMCS.MCSAtomCompareParameters((object)arg1) → None :

  Bases: `instance`

  Parameters controlling how atom-atom matching is done

  C++ signature :

    void __init__(_object*)

  property CompleteRingsOnly

    results cannot include lone ring atoms

  property MatchChiralTag

    include atom chirality in the match

  property MatchFormalCharge

    include formal charge in the match

  property MatchIsotope

    use isotope atom queries in MCSResults

  property MatchValences

    include atom valences in the match

  property MaxDistance

    Require atoms to be within this many angstroms in 3D

  property RingMatchesRingOnly

    ring atoms are only allowed to match other ring atoms

class rdkit.Chem.rdFMCS.MCSBondCompare((object)arg1) → None :

  Bases: `instance`

  Base class. Subclass and override MCSBondCompare.__call__() to define custom bond compare functions, then set MCSParameters.BondTyper to an instance of the subclass

  C++ signature :

    void __init__(_object*)

  CheckBondRingMatch((MCSBondCompare)self, (MCSBondCompareParameters)parameters, (rdkit.Chem.rdchem.Mol)mol1, (int)bond1, (rdkit.Chem.rdchem.Mol)mol2, (int)bond2) → bool :

    Return True if both bonds are, or are not, part of a ring

    C++ signature :

      bool CheckBondRingMatch(RDKit::PyMCSBondCompare {lvalue},RDKit::MCSBondCompareParameters,RDKit::ROMol,unsigned int,RDKit::ROMol,unsigned int)

  CheckBondStereo((MCSBondCompare)self, (MCSBondCompareParameters)parameters, (rdkit.Chem.rdchem.Mol)mol1, (int)bond1, (rdkit.Chem.rdchem.Mol)mol2, (int)bond2) → bool :

    Return True if both bonds have, or have not, a stereo descriptor

    C++ signature :

      bool CheckBondStereo(RDKit::PyMCSBondCompare {lvalue},RDKit::MCSBondCompareParameters,RDKit::ROMol,unsigned int,RDKit::ROMol,unsigned int)

class rdkit.Chem.rdFMCS.MCSBondCompareParameters((object)arg1) → None :

  Bases: `instance`

  Parameters controlling how bond-bond matching is done

  C++ signature :

    void __init__(_object*)

  property CompleteRingsOnly

    results cannot include partial rings

  property MatchFusedRings

    enforce check on ring fusion, i.e. alpha-methylnaphthalene won’t match beta-methylnaphtalene, but decalin will match cyclodecane unless MatchFusedRingsStrict is True

  property MatchFusedRingsStrict

    only enforced if MatchFusedRings is True; the ring fusion must be the same in both query and target, i.e. decalin won’t match cyclodecane

  property MatchStereo

    include bond stereo in the comparison

  property RingMatchesRingOnly

    ring bonds are only allowed to match other ring bonds

class rdkit.Chem.rdFMCS.MCSFinalMatchCheck((object)arg1) → None :

  Bases: `instance`

  Base class. Subclass and override MCSFinalMatchCheck.__call__() to define a custom boolean callback function. Returning True will cause the growing seed to be accepted, False to be rejected

  C++ signature :

    void __init__(_object*)

class rdkit.Chem.rdFMCS.MCSParameters((object)arg1) → None :

  Bases: `instance`

  Parameters controlling how the MCS is constructed

  C++ signature :

    void __init__(_object*)

  property AtomCompareParameters

    parameters for comparing atoms

  property AtomTyper

    atom typer to be used. Must be one of the members of the rdFMCS.AtomCompare class or an instance of a user-defined subclass of rdFMCS.MCSAtomCompare

  property BondCompareParameters

    parameters for comparing bonds

  property BondTyper

    bond typer to be used. Must be one of the members of the rdFMCS.BondCompare class or an instance of a user-defined subclass of rdFMCS.MCSBondCompare

  property FinalMatchChecker

    seed final match checker callback class. Must be a user-defined subclass of rdFMCS.MCSFinalMatchCheck

  property InitialSeed

    SMILES string to be used as the seed of the MCS

  property MaximizeBonds

    toggles maximizing the number of bonds (instead of the number of atoms)

  property ProgressCallback

    progress callback class. Must be a user-defined subclass of rdFMCS.Progress

  property ShouldAcceptMCS

    MCS acceptance callback class. Must be a user-defined subclass of rdFMCS.MCSAcceptance

  property StoreAll

    toggles storage of degenerate MCSs

  property Threshold

    fraction of the dataset that must contain the MCS

  property Timeout

    timeout (in seconds) for the calculation

  property Verbose

    toggles verbose mode

class rdkit.Chem.rdFMCS.MCSProgress((object)arg1) → None :

  Bases: `instance`

  Base class. Subclass and override MCSProgress.__call__() to define a custom callback function

  C++ signature :

    void __init__(_object*)

class rdkit.Chem.rdFMCS.MCSProgressData((object)arg1) → None :

  Bases: `instance`

  Information about the MCS progress

  C++ signature :

    void __init__(_object*)

  property numAtoms

    number of atoms in MCS

  property numBonds

    number of bonds in MCS

  property seedProcessed

    number of processed seeds

class rdkit.Chem.rdFMCS.MCSResult

  Bases: `instance`

  used to return MCS results

  Raises an exception This class cannot be instantiated from Python

  property canceled

    if True, the MCS calculation did not finish

  property degenerateSmartsQueryMolDict

    Dictionary collecting all degenerate (SMARTS, queryMol) pairs (empty if MCSParameters.StoreAll is False)

  property numAtoms

    number of atoms in MCS

  property numBonds

    number of bonds in MCS

  property queryMol

    query molecule for the MCS

  property smartsString

    SMARTS string for the MCS

class rdkit.Chem.rdFMCS.RingCompare

  Bases: `enum`

  IgnoreRingFusion = rdkit.Chem.rdFMCS.RingCompare.IgnoreRingFusion
  PermissiveRingFusion = rdkit.Chem.rdFMCS.RingCompare.PermissiveRingFusion
  StrictRingFusion = rdkit.Chem.rdFMCS.RingCompare.StrictRingFusion
  names = {'IgnoreRingFusion': rdkit.Chem.rdFMCS.RingCompare.IgnoreRingFusion, 'PermissiveRingFusion': rdkit.Chem.rdFMCS.RingCompare.PermissiveRingFusion, 'StrictRingFusion': rdkit.Chem.rdFMCS.RingCompare.StrictRingFusion}
  values = {0: rdkit.Chem.rdFMCS.RingCompare.IgnoreRingFusion, 1: rdkit.Chem.rdFMCS.RingCompare.PermissiveRingFusion, 2: rdkit.Chem.rdFMCS.RingCompare.StrictRingFusion}