User 870ab5b546
30-09-2014 00:38:35
The code:
final String SELF = "ChemUtils.checkValence: ";
origMol.valenceCheck();
final Molecule mol = origMol.clone();
boolean throwError = false;
debugPrintMRV(SELF + "checking for coordinate bonds starting at "
+ "shortcut groups in:\n", mol);
ValenceException exception = new ValenceException("You have drawn a "
+ "coordinate bond that originates at a shortcut group. A "
+ "coordinate bond must originate at an atom. ");
for (final Sgroup sgroupRaw : mol.getSgroupArray()) {
if (sgroupRaw instanceof SuperatomSgroup) {
final SuperatomSgroup sgroup = (SuperatomSgroup) sgroupRaw;
final SgroupAtom superatom = sgroup.getSuperAtom();
final MolAtom attachPt = sgroup.findAttachAtom();
if (attachPt != null) {
debugPrint(SELF + "found shortcut group ", superatom,
" with attachment point ", attachPt,
mol.indexOf(attachPt) + 1, " with ",
attachPt.getBondCount(),
" bond(s); checking for coordinate bond.");
for (final MolBond bond : attachPt.getBondArray()) {
if (bond.getType() == MolBond.COORDINATE) {
debugPrint(SELF + "Coordinate bond originates "
+ "at attachment point of shortcut group ",
superatom, mol.indexOf(attachPt) + 1);
final MolAtom atom1 = bond.getAtom1();
final MolAtom atom2 = bond.getAtom2();
// pointer equality:
final int[] badAtomNums = ArrayUtils.addAll(
exception.getBadAtomNums(),
new int[] {mol.indexOf(superatom) + 1,
mol.indexOf(atom1 == attachPt
|| atom1 == (MolAtom) superatom
? atom2 : atom1) + 1});
exception.setBadAtomNums(badAtomNums);
throwError = true;
} // if bond is coordinate
} // for each bond to the superatom attachment point
} // if there's an attachment point
} // if shortcut group is a superatom
} // for each shortcut group
if (throwError) {
debugPrintMRV(SELF + "Coordinate bond error(s) in:\n", mol);
throw exception;
} // if should throw an error
debugPrint(SELF + "no coordinate bonds starting at shortcut group; "
+ "checking for valence errors.");
mol.ungroupSgroups(SHORTCUT_GROUPS); // line 876
debugPrintMRV(SELF + "after ungroupSgroups():\n", mol);
...
The substrate:
<?xml version="1.0" encoding="windows-1252"?>
<cml xmlns="http://www.chemaxon.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.chemaxon.com/marvin/schema/mrvSchema_14_8_4.xsd" version="ChemAxon file format v14.8.4, generated by v14.9.8.0">
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14" elementType="C C N C C C
R C C C C C C C" sgroupRef="0 0 0 0 0 0 sg1 0 0 0 0 0 0 sg2" x2="-1.5399999618530273 -2.873669302901286 -2.873669302901286 -1.5399999618530273 -0.20633062080476905 -0.20633062080476905 -4.2073533150385165 2.4610227323807212 3.7946920734289815 3.7946920734289824 2.461022732380724 1.1273533913324643 1.127353391332463 5.128376085566212" y2="1.973158870389245 1.2031419298302044 -0.3368919512878767 -1.1069088918469172 -0.3368919512878767 1.2031419298302044 1.9731334595040955 1.2031165189450506 1.9731334595040926 3.513167340622174 4.283184281181216 3.513167340622174 1.973133459504094 4.283158870296064"/>
<bondArray>
<bond id="b1" atomRefs2="a1 a2" order="1"/>
<bond id="b2" atomRefs2="a2 a3" order="2"/>
<bond id="b3" atomRefs2="a3 a4" order="1"/>
<bond id="b4" atomRefs2="a4 a5" order="2"/>
<bond id="b5" atomRefs2="a5 a6" order="1"/>
<bond id="b6" atomRefs2="a1 a6" order="2"/>
<bond id="b7" atomRefs2="a2 a7" order="1"/>
<bond id="b8" atomRefs2="a8 a9" order="1"/>
<bond id="b9" atomRefs2="a9 a10" order="2"/>
<bond id="b10" atomRefs2="a10 a11" order="1"/>
<bond id="b11" atomRefs2="a11 a12" order="2"/>
<bond id="b12" atomRefs2="a12 a13" order="1"/>
<bond id="b13" atomRefs2="a8 a13" order="2"/>
<bond id="b14" atomRefs2="a10 a14" order="1"/>
<bond id="b15" atomRefs2="a13 a6" order="1"/>
</bondArray>
<molecule id="sg1" role="SuperatomSgroup" title="OMe" leftName="MeO" molID="m2">
<atomArray atomID="a15 a16" elementType="O C" attachmentPoint="1 0" sgroupAttachmentPoint="1 0" x2="-7.892500381469727 -6.352500381469726" y2="3.8499999046325684 3.8499999046325684"/>
<bondArray>
<bond id="b16" atomRefs2="a16 a15" order="1"/>
</bondArray>
<AttachmentPointArray>
<attachmentPoint atom="a15" order="1" bond="b7"/>
</AttachmentPointArray>
</molecule>
<molecule id="sg2" role="SuperatomSgroup" title="OMe" leftName="MeO" molID="m3">
<atomArray atomID="a17 a18" elementType="O C" attachmentPoint="1 0" sgroupAttachmentPoint="1 0" x2="5.868394939919245 5.098377999360202" y2="5.93557983760554 4.601910496557284"/>
<bondArray>
<bond id="b17" atomRefs2="a18 a17" order="1"/>
</bondArray>
<AttachmentPointArray>
<attachmentPoint atom="a17" order="1" bond="b14"/>
</AttachmentPointArray>
</molecule>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>
The exception:
Sep 29, 2014 8:14:21 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: java.lang.UnsupportedOperationException: ValenceCheck is supported for atoms in molecules only
at chemaxon.struc.MolAtom.valenceCheck(MolAtom.java:4069)
at chemaxon.struc.Molecule.ungroupSgroup(Molecule.java:2627)
at chemaxon.struc.Molecule.ungroupSgroup(Molecule.java:2488)
at chemaxon.struc.Molecule.ungroupSgroups(Molecule.java:2568)
at chemaxon.struc.Molecule.ungroupSgroups(Molecule.java:2550)
at com.epoch.chem.ChemUtils.checkValence(ChemUtils.java:876)
at com.epoch.responses.Response.initializeResponse(Response.java:166)
at com.epoch.responses.Response.<init>(Response.java:104)
at com.epoch.qBank.Question.parseResponse(Question.java:1216)
at com.epoch.session.HWSession.submitResponse(HWSession.java:928)
at org.apache.jsp.homework.answerframe_jsp._jspService(answerframe_jsp.java:582)
What does this exception mean? Using JChem and MarvinSketch 14.9.8.0; the structure would have been drawn with MarvinSketch. If there is something malformed about the MRV, then there is something wrong with how MarvinSketch converted the drawing into MRV.