1
$\begingroup$

I recently started to perform natural resonance theory (NRT) analysis with NBO6. This program may automatically create a chemical markup language (cml) file with the treated structures. Unfortunately I don't speak cml well enough to judge if the file generated is any good.

What I would like to do is to convert this generated file into an image. That means, that the included 3D coordinates have to be flattened to 2D. I think the problem lies at this step as I get an erroneous structure reported.

As a test molecule I chose acetic acid and I am including a total of three resonance structures (It gets worse when I use more). The first and main contributor is displayed just fine. The second has missing formal charges. These are not explicitly given in the cml file, so they would need to be calculated. Openbabel is certainly able to do that, but for some reason, it is not working here. The third structure is completely ripped apart. The atoms should be at the same position as in the first and second image.

I am using a self-compiled local version of openbabel (2.3.2) with the following command (test.cml at the end):

  ~/local/tools/openbabel-install/bin/babel -icml test.cml -opng test.png

I obtain the following image:

openbabel output

Along with the error messages:

==============================
*** Open Babel Error  in DoHCounts
  In atom a1 the number of explicit hydrogens exceeds the hydrogenCount attribute.
==============================
*** Open Babel Error  in DoHCounts
  In atom a1 the number of explicit hydrogens exceeds the hydrogenCount attribute.
==============================
*** Open Babel Error  in DoHCounts
  In atom a1 the number of explicit hydrogens exceeds the hydrogenCount attribute.
3 molecules converted
3 errors 109 audit log messages

I don't have any idea how to access those audit log messages (/var/log/messages: Permission denied) and if they are in any way helpful.
However, the error messages already seem to indicate, that the generated cml file is faulty.

<?xml version="1.0"?>
<cml title="Resonance forms from NRT analysis">
 <molecule id="1" title="Wgt=64.49%">
  <atomArray>
   <atom id="a1" elementType="C" hydrogenCount="0" x3="-1.40" y3="-0.11" z3="0.00" lonePair="0"/>
   <atom id="a2" elementType="H" hydrogenCount="0" x3="-1.93" y3="0.86" z3="0.00" lonePair="0"/>
   <atom id="a3" elementType="H" hydrogenCount="0" x3="-1.70" y3="-0.70" z3="0.89" lonePair="0"/>
   <atom id="a4" elementType="H" hydrogenCount="0" x3="-1.70" y3="-0.70" z3="-0.89" lonePair="0"/>
   <atom id="a5" elementType="C" hydrogenCount="0" x3="0.09" y3="0.13" z3="-0.00" lonePair="0"/>
   <atom id="a6" elementType="O" hydrogenCount="0" x3="0.78" y3="-1.05" z3="0.00" lonePair="2"/>
   <atom id="a7" elementType="O" hydrogenCount="0" x3="0.65" y3="1.21" z3="0.00" lonePair="2"/>
   <atom id="a8" elementType="H" hydrogenCount="0" x3="1.73" y3="-0.80" z3="0.00" lonePair="0"/>
  </atomArray>
  <bondArray>
   <bond atomRefs2="a1 a2" order="1"/>
   <bond atomRefs2="a1 a3" order="1"/>
   <bond atomRefs2="a1 a4" order="1"/>
   <bond atomRefs2="a1 a5" order="1"/>
   <bond atomRefs2="a5 a6" order="1"/>
   <bond atomRefs2="a5 a7" order="2"/>
   <bond atomRefs2="a6 a8" order="1"/>
  </bondArray>
 </molecule>
 <molecule id="2" title="Wgt=23.43%">
  <atomArray>
   <atom id="a1" elementType="C" hydrogenCount="0" x3="-1.40" y3="-0.11" z3="0.00" lonePair="0"/>
   <atom id="a2" elementType="H" hydrogenCount="0" x3="-1.93" y3="0.86" z3="0.00" lonePair="0"/>
   <atom id="a3" elementType="H" hydrogenCount="0" x3="-1.70" y3="-0.70" z3="0.89" lonePair="0"/>
   <atom id="a4" elementType="H" hydrogenCount="0" x3="-1.70" y3="-0.70" z3="-0.89" lonePair="0"/>
   <atom id="a5" elementType="C" hydrogenCount="0" x3="0.09" y3="0.13" z3="-0.00" lonePair="0"/>
   <atom id="a6" elementType="O" hydrogenCount="0" x3="0.78" y3="-1.05" z3="0.00" lonePair="1"/>
   <atom id="a7" elementType="O" hydrogenCount="0" x3="0.65" y3="1.21" z3="0.00" lonePair="3"/>
   <atom id="a8" elementType="H" hydrogenCount="0" x3="1.73" y3="-0.80" z3="0.00" lonePair="0"/>
  </atomArray>
  <bondArray>
   <bond atomRefs2="a1 a2" order="1"/>
   <bond atomRefs2="a1 a3" order="1"/>
   <bond atomRefs2="a1 a4" order="1"/>
   <bond atomRefs2="a1 a5" order="1"/>
   <bond atomRefs2="a5 a6" order="2"/>
   <bond atomRefs2="a5 a7" order="1"/>
   <bond atomRefs2="a6 a8" order="1"/>
  </bondArray>
 </molecule>
 <molecule id="3" title="Wgt=4.20%">
  <atomArray>
   <atom id="a1" elementType="C" hydrogenCount="0" x3="-1.40" y3="-0.11" z3="0.00" lonePair="0"/>
   <atom id="a2" elementType="H" hydrogenCount="0" x3="-1.93" y3="0.86" z3="0.00" lonePair="0"/>
   <atom id="a3" elementType="H" hydrogenCount="0" x3="-1.70" y3="-0.70" z3="0.89" lonePair="0"/>
   <atom id="a4" elementType="H" hydrogenCount="0" x3="-1.70" y3="-0.70" z3="-0.89" lonePair="0"/>
   <atom id="a5" elementType="C" hydrogenCount="0" x3="0.09" y3="0.13" z3="-0.00" lonePair="0"/>
   <atom id="a6" elementType="O" hydrogenCount="0" x3="0.78" y3="-1.05" z3="0.00" lonePair="3"/>
   <atom id="a7" elementType="O" hydrogenCount="0" x3="0.65" y3="1.21" z3="0.00" lonePair="1"/>
   <atom id="a8" elementType="H" hydrogenCount="0" x3="1.73" y3="-0.80" z3="0.00" lonePair="0"/>
  </atomArray>
  <bondArray>
   <bond atomRefs2="a1 a2" order="1"/>
   <bond atomRefs2="a1 a3" order="1"/>
   <bond atomRefs2="a1 a4" order="1"/>
   <bond atomRefs2="a1 a5" order="1"/>
   <bond atomRefs2="a5 a7" order="3"/>
   <bond atomRefs2="a6 a8" order="1"/>
  </bondArray>
 </molecule>
</cml>

If you look at the coordinate information, you will see, that they are identical. The bond array just changes along with the lone pairs. It is also obvious from where the above mentioned errors stem from. Each entry has hydrogenCount="0", which is maybe correct because there are explicit hydrogens. But I am not sure. I found an open bug report referring to this attribute.

Now that I seem to not find a reason for this behaviour I need to find an alternative. The currently only viable and reliable method for me is to interpret the output of the NRT by hand.

Resulting from this I have a few questions:

  • Is the produced cml file correct? Does it contain errors and hence the problem is not with openbabel?
  • If the file is correct, are there alternatives to openbabel, which treat it correctly and which are able to convert it to a 2D image (structural representation)? (I would prefer a commandline tool.)

The output should be similar to this manually created image:

(somewhat) correct/ expected output

I have tried other programs, so far with not much luck.
Chemdraw can read the cml file and produces the structures with the correct bonds and the atoms are in the correct position. However, charges are missing and all molecules are at the same position, thus making it quite hard to obtain a good image. It also fails to read the title statement.
JChemPaint while technically able to read cml, fails to read this file. I could pinpoint it to the third structure, which produces an error and aborts. If only the first two are included it also fails to produce the charges.
ChemSketch cannot read cml formatting.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.