How to find the largest cyclic substructure with RDKit? I have a bunch of structures and of each I would like to find the largest cyclic substructure.
I'm not a chemist, so I don't know if there is a common terminology for this. I hope, I made it clear what I'm looking for.
Example:

Each structure on the top (1,2,3) as input should return the bottom structure (4).
There is the rdkit.Chem.MCS module which will return the maximum common substructure of a set of molecules.
But that's not what I'm looking for.
Any ideas? And hints where or which module to look at...? Which term to search for?
I'm aware that there is a RDKit mailing list, however, I'm asking here first, because of the possibility to easily attach images. If nobody can help me here, I will try there. Maybe it already goes into &quot;heavier&quot; programming which then would be more a topic for StackOverflow.
In the RDKit Cookbook is an example how to find the indices of ring systems.
RDKit Cookbook Example
Having the indices, it is simple to find the largest ring.
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
IPythonConsole.molSize = (400, 300)
IPythonConsole.drawOptions.addAtomIndices = True

m = Chem.MolFromSmiles('C1=CC2C(C=C1)=c1ccccc1=C2C1C=C(c2ccccc2)c2cccc3c4ccccc4nc1c23')
m


# the cook book example
def GetRingSystems(mol, includeSpiro=False):
    ri = mol.GetRingInfo()
    systems = []
    for ring in ri.AtomRings():
        ringAts = set(ring)
        nSystems = []
        for system in systems:
            nInCommon = len(ringAts.intersection(system))
            if nInCommon and (includeSpiro or nInCommon&gt;1):
                ringAts = ringAts.union(system)
            else:
                nSystems.append(system)
        nSystems.append(ringAts)
        systems = nSystems
    return systems

ringSys = GetRingSystems(m)
ringSys

[{16, 17, 18, 19, 20, 21},
 {13, 14, 15, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35},
 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}]

Highlighting the largest ring for proof.
highlightAtoms = max(ringSys, key=len)
Draw.MolToImage(m, size=(400,300), highlightAtoms=highlightAtoms)