rdkit-js icon indicating copy to clipboard operation
rdkit-js copied to clipboard

Add reactions drawing examples

Open MichelML opened this issue 3 years ago • 6 comments

MichelML avatar Jun 23 '22 14:06 MichelML

Is this already possible? I'd love to use this feature.

willfinnigan avatar Jan 16 '23 16:01 willfinnigan

This features looks like it is low priority for RDKit.js, so I'm currently using python to generate the image in the backend and then feeding that to the web UI as a media asset: https://www.rdkit.org/docs/GettingStartedInPython.html#drawing-chemical-reactions

Non-ideal and puts extra load on the backend, but I don't see any easier route yet (aside from splitting the reaction up and rendering each component individually)

jacksund avatar May 12 '24 16:05 jacksund

Splitting it up and manually joining the pieces together with svg2 is what I ended up doing. I could do with finding the time to make the arrow a bit nicer, but its functional for now.

Screenshot 2024-05-13 at 10 46 38

I did used to render on the server, but I wanted to make a totally client side version.

willfinnigan avatar May 13 '24 09:05 willfinnigan

RDKit JS can render reactions, it's just not documented. E.g. something like:

const rdkit = await window.initRDKitModule()
const rxn = rdkit.get_rxn(smiles)
const svg = rxn.get_svg(width, height) 

molhanec avatar May 13 '24 11:05 molhanec

That's awesome!

However to my eye the reaction drawing doesn't look as nice as the stand alone molecules

Screenshot 2024-06-29 at 17 32 09

willfinnigan avatar Jun 29 '24 16:06 willfinnigan