Number of atoms within a biggest ring?

Hi there,

I would like to know if there is a way to count the atoms in the largest ring within a structure and to obtain the result as a column? I am familiar with the Topology Node from JChem, but one needs a licence for it and I do not really have a opportunity to have it.

Thank you :slight_smile:

Hi @nejraG

If you are familiar with RDKit on Python, you could implement the following solution using a Python node on KNIME:

based on the RDKit Python library:

https://www.rdkit.org/docs/Cookbook.html#rings-aromaticity-and-kekulization

Hope this helps.

Best

Ael

2 Likes

Hi @aworker,

i tried what you proposed and it worked in some cases. What I need is that the atoms making this structure be included. Like in example below. And what it did, was including that ring (in this case made of 14 atoms) and another ring also (hier made out of 6 atoms). And i do not need the second one, since my criteria is the strucutre should have at least nine atoms. So in this case I would like to have only number 14 in a output table. Is it possible to achieve it?

Processing: Screenshot from 2021-10-22 14-29-10.xcf…

Hi @nejraG

Thanks for your feedback and for having tried the proposed solution.
I found challenging your question so I tried myself in the meanwhile. Eventually I found the following solution which I hope will answer your question. Otherwise please let me know:

The Python code is the following:

from pandas import DataFrame

from rdkit import Chem
from rdkit.Chem import Draw

# 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>1):
                ringAts = ringAts.union(system)
            else:
                nSystems.append(system)
        nSystems.append(ringAts)
        systems = nSystems
    return systems

Smiles = input_table_1['Smiles'].tolist()

ringSys = [];
RDKitMols = [];
for i, (smile) in enumerate( Smiles):
	m = Chem.MolFromSmiles( smile)
	RDKitMols.append(m)	
	rings = ';'.join( str(e) for e in GetRingSystems(m))
	ringSys.append( rings)

# Copy input to output
output_table_1 = input_table_1.copy()

# Add Longest Rings column to Table
output_table_1[ "Smiles (RDKit)"] = RDKitMols
output_table_1[ "Rings"] = ringSys

I could have done everything in Python and just output the result at the -Python Script- node but I preferred to do the maximum using KNIME, programming only what is specifically needed in Python inside the -Python Scripting- node.

The result after keeping only rings of at least 9 atoms inside the most outer ring:

20211020 Pikairos Number of atoms within a biggest ring.knwf (171.5 KB)

The workflow is self explained but do not hesitate to get back in touch if you have any questions.

Hope this helps.

Best

Ael

3 Likes

Thank you for answer and sorry for delayed response. I have tried it and unfortunately it does not work for every case. I just want those atoms directly included in formation of the ring. No other atoms.Processing: 14.xcf…
14
Like in this figure, i just want these black atoms since these are the ones who are involved in the formation of the ring. The red atoms as well es any others functional groups that are hanging on that large cycle can not be included in the ring size. The same goes for these fused rings. Only inner atoms of the ring, if you understand what I am thinking :slight_smile:
Thank you!

Also, I have a structures that are made from 2,3 or 4 large rings (large ring- minimum size 9 atoms), and I want them to be recognized as structures having a core made of 2 rings one having 10 atoms other 16 for example.1______v2002-large
In this figure is Vancomycin, you see it has 3 large rings, two having size 16 and one 12, so the result should be like 12,16,16 in this case. Is it possible to do it?
Thanks :slight_smile: