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

Use rdkit-js as vanilla.js without wasm module #272

Open
ninabina921 opened this issue Nov 30, 2022 · 9 comments
Open

Use rdkit-js as vanilla.js without wasm module #272

ninabina921 opened this issue Nov 30, 2022 · 9 comments

Comments

@ninabina921
Copy link

Do you have a version of rdkit-js that is strictly javascript that does not require a wasm-module? I currently use smiles-drawer, however it lacks many features that rdkit-js has.

@MichelML
Copy link
Collaborator

@ninabina921 unfortunately this is not possible as rdkit-js is built on top of the main rdkit package which is built in C++ and python, wasm is the necessary building block to offer rdkit in javascript, I will close this but feel free to comment with additional thoughts if this doesn't answer your question 👍

Smiles-drawer is an alternative like you said, but it's indeed less powerful and flexible

@ptosco
Copy link

ptosco commented Dec 19, 2022

@ninabina921 In case this is still of interest, here:
https://github.com/rdkit/rdkit-structure-renderer/blob/master/public/RDKit_minimal_plainJs.1.1.11.js
you may find a vanilla JS version of the RDKit MinimalLib, which was compiled to plain JS with emscripten.

@MichelML MichelML reopened this Dec 19, 2022
@MichelML
Copy link
Collaborator

MichelML commented Dec 19, 2022

@ptosco this is so great! Could we adapt the dockerfile to output the fully js-compiled file? What are the caveats compared to the wasm module approach? https://github.com/rdkit/rdkit-js/blob/master/Dockerfile . An example of your emscripten config to achieve this would be greatly appreciated. Any additional explanation would be more than welcome.

This is a big update and I think will allow newcomers to get started and use the library more easily since having a single js file makes it way more easy to import rdkit-js in modern front-end stacks.

Please give more context here, and if it's mature enough, I'll be happy to release the lib with the fully compiled js version.

Merry Christmas in advance!

@ptosco
Copy link

ptosco commented Dec 19, 2022

Yes, we can. Well, the main drawback is that performance is worse. The main plus is that it can be used in headless browsers like PhantomJS and Puppeteer.

@MichelML
Copy link
Collaborator

@ptosco can you share an example of the build command you use for that, basically an alternative to https://github.com/rdkit/rdkit-js/blob/master/Dockerfile#L50 to generate the vanilla js output?

@ptosco
Copy link

ptosco commented Dec 20, 2022

@MichelML You only need to add the following CMAKE_EXE_LINKER_FLAGS: --memory-init-file 0 -s WASM=0.

@MichelML
Copy link
Collaborator

Thank you, will try that!

@bugzpodder
Copy link

bugzpodder commented Apr 2, 2023

just trying to integrate the react version into nextjs and wasnt fun

  • adding the @rdkit/rdkit package (pretty standard)
  • Add a copy pasted version of MoleculeStructure. wish this can just be exported as part of the react package
  • Add initRDKit function that MoleculeStructure uses into my codebase
  • Copy RDKMinimal.{js|wasm} from node_module into public/
  • Add a script tag to the app to load RDK_Minimal.js into the app

I think what's in the README and the doc site isn't nearly enough to encapsulate these steps. Even when the demo react example is working it took some reverse engineering to actually get to the steps above ^^

@MichelML
Copy link
Collaborator

MichelML commented Apr 2, 2023

Thanks for the feedback @bugzpodder , this is something we are aware of. If you feel confident enough to make a PR to (minimally) improve the documentation based on your experience integrating the package in a react app, please help us make this project better 🙏 . Otherwise, I'll do it in a near future 👍 .

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

4 participants