Re: [Rdkit-discuss] A question about detection of armaticity in SMILES
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Greg L. <gre...@gm...> - 2009-10-21 03:40:53
|
Dear Abhinav, On Wed, Oct 21, 2009 at 1:15 AM, Abhinav Chawade <thi...@gm...> wrote: > Hello > I am working on a project which requires interpretation and conversion of > SMILES to a graph. My question is how to detect aromatic rings in SMILES? I > am familiar with Huckel's rule and hybridization. Any reply, greatly > appreciated. When you convert SMILES to a molecule with the RDKit it perceives the rings in the system and identifies which of those rings it considers to be aromatic (based on Hueckel's rule). The "rules" for aromaticity are described in the RDKit Book: http://rdkit.svn.sourceforge.net/viewvc/rdkit/tags/Release_Q32009_1/Docs/Book/RDKit_Book.pdf?revision=1262 If you're interested in identifying which rings are aromatic, you need to do a bit of work. Each molecule has a RingInfo object associated with it that stores the rings found when the molecule is built, you get this with the GetRingInfo method: [2]>>> m = Chem.MolFromSmiles('c1cccc2c1CCCC2') [3]>>> ri = m.GetRingInfo() You can interrogate the RingInfo object to tell you the atoms that make up each ring: [5]>>> ri.AtomRings() Out[5] ((0, 5, 4, 3, 2, 1), (6, 7, 8, 9, 4, 5)) or the bonds that make up each ring: [6]>>> ri.BondRings() Out[6] ((9, 4, 3, 2, 1, 0), (6, 7, 8, 10, 4, 5)) To detect aromatic rings, I would loop over the bonds in each ring and flag the ring as aromatic if all bonds are aromatic: [7]>>> def isRingAromatic(mol,bondRing): ...: for id in bondRing: ...: if not mol.GetBondWithIdx(id).GetIsAromatic(): ...: return False ...: return True ...: [8]>>> isRingAromatic(m,ri.BondRings()[0]) Out[8] True [10]>>> isRingAromatic(m,ri.BondRings()[1]) Out[10] False Now you have the list of rings and can test if the individual rings are aromatic;* does this answer your question? -greg * note that in the case where the aromaticity is due to fused rings instead of individual ones (there's an example in the pdf above), this approach will fail because GetRingInfo() only returns the smallest rings. This is not a situation that occurs very frequently, but if you need to work around it, you'll have to do the graph-traversal yourself. |