On Tue, Apr 1, 2008 at 10:47 PM, Noel O'Boyle <[email protected]> wrote:
> I've been looking into depiction in RDKit. It uses sping, which
>  unfortunately looks like it's not very up to date. I know that BKChem
>  has moved from sping to pycairo. At the moment, is it actually
>  possible to make a PNG with RDKit?

First an example, then some comments:
#-------- ------------ ------------
from Chem import AllChem
from sping.PIL.pidPIL import PILCanvas as Canvas
from Chem.Draw.MolDrawing import MolDrawing

m = Chem.MolFromSmiles('c1ccncc1')
AllChem.Compute2DCoords(m)
Chem.Kekulize(m) # kekulized drawings are much more pleasing.

canvas = Canvas(size=(200,200))
drawer = MolDrawing(canvas=canvas)
drawer.AddMol(m)
canvas.save('out.png')
#-------- ------------ ------------

It's true that sping isn't particularly up to date, but the version
that's distributed with the RDKit is reasonably functional, at least
for drawing molecules. I have looked at pycairo a couple of times
because it seems quite nice, unfortunately each time I get turned off
by how many separate components there are to install.

Though the current drawing code works, I'm not particularly thrilled
with it; the quality of the pictures produced isn't what I would like
to have. This post to the devel list was the result of some
experiments I did with alternate drawing:
http://sourceforge.net/mailarchive/forum.php?thread_name=60825b0f0803161119q740ca0d7jabd174d6103f8a83%40mail.gmail.com&forum_name=rdkit-devel
Since the sample image seems to have gotten lost there, it's attached
to this message as well.
A substantial advantage of the (simple) refactoring I did for this new
example is that it's pretty straightforward to use almost any drawing
system.

If people have comments or suggestions on this topic, I am very happy
to hear them.

-greg

<<attachment: foo.png>>

Reply via email to