Ok guys, I came up with a possible solution for the N,C 6 rings aromatic 
rearomatisation after kekulize.


I still need to find a ways to do it also for guanidinium salts.

?

def TestL_n(L,n,aro):
    suppl = 
Chem.SDMolSupplier('/Users/mbp/Downloads/molecules-20-18279-s001/Compounds List 
for Heat-of-Combustion Calculations.sdf',removeHs=False)
    i=0
    cp=0
    v=zeros(len(L))
    for mol in suppl:
        if aro:
            s = Chem.MolToSmiles(mol)
            m = rearomatization(s)
        else:
            m = mol
        i=i+1
        for j in range(0, len(L)):
            if j==n-1:
                try:
                    c= Occ(L[j],m)
                    v[j]+=c
                    if c>0:
                        cp+=1
                        print Chem.MolToSmiles(Chem.RemoveHs(m))
                except:
                    print "error"
    return v[n-1],cp


# r6 (C or N) rearomatization: C/N & guanidinium
def keep6aro(m):  #[N;v3X3,v4X4+][CX3](=[N;v3X2,v4X3+])[N;v3X3,v4X4+]
    # greg version
    r6 = 
Chem.MolFromSmarts('[#6,#7;a]1[#6,#7;a][#6,#7;a][#6,#7;a][#6,#7;a][#6,#7;a]1') 
# ring of 6 of C or N only!
    atomkeep = m.GetSubstructMatches(r6)
    ri = m.GetRingInfo()
    BondRing = ri.BondRings()
    bondkeep=[]
    for bondring in BondRing:
        if len(bondring)==6 and isRingAromatic(m,bondring):
            bondkeep.append(bondring)
    return atomkeep, bondkeep

def Aromatics6ring2(m,atomkeep,bondkeep):  
#[N;v3X3,v4X4+][CX3](=[N;v3X2,v4X3+])[N;v3X3,v4X4+]
    # greg version
    for match in atomkeep:
        for mi in match:
            m.GetAtomWithIdx(mi).SetIsAromatic(True)
    for bondring in bondkeep:
        for bondid in bondring:
            mb = m.GetBondWithIdx(bondid)
            mb.SetBondType(Chem.rdchem.BondType.AROMATIC)
            mb.SetIsAromatic(True)
    return m

def isRingAromatic(mol,BondRing):
    for id in BondRing:
        if not mol.GetBondWithIdx(id).GetIsAromatic():
            return False
    return True

def rearomatization(s):
    mol = Chem.MolFromSmiles(s)
    atomkeep, bondkeep= keep6aro(mol)
    Chem.rdmolops.Kekulize(mol,clearAromaticFlags=True)
    mol=Aromatics6ring2(mol,atomkeep,bondkeep)
    return mol


Dr. Guillaume GODIN
Principal Scientist
Chemoinformatic & Datamining
Innovation
CORPORATE R&D DIVISION
DIRECT LINE +41 (0)22 780 3645
MOBILE          +41 (0)79 536 1039
        Firmenich SA
        RUE DES JEUNES 1 | CASE POSTALE 239 | CH-1211 GENEVE 8

________________________________
De : Greg Landrum <greg.land...@gmail.com>
Envoyé : jeudi 22 septembre 2016 10:22
À : Guillaume GODIN
Cc : RDKit Discuss
Objet : Re: [Rdkit-discuss] rearomatize only benzene rigns after kekulize + 
clearAromaticFlags



On Wed, Sep 21, 2016 at 4:31 PM, Guillaume GODIN 
<guillaume.go...@firmenich.com<mailto:guillaume.go...@firmenich.com>> wrote:

After testing the code, It works perfectly, thanks!

Well, there's at least that. ;-)


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.

Before going further with this I have a question for you (note that I still 
haven't had time to read the paper in detail): I understand that in order to 
exactly reproduce the results from that paper you do need to reproduce the 
aromaticity model used. However, if you were to borrow the methods and data 
from the paper, you could theoretically build your own models based on RDKit 
aromaticity. This would likely be more efficient at runtime than re-perceiving 
aromaticity.


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.

 "Revoking" aromaticity is tricky because you really need to also kekulize the 
rings that you remove aromaticity from.
I think you're going to be better off just describing the features that are 
aromatic and applying the method I described in the previous message.

The SMARTS I sent to you should certainly work for fused rings like naphthalene 
and could be adapted to support heteroatoms. Guanidinium is a different problem 
though... the RDKit does not tolerate aromatic bonds/atoms that aren't in 
rings. What exactly do you want to do there?

-greg
**********************************************************************  
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
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to