bracketed expansion of chemical abbreviations

56 views
Skip to first unread message

Gabe

unread,
Apr 15, 2012, 8:01:25 PM4/15/12
to indigo-general
Hi everyone,

I'm new to Indigo (and chemi-informatics in general) so forgive me if
this is a simple question. I'm using indigo-depict to convert SDF and
MOL files to images (PNGs). When the MOL files contain chemical
abbreviations like "NO2" or "CH2CH3", indigo-depict correctly expands
them to show the entire structure, however it also puts brackets
around the expanded group, and shows the abbreviation that was
expanded next to it. Here's an example:

http://i.imgur.com/QI9fL.jpg

is it possible to control this behavior? It would be nice, for
example, to be able to turn-off the brackets with a command-line
switch.

Thanks very much for your help,

Gabe

Mikhail Kozhevnikov

unread,
Apr 16, 2012, 4:44:53 AM4/16/12
to indigo-...@googlegroups.com, gabrie...@gmail.com
Hello Gabe,

These structures are represented by S-groups in MOL/SDF files -- in this case, so-called Superatom S-groups. Indigo-depict generally renders whatever it is given, but one can get rid of the S-groups using the Indigo API prior to rendering. That should only take several lines of code in C, Java or Python. Would that work for you?

Cheers, 
Mikhail

Gabe

unread,
Apr 16, 2012, 8:48:04 AM4/16/12
to indigo-...@googlegroups.com, gabrie...@gmail.com
Thanks very much Mikhail,

Since your reply, I've gotten a little python script up-and-running that does the rending for me, instead of using indigo-depict.  However, I'm not sure how to change the S-group behavior... could you give me a little more info?  The only rendering option I can find that mentions superatoms is render-superatom-mode, but when I try to change this to 'collapse' it crashes with this error:

indigo.IndigoException: 'red-black tree: insert(): key already present'

which I'm afraid I don't understand.  I apologize if this is a trivial problem -- I don't know much python (and zero C++/java)... thanks very much in advance for your patience and for any tips you can give me.

Best,

Gabe

PS - here's my little script:

#!/usr/bin/python

import sys
import indigo_renderer
from indigo import *

indigo = Indigo()
renderer = indigo_renderer.IndigoRenderer(indigo)

mol1 = indigo.loadMoleculeFromFile(sys.argv[1])
print "\tmol weight: " + str(mol1.molecularWeight())
print "\trendering PNG..."
indigo.setOption("render-output-format","png")
#indigo.setOption("render-superatom-mode", "collapse")  #<-- causes crash 
indigo.setOption("render-margins",50,50)
mol1.layout()

renderer.renderToFile(mol1, sys.argv[1] + ".png")




On Monday, April 16, 2012 3:44:53 AM UTC-5, Mikhail Kozhevnikov wrote:
Hello Gabe,

These structures are represented by S-groups in MOL/SDF files -- in this case, so-called Superatom S-groups. Indigo-depict generally renders whatever it is given, but one can get rid of the S-groups using the Indigo API prior to rendering. That should only take several lines of code in C, Java or Python. Would that work for you?

Cheers, 
Mikhail

Mikhail Kozhevnikov

unread,
Apr 16, 2012, 11:29:17 AM4/16/12
to indigo-...@googlegroups.com, Gabriel Simon
Try running this before rendering: 
for g in [g for g in mol1.iterateSuperatoms()]:
g.remove()

And thanks for reporting the crash! It looks like a bug, we'll fix it shortly.

Cheers,
Mikhail
Reply all
Reply to author
Forward
0 new messages