Thanks Greg,
After testing the code, It works perfectly, thanks! Unfortunatly, I discovered that it's still not compatible with the aromaticity method used in the article i mention in another post from Rudolf Naef. I need to keep aromaticity of all 6 rings (having C or N which is possible using your function), but also keep info of aromaticity of fused 6 rings (aka. naphthalene, ...) + convert/keep guanidium moieties aromatic too. So, I would be more interesting to fine a fast process to revoke aromaticity on rings that are not 6 members rings only, which should preserve all 6 rings + fused aromatic rings and also set guanidium salt as aromatic. Would it be possible to do that ? Best regards, Guillaume ________________________________ De : Greg Landrum <greg.land...@gmail.com> Envoyé : mardi 20 septembre 2016 16:41 À : Guillaume GODIN Cc : RDKit Discuss Objet : Re: [Rdkit-discuss] rearomatize only benzene rigns after kekulize + clearAromaticFlags Guillaume, Here's how to read in a molecule and skip aromaticity perception: In [12]: m = Chem.MolFromSmiles('c1ccccc1-c1cccnc1-c1cc[nH]c1',sanitize=False) In [13]: Chem.SanitizeMol(m,sanitizeOps=Chem.SANITIZE_ALL^Chem.SANITIZE_SETAROMATICITY) Out[13]: rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_NONE In [14]: Chem.MolToSmiles(m) Out[14]: 'C1=CC=C(C2=CC=CN=C2C2=CNC=C2)C=C1' Then you need to find all of the benzene-like rings and set the appropriate flags: In [16]: def set_aroms(m,pattern='[#6]1=[#6][#6]=[#6][#6]=[#6]1'): ...: p = Chem.MolFromSmarts(pattern) ...: matches = m.GetSubstructMatches(p) ...: for match in matches: ...: for mi in match: ...: m.GetAtomWithIdx(mi).SetIsAromatic(True) ...: for bond in p.GetBonds(): ...: mb = m.GetBondBetweenAtoms(match[bond.GetBeginAtomIdx()],match[bond.GetEndAtomIdx()]) ...: assert mb ...: mb.SetBondType(Chem.BondType.AROMATIC) ...: mb.SetIsAromatic(True) ...: ...: In [17]: set_aroms(m) In [18]: Chem.MolToSmiles(m) Out[18]: 'C1=CN=C(C2=CNC=C2)C(c2ccccc2)=C1' Note that the RDKit does have a simplified aromaticity model available out of the box that only recognizes aromaticity in 5- and 6- rings, but this isn't quite as simple as what you're looking for. Best, -greg On Tue, Sep 20, 2016 at 6:52 AM, Guillaume GODIN <guillaume.go...@firmenich.com<mailto:guillaume.go...@firmenich.com>> wrote: Dear All, I would like to kekulize the molecule, but only conserve the aromaticity knowledge of C6 (benzene like) type rings So what to need to do after this command? Chem.rdmolops.Kekulize(mol, clearAromaticFlags=True) Should I need to store benzene like location before the Kekulize process and restore it after and How to restore it (SetIsAromatic of atoms as true and change bondtype )? best regards, Guillaume GODIN ********************************************************************** DISCLAIMER This email and any files transmitted with it, including replies and forwarded copies (which may contain alterations) subsequently transmitted from Firmenich, are confidential and solely for the use of the intended recipient. The contents do not represent the opinion of Firmenich except to the extent that it relates to their official business. ********************************************************************** ------------------------------------------------------------------------------ _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net<mailto:Rdkit-discuss@lists.sourceforge.net> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
------------------------------------------------------------------------------
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss