extract MOL data

25 views
Skip to first unread message

Angel

unread,
Sep 30, 2010, 4:41:40 AM9/30/10
to kemia-discuss
Hello

Kemia looks very promising for me. Looking at the SMILES demo page I
have found how to feed Kemia with a SMILES string.
What I would also like is to extract the molecule data (in MOL format)
from Kemia into a Javascript variable.
Any help will be appreciated

Paul Novak

unread,
Sep 30, 2010, 11:52:09 AM9/30/10
to kemia-...@googlegroups.com
Hi Angel,

Glad you like it.  I'd love to hear any comments you have and what parts of it you find useful.

To convert from a kemia.model.Molecule to MOL format, you want the kemia.io.mdl.writeMolfile method.

For example, you could alter the promptHandler method of the SMILES demo to display an alert displaying the molfile by adding the code below (in bold):

var promptHandler = function(smiles) {
  if (smiles != null) {
    var timer = goog.now();
    var mol=kemia.io.smiles.SmilesParser.parse(smiles);
    kemia.layout.CoordinateGenerator.generate(mol);
    mol_renderer.setModels([mol]);
    goog.dom.setTextContent(goog.dom.getElement('perf'), (goog.now() - timer) + 'ms');

    var model = mol_renderer.getModels()[0];
    var mol_block = kemia.io.mdl.writeMolfile(model);
    alert(mol_block);
  }
}

Does this answer your question?  Thanks for trying kemia!

Regards,

Paul.

Angel

unread,
Sep 30, 2010, 3:00:22 PM9/30/10
to kemia-discuss
Thanks, Paul!

>      var mol_block = kemia.io.mdl.writeMolfile(model);

Yes, thats looks like what I need . I'll give it a try and let you
know.

Another thing I'm interested on is localization of the interface. I
have found a way to do it with some changes in the kemia.js file. It
seems to work, but I've broken the ability to draw a molecule.

Problem is I have never used GIT. We'll see.

More later on

Paul

unread,
Oct 1, 2010, 12:00:28 PM10/1/10
to kemia-discuss
Hi Angel,

Localization is something we plan to do eventually. I created a
ticket for it at http://kemia.lighthouseapp.com/projects/58696-kemia/tickets/75-interface-localization.
Feel free to create new tickets for any other things you think Kemia
needs.

It would be really great if you could share any translations you come
up with.

Git is a little different from centralized version-control such as CVS
or SVN--but definitely worth getting acquainted with. Hacking on the
compiled javascript is going to be difficult, if you want to get into
it, I suggest forking on github (as described below), making changes
and then re-compiling per the instructions in the README file.

Here is a guide to the Kemia development team workflow,
http://github.com/kemia/kemia/wiki/Contributor-Workflow-with-Github.
One of the benefits of forking to your own github repository is that
you can make changes and share them for discussion with the team even
if they are not ready to merge with the 'production' code. Just
'push' your local changes to your fork on github so everyone can see
it, as described under 'Interim Publish to Your Fork' (This would be a
good way to share your translations.)

To re-compile, the easiest way is to follow the steps in the kemia/
README using ant.

Regards,

Paul.

Angel

unread,
Oct 4, 2010, 3:07:20 PM10/4/10
to kemia-discuss
Ok, I've got something working. If you are interested, see
http://biomodel.uah.es/en/DIY/Kemia/

The interface to Kemia Renderer ("v.10" link) is working.
With the Kemia Editor ("v.11"), I broke something so it does not allow
drawing right now. But the javascript input/output works and I could
translate the interface.

I don't have the time and effort now to learn to use GIT. And my
ability to use Ant (from inside Eclipse) is very limited.
I will be happy to contribute the Spanish translations when you
implement the means.

I have observed that the current kemia-whitespace-only.js used in the
demo pages relies on external files coming from another server (images
for the toolbar, at least). This is highly undesirable in my opinion,
as it makes portability hard. I am also interested in developing
applications that run offline. I understand that Kemia is at an early
stage, but I will place a ticket regarding this anyway.

Thanks again for showing and offering this product!



Paul

unread,
Oct 4, 2010, 3:16:48 PM10/4/10
to kemia-discuss
Hi Angel,

This is awesome, thanks for sharing! I will see if I can figure out
why drawing is not working. Thanks for offering to contribute to
translations when the time comes.

Regards,

Paul.

On Oct 4, 3:07 pm, Angel <complute...@gmail.com> wrote:
> Ok, I've got something working. If you are interested, seehttp://biomodel.uah.es/en/DIY/Kemia/

Angel

unread,
Oct 4, 2010, 3:33:31 PM10/4/10
to kemia-discuss
On 4 oct, 21:16, Paul <nova...@gmail.com> wrote:
> This is awesome, thanks for sharing!  I will see if I can figure out
> why drawing is not working.  

Don't worry too much. I was messing up with the .js file. Probably
stepped over something. The copy of the demo page works fine.

Angel

unread,
Oct 6, 2010, 3:14:23 PM10/6/10
to kemia-discuss
My problem wiht the editor seems to be related to the removal of the
initial loading of a reaction drawing. If I put that back, I can draw
new atoms.

How can I start with an empty editor?

Paul

unread,
Oct 6, 2010, 3:28:45 PM10/6/10
to kemia-discuss
The way you are doing it is fine, it *should* have worked.

There is also a .clean() method you could call to clear the editor,
but I think the problem is that so far the editor has been mainly used
to edit reactions, and render molecules, but not edit single
molecules. In other words the toolbar plugins are assuming a
reaction, not a molecule. In other words, this is a bug. Thanks for
finding it. :)

I have created a ticket at
http://kemia.lighthouseapp.com/projects/58696-kemia/tickets/89-editor-should-be-able-to-edit-single-molecules-outside-of-a-reaction.

Regards,

Paul.
Message has been deleted

Paul

unread,
Oct 6, 2010, 3:54:04 PM10/6/10
to kemia-discuss
You can call the editor's .clear() method. But that will initialize
the editor with a reaction object, not a molecule.

Paul

unread,
Oct 14, 2010, 11:08:40 AM10/14/10
to kemia-discuss
Angel,

There is now a molecule editor demo at http://kemia.github.com/demos/2010/10/12/molecule-editor.html
that should help you get kemia to do what you want. It also has a
molecule-appropriate toolbar without plus and arrow buttons.
Unfortunately, you would have to re-do the English-Spanish translation
substitutions until we get localization set up.

Regards,

Paul.
Reply all
Reply to author
Forward
0 new messages