Hi,
I've got some problems generating the correct images of the molecules.
I'm new to Python and RDKit, so maybe I did something wrong.
Could someone help me and correct the code?
I've got a cluster of five compounds and I want to display them, but with 
Draw.MolsToGridImage(mols) I didn't obtain correct images.
I've searched for another method, but I obtain again this image...

#now display structures from one of the clusters
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole

m1 = ms[99]
m2 = ms[18]
m3 = ms[19]
m4 = ms[58]
m5 = ms[60]
mols=(m1,m2,m3,m4,m5)
smile1 = Chem.MolToSmiles(m1)
from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2D
from IPython.display import SVG

def moltosvg(mol, molSize = (300,300), kekulize = True):
    mc = Chem.Mol(mol.ToBinary())
    if kekulize:
        try:
            Chem.Kekulize(mc)
        except:
            mc = Chem.Mol(mol.ToBinary())
    if not mc.GetNumConformers():
        rdDepictor.Compute2DCoords(mc)
    drawer = rdMolDraw2D.MolDraw2DSVG(molSize[0],molSize[1])
    drawer.DrawMolecule(mc)
    drawer.FinishDrawing()
    svg = drawer.GetDrawingText()
    return svg.replace('svg:','')
SVG(moltosvg(m1))
[cid:949a3b76-5d3b-4ed6-8c7a-2ea9a87e8f8b]
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
  • [Rdkit-discuss]... Francesca Magarotto - francesca.magarot...@studio.unibo.it

Reply via email to