Dear Stéphane, I am not sure if there's a direct way to achieve bonds highlighting. You can highlight them manually by:
mol = Chem.MolFromSmiles('c1cc(C(=O)O)c(OC(=O)C)cc1') patt = Chem.MolFromSmarts('C(=O)O') hit_ats = list(mol.GetSubstructMatch(patt)) hit_bonds = [] for bond in patt.GetBonds(): aid1 = hit_ats[bond.GetBeginAtomIdx()] aid2 = hit_ats[bond.GetEndAtomIdx()] hit_bonds.append(mol.GetBondBetweenAtoms(aid1,aid2).GetIdx()) d = Draw.rdMolDraw2D.MolDraw2DSVG(500, 500) Draw.rdMolDraw2D.PrepareAndDrawMolecule(d, mol, highlightAtoms=hit_ats,highlightBonds=hit_bonds) Note that this will highlight only a single match of the substructure and not all matches, for that, use GetSubstructMatches and modify the code accordingly. You may see the documentation for the given example: https://www.rdkit.org/docs/GettingStartedInPython.html#drawing-molecules I hope this helps, Best regards, Omar On Mon, Jan 25, 2021 at 5:17 PM BOURG Stephane <stephane.bo...@cnrs.fr> wrote: > Dear all, > > > > Within rdkit '2020.03.6' the following code in a jupyter notebook goves > the first image below : > > > > from rdkit import Chem > > from rdkit.Chem.Draw import IPythonConsole > > > > m = Chem.MolFromSmiles('c1cc(C(=O)O)c(OC(=O)C)cc1') > > substructure = Chem.MolFromSmarts('C(=O)O') > > print(m.GetSubstructMatches(substructure)) > > m > > > > > > The same code with rdkit 2020.09.3 doesn’t highlight the bond. > > > > What should I correct to highlight the bonds ? > > > > Many thanks > > > > > > Stéphane BOURG, Ph. D. > > Equipe Bioinformatique Structurale et Chémoinformatique (SBC) > > > > Institut de Chimie Organique et Analytique (ICOA) > > UMR CNRS-Université d’Orléans 7311 > > Pôle de Chimie > > Rue de Chartres – BP 6759 > > 45 067 Orléans Cedex 2 > > > > Tél : +33 (0)2 38 49 45 89 > > E-mail : stephane.bo...@cnrs.fr > > > > > _______________________________________________ > Rdkit-discuss mailing list > 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