Skip to content

amitsetty/Kekule.js

 
 

Repository files navigation

Kekule.js

Kekule.js is an open source JavaScript toolkit for chemoinformatics released under MIT license. It can be used in both web applications and node applications to read, write, display and edit chemical objects (e.g. molecules) and to perform some chemical algorithms (e.g. molecule structure comparing, searching, aromatic detection).

More details about this project can be found in Kekule.js website.

Installation

For web applications, Kekule.js can be used in a traditional way by simply including it in the HTML page with <script> tag:

<script src="kekule.js?module=io,chemWidget,algorithm"></script>

Note the module param after "?". In the example above, module io, chemWidget and algorithm, as well as other prerequisite modules will be loaded.

If widget or chem widget modules are used, additional style sheet file also need to be linked in HTML page:

<link rel="stylesheet" type="text/css" href="themes/default/kekule.css" />

The whole package can also be installed by npm in both web and node applications:

$ npm install kekule

In Node or Webpack environment, the Kekule namespace should be imported into the application:

var Kekule = require('kekule').Kekule;

After installation (in web or in node.js environment), you can run a small test to ensure that the toolkit works properly:

// Create a simple CO2 molecule
var mol = new Kekule.Molecule();
var atomC = mol.appendAtom('C');
var atomO1 = mol.appendAtom('O');
var atomO2 = mol.appendAtom('O');
mol.appendBond([atomC, atomO1], 2);
mol.appendBond([atomC, atomO2], 2);

// Get formula
var formula = mol.calcFormula();
console.log('Formula: ', formula.getText());

// Output SMILES (IO module should be loaded in web application)
var smiles = Kekule.IO.saveFormatData(mol, 'smi');
console.log('SMILES: ', smiles);

// Output MOL2k (IO module should be loaded in web application)
var mol2k = Kekule.IO.saveFormatData(mol, 'mol');
console.log('MOL 2000: \n', mol2k);

Dynamic Module Loading

The Kekule.js package is divided into several independent modules. Instead of loading all of them at the beginning, a dynamic loading approach can be used for better performance in both web and Node environment. For example:

Kekule.modules(['algorithm', 'calculation'], function(error) {
    if (!error)
    {
        // algorithm and calculation modules loaded successfully, functions can be used now.
    }
});

Documentations and Demos

A set of tutorials and demos are built to explain the basic operations in Kekule.js (e.g. creating molecule, loading and saving chemical objects, getting molecule information and usage of chem widgets).

The full API documents can be found here.

License

The toolkit is released under MIT license.

About

A web based chemoinformatics library written in JavsScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 62.3%
  • HTML 28.2%
  • CSS 7.0%
  • PHP 2.2%
  • Python 0.2%
  • Makefile 0.1%