New version of rdkit can draw molecule as SVG.
And newest version of it can change atom font size.
I’m waiting for this function for a long time. ;-)
Let’s Draw!
From ipython notebook…
from __future__ import print_function from rdkit import Chem from rdkit.Chem import Draw from rdkit.Chem.Draw import IPythonConsole from rdkit.Chem import rdDepictor from IPython.display import SVG mol = Chem.MolFromSmiles('CN1CCN(S(=O)(C2=CC=C(OCC)C(C3=NC4=C(N(C)N=C4CCC)C(N3)=O)=C2)=O)CC1') rdDepictor.Compute2DCoords(mol) mc = Chem.Mol(mol.ToBinary()) Chem.Kekulize(mc) drawer = Draw.MolDraw2DSVG(400,400) drawer.DrawMolecule(mc) drawer.FinishDrawing() svg = drawer.GetDrawingText().replace("svg:","") drawer.FontSize() Out[39]: 0.5 SVG(svg)
Next change font size.(default size is 0.5.)
drawer = Draw.rdMolDraw2D.MolDraw2DSVG(400,400) # set font size more larger drawer.SetFontSize(0.8) drawer.DrawMolecule(mc) drawer.FinishDrawing() svg = drawer.GetDrawingText().replace("svg:","") SVG(svg)
Cool!
Nice stuff.
I want to embed SVG image to markdown format.
Are there any good practice to do that ?