Collections:
ketcher.getSmiles() and ketcher.getSmarts()
How to export the chemical structure in SMILES and SMARTS formats from the Ketcher with the ketcher.getSmiles() and ketcher.getSmarts() methods?
✍: FYIcenter.com
To export the chemical structure (molecule, reaction, or substructure pattern)
in SMILES and SMARTS formats from the Ketcher,
you can use the getSmiles() and getSmarts() methods provided by the Ketcher API
as shown in below:
1. As shown in previous tutorials, load the Ketcher editor in an "iframe" HTML element, create a "button" HTML element with "click" event handler, and access the "ketcher" object from the "iframe" element.
2. Call ketcher.getSmiles() and getSmarts() methods to export the chemical structure from the Ketcher editor.
The following HTML document gives you an example of how to export the chemical structure in SMILES and SMARTS formats from the Ketcher:
<html> <!-- export-as-SMILES-SMARTS.html Copyright (c) FYIcenter.com. --> <head> <title>Export Chemical Structure in SMILES and SMARTS Formats</title> </head> <body> <p>Create a chemical structure, then click export buttons below the editor:</p> <iframe id=frmKetcher src="/ketcher/index.html" style="width: 680px; height: 400px;"></iframe> <p><button onclick="exportSMILES();">Export in SMILES</button></p> <pre id=output1 style="background-color: #ddd;"> </pre> <script> function exportSMILES() { frm = document.getElementById("frmKetcher"); ketcher = frm.contentWindow.ketcher; promise = ketcher.getSmiles(); promise.then( function(value) { document.getElementById("output1").innerHTML = value; }, function(error) { document.getElementById("output1").innerHTML = error.toString(); } ); } </script> <p><button onclick="exportSMARTS();">Export in SMARTS</button></p> <pre id=output2 style="background-color: #ddd;"> </pre> <script> function exportSMARTS() { frm = document.getElementById("frmKetcher"); ketcher = frm.contentWindow.ketcher; promise = ketcher.getSmarts(); promise.then( function(value) { document.getElementById("output2").innerHTML = value; }, function(error) { document.getElementById("output2").innerHTML = error.toString(); } ); } </script> </body> </html>
3. 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.
4. Draw a simple reaction structure in the editor.
5. Click "Export in SMILES" button, you will see the chemical structure represented in SMILES format displayed.
8. Click "Export in SMARTS" button, you will see the chemical structure represented in SMARTS format displayed.
⇒ Call getSmiles() and getSmarts() Parallelly
2023-12-10, 1401🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1003801 Names: InChIKey: ONSPOBHCPINTRF-UHFFFAOYS A-NSMILES: C1OCOCOCOCOCO...
Molecule Summary: ID: FYI-1000268 SMILES: N[17C@@](F)([18C])C(=[19 O])[20O]Received at FYIcenter.com...
Molecule Summary: ID: FYI-1002977 Names: InChIKey: DIHXZROBWMEZEQ-UHFFFAOYS A-NSMILES: c1ccc2c(c1)CC...
Molecule Summary: ID: FYI-1002871 Names: InChIKey: SSUOSVQNPYIPHR-UHFFFAOYS A-NSMILES: CCCCNC(=O)c2c...
Molecule Summary: ID: FYI-1003021 Names: InChIKey: YASIMYOXMCGFQW-UHFFFAOYS A-NSMILES: CCCCCCCCNS(=O...