Possible to generate png from SMILES without using the GUI

Hi,

I have a project where i need to generate nice looking molecule images
from preferable SMILES format, other similar formats could be OK as
input. In the avogadro gui its possible to do exactly this, but the
problem is that it requires several manual step and for the amount of
molecules i need to generate it will be too cumbersome. From searching
the avogadro wiki i cant find that it exist any cli that would alow me
to do this, but i have found that there is python bindings that support
automatize some operation. Would it be possible to to this from python
using libavogadro?
I have testet the python example in avogadro github repository
"avogadro/libavogadro/examples/python/standalone.py" by using this it
looks likes it possible automatize the first part - loading the
molecule, but I cant see any possibility to export this in the api, is
it missing or is it just me not looking after it in the correct place?
If its not yet possible to export with the api, would adding that
feature be hard? and where in the code should i start to look to do it?

Regards,
Simon

Hi,

On Wed, Jan 9, 2013 at 9:08 PM, Simon Norberg simon@dackbrann.net wrote:

Hi,

I have a project where i need to generate nice looking molecule images
from preferable SMILES format, other similar formats could be OK as
input. In the avogadro gui its possible to do exactly this, but the
problem is that it requires several manual step and for the amount of
molecules i need to generate it will be too cumbersome. From searching
the avogadro wiki i cant find that it exist any cli that would alow me
to do this, but i have found that there is python bindings that support
automatize some operation. Would it be possible to to this from python
using libavogadro?
I have testet the python example in avogadro github repository
"avogadro/libavogadro/examples/python/standalone.py" by using this it
looks likes it possible automatize the first part - loading the
molecule, but I cant see any possibility to export this in the api, is
it missing or is it just me not looking after it in the correct place?
If its not yet possible to export with the api, would adding that
feature be hard? and where in the code should i start to look to do it.

Avogadro uses OpenBabel for this (http://openbabel.org). It supports batch
conversions for files using the (o)babel program. If you have Avogadro
installed, this is most likely installed on your system too.

babel mysmiles.smi foo.png -m

The -m option turns the multi-molecule file into seperate png files
(foo1.png, foo2.png, …). There is also support for SVG output.

Hope this helps,
Tim

Regards,
Simon


Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only – learn more at:
http://p.sf.net/sfu/learnmore_122412


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-devel

Avogadro uses OpenBabel for this (http://openbabel.org). It supports
batch conversions for files using the (o)babel program. If you have
Avogadro installed, this is most likely installed on your system too.

babel mysmiles.smi foo.png -m

The -m option turns the multi-molecule file into seperate png files
(foo1.png, foo2.png, …). There is also support for SVG output.

Hope this helps,
Tim
Hi Tim,
Thansk for the hint, but I guess I didn’t specify what i meant with nice
looking images Avogadro generates well enough, the image i want to
create is a image of a 3d molecule. Similar to what you export from
avogadro when you choose to export a PNG.
OpenBabel is only able to generate 2d text based image AFAIK. One
possibility i have tested is to use OpenBabel to generate a .pdb file
and then use raster3D to generate a 3d molecule image.
The image raster3d generate isn’t as nice as avogadros, and i have a
hard time to render a atom of constant size. I want to have a Carbon
atom to be the same size in pixels regardless of generating a simple CO
or a more complex molecule. I dont know if avogadro supports this
either, but at least if i could hack a python script i might be able to
fix it myself in avogadro.

Regards,
Simon

On Tue, Jan 15, 2013 at 11:32 AM, Simon Norberg simon@dackbrann.net wrote:

Avogadro uses OpenBabel for this (http://openbabel.org). It supports
batch conversions for files using the (o)babel program. If you have
Avogadro installed, this is most likely installed on your system too.

babel mysmiles.smi foo.png -m

The -m option turns the multi-molecule file into seperate png files
(foo1.png, foo2.png, …). There is also support for SVG output.

Hope this helps,
Tim
Hi Tim,
Thansk for the hint, but I guess I didn’t specify what i meant with nice
looking images Avogadro generates well enough, the image i want to
create is a image of a 3d molecule. Similar to what you export from
avogadro when you choose to export a PNG.
OpenBabel is only able to generate 2d text based image AFAIK. One
possibility i have tested is to use OpenBabel to generate a .pdb file
and then use raster3D to generate a 3d molecule image.
The image raster3d generate isn’t as nice as avogadros, and i have a
hard time to render a atom of constant size. I want to have a Carbon
atom to be the same size in pixels regardless of generating a simple CO
or a more complex molecule. I dont know if avogadro supports this
either, but at least if i could hack a python script i might be able to
fix it myself in avogadro.

Avogadro doesn’t have that level of control from the command line, the
Python bindings might be enough to allow you to accomplish what you
need (and I remember Tim writing some blog posts about doing similar
things there).

Thanks,

Marcus