indigo.calculate() - Calculates Chemical Properties

Q

How to calculate chemical properties of a given structure with the indigo.calculate() method?

✍: FYIcenter.com

A

If you want to calculate chemical properties like mass and weight of a given chemical structure you can use the indigo.calculate() method on the Ketcher Indigo interface.

Here is an HTML document that shows you how to export the chemical structure from the Ketcher editor and calculate its properties.

<html>
<!-- indigo-calculate-properties.html Copyright (c) FYIcenter.com. -->
<head>
<title>Calculate Chemical Properties</title>
</head>
<body>
<p>Create a chemical 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();">Calculate Chemical Properties</button></p>
<p>SMILES:</p>
<pre id=smiles style="background-color: #ddd;"></pre>
<p>Properties:</p>
<pre id=output style="background-color: #ddd;"></pre>
<script>
  var ketcher = null;

function generate() {
  frm = document.getElementById("frmKetcher");
  ketcher = frm.contentWindow.ketcher;
  indigo = ketcher.indigo;

  promiseSmiles = ketcher.getSmiles();
  promiseOutput = promiseSmiles.then(consumeSmiles, consumeSmiles);
  promiseOutput.then(consumeOutput, consumeOutput);
}

function consumeSmiles(result) {
  document.getElementById("smiles").innerHTML = result;
  return indigo.calculate(result); 
}

function consumeOutput(result) {
  document.getElementById("output").innerHTML = JSON.stringify(result, undefined, 2);
}
</script>
</body>
</html>

Open the above HTML document on your local Web server. Draw a chemical reaction in the editor.

Click "Calculate Chemical Properties" button, you will see that the SMILES representation of the reaction and its chemical properties are displayed:

SMILES:
C1C=CC=CC=1>>C1C=CC=CC=1

Properties:
{
  "molecular-weight": "[78.1118417] > [78.1118417]",
  "most-abundant-mass": "[78.0469501] > [78.0469501]",
  "monoisotopic-mass": "[78.0469501] > [78.0469501]",
  "mass-composition": "[C 92.26 H 7.74] > [C 92.26 H 7.74]",
  "gross": "[C6 H6] > [C6 H6]"
}

 

indigo.generateImageAsBase64() - Generate Image as Base64

What Is Ketcher Indigo Interface

Ketcher Indigo Interface

⇑⇑ Ketcher - Chemical Structure Editor

2023-11-09, 278🔥, 0💬