diff --git a/api/wasm/indigo-ketcher/indigo-ketcher.cpp b/api/wasm/indigo-ketcher/indigo-ketcher.cpp index c54f698ed8..85c697b6e0 100644 --- a/api/wasm/indigo-ketcher/indigo-ketcher.cpp +++ b/api/wasm/indigo-ketcher/indigo-ketcher.cpp @@ -423,6 +423,7 @@ namespace indigo if (objectId >= 0) return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); } + if (use_document) { print_js("try as document"); @@ -514,6 +515,16 @@ namespace indigo } } exceptionMessages.emplace_back(indigoGetLastError()); + + // Let's try a simple molecule + print_js("try as molecule"); + objectId = indigoLoadMoleculeFromBuffer(data.c_str(), data.size()); + if (objectId >= 0) + { + return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); + } + exceptionMessages.emplace_back(indigoGetLastError()); + // Let's try query molecule print_js("try as query molecule"); objectId = indigoLoadQueryMoleculeFromBuffer(data.c_str(), data.size()); @@ -530,15 +541,6 @@ namespace indigo return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETReactionQuery); } - // Let's try a simple molecule - print_js("try as molecule"); - objectId = indigoLoadMoleculeFromBuffer(data.c_str(), data.size()); - if (objectId >= 0) - { - return IndigoKetcherObject(objectId, IndigoKetcherObject::EKETMolecule); - } - exceptionMessages.emplace_back(indigoGetLastError()); - // Let's try reaction print_js("try as reaction"); objectId = indigoLoadReactionFromBuffer(data.c_str(), data.size()); @@ -707,6 +709,27 @@ namespace indigo return _checkResultString(indigoCheckObj(iko.id(), properties.c_str())); } + std::string pka(const std::string& data, const std::map& options) + { + const IndigoSession session; + const auto iko = loadMoleculeOrReaction(data.c_str(), options); + return std::to_string(indigoPka(iko.id())); + } + + std::string logp(const std::string& data, const std::map& options) + { + const IndigoSession session; + const auto iko = loadMoleculeOrReaction(data.c_str(), options); + return std::to_string(indigoLogP(iko.id())); + } + + std::string molarRefractivity(const std::string& data, const std::map& options) + { + const IndigoSession session; + const auto iko = loadMoleculeOrReaction(data.c_str(), options); + return std::to_string(indigoMolarRefractivity(iko.id())); + } + std::string calculateCip(const std::string& data, const std::string& outputFormat, const std::map& options) { const IndigoSession session; @@ -1149,7 +1172,9 @@ namespace indigo emscripten::function("calculateMacroProperties", &calculateMacroProperties); emscripten::function("render", &render); emscripten::function("reactionComponents", &reactionComponents); - + emscripten::function("pka", &pka); + emscripten::function("logp", &logp); + emscripten::function("molarRefractivity", &molarRefractivity); emscripten::register_vector("VectorInt"); emscripten::register_map("MapStringString"); }; diff --git a/api/wasm/indigo-ketcher/test/test.js b/api/wasm/indigo-ketcher/test/test.js index 33a32975e7..ff819b3aea 100644 --- a/api/wasm/indigo-ketcher/test/test.js +++ b/api/wasm/indigo-ketcher/test/test.js @@ -1263,6 +1263,36 @@ M END }); } + { + test("calculate pka", "PKa", () => { + let options = new indigo.MapStringString(); + let pka = indigo.pka('C([C@@H](C(=O)O)N)S', options); + assert.equal(pka.toString(), '4.006667'); + options.delete(); + assert(true); + }); + } + + { + test("calculate LogP", "LogP", () => { + let options = new indigo.MapStringString(); + let pka = indigo.logp('C([C@@H](C(=O)O)N)S', options); + assert.equal(pka.toString(), '-0.671900'); + options.delete(); + assert(true); + }); + } + + { + test("molar refractivity", "molarRefractivity", () => { + let options = new indigo.MapStringString(); + let pka = indigo.molarRefractivity('C([C@@H](C(=O)O)N)S', options); + assert.equal(pka.toString(), '29.464200'); + options.delete(); + assert(true); + }); + } + // Run tests run(); });