partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
248 stars 61 forks source link

Embedding RXN format #227

Closed registerme1963 closed 3 years ago

registerme1963 commented 3 years ago

I'm trying to embed RXN or RXN V3000 format as inline source. but the reaction is not displayed. The following is the rxn v3000 data

`$RXN V3000 ACS Document 1996 ChemDraw06082119112D

M V30 COUNTS 1 1 M V30 BEGIN REACTANT M V30 BEGIN CTAB M V30 COUNTS 6 6 0 0 0 M V30 BEGIN ATOM M V30 1 C -0.714471 0.412500 0.000000 0 M V30 2 C -0.714471 -0.412500 0.000000 0 M V30 3 C 0.000000 -0.825000 0.000000 0 M V30 4 C 0.714471 -0.412500 0.000000 0 M V30 5 C 0.714471 0.412500 0.000000 0 M V30 6 C 0.000000 0.825000 0.000000 0 M V30 END ATOM M V30 BEGIN BOND M V30 1 2 1 2 M V30 2 1 2 3 M V30 3 2 3 4 M V30 4 1 4 5 M V30 5 2 5 6 M V30 6 1 6 1 M V30 END BOND M V30 END CTAB M V30 END REACTANT M V30 BEGIN PRODUCT M V30 BEGIN CTAB M V30 COUNTS 7 7 0 0 0 M V30 BEGIN ATOM M V30 1 C -0.714471 0.000000 0.000000 0 M V30 2 C -0.714471 -0.825000 0.000000 0 M V30 3 C -0.000000 -1.237500 0.000000 0 M V30 4 C 0.714471 -0.825000 0.000000 0 M V30 5 C 0.714471 0.000000 0.000000 0 M V30 6 C -0.000000 0.412500 0.000000 0 M V30 7 Cl -0.000000 1.237500 0.000000 0 M V30 END ATOM M V30 BEGIN BOND M V30 1 2 1 2 M V30 2 1 2 3 M V30 3 2 3 4 M V30 4 1 4 5 M V30 5 2 5 6 M V30 6 1 6 1 M V30 7 1 6 7 M V30 END BOND M V30 END CTAB M V30 END PRODUCT M END ` Is there any solution? rV

partridgejiang commented 3 years ago

Hi @registerme1963, the implmentation of reaction (and MOL RXN format) is not fully baked in Kekule.js currently, especially in rendering. A workaround presently is to create a custom data reader to convert RXN format data into a ChemDocument. A small demo (with that type of reader, MyMdlRxnToChemDocReader, from line 98 to 255) can be viewed at http://partridgejiang.github.io/Kekule.js/demos/items/chemViewer/rxnEmbedView.html. Please run the demo with the latest dist of Kekule.js, as it fixes some small bugs with RXN3000 format.

registerme1963 commented 3 years ago

Thank you. I'll add the script in the js/ folder of my application and call it

registerme1963 commented 3 years ago

Hi, Sorry, it did not work in my xampp localhost. I just copied the source code from the demo and kekule.js downloaded from here

registerme1963 commented 3 years ago

I realized that It is better to go with JSON. Thanks for the help