Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Obtain the WASM Version of Indigo Toolkit for Web Use? #2360

Open
SeungyulOh opened this issue Sep 12, 2024 · 7 comments
Open

How to Obtain the WASM Version of Indigo Toolkit for Web Use? #2360

SeungyulOh opened this issue Sep 12, 2024 · 7 comments

Comments

@SeungyulOh
Copy link

Is it possible to convert the Indigo Toolkit to WebAssembly (WASM) for use on the web? I couldn't find any information related to WASM on the download page, but from the issues section, it seems like the Indigo Toolkit is being used in WASM format within Ketcher. How can I obtain the WASM-converted version of the Indigo Toolkit?

@SeungyulOh
Copy link
Author

image

#2359

@even1024
Copy link
Collaborator

You can build it from the source code. There is an instruction here: https://github.com/epam/Indigo/blob/master/README.md
Check "How to build Indigo-WASM" section.

@AliaksandrDziarkach
Copy link
Collaborator

You can get it from NPM repository - https://www.npmjs.com/package/indigo-ketcher

@SeungyulOh
Copy link
Author

SeungyulOh commented Sep 23, 2024

You can get it from NPM repository - https://www.npmjs.com/package/indigo-ketcher

The package does not include all the features I need. For example, I want to declare an IndigoObject and implement the functionality to directly add atoms and bonds, as shown in the addAtom function.
indigo.h

I have been able to use these functions successfully in Python, but I am curious if it is possible to use these features, such as the ones in [indigo.h] on the web.

@SeungyulOh
Copy link
Author

You can build it from the source code. There is an instruction here: https://github.com/epam/Indigo/blob/master/README.md Check "How to build Indigo-WASM" section.

I was planning to try this approach. Specifically, I want to convert the indigo module and the indigo-render module into WebAssembly (WASM). Is this possible? From the instructions, it seems like only the contents in the indigo-ketcher folder are supported, and when I tried it, I was able to convert the contents of the indigo-ketcher folder into WASM. However, my goal is to use the indigo module and indigo-render module on the web.

Indigo module
Indigo-renderer module

@even1024
Copy link
Collaborator

"I want to convert the indigo module and the indigo-render module into WebAssembly (WASM)." - you can do that without a special wrapper which exports API to WASM. And you can see such wrapper in the indigo-ketcher. It exports the following list of functions to WASM:

EMSCRIPTEN_BINDINGS(module)
{
    emscripten::function("version", &version);
    emscripten::function("versionInfo", &versionInfo);
    emscripten::function("convert", &convert);
    emscripten::function("convert_explicit_hydrogens", &convert_explicit_hydrogens);
    emscripten::function("aromatize", &aromatize);
    emscripten::function("dearomatize", &dearomatize);
    emscripten::function("layout", &layout);
    emscripten::function("clean2d", &clean2d);
    emscripten::function("automap", &automap);
    emscripten::function("check", &check);
    emscripten::function("calculateCip", &calculateCip);
    emscripten::function("calculate", &calculate);
    emscripten::function("render", &render);
    emscripten::function("reactionComponents", &reactionComponents);

    emscripten::register_vector<int>("VectorInt");
    emscripten::register_map<std::string, std::string>("MapStringString");
};

If you want more functionality, you have to extend indigo-ketcher.cpp. There is no way to use indigo and indigo-renderer modules without an indigo-ketcher.cpp wrapper class. You will meet the same situation with any C++ library - you need a special wrapper to export what you need.

@SeungyulOh
Copy link
Author

"I want to convert the indigo module and the indigo-render module into WebAssembly (WASM)." - you can do that without a special wrapper which exports API to WASM. And you can see such wrapper in the indigo-ketcher. It exports the following list of functions to WASM:

EMSCRIPTEN_BINDINGS(module)
{
    emscripten::function("version", &version);
    emscripten::function("versionInfo", &versionInfo);
    emscripten::function("convert", &convert);
    emscripten::function("convert_explicit_hydrogens", &convert_explicit_hydrogens);
    emscripten::function("aromatize", &aromatize);
    emscripten::function("dearomatize", &dearomatize);
    emscripten::function("layout", &layout);
    emscripten::function("clean2d", &clean2d);
    emscripten::function("automap", &automap);
    emscripten::function("check", &check);
    emscripten::function("calculateCip", &calculateCip);
    emscripten::function("calculate", &calculate);
    emscripten::function("render", &render);
    emscripten::function("reactionComponents", &reactionComponents);

    emscripten::register_vector<int>("VectorInt");
    emscripten::register_map<std::string, std::string>("MapStringString");
};

If you want more functionality, you have to extend indigo-ketcher.cpp. There is no way to use indigo and indigo-renderer modules without an indigo-ketcher.cpp wrapper class. You will meet the same situation with any C++ library - you need a special wrapper to export what you need.

If I want to use a function like indigoAddAtom in WASM, my understanding is that I need to create a corresponding wrapper function("new_function") in indigo-ketcher.cpp and then add it like this:

EMSCRIPTEN_BINDINGS(module)
{
    ...
    emscripten::function("new_function", &new_function);
};

Is this correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants