export error

User 870ab5b546

09-09-2013 21:58:50

Trying to reduce the use of applets in our code by replacing MarvinView with images generated on the back end. Using Marvin/JChem 5.11.5.  The code:


    public static void writeMolImage(String molStr, String fileName, long flags) {
final String SELF = "MolString.writeMolImage: ";
try {
final File outFile = new File(AppConfig.appRoot + '/' + fileName);
if (outFile.exists()) return;
final FileOutputStream outStream = new FileOutputStream(outFile);
final StringBuilder optsBld = new StringBuilder();
optsBld.append(PNG);
final Molecule mol = MolImporter.importMol(molStr);
final boolean isLewis = molStr.contains("Lewis ");
final int[] dims = getBestAppletSize(mol, isLewis);
optsBld.append(":w").append(dims[0]).append(",h").append(dims[1]);
optsBld.append(",valenceErrorVisible");
optsBld.append(",H_").append(
Question.showNoHydrogens(flags) ? "off"
: Question.showHeteroHydrogens(flags) ? "hetero"
: Question.showAllHydrogens(flags) ? "all"
: "heteroterm");
optsBld.append(",cv_").append(Question.showAllCarbons(flags)
? "on" : "inChain");
if (Question.showLonePairs(flags)) optsBld.append(",lp");
if (Question.showMapping(flags)) optsBld.append(",amap");
if (Question.showRSLabels(flags)) optsBld.append(",chiral_all");
final String opts = optsBld.toString();
debugPrint(SELF + "writing to ", fileName, " with options ",
opts, ":\n", molStr);
final MolExporter exporter = new MolExporter(outStream, opts);
exporter.write(mol);
exporter.close();
} catch (MolFormatException e) {
System.out.println(SELF + "caught MolFormatException: ");
e.printStackTrace();
} catch (MolExportException e) {
System.out.println(SELF + "caught MolExportException: ");
e.printStackTrace();
} catch (FileNotFoundException e) {
System.out.println(SELF + "caught FileNotFoundException: ");
e.printStackTrace();
} catch (IOException e) {
System.out.println(SELF + "caught IOException: ");
e.printStackTrace();
} // try
} // writeMolImage(String, String, int)

The log:


MolString.writeMolImage: writing to figures/5883_molImg33725.png with options png:w250,h214,valenceErrorVisible,H_off,cv_on:
<?xml version="1.0" ?>
<cml>
<MDocument atomSetRGB="0:N,1:#0000ff,2:N,3:#0000ff" atomSetFont="0:SansSerif-PLAIN-12,1:SansSerif-PLAIN-12,2:Serif-PLAIN-14,3:Serif-PLAIN-14">
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12"
elementType="F Cl Br I C C C C C C C C"
mrvSetSeq="1 0 0 2 0 0 0 0 0 0 0 0"
x2="7.2 11.6 11.68888888888889 8.133333333333333 14.8 15.644444444444446 11.377777777777778 9.822222222222223 5.022222222222222 8.444444444444445 4.355555555555556 8.711111111111112"
y2="7.466666666666667 6.266666666666667 2.666666666666667 2.0444444444444447 7.733333333333333 2.177777777777778 10.222222222222223 5.2444444444444445 1.9555555555555557 0.08888888888888889 7.288888888888889 9.866666666666667"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="1" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a2 a5" order="1" />
<bond atomRefs2="a3 a6" order="1" />
<bond atomRefs2="a1 a7" order="1" />
<bond atomRefs2="a4 a8" order="1" />
<bond atomRefs2="a4 a9" order="1" />
<bond atomRefs2="a4 a10" order="1" />
<bond atomRefs2="a1 a11" order="1" />
<bond atomRefs2="a1 a12" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MTextBox color="#0000ff">
<Field name="text"> + </Field>
<MPoint x="6.094664102884943" y="8.438669230448392" />
<MPoint x="8.094664102884943" y="8.438669230448392" />
<MPoint x="8.094664102884943" y="7.438669230448392" />
<MPoint x="6.094664102884943" y="7.438669230448392" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="6.872222222222223" y="8.561111111111112" />
<MPoint x="8.872222222222224" y="8.561111111111112" />
<MPoint x="8.872222222222224" y="6.561111111111112" />
<MPoint x="6.872222222222223" y="6.561111111111112" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="6.872222222222223" y="7.227777777777779" />
<MPoint x="8.872222222222224" y="7.227777777777779" />
<MPoint x="8.872222222222224" y="5.227777777777779" />
<MPoint x="6.872222222222223" y="5.227777777777779" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="6.605555555555556" y="8.561111111111112" />
<MPoint x="8.605555555555556" y="8.561111111111112" />
<MPoint x="8.605555555555556" y="6.561111111111112" />
<MPoint x="6.605555555555556" y="6.561111111111112" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="6.605555555555556" y="7.227777777777779" />
<MPoint x="8.605555555555556" y="7.227777777777779" />
<MPoint x="8.605555555555556" y="5.227777777777779" />
<MPoint x="6.605555555555556" y="5.227777777777779" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="7.304574313838127" y="7.51732082781162" />
<MPoint x="9.304574313838128" y="7.51732082781162" />
<MPoint x="9.304574313838128" y="5.517320827811619" />
<MPoint x="7.304574313838127" y="5.517320827811619" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="7.116012505521716" y="7.328759019495208" />
<MPoint x="9.116012505521716" y="7.328759019495208" />
<MPoint x="9.116012505521716" y="5.328759019495208" />
<MPoint x="7.116012505521716" y="5.328759019495208" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="6.173203463939652" y="7.51732082781162" />
<MPoint x="8.173203463939652" y="7.51732082781162" />
<MPoint x="8.173203463939652" y="5.517320827811619" />
<MPoint x="6.173203463939652" y="5.517320827811619" />
</MTextBox>
<MTextBox color="#0000ff">
<Field name="text"> \u2022 </Field>
<MPoint x="6.361765272256063" y="7.328759019495208" />
<MPoint x="8.361765272256063" y="7.328759019495208" />
<MPoint x="8.361765272256063" y="5.328759019495208" />
<MPoint x="6.361765272256063" y="5.328759019495208" />
</MTextBox>
<MTextBox>
<Field name="text"> - </Field>
<MPoint x="11.816447008226168" y="7.238669230448391" />
<MPoint x="13.816447008226168" y="7.238669230448391" />
<MPoint x="13.816447008226168" y="6.238669230448391" />
<MPoint x="11.816447008226168" y="6.238669230448391" />
</MTextBox>
<MTextBox>
<Field name="text"> \u2022 </Field>
<MPoint x="10.75098124171743" y="7.071568061077271" />
<MPoint x="12.75098124171743" y="7.071568061077271" />
<MPoint x="12.75098124171743" y="5.071568061077271" />
<MPoint x="10.75098124171743" y="5.071568061077271" />
</MTextBox>
<MTextBox>
<Field name="text"> \u2022 </Field>
<MPoint x="10.939543050033842" y="7.260129869393682" />
<MPoint x="12.939543050033842" y="7.260129869393682" />
<MPoint x="12.939543050033842" y="5.260129869393682" />
<MPoint x="10.939543050033842" y="5.260129869393682" />
</MTextBox>
<MTextBox>
<Field name="text"> 2+ </Field>
<MPoint x="11.860891452670614" y="3.6386692304483916" />
<MPoint x="13.860891452670614" y="3.6386692304483916" />
<MPoint x="13.860891452670614" y="2.6386692304483916" />
<MPoint x="11.860891452670614" y="2.6386692304483916" />
</MTextBox>
<MTextBox>
<Field name="text"> \u2022 </Field>
<MPoint x="11.494444444444444" y="2.427777777777778" />
<MPoint x="13.494444444444444" y="2.427777777777778" />
<MPoint x="13.494444444444444" y="0.4277777777777778" />
<MPoint x="11.494444444444444" y="0.4277777777777778" />
</MTextBox>
<MTextBox>
<Field name="text"> \u2022 </Field>
<MPoint x="11.227777777777778" y="2.427777777777778" />
<MPoint x="13.227777777777778" y="2.427777777777778" />
<MPoint x="13.227777777777778" y="0.4277777777777778" />
<MPoint x="11.227777777777778" y="0.4277777777777778" />
</MTextBox>
<MTextBox>
<Field name="text"> 2- </Field>
<MPoint x="6.9835529917738315" y="3.0164470082261694" />
<MPoint x="8.98355299177383" y="3.0164470082261694" />
<MPoint x="8.98355299177383" y="2.0164470082261694" />
<MPoint x="6.9835529917738315" y="2.0164470082261694" />
</MTextBox>
</MDocument>
</cml>

The image generated is shown.  Note the weird blue boxes.  (The electrons and the atom should be blue.) Pasting the same MRV into MarvinSketch 6.0.3, I see the same weird boxes.  However, the MRV looks just fine when displayed in MarvinView 5.4.1.1. ??  

ChemAxon a202a732bf

10-09-2013 09:11:26

Dear Bob,


the MRV file you have attached contains several text boxes containing bullets and + or - signs, these are probably present in the original 'molStr' object as well. You can see these text boxes in the attached image as blue boxes. There is indeed a bug in our MRV import which was not present in the earlier versions of Marvin: font colors of text boxes are converted to line colors of the text box frame, that's why you can not see the boxes in the older version (there the bullets are blue). We will fix this bug in the following major release.


Best regards,


Zsuzsa

ChemAxon a202a732bf

11-09-2013 07:23:18

Dear Bob,


Sorry, I made a misleading promise about the next release. We are just going to release a major version in the upcoming days, which had a development deadline much earlier. Let me clarify: by next major release (which will contain the fix of the MRV import bug) I meant the one following that.


Best regards,


Zsuzsa