NodeJS/TypeScript Port of InChI 1.06
How to use this library?
Using the library in your source code.
- This library has a dependency on ffi-napi so you may need to install some necessary build tools for it to work.
- Alternately, you can also use Docker to automatically set up your dev environment with required dependencies. Here's the Dockerfile that we are using for the same.
Running a JSON-RPC 2.0 server.
- This library exposes a Docker image which you can run to spin off a JSON-RPC 2.0 server.
- You can interact with that server from your source code by making a HTTP
POST
request.
- The request's
body
should be JSON-RPC 2.0 compliant. For e.g.,
{
"jsonrpc": "2.0",
"method": "GetStringLength",
"params": ["my-string"],
"id": 1
}
- The response can look like:
{
"jsonrpc": "2.0",
"id": 1,
"result": 9
}
- In case of an error, the response can look like:
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"message": "Expected 1 arguments, got 2",
"code": -32602
}
}
API Porting Status
We are slowly working towards exposing all the InCHI functions. PRs welcome.
A. Generation of InChI from structure
B. Generation of InChI from structure, step-by-step way
C. Generation of InChI directly from Molfile
D. Restoring structure from InChI or AuxInfo
E. InChIKey
F. Test and utlity procedures
G. Status Objects
H. Molecule Objects
I. InChI Builder Objects
J. InChIKey Builder Objects
Contributors' Notes
Intro
- This library is a NodeJS/TypeScript port of InChI 1.06. API documentation of the original C based library is present here. Derived some inspiration from smikes/inchi.
- The Shared Object file,
libinchi.so.1.06.00
, contains all the InChI related business logic, is installed from InChITRUST, and is licensed under IUPAC/InChI Trust Licence.
Which porting approach is used?
- Here's a cool overview of integrating native modules with NodeJS applications: N-API - The new native in Node.JS by Atishay Jain.
- This library uses foreign function interface to access the native InChI module. The decision was mainly taken to achieve an ease of development that ffi provides as compared to using nan, Node-API, or node-addon-api.
- One can port the InChI library using the above tools also. These examples may provide you a good idea on how to move forward.
- For using ffi, 2 libraries were considered: ffi and ffi-napi.
ffi-napi
was adopted because it supports the latest/recent versions of NodeJS; it is tested to run on Node 6 and above, whereas ffi
is only tested to run on Node v0.6, v0.8, v0.9 and v0.10.
- You can learn more about
ffi-napi
/ffi
via this tutorial.
How are the types
ported?
- Information given in this tutorial was used.
- But for compliance with N-API, different type-mapping libraries were used as compared to what's prescribed in the above tutorial.
- Here's some detailed docs on how to use the
ref
/ref-napi
modules.
- For mapping Enums, enum is used.