Collections:
JSApplet.Inchi.computeInchi() - Generate InChI
How to generate InChI and InChIKey with the JSApplet.Inchi.computeInchi() method?
✍: FYIcenter.com
The latest version of JSME allows you to generate InChI and InChIKey
from a given molecule in SDF format.
Here are the steps you can follow to do this in JavaScript code:
1. Create an empty object called "JSApplet" and add a property called "Inchi" with an other empty object.
<script>
var JSApplet = {};
JSApplet.Inchi = {};
</script>
2. Load the 96E40B969193BD74B8A621486920E79C.cache.js file, which will populate JavaScript code to "JSApplet.Inchi", including the JSApplet.Inchi.computeInchi() method.
<script type="text/javascript" src="/jsme/96E40B969193BD74B8A621486920E79C.cache.js"></script>
3. Add a callback function to catch the result object generated by the JSApplet.Inchi.computeInchi() method.
<script>
var result;
JSApplet.Inchi.__resultHandler = function (inchi_result) {
result = inchi_result
};
...
4. Invoke the JSApplet.Inchi.computeInchi() method and remove the callback function.
...
var sdf = document.getElementById("sdf").value;
JSApplet.Inchi.computeInchi(sdf, "JSApplet.Inchi.__resultHandler");
delete JSApplet.Inchi.__resultHandler;
...
5. Process the result object, which contains 5 properties: inchi, auxinfo, warning, error, and key.
...
var text = "";
Object.keys(result).forEach(function (k) {
text += k + ": " + result[k] + "\n"
});
document.getElementById("inchi").value = text;
The following HTML document example, generate-inchi.html, shows you how to apply those steps:
<html>
<!-- generate-inchi.html Copyright (c) FYIcenter.com. All rights reserved. -->
<head>
<body>
<p>Input Mol/SDF:<br/>
<textarea id="sdf" rows="10" cols="60">
JME 2022-09-26 Wed Jan 04 16:10:11 GMT-500 2023
6 6 0 0 0 0 0 0 0 0999 V2000
2.4249 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4249 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.2124 2.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.2124 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 2 0 0 0 0
3 4 1 0 0 0 0
4 5 2 0 0 0 0
5 6 1 0 0 0 0
6 1 2 0 0 0 0
M END
</textarea>
</p>
<p>Output InChI and InChIKey:<br/>
<textarea id="inchi" rows="10" cols="60"></textarea>
</p>
<script>
var JSApplet = {};
JSApplet.Inchi = {};
</script>
<script type="text/javascript" src="/jsme/96E40B969193BD74B8A621486920E79C.cache.js"></script>
<script>
var result;
JSApplet.Inchi.__resultHandler = function (inchi_result) {
result = inchi_result
};
var sdf = document.getElementById("sdf").value;
JSApplet.Inchi.computeInchi(sdf, "JSApplet.Inchi.__resultHandler");
delete JSApplet.Inchi.__resultHandler;
var text = "";
Object.keys(result).forEach(function (k) {
text += k + ": " + result[k] + "\n"
});
document.getElementById("inchi").value = text;
</script>
</body>
</html>
2023-01-18, 805🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1001812 SMILES: CC(C)CCCCCCOC(=O)C1=CC=C C=C1C(=O)OCCCCCCC(C)CReceived at ...
Molecule Summary: ID: FYI-1014505 Names: InChIKey: QKPCMWRHMJLGDQ-UHFFFAOYS A-NSMILES: COc2c(CCO)ccc...
Molecule Summary: ID: FYI-1000189 SMILES: Cc1ccc(C(=O)OCC(=O)Nc2cc ccc2)cc1CReceived at FYIcenter.co...
Molecule Summary: ID: FYI-1001172 SMILES: CC(C)(C)O Received at FYIcenter.com on: 2022-02-14
Molecule Summary: ID: FYI-1001005 SMILES: C12CCC(C)3C(C(C)CCC(=O)O )CCC3C1C(I)CC(C)1CCCCC12 CReceived...