Collections:
Export Chemical Structure in All Formats
How to export the chemical structure in all Formats?
✍: FYIcenter.com
If you want to export the chemical structure
from the Ketcher editor in all formats,
you can call those get*() methods in chained promises
as shown the HTML document below:
<html>
<!-- export-structure-in-all-formats.html Copyright (c) FYIcenter.com. -->
<head>
<title>Export Chemical Structure in All 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="exportAll();">Export in All Formats</button></p>
<p>Output:</p>
<pre id=output style="background-color: #ddd;"></pre>
<script>
var ketcher = null;
var structure = null;
function exportAll() {
frm = document.getElementById("frmKetcher");
ketcher = frm.contentWindow.ketcher;
structure = "";
ketcher.getSmiles()
.then(consumeSmiles, consumeSmiles)
.then(consumeSmarts, consumeSmarts)
.then(consumeMolfile, consumeMolfile)
.then(consumeRxn, consumeRxn)
.then(consumeCDXml, consumeCDXml)
.then(consumeKet, consumeKet)
.finally(consumeEnd);
}
function consumeSmiles(result) {
structure += "\nSMILES:\n";
structure += result.toString()+"\n";
return ketcher.getSmarts();
}
function consumeSmarts(result) {
structure += "\nSMARTS:\n";
structure += result.toString()+"\n";
return ketcher.getMolfile();
}
function consumeMolfile(result) {
structure += "\nMolfile:\n";
structure += result.toString()+"\n";
return ketcher.getRxn();
}
function consumeRxn(result) {
structure += "\nRXN:\n";
structure += result.toString()+"\n";
return ketcher.getCDXml();
}
function consumeCDXml(result) {
structure += "\nCDXml\n";
structure += result.toString()+"\n";
return ketcher.getKet();
}
function consumeKet(result) {
structure += "\nKetcher:\n";
structure += result.toString()+"\n";
}
function consumeEnd(result) {
document.getElementById("output").innerText
= structure.replace(/&/g, '&').replace(/</g, '<');
}
</script>
</body>
</html>
Open the above HTML document on your local Web server. Draw a simple molecule structure in the editor.
Click "Export in All Formats" button, you will see that the structure is exported and displayed in all formats.
⇒ Export Chemical Structure in All Formats Failed
2024-01-15, 1091🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1000333 SMILES: Cc1cc(c(cc1F)[C@](C)(C(= O)OC)NCC(C)C)FReceived at FYIcent...
Molecule Summary: ID: FYI-1003951 Names: InChIKey: FAUPJUJQOJXWNE-UHFFFAOYS A-NSMILES: CCc4nc(C(N)=O...
Molecule Summary: ID: FYI-1000214 SMILES: CCOC(=O)C(C)(C)C=O Received at FYIcenter.com on: 2020-12-2...
Molecule Summary: ID: FYI-1005814 Names: InChIKey: RMTXRSKFJQIXGO-JIYPWYQOS A-NSMILES: C/C(C)=C\\C=C...
Molecule Summary: ID: FYI-1000969 SMILES: O=C1CSC(=S)N1CCN1CCCCC1 Received at FYIcenter.com on: 2021...