rdkit in javascript

I think this project is very cooooooooool. ;-)

This project is trying to convert c++ to javascript using emscripten.
Emscripten is an LLVM-based project that compiles C and C++ into highly-optimizable JavaScript in asm.js format.
So, if rdkit.js works well, I can write chemoinformatic function using only javascript.
It’s sounds nice.
I tried it.
I build rdkit.js by myself. But, if you installed nodejs and npm, you can latest version of rdkit.js from https://www.npmjs.com/package/rdkit.

I wrote very simple sample.
I used flask.
Like …..

iwatobipen$ tree
├── __init__.py
├── app.py
├── static
│   └── rdkit.js
└── templates
    └── top.html



from flask import Flask
from flask import render_template

app = Flask(__name__)

def toppage():
    return render_template('top.html')

if __name__ == '__main__':
    app.run(debug = True)


<script type='text/javascript' src='/static/rdkit.js'></script>
function molwt( smi ){
	var mol = RDKit.Molecule.fromSmiles( smi );
	var mw = mol.getMW();
	alert( mw );


<h>rdkitjs test</h><br><br>

<form name='chemo'>
    Input smilestrings;<br> 
    	<input type='text' name='smi'>
    calc molwt<br>
    	<input name='calc' value='cal' type='button' onClick='molwt( document.chemo.smi.value )'>

It’s ready.
Now type ‘python app.py’ and access
And input some smilestrings, and push the button.
I got following response.
Screen Shot 2015-05-21 at 10.53.40 PM
Yah! Great!
Lots of function can use in the library.
I uploaded the code to github.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.