Call getInchi() and generateInchIKey() Methods

Q

How to generate the InChI and InChIKey with the ketcher.getInchi() and ketcher.generateInchIKey() methods?

✍: FYIcenter.com

A

InChI (International Chemical Identifier) and InChIKey (InChI Key) are identifiers of molecule structures, originally developed by Initially developed by the International Union of Pure and Applied Chemistry (IUPAC) and National Institute of Standards and Technology (NIST).

To generate InChI and InChIKey from the molecule structure in the Ketcher, you can use the getInchi() and generateInchIKey() methods provided by the Ketcher API as shown in below:

<html>
<!-- generate-molecule-InChI-InChIKey.html Copyright (c) FYIcenter.com. -->
<head>
<title>Generate Molecule InChI and InChIKey</title>
</head>
<body>
<p>Create a molecule structure, then click generate button below the editor:</p>
<iframe id=frmKetcher src="/ketcher/index.html"
  style="width: 680px; height: 400px;"></iframe>

<p><button onclick="generate();">Generate InChI and InChIKey</button></p>
<p>Output:</p>
<pre id=output style="background-color: #ddd;"></pre>
<script>
  var ketcher = null;
  var display = document.getElementById("output");

function generate() {
  frm = document.getElementById("frmKetcher");
  ketcher = frm.contentWindow.ketcher;
  display.innerHTML = "";
  generateInChI();
  generateInChIKey();
}

function generateInChI() {
  let promise = ketcher.getInchi();
  promise.then(
    function(value) {
      display.innerHTML = display.innerHTML+"\nInChI:\n"+value+"\n";
    },
    function(error) {
      display.innerHTML = display.innerHTML+"\nInChI:\n"+error.toString()+"\n";
    }
  );
}

function generateInChIKey() {
  let promise = ketcher.generateInchIKey();
  promise.then(
    function(value) {
      display.innerHTML = display.innerHTML+"\nInChIKey:\n"+value+"\n";
    },
    function(error) {
      display.innerHTML = display.innerHTML+"\nInChIKey:\n"+error.toString()+"\n";
    }
  );
}
</script>
</body>
</html>

Open the above HTML document on your local Web server. Draw a simple molecule structure in the editor.

Click "Generate InChI and InChIKey" button, you will see that InChI and InChIKey are generated and displayed correctly.

Generate InChI and InChIKey Identifiers
Generate InChI and InChIKey Identifiers

 

generateImage() - Generate Image from Structure

Export Chemical Structure in All Formats Failed

Ketcher JavaScript API

⇑⇑ Ketcher - Chemical Structure Editor

2023-12-14, 381🔥, 0💬