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, 839🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1000180 SMILES: O=C1N[C@H](C)CNC2=C1SC(C =C3)=C2C4=C3N=C(OC5=NC(C l)=NC=C5CO...
Molecule Summary: ID: FYI-1002068 Names: CYCLOHEXANE; InChIKey: XDTMQSROBMDMFD-UHFFFAOYS A-NSMILES: ...
Molecule Summary: ID: FYI-1006452 Names: InChIKey: KSFZRMNZDYFUAU-BYEGLACWS A-NSMILES: Cl[Ru]13Oc5c(...
Molecule Summary: ID: FYI-1004891 Names: InChIKey: GJJFMKBJSRMPLA-UHFFFAOYS A-NSMILES: CCN(CC)C(=O)C...
Molecule Summary: ID: FYI-1003617 Names: InChIKey: JXYMDYHCYZVRON-UHFFFAOYS A-NSMILES: c1ccc3c(c1)CC...