Collections:
ketcher.getRxn() - Export Reaction in RXN Format
How to export the reaction structure in RXN format from the Ketcher with the ketcher.getRxn() method?
✍: FYIcenter.com
To export the reaction structure in RXN format from the Ketcher, you can use the getRxn() method provided by the Ketcher API as shown in below:
1. Load the Ketcher editor in an "iframe" HTML element:
<iframe id=frmKetcher src="/ketcher/index.html" style="width: 680px; height: 400px;"></iframe>
2. Create a "button" HTML element with a "click" event handler.
<p><button onclick="exportRXN();">Export Reaction in RXN</button></p>
3. Access the "ketcher" object from the "iframe" element in the "click" event handler directly, since the "iframe" element is already loaded:
frm = document.getElementById("frmKetcher"); ketcher = frm.contentWindow.ketcher;
3. Access the "ketcher" object from the "iframe" element in the "click" event handler directly, since the "iframe" element is already loaded:
frm = document.getElementById("frmKetcher"); ketcher = frm.contentWindow.ketcher;
4. Call the ketcher.getRxn() method to export the reaction structure from the Ketcher editor. Note that this method returns a "promise" object, which represents a child thread to perform the task. We need to add two handlers through the promise.then() method to catch the result and error.
The following HTML document gives you an example of how to export the reaction structure in RXN format from the Ketcher:
<html> <!-- export-reaction-as-RXN.html Copyright (c) FYIcenter.com. --> <head> <title>Export Reaction Structure in RXN Format</title> </head> <body> <p>Create a reaction structure, then click the export button below the editor:</p> <iframe id=frmKetcher src="/ketcher/index.html" style="width: 680px; height: 400px;"></iframe> <p><button onclick="exportRXN();">Export Reaction in RXN</button></p> <pre id=output style="background-color: #ddd;"> </pre> <script> function exportRXN() { frm = document.getElementById("frmKetcher"); ketcher = frm.contentWindow.ketcher; promise = ketcher.getRxn(); promise.then( function(value) { document.getElementById("output").innerHTML = value; }, function(error) { document.getElementById("output").innerHTML = error.toString(); } ); } </script> </body> </html>
5. Put the above HTML document on your local Web server and open it in your browser, you will see the Ketcher editor loaded and ready to use.
6. Draw a simple reaction structure in the editor.
7. Click "Export Reaction in RXN" button, you will see the reaction structure represented in RXN format displayed:
⇒ ketcher.getSmiles() and ketcher.getSmarts()
2023-12-10, 587🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1003769 Names: InChIKey: DYAIAHUQIPBDIP-AXAPSJFSS A-NSMILES: O=C(O)C3=C(CS...
Reaction Summary: ID: FYI-1006692 Formula: SMILES: Cl.[Na]O>>[Na]Cl.O Received at FYIcenter.com on: ...
Molecule Summary: ID: FYI-1003526 Names: InChIKey: JXAOTICXQLILTC-UHFFFAOYS A-NSMILES: NC1C(O)C(O)C(...
Molecule Summary: ID: FYI-1006447 Names: InChIKey: SPMVMDHWKHCIDT-UHFFFAOYS A-NSMILES: COc4cc3nccc(O...
Molecule Summary: ID: FYI-1001439 SMILES: ClC1=NC=C(N=C1)N2C(=NC=N 2)[C@H](C)NC(=O)C3=CC(OC (F)(F)F)=C...