How to render chemical reactions in Windows Forms?

2.5k views Asked by At

How can I represent chemical reactions in windows form? I am using c# language. It is possible to represent mathematical formulas using mimetxt.dll, but what about chemical reactions?

In short, I want to represent on win forms 2H2 + O2 = 2H2O and complex forms in proper format like:

enter image description here

How can I achieve this?

5

There are 5 answers

3
Phil Wright On

This is not really the kind of simple question that is likely to get a good answer.

Someone who is working in the chemistry field might know of a helper library that can be used to draw these kinds of diagrams. But you need to hope someone with that specialist knowledge exists and notices your question. Alternatively you are going to have to write all the code yourself and given you want to represent arbitrarily complex diagrams this is a non-trivial task.

I recommend trying to find commercial software for drawing diagrams and asking those companies if you can draw what you need. Companies such as Dundas and SoftwareFX are worth trying first. Also try looking at commercial applications used in the chemical industries to see if anyone else draws these things and see if you can ask them how they did it.

0
Mike On

This may be too late for your purposes, but I've been using OpenBabel with great success. I've been able to convert between Canonical SMILES, SDF files, etc. to PNG and SVG formats. (Shameless plug) An example of it in action using the IPython notebook can be found on my blog. It's in C++, but has Python bindings, too.

0
Mike Williams On

We have an open source application known as Chem4Word. In that we are displaying structures in a windows form via a WPF user control.

If you take a look in our GitHub repository at https://github.com/Chem4Word/Version3 you will find a windows forms application which we use for initial testing which can display structure from molfile. Open the main Chem4Word solution there is a test harness folder in which the app lives, set that as the start up project to have a play with it.

1
Xiaojun Ji On

There are some commercial products that can meet your requirement. However, if you are looking for open source solutions, like most chemists do, here are some recommendations based on my own experiences.

Since you are using .NET, Indigo toolkit from GGA software is a good choice. http://www.ggasoftware.com/opensource/indigo It has a very easy-to-read API documentation with a lot of examples. The rendering module of Indigo can render pictures of molecules and reactions from various file formats (SMILES, mol, sdf, rdf, rxn, etc...) with very good quality. I believe it can meet most of your requirements on rendering a chemical reaction.

I myself have been using OpenBabel for quite awhile. It is also a very good development tool for cheminformatics. It is written in C++ and has a .NET binding too. Some of the advanced functions are not included in the NET version of library but I am pretty sure that the rendering module is included. The quality of the picture is as good as Indigo but the API document is not so user friendly. In addition, you need to install the whole package before you can use it. If you are developing a Webform application using ASP.NET, you may have authorization problem accessing local codes on server side. I have to say, it is a pain in the *.

There is also Chemaxon software can do the rendering work for you too. It is commercial software, but some basic function such as rendering a reaction is free. It is based on Java but has a NET binding. The API documentation is OK. Of course, you need to install java on you computer.

0
tony yuan On