<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.3.4">Jekyll</generator><link href="https://chem-bla-ics.linkedchemistry.info/feed/by_tag/usefulchem.xml" rel="self" type="application/atom+xml" /><link href="https://chem-bla-ics.linkedchemistry.info/" rel="alternate" type="text/html" /><updated>2026-06-15T12:00:19+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/feed/by_tag/usefulchem.xml</id><title type="html">chem-bla-ics</title><subtitle>Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.</subtitle><author><name>Egon Willighagen</name></author><entry><title type="html">Creating CMLReact from UsefulChem Ugi Reactions</title><link href="https://chem-bla-ics.linkedchemistry.info/2008/08/31/creating-cmlreact-from-usefulchem-ugi.html" rel="alternate" type="text/html" title="Creating CMLReact from UsefulChem Ugi Reactions" /><published>2008-08-31T00:20:00+00:00</published><updated>2008-08-31T00:20:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2008/08/31/creating-cmlreact-from-usefulchem-ugi</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2008/08/31/creating-cmlreact-from-usefulchem-ugi.html"><![CDATA[<p><a href="http://blog.openwetware.org/scienceintheopen/">Cameron</a>, <a href="http://usefulchem.blogspot.com/">Jean-Claude</a> and I were invited to
<a href="http://wwmm.ch.cam.ac.uk/blogs/murrayrust/">Peter</a>’s place in Cambridge, where we are now hacking on CMLReact for the
<a href="http://usefulchem.wikispaces.com/exp023">Ugi reactions</a> Jean-Claude has been working on. I just finished a script that uses the
CDK and Sam’s interface to the <a href="http://cheminfo.informatics.indiana.edu/~rguha/code/java/nightly/api/org/openscience/cdk/inchi/package-frame.html">InChI library</a>
to convert a list of four reactants and one Ugi product into CMLReact (doi:<a href="http://dx.doi.org/10.1021/ci0502698">10.1021/ci0502698</a>).
The full <a href="https://en.wikipedia.org/wiki/BeanShell">BeanShell</a> script looks like:</p>

<pre><code class="language-beanshell">#!/usr/bin/bsh

import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;

import org.openscience.cdk.*;
import org.openscience.cdk.exception.*;
import org.openscience.cdk.inchi.*;
import org.openscience.cdk.interfaces.*;
import org.openscience.cdk.io.CMLWriter;

import org.openscience.cdk.libio.cml.Convertor;
import org.xmlcml.cml.element.CMLReaction;

import net.sf.jniinchi.INCHI_RET;

InChIGeneratorFactory factory = new InChIGeneratorFactory();
// Get InChIToStructure

File file = new File("inchi.ugi.txt"); // five inchis expected, last being the product
BufferedReader reader = new BufferedReader(new FileReader(file));

String first = reader.readLine();
String second = reader.readLine();
String third = reader.readLine();
String fourth = reader.readLine();
String product = reader.readLine();

System.out.println("First: " + first);
IMolecule firstAC;
{
  InChIToStructure intostruct = factory.getInChIToStructure(first, DefaultChemObjectBuilder.getInstance());

  INCHI_RET ret = intostruct.getReturnStatus();
  if (ret == INCHI_RET.WARNING) {
    // Structure generated, but with warning message
    System.out.println("InChI warning: " + intostruct.getMessage());
  } else if (ret != INCHI_RET.OKAY) {
    // Structure generation failed
    throw new CDKException("Structure generation failed failed: " + ret.toString()
      + " [" + intostruct.getMessage() + "]");
  }

  firstAC = new Molecule(intostruct.getAtomContainer());
}

System.out.println("Second: " + second);
IMolecule secondAC;
{
  InChIToStructure intostruct = factory.getInChIToStructure(second, DefaultChemObjectBuilder.getInstance());

  INCHI_RET ret = intostruct.getReturnStatus();
  if (ret == INCHI_RET.WARNING) {
    // Structure generated, but with warning message
    System.out.println("InChI warning: " + intostruct.getMessage());
  } else if (ret != INCHI_RET.OKAY) {
    // Structure generation failed
    throw new CDKException("Structure generation failed failed: " + ret.toString()
      + " [" + intostruct.getMessage() + "]");
  }

  secondAC = new Molecule(intostruct.getAtomContainer());
}

System.out.println("Third: " + third);
IMolecule thirdAC;
{
  InChIToStructure intostruct = factory.getInChIToStructure(third, DefaultChemObjectBuilder.getInstance());

  INCHI_RET ret = intostruct.getReturnStatus();
  if (ret == INCHI_RET.WARNING) {
    // Structure generated, but with warning message
    System.out.println("InChI warning: " + intostruct.getMessage());
  } else if (ret != INCHI_RET.OKAY) {
    // Structure generation failed
    throw new CDKException("Structure generation failed failed: " + ret.toString()
      + " [" + intostruct.getMessage() + "]");
  }

  thirdAC = new Molecule(intostruct.getAtomContainer());
}

System.out.println("Fourth: " + fourth);
IMolecule fourthAC;
{
  InChIToStructure intostruct = factory.getInChIToStructure(fourth, DefaultChemObjectBuilder.getInstance());

  INCHI_RET ret = intostruct.getReturnStatus();
  if (ret == INCHI_RET.WARNING) {
    // Structure generated, but with warning message
    System.out.println("InChI warning: " + intostruct.getMessage());
  } else if (ret != INCHI_RET.OKAY) {
    // Structure generation failed
    throw new CDKException("Structure generation failed failed: " + ret.toString()
      + " [" + intostruct.getMessage() + "]");
  }

  fourthAC = new Molecule(intostruct.getAtomContainer());
}

System.out.println("Product: " + product);
IMolecule productAC;
{
  InChIToStructure intostruct = factory.getInChIToStructure(product, DefaultChemObjectBuilder.getInstance());

  INCHI_RET ret = intostruct.getReturnStatus();
  if (ret == INCHI_RET.WARNING) {
    // Structure generated, but with warning message
    System.out.println("InChI warning: " + intostruct.getMessage());
  } else if (ret != INCHI_RET.OKAY) {
    // Structure generation failed
    throw new CDKException("Structure generation failed failed: " + ret.toString()
      + " [" + intostruct.getMessage() + "]");
  }

  productAC = new Molecule(intostruct.getAtomContainer());
}

IReaction ugiReaction = new Reaction();
ugiReaction.addReactant(firstAC);
ugiReaction.addReactant(secondAC);
ugiReaction.addReactant(thirdAC);
ugiReaction.addReactant(fourthAC);
ugiReaction.addProduct(productAC);

StringWriter stringWriter = new StringWriter();
CMLWriter cmlWriter = new CMLWriter(stringWriter);

cmlWriter.write(ugiReaction);
cmlWriter.close();
System.out.println(stringWriter.toString());
</code></pre>

<p>My apologies for the code duplication, but never tried inline functions in BeanShell yet… You can
monitor the efforts at <a href="http://docs.google.com/Doc?id=dq5m5bs_12hb8d2wcw">Google Docs</a>.</p>]]></content><author><name>Egon Willighagen</name></author><category term="cml" /><category term="cdk" /><category term="inchi" /><category term="justdoi:10.1021/ci0502698" /><category term="usefulchem" /><summary type="html"><![CDATA[Cameron, Jean-Claude and I were invited to Peter’s place in Cambridge, where we are now hacking on CMLReact for the Ugi reactions Jean-Claude has been working on. I just finished a script that uses the CDK and Sam’s interface to the InChI library to convert a list of four reactants and one Ugi product into CMLReact (doi:10.1021/ci0502698). The full BeanShell script looks like:]]></summary></entry><entry><title type="html">UgiChem2CML</title><link href="https://chem-bla-ics.linkedchemistry.info/2008/08/31/ugichem2cml.html" rel="alternate" type="text/html" title="UgiChem2CML" /><published>2008-08-31T00:00:00+00:00</published><updated>2008-08-31T00:00:00+00:00</updated><id>https://chem-bla-ics.linkedchemistry.info/2008/08/31/ugichem2cml</id><content type="html" xml:base="https://chem-bla-ics.linkedchemistry.info/2008/08/31/ugichem2cml.html"><![CDATA[<p>The nice thing about a hacksession, is that you have something to write about. Below a screenshot of a
<a href="https://en.wikipedia.org/wiki/Ugi_reaction">Ugi reaction</a> in <a href="http://www.bioclipse.net/">Bioclipse</a>…
note the <em>source</em> tab of the editor, which holds the CML. Now, JChemPaint can do reactions too (I did that in 2003
in Peter’s group, but seems to be offline at this moment), but this was the quick hack to do the CMLReact in
<a href="http://docs.google.com/Doc?id=dq5m5bs_12hb8d2wcw">Google Docs</a> (or soon to be):</p>

<p><img src="/assets/images/ugiBioclipse.png" alt="" /></p>

<p>And this is us this afternoon:</p>

<p><img src="/assets/images/CIMG0503_s.JPG" alt="" /></p>]]></content><author><name>Egon Willighagen</name></author><category term="bioclipse" /><category term="cml" /><category term="ugi" /><category term="usefulchem" /><summary type="html"><![CDATA[The nice thing about a hacksession, is that you have something to write about. Below a screenshot of a Ugi reaction in Bioclipse… note the source tab of the editor, which holds the CML. Now, JChemPaint can do reactions too (I did that in 2003 in Peter’s group, but seems to be offline at this moment), but this was the quick hack to do the CMLReact in Google Docs (or soon to be):]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://chem-bla-ics.linkedchemistry.info/assets/images/CIMG0503_s.JPG" /><media:content medium="image" url="https://chem-bla-ics.linkedchemistry.info/assets/images/CIMG0503_s.JPG" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>