Skip to content

Commit

Permalink
#1959 Preview: Saved in the Ketcher IDT file should be opened
Browse files Browse the repository at this point in the history
Fix monomer library load and parse.
Add UT.
  • Loading branch information
AliaksandrDziarkach committed May 23, 2024
1 parent b15b3f6 commit 883cb7c
Show file tree
Hide file tree
Showing 6 changed files with 169,990 additions and 23 deletions.
32 changes: 26 additions & 6 deletions api/wasm/indigo-ketcher/indigo-ketcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,18 +440,38 @@ namespace indigo
std::string convert(const std::string& data, const std::string& outputFormat, const std::map<std::string, std::string>& options)
{
const IndigoSession session;
indigoSetOptions(options);
std::map<std::string, std::string> options_copy = options;
if (outputFormat.find("smarts") != std::string::npos)
std::map<std::string, std::string> options_copy;
for (const auto& option : options)
{
options_copy["query"] = "true";
if (option.first != "monomerLibrary")
{
options_copy[option.first] = option.second;
}
}

auto monomerLibrary = options.find("monomerLibrary");
if (monomerLibrary != options.end() && monomerLibrary->second.size())
{
options_copy["monomerLibrary"] = "";
IndigoKetcherObject iko = loadMoleculeOrReaction(monomerLibrary->second, options_copy);
const char* ignore_stereo_option = "ignore-stereochemistry-errors";
std::map<std::string, std::string> options_lib = options_copy;
options_lib["input-format"] = "chemical/x-indigo-ket";
options_lib[ignore_stereo_option] = "true";
indigoSetOptions(options_lib);
IndigoKetcherObject iko = loadMoleculeOrReaction(monomerLibrary->second, options_lib);
auto ignore_stereo = options.find(ignore_stereo_option);
if (ignore_stereo == options.end())
{
// no ignore stereo erros option set - should reset to default "false"
options_lib[ignore_stereo_option] = "false";
indigoSetOptions(options_lib);
}
}

if (outputFormat.find("smarts") != std::string::npos)
{
options_copy["query"] = "true";
}
indigoSetOptions(options);
IndigoKetcherObject iko = loadMoleculeOrReaction(data, options_copy);
return iko.toString(options, outputFormat.size() ? outputFormat : "ket");
}
Expand Down
2 changes: 1 addition & 1 deletion api/wasm/indigo-ketcher/test/idt_maxmgc.ket

Large diffs are not rendered by default.

Loading

0 comments on commit 883cb7c

Please sign in to comment.