Closed bergwerf closed 4 years ago
I am also looking into https://github.com/metamolecular/inchi-js
Hi @bergwerf, I have updated InChI.js in the repo to include a wrapper function to calculate InChI Key from InChI string:
// use script file inchi.js first
var module = InChIModule();
var molToInChIJson = module.cwrap('molToInchiJson', 'string', ['string', 'string']);
var getInChIKeyJson = module.cwrap('getInChIKeyJson', 'string', ['string', 'number', 'number']);
var molData = '.......'; // suppose we have MOL format file data here
// get InChI from MOL data
var inchiJson = JSON.parse(molToInChIJson(molData, ''));
// get InChI Key from InChI
var inchiKeyJson = JSON.parse(getInChIKeyJson(inchiJson.inchi, 1, 1)); // get key and xtra1, xtra2 block
if (inchiKeyJson.success)
console.log(inchiKeyJson.inchiKey, inchiKeyJson.xtra1, inchiKeyJson.xtra2);
Awesome! Thank you for your effort.
It looks like you know quite a bit better than me how to work with the InChI C library :) (and how to get it to compile to JavaScript). Could you help me with adding a function to also obtain an InChIKey?