severe bug in JChem 5.3 MEFlow.getMolObject()

User 870ab5b546

07-03-2010 19:21:14

The code:


        for (MEFlow eFlow : eFlows) {
debugPrint("Processing Flow # ", ++flowNum, ": ");
final Object source = eFlow.getMolObject(MEFlow.E_SOURCE);
final Object sink = eFlow.getMolObject(MEFlow.E_SINK);
if (source instanceof MolAtom) {
debugPrint("Source is MolAtom.");
...
} else if (source instanceof MolBond) {
debugPrint("Source is MolBond.");
...
} else {
debugPrint("Source is unknown type.");
} // end source

// calculate bond orders and unshared electron counts for sinks
if (sink instanceof MolAtom[] // incipient bond
// *** or 2e arrow atom to atom = incipient bond ***
|| (source instanceof MolAtom
&& sink instanceof MolAtom
&& eFlow.getNumElectrons() == 2)) {
debugPrint("Sink is MolAtom[].");
...
} else if (sink instanceof MolAtom) {
debugPrint("Sink is MolAtom.");
...
} else if (sink instanceof MolBond) {
debugPrint("Sink is MolBond.");
...
} else {
debugPrint("Sink is unknown.");
} // end sink
doc.removeObject(eFlow);
} // next EFlow arrow flowNum


The input MRV:


<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8"
elementType="C C C C Br O C C"
formalCharge="0 0 0 0 0 -1 0 0"
x2="17.475572892575848 18.80925201440388 20.14293113623192 20.177234724002336 21.510913845830373 17.475572892575848 18.039252014403882 19.579252014403885"
y2="-5.895710214222811 -6.665710214222813 -5.895710214222811 -4.115085128392124 -3.345085128392123 -4.355710214222812 -7.999389336050847 -7.999389336050847"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="1" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a4 a5" order="1" />
<bond atomRefs2="a1 a6" order="1" />
<bond atomRefs2="a2 a7" order="1" />
<bond atomRefs2="a2 a8" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a6" />
<MAtomSetPoint atomRefs="m1.a6 m1.a4" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o3" arcAngle="-254.995522631729" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a4 m1.a5" />
<MAtomSetPoint atomRefs="m1.a5" />
</MEFlow>
</MDocument>
</cml>

The output:


Processing Flow # 1: 
Source is unknown type.
Sink is MolAtom[].
Sink is incipient bond:
Adding a new bond between these atoms
Processing Flow # 2:
Source is MolBond.
Source bond electron count changed from 2 to 0
Breaking single bond connecting atoms C4 with parity 3 and Br5 with parity 0; changing parities to 0.
Sink is MolAtom.
Setting bond 8 to ChemAxon type 1
Removing bond 4

How can it be possible for the source of an electron-flow arrow to be neither a MolAtom nor a MolBond???


Clearly the source of the electron-flow arrow IS a MolAtom!!!  Why does JChem not recognize it???


Please fix!!!

User 870ab5b546

08-03-2010 23:15:04

According to the JChem documentation,



getMolObject


public java.lang.Object getMolObject(int i)

Gets the electron source or sink.

 


Parameters:
i - E_SOURCE or E_SINK
Returns:
a MolAtom, MolBond or MolAtom[2] (incipient bond) object


 


But clearly getMolObject() is returning none of these objects, or my code would be working.


I notice in the XML that there is a new kind of object, the MEFlowBasePoint.  So I modified my code as follows, but still no joy:


public static Molecule getProducts(String reactants,
            boolean fromMechCalculator)
            throws MechError, MolFormatException {
        final Molecule molecule = MolImporter.importMol(reactants);
        molecule.dearomatize();
        theMolecule = molecule; // ref for printing
        final ArrayList<MechFlow> eFlows = new ArrayList<MechFlow>();
        final MDocument doc = molecule.getDocument();
        if (doc == null) {
            Utils.alwaysPrint("MechSolver error: molecule "
                    + "contains no MDocument (no flows)");
            return new Molecule(); // return an empty molecule
        }
        for (int objNum = 0; objNum < doc.getObjectCount(); ++objNum) {
            final MObject o = doc.getObject(objNum);
            if (o instanceof MEFlow) eFlows.add(new MechFlow((MEFlow) o));
        }
        debugPrint("\nMechSolver: Input molecule:\n", reactants,
                molecule.getAtomCount(), " atoms, ",
                molecule.getBondCount(), " bonds, ",
                eFlows.size(), " e-flow arrows.\n");

    // Find atoms in molecule fragments touched by e-flow arrows, and remove
    // atoms not in such molecule fragments.
        final ArrayList<MolAtom> atomsInTouchedMols = new ArrayList<MolAtom>();
        for (MechFlow eFlow : eFlows) {
            final MolAtom[] srcAtoms = eFlow.getSrcAtoms();
            addAtomsInTouchedMols(srcAtoms[0], atomsInTouchedMols); // line 93
            final MolAtom[] sinkAtoms = eFlow.getSinkAtoms();
            addAtomsInTouchedMols(sinkAtoms[0], atomsInTouchedMols);
            if (eFlow.sinkIsIncipBond()) {
                addAtomsInTouchedMols(sinkAtoms[1], atomsInTouchedMols);
            } // end sink
        } // for each flow
...

public MolAtom[] getSrcAtoms() {
        return getAtoms(MEFlow.E_SOURCE);
    } // getSrcAtoms()

public MolAtom[] getSinkAtoms() {
        return getAtoms(MEFlow.E_SINK);
    } // getSinkAtoms()

public MolAtom[] getAtoms(int srcOrSnk) {
        return getAtoms(meFlow.getMolObject(srcOrSnk));
    } // getAtoms(int)

public static MolAtom[] getAtoms(Object terminus) {
        final String SELF = "MechFlow.getAtoms: ";
        MolAtom[] atoms;
        if (isAtom(terminus)) {
            debugPrint(SELF + "arrow terminus is atom.");
            atoms = new MolAtom[] {getAtom(terminus)};
        } else if (isBond(terminus)) {
            debugPrint(SELF + "arrow terminus is bond.");
            MolBond bond = (MolBond) terminus;
            atoms = new MolAtom[] {bond.getAtom1(), bond.getAtom2()};
        } else if (isIncipBond(terminus)) {
            debugPrint(SELF + "arrow terminus is incipient bond.");
            atoms = (MolAtom[]) terminus;
        } else {
            debugPrint(SELF + "arrow terminus is unknown type.");
            atoms = new MolAtom[0];
        }
        return atoms;
    } // getAtoms(Object)

public static boolean isAtom(Object terminus) {
        return (terminus instanceof MolAtom
                || terminus instanceof MEFlowBasePoint);
    } // isAtom(Object)

public static boolean isBond(Object terminus) {
        return (terminus instanceof MolBond);
    } // isBond(Object)

public static boolean isIncipBond(Object sink) {
        return (sink instanceof MolAtom[]);
    } // isIncipBond(Object)

public static MolAtom getAtom(Object terminus) {
        final String SELF = "MechFlow.getAtom: ";
        MolAtom atom;
        if (terminus instanceof MolAtom) {
            debugPrint(SELF + "getting MolAtom atom.");
            atom = (MolAtom) terminus;
        } else if (terminus instanceof MEFlowBasePoint) {
            debugPrint(SELF + "getting MEFlowBasePoint atom.");
            atom = ((MEFlowBasePoint) terminus).getAtom();
        } else {
            debugPrint(SELF + "unknown type, getting null atom.");
            atom = null;
        }
        return atom;
    } // getAtom(Object)

Output:


MechSolver: Input molecule:
<?xml version="1.0" ?>
<cml>
<MDocument>
  <MChemicalStruct>
    <molecule molID="m1">
      <atomArray
          atomID="a1 a2 a3 a4 a5 a6"
          elementType="C C O C C Br"
          formalCharge="0 0 -1 0 0 0"
          x2="-2.983750104904175 -4.317390104904175 -4.317390104904175 -1.6501101049041749 -1.6501101049041749 -0.31643098307613915"
          y2="-0.3176249928474426 0.4523750071525574 1.9923750071525574 1.9923750071525577 0.4523750071525574 2.7623750071525577"
          />
      <bondArray>
        <bond atomRefs2="a1 a2" order="1" />
        <bond atomRefs2="a1 a5" order="1" />
        <bond atomRefs2="a2 a3" order="1" />
        <bond atomRefs2="a4 a5" order="1" />
        <bond atomRefs2="a4 a6" order="1" />
      </bondArray>
    </molecule>
  </MChemicalStruct>
  <MEFlow id="o2" arcAngle="150.0" headSkip="0.15" headLength="0.5"
          headWidth="0.4" tailSkip="0.25">
    <MEFlowBasePoint atomRef="m1.a3" />
    <MAtomSetPoint atomRefs="m1.a3 m1.a4" weights="0.25 0.75" />
  </MEFlow>
  <MEFlow id="o3" arcAngle="248.39738999999997" headSkip="0.25"
          headLength="0.5" headWidth="0.4" tailSkip="0.15">
    <MAtomSetPoint atomRefs="m1.a4 m1.a6" />
    <MAtomSetPoint atomRefs="m1.a6" />
  </MEFlow>
</MDocument>
</cml>
6 atoms, 5 bonds, 2 e-flow arrows.

MechFlow.getAtoms: arrow terminus is unknown type.
java.lang.ArrayIndexOutOfBoundsException: 0
    at com.prenhall.epoch.mechanisms.MechSolver.getProducts(MechSolver.java:93)
    at org.apache.jsp.public_.mechmarvin_jsp._jspService(mechmarvin_jsp.java:84)

I see from the MEFlowBasePoint documentation that Peter was writing it.  Is it possible that he left something unfinished and broken before he passed away?

User 870ab5b546

08-03-2010 23:56:07

One more bit of information: getMolObject() is returning null.


public static MolAtom[] getAtoms(Object terminus) {
        final String SELF = "MechFlow.getAtoms: ";
        MolAtom[] atoms;
        if (isAtom(terminus)) {
            debugPrint(SELF + "arrow terminus is atom.");
            atoms = new MolAtom[] {getAtom(terminus)};
        } else if (isBond(terminus)) {
            debugPrint(SELF + "arrow terminus is bond.");
            MolBond bond = (MolBond) terminus;
            atoms = new MolAtom[] {bond.getAtom1(), bond.getAtom2()};
        } else if (isIncipBond(terminus)) {
            debugPrint(SELF + "arrow terminus is incipient bond.");
            atoms = (MolAtom[]) terminus;
        } else {
            debugPrint(SELF + "arrow terminus is unknown type ", // line 274
                    terminus.getClass().getName());
            atoms = new MolAtom[0];
        }
        return atoms;
    } // getAtoms(Object)

java.lang.NullPointerException
    at com.prenhall.epoch.mechanisms.MechFlow.getAtoms(MechFlow.java:274)
    at com.prenhall.epoch.mechanisms.MechFlow.getAtoms(MechFlow.java:286)
    at com.prenhall.epoch.mechanisms.MechFlow.getSrcAtoms(MechFlow.java:293)
    at com.prenhall.epoch.mechanisms.MechSolver.getProducts(MechSolver.java:92)
    at org.apache.jsp.public_.mechmarvin_jsp._jspService(mechmarvin_jsp.java:84)

Please fix ASAP.

ChemAxon 12eab24e0a

10-03-2010 12:16:46

Dear Bob,


Unfortunately it was completely Peter's topic, so we have to investigate the problem now. We are working on it.

Thank you for your patience!


Eva

User 870ab5b546

10-03-2010 14:47:33

OK.  While you're at it, though, I would like to recommend that you add the following methods to MEFlow:


/** Gets the origin of the electron-flow arrow (MolAtom, MolBond, or 
* MEFlowBasePoint).
* @return origin of the electron-flow arrow
*/
public Object getSource() { return getMolObject(E_SOURCE); }

/** Gets the destination of the electron-flow arrow (MolAtom, MolBond, or
* MolAtom[2] for incipient bond).
* @return destination of the electron-flow arrow
*/
public Object getSink() { return getMolObject(E_SINK); }

/** Gets whether this arrow's source is an atom.
* @return whether this arrow's source is an atom
*/
public boolean sourceIsAtom() {
return isAtom(getSource());
} // sourceIsAtom()

/** Gets whether this arrow's sink is an atom.
* @return whether this arrow's sink is an atom
*/
public boolean sinkIsAtom() {
return isAtom(getSink());
} // sinkIsAtom()

/** Gets whether the arrow's terminus is at an atom.
* @param terminus the arrow terminus
* @return whether the arrow's terminus is at an atom
*/
public static boolean isAtom(Object terminus) {
return (terminus instanceof MolAtom
|| terminus instanceof MEFlowBasePoint);
} // isAtom(Object)

/** Gets whether this arrow's source is a bond.
* @return whether this arrow's source is a bond
*/
public boolean sourceIsBond() {
return isBond(getSource());
} // sourceIsBond()

/** Gets whether this arrow's sink is a bond.
* @return whether this arrow's sink is a bond
*/
public boolean sinkIsBond() {
return isBond(getSink());
} // sinkIsBond()

/** Gets whether the arrow's terminus is at a bond.
* @param terminus the arrow terminus
* @return whether the arrow's terminus is at a bond
*/
public static boolean isBond(Object terminus) {
return (terminus instanceof MolBond);
} // isBond(Object)

/** Gets whether this arrow's sink is an incipient bond.
* @return whether this arrow's sink is an incipient bond
*/
public boolean sinkIsIncipBond() {
return isIncipBond(getSink());
} // sinkIsIncipBond()

/** Gets whether the arrow's sink is at an incipient bond.
* @param sink the arrow sink
* @return whether the arrow's sink is at an incipient bond
*/
public static boolean isIncipBond(Object sink) {
return (sink instanceof MolAtom[]);
} // isIncipBond(Object)

/** Gets the atom at the source of this arrow. Use only after sourceIsAtom().
* @return the atom at the source of this arrow
*/
public MolAtom getSourceAtom() {
return getAtom(getSource());
} // getSourceAtom()

/** Gets the atom at the sink of this arrow. Use only after sinkIsAtom().
* @return the atom at the sink of this arrow
*/
public MolAtom getSinkAtom() {
return getAtom(getSink());
} // getSinkAtom()

/** Gets the atom at the terminus of an arrow.
* @param terminus the arrow terminus
* @return the atom at the terminus of an arrow
*/
public static MolAtom getAtom(Object terminus) {
public MolAtom atom;
if (terminus instanceof MolAtom) {
atom = (MolAtom) terminus;
} else if (terminus instanceof MEFlowBasePoint) {
atom = ((MEFlowBasePoint) terminus).getAtom();
} else {
atom = null;
}
return atom;
} // getAtom(Object)

/** Gets the bond at the terminus of an arrow.
* @param terminus the arrow terminus
* @return the bond at the terminus of an arrow
*/
public static MolBond getBond(Object terminus) {
return ((MolBond) terminus);
} // getBond(Object)

/** Gets the bond at the source of this arrow. Use only after sourceIsBond().
* @return the bond at the source of this arrow
*/
public MolBond getSourceBond() {
return getBond(getSource());
} // getSourceBond()

/** Gets the bond at the sink of this arrow. Use only after sinkIsBond().
* @return the bond at the sink of this arrow
*/
public MolBond getSinkBond() {
return getBond(getSink());
} // getSinkBond()

/** Gets the atom or atoms at the arrow source.
* @return the atom or atoms at the arrow source
*/
public MolAtom[] getSourceAtoms() {
return getAtoms(getSource());
} // getSourceAtoms()

/** Gets the atom or atoms at the arrow sink.
* @return the atom or atoms at the arrow sink
*/
public MolAtom[] getSinkAtoms() {
return getAtoms(getSink());
} // getSinkAtoms()

/** Gets the atom or atoms at the terminus of an arrow.
* @param terminus the arrow terminus
* @return the atom or atoms at the terminus of an arrow
*/
public static MolAtom[] getAtoms(Object terminus) {
public MolAtom[] atoms;
if (isAtom(terminus)) {
atoms = new MolAtom[] {getAtom(terminus)};
} else if (isBond(terminus)) {
MolBond bond = (MolBond) terminus;
atoms = new MolAtom[] {bond.getAtom1(), bond.getAtom2()};
} else if (isIncipBond(terminus)) {
atoms = (MolAtom[]) terminus;
} else {
atoms = new MolAtom[0];
}
return atoms;
} // getAtoms(Object)

ChemAxon 12eab24e0a

10-03-2010 21:13:05

Dear Bob,


The bug is fixed, it's going to be in the 5.3.2 release, which is coming out next week. The other suggestion, you've mentioned is really seems usefull, but I can not put it into the 5.3.2. I prefer test developments before I release it, and I can not finish that in time. Probably in 5.4 we can have it.


Thanks again,


Eva

User 973f05c12c

19-03-2010 02:57:17

I'm running into this bug and it's really affecting my ability to draw chemical mechanisms (I've been working around it by deleting offending electron-flow arrows). 


When will 5.3.2 be available?  Is it possible to download a testing version or the patched source?  I really need a fix soon.


Thanks,


Malay


P.S. besides this bug, marvinsketch is awesome!

ChemAxon 7c2d26e5cf

23-03-2010 13:56:31

Marvin 5.3.2 can be expected in a couple days.

User 870ab5b546

21-04-2010 15:50:16

I have downloaded Marvin 5.3.2, and I am now experiencing a new problem regarding electron-flow arrows.


After importing a document with flow arrows and molecules, I convert the Molecule to its fragments, which should associate the MolAtoms with the fragments, and store the Molecule fragments in appropriate MechStages.  I then extract the MEFlow arrows, use the MolAtoms of the sources and sinks of the MEFlows to find their associated Molecules, and put them in the MechStages that their associated Molecules are in.  Then, when I am ready to calculate products of flow arrows in each stage, I fuse all the stage's Molecules together, create a new MDocument from it, add the MEFlows to it, and export it to MRV format.


In cases where an electron-flow arrow begins at an atom, I am now getting a MolExportException:


MechStage.setStageMDoc: creating MDocument with molecule:
[OH-].[H][N+](C)(C)C
MechStage.setStageMDoc: adding flow:
Source Bond: N[+1]1 to H4, order 1
Sink Atom: N[+1]1
MechStage.setStageMDoc: adding flow:
Source Atom: O[-1]5
Sink Incip Bond: O[-1]-1 to H-1
MechStage.setStageMDoc: can't export stage MDocument:
document does not contain MolAtom@1fe8884[O] (0) in MAtomSetPoint
chemaxon.marvin.io.MolExportException: document does not contain MolAtom@1fe8884[O] (0) in MAtomSetPoint
at chemaxon.marvin.io.formats.cml.MrvExport.findMolAtomIds(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendPoint(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendMObject(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert0(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.MDocument.exportToObject(Unknown Source)
at chemaxon.struc.MDocument.exportToFormat(Unknown Source)
at com.prenhall.epoch.mechanisms.MechStage.setStageMDoc(MechStage.java:358)

Note that the sink incipient bond of the second arrow contains O and H atoms whose coordinates are -1.  This is pretty strange, because the source O atom, index 5, is the SAME ATOM as the sink O atom, index -1.  Why would the same atom have different indices with respect to the same parent???


Clearly something is wrong in the way that the incipient bond atoms are stored or retrieved.


Here is the code for printing the flow arrows:


    /** Prints details about the electron-flow arrow.  */
void print() {
final MolAtom[] srcAtoms = getSrcAtoms();
final Molecule parent = (Molecule) srcAtoms[0].getParent();
print(parent);
} // print()

/** Prints details about the electron-flow arrow.
* @param parent molecule containing the atoms of the electron-flow
* arrows
*/
void print(Molecule parent) {
final MolAtom[] srcAtoms = getSrcAtoms();
debugPrint(" Parent molecule is ", parent);
if (srcIsAtom()) {
Utils.alwaysPrint(" Source Atom: ", srcAtoms[0],
parent.indexOf(srcAtoms[0]));
} else if (srcIsBond()) {
Utils.alwaysPrint(" Source Bond: ", srcAtoms[0],
parent.indexOf(srcAtoms[0]), " to ",
srcAtoms[1], parent.indexOf(srcAtoms[1]),
", order ", getSrcBond().getType());
} else Utils.alwaysPrint(" Source: INVALID! Neither atom nor bond");
final MolAtom[] sinkAtoms = getSinkAtoms();
if (sinkIsAtom()) {
Utils.alwaysPrint(" Sink Atom: ", sinkAtoms[0],
parent.indexOf(sinkAtoms[0]));
} else if (sinkIsBond()) {
Utils.alwaysPrint(" Sink Bond: ", sinkAtoms[0],
parent.indexOf(sinkAtoms[0]), " to ",
sinkAtoms[1], parent.indexOf(sinkAtoms[1]),
", order ", getSinkBond().getType());
} else if (sinkIsIncipBond()) {
Utils.alwaysPrint(" Sink Incip Bond: ", sinkAtoms[0],
parent.indexOf(sinkAtoms[0]), " to ",
sinkAtoms[1], parent.indexOf(sinkAtoms[1]));
} else Utils.alwaysPrint(" Sink: INVALID! Neither atom "
+ "nor bond nor incipient bond");
} // print(Molecule)

    /** Gets the atom or atoms at the arrow source.  
* @return the atom or atoms at the arrow source
*/
MolAtom[] getSrcAtoms() {
return getAtoms(getSource());
} // getSrcAtoms()

/** Gets the atom or atoms at the arrow sink.
* @return the atom or atoms at the arrow sink
*/
MolAtom[] getSinkAtoms() {
return (is2electronAtom2Atom()
? new MolAtom[] {getSrcAtom(), getSinkAtom()}
: getAtoms(getSink()));
} // getSinkAtoms()

/** Gets the atom or atoms at the terminus of an arrow.
* @param terminus the arrow terminus
* @return the atom or atoms at the terminus of an arrow
*/
private static MolAtom[] getAtoms(Object terminus) {
final String SELF = "MechFlow.getAtoms: ";
MolAtom[] atoms;
if (isAtom(terminus)) {
debugPrint(SELF + "arrow terminus is atom.");
atoms = new MolAtom[] {getAtom(terminus)};
} else if (isBond(terminus)) {
debugPrint(SELF + "arrow terminus is bond.");
final MolBond bond = (MolBond) terminus;
atoms = new MolAtom[] {bond.getAtom1(), bond.getAtom2()};
} else if (isIncipBond(terminus)) {
debugPrint(SELF + "arrow terminus is incipient bond.");
atoms = (MolAtom[]) terminus;
} else {
try {
debugPrint(SELF + "terminus is of unknown type ",
terminus.getClass().getName(),
", getting empty array.");
} catch (NullPointerException e) {
debugPrint(SELF + "terminus is null, getting empty array.");
}
atoms = new MolAtom[0];
}
return atoms;
} // getAtoms(Object)

    /** Gets the origin of the electron-flow arrow (MolAtom or MolBond).
* @return origin of the electron-flow arrow
*/
Object getSource() { return meFlow.getMolObject(MEFlow.E_SOURCE); }
/** Gets the destination of the electron-flow arrow (MolAtom, MolBond, or
* MolAtom[2] for incipient bond).
* @return destination of the electron-flow arrow
*/
Object getSink() { return meFlow.getMolObject(MEFlow.E_SINK); }


I'm also attaching a picture of the Marvin picture that's generating the error.


Please advise.


P.S.  Note how in the Marvin drawing, the electron-flow arrow overlaps with the incipient H attached to O.  It shouldn't.  


User 870ab5b546

26-04-2010 23:14:09

Hi folks, no feedback on this one?

ChemAxon e500b51457

27-04-2010 12:52:57

Hi Bob,

Apologies for the late answer.
We are investigating the issue and we will get back with an answer soon.

Regards,
Erika.

User 870ab5b546

03-05-2010 16:46:08










Erika wrote:

Hi Bob,

Apologies for the late answer.
We are investigating the issue and we will get back with an answer soon.

Regards,
Erika.



Hi, any progress?

ChemAxon 40e8f9506d

04-05-2010 11:28:00

Dear Bob,


my colleagues are still investigating the issue, we will be back with an answer as soon as possible.


Thank you for your patience.


Annamaria

ChemAxon 12eab24e0a

05-05-2010 09:19:06

Dear Bob,



I'm really sorry about the late answer. I would like to ask you, if it
has ever worked for you, (and it is something new, which has came out
as a side effect of our developments) or this is the first time you
have tried to implement it.

Just because - as I see it - the problem you have run into, is based on that you convert
the Molecule to its fragments, producing new Molecules. MEFlow is implemented between atoms, bonds, or array of atoms in a 
well defined molecule, but not between different molecules. And this case it's
normal, that atom indexes became -1.



Thank you again for your patience, and waiting for your answer

Eva

User 870ab5b546

05-05-2010 12:40:41

The code that is now failing has worked well for years.  It broke only when I upgraded from Marvin 5.2 to Marvin 5.3.


Note that the error says that the MolAtom associated with the MAtomSetPoint isn't in the MDocument.


MechStage.setStageMDoc: can't export stage MDocument:
document does not contain MolAtom@1fe8884[O] (0) in MAtomSetPoint


But here is the code that throws the error:


    /** Creates an MDocument and MRV representation containing this stage's 
* molecules and electron-flow arrows.
*/
public void setStageMDoc() {
final String SELF = "MechStage.setStageMDoc: ";
final Molecule fused = getFusedMolecule();
debugPrint(SELF + "creating MDocument with molecule:\n", fused);
stageMDoc = new MDocument(fused);
for (MechFlow flow : flows) {
debugPrint(SELF + "adding flow: ");
flow.print();
stageMDoc.addObject(flow.getMEFlow());
}
try {
stageXML = stageMDoc.exportToFormat("mrv");
} catch (MolExportException e) {
Utils.alwaysPrint(SELF + "can't export stage MDocument:\n",
e.getMessage());
e.printStackTrace();
} // try
} // setStageMDoc()

/** Gets all this stage's molecules fused into a single Molecule object.
* @return a Molecule containing all of this stage's molecules
*/
public Molecule getFusedMolecule() {
final Molecule fMol = new Molecule();
for (Molecule mol : getMoleculeArray())
fMol.fuse(mol);
return fMol;
} // getFusedMolecule()

The fused molecule contains all of the atoms with which the MEFlows are associated, so the error message makes no sense.


I think this bug is related to the one I reported earlier in this post.  I think Peter was fiddling around with having electron-flow arrows originating at lone pairs instead of atoms, and I think he left something broken when he died unexpectedly.


ChemAxon 12eab24e0a

07-05-2010 14:13:56

Dear Bob,



MrvExport is giving that exception because of the -1 index of the O
and H atoms, or any atom with an index of -1 is producing this behavior, and that's normal.What I really don't understand, is how did you get this atom index!  I
guess it's because you've tried to create an MEFlow between atoms/bonds
of different molecules, but I don't know, how did you create that electron-flow.

Electron-flow arrows are originated at points(MPoint) which are associated with atoms/atom arrays, it's not the
lone-pair, so that can not be the bug.

I could not reproduce the bug in MSketch by drawing, and using
export-import. I couldn't produce any atom with -1 index in the
MDocument  in the MAtomSetPoint, (even I've  created the same molecule
as you did). If you could send me the code that produce those atoms, that might help me a lot.



Thank you,

Eva

User 870ab5b546

07-05-2010 15:18:28

I think I've narrowed down the problem to a MolImporter bug.  I've found an even simpler way of generating the error.  The code:


    public static Molecule getProducts(String reactants,
boolean fromMechCalculator)
throws MechError, MolFormatException {
debugPrintMRV("MechSolver: reactants: \n", reactants);
final Molecule molecule = MolImporter.importMol(reactants);
molecule.dearomatize();
refMol = molecule; // ref for printing

// Get the electron-flow arrows from the document.
final MDocument doc = molecule.getDocument();
final ArrayList<MechFlow> eFlows = new ArrayList<MechFlow>();
if (doc == null) {
Utils.alwaysPrint("MechSolver error: molecule "
+ "contains no MDocument (no flows)");
return new Molecule(); // return an empty molecule
} else for (int objNum = 0; objNum < doc.getObjectCount(); ++objNum) {
final MObject o = doc.getObject(objNum);
if (o instanceof MEFlow) eFlows.add(new MechFlow((MEFlow) o));
}
debugPrint("\nMechSolver: reaction has ",
molecule.getAtomCount(), " atoms, ",
molecule.getBondCount(), " bonds, ",
eFlows.size(), " e-flow arrows.\n");

The debugging output from Marvin 5.3.2:


MechSolver: reactants: 
<?xml version="1.0" ?>
<cml>
<MDocument>
<MEFlow id="o1" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a2" />
<MAtomSetPoint atomRefs="m1.a2 m1.a3" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
<MAtomSetPoint atomRefs="m1.a4" />
</MEFlow>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4"
elementType="C O C Br"
formalCharge="0 -1 0 0"
x2="-9.143750190734863 -7.603750190734863 -6.737500190734863 -5.197500190734863"
y2="8.036874771118164 8.036874771118164 4.76437520980835 4.76437520980835"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a3 a4" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

java.lang.NullPointerException
at chemaxon.struc.MoleculeGraph.indexOf(Unknown Source)
at chemaxon.struc.MoleculeGraph.contains(Unknown Source)
at chemaxon.struc.Molecule.contains(Unknown Source)
at chemaxon.struc.RgMolecule.contains(Unknown Source)
at chemaxon.struc.graphics.MChemicalStruct.containsAtom(Unknown Source)
at chemaxon.struc.graphics.MEFlowBasePoint.checkValidity(Unknown Source)
at chemaxon.struc.graphics.MPolyline.checkValidity(Unknown Source)
at chemaxon.struc.MDocument.setMainMoleculeGraph(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvImport.readMDocument(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvImport.readMRV(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvImport.readDocument(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol0(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol(Unknown Source)
at chemaxon.formats.MolImporter.readMol(Unknown Source)
at chemaxon.formats.MolImporter.read(Unknown Source)
at chemaxon.formats.MolImporter.importMol(Unknown Source)
at chemaxon.formats.MolImporter.importMol(Unknown Source)
at com.prenhall.epoch.mechanisms.MechSolver.getProducts(MechSolver.java:65)
at org.apache.jsp.public_.mechmarvin_jsp._jspService(mechmarvin_jsp.java:84)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
...

With different starting materials in Marvin 5.3.2:


MechSolver: reactants: 
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5"
elementType="C C C C C"
x2="-2.0693750381469727 -3.315241367163999 -2.83937894977678 -1.2993711265171655 -0.8235087091299444"
y2="3.3312422643143016 2.4260256658022996 0.9614782258824066 0.9614782258824066 2.4260256658022996"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="1" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a4 a5" order="1" />
<bond atomRefs2="a1 a5" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="248.39738999999997" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a1 m1.a5" />
<MAtomSetPoint atomRefs="m1.a5" />
</MEFlow>
</MDocument>
</cml>


MechSolver: reaction has 5 atoms, 5 bonds, 1 e-flow arrows.

The first set of starting materials in Marvin 5.2.6:


MechSolver: Input molecule:
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4"
elementType="C O C Br"
formalCharge="0 -1 0 0"
x2="-15.303750038146973 -13.763750038146972 -13.426875114440918 -11.886875114440917"
y2="9.384374618530273 9.384374618530273 6.208125114440918 6.208125114440918"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a3 a4" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MAtomSetPoint atomRefs="m1.a2" />
<MAtomSetPoint atomRefs="m1.a2 m1.a3" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o3" arcAngle="-254.995522631729" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
<MAtomSetPoint atomRefs="m1.a4" />
</MEFlow>
</MDocument>
</cml>


I see that one difference between Marvin 5.3 and Marvin 5.2 is that Marvin 5.3 generates XML with an MEFlow that has an MEFlowBasePoint, whereas Marvin 5.2 generates XML with MEFlows that have only MAtomSetPoints.  I think it is likely that MolImporter does not assign the MEFlowBasePoint to an atom.  As I said earlier, I believe that Peter was trying to develop a way to begin MEFlow arrows at lone pairs instead of atoms, and the MEFlowBaePoint was intended to accomplish this goal.  Unfortunately, he died before he had implemented it completely, and as a result, the endpoints of MEFlows that begin at atoms are no longer being associated with those atoms, even though the atom reference is being given.  Please fix ASAP.


User 870ab5b546

07-05-2010 16:22:10










ehollo wrote:

Dear Bob,



MrvExport is giving that exception because of the -1 index of the O
and H atoms, or any atom with an index of -1 is producing this behavior, and that's normal.What I really don't understand, is how did you get this atom index!  I
guess it's because you've tried to create an MEFlow between atoms/bonds
of different molecules, but I don't know, how did you create that electron-flow.

Thank you,

Eva



I use Marvin to generate an MRV.  I import the MRV into a Molecule with MolImporter, and I get the MDocument from the Molecule.  I fragment the Molecule into its constituent Molecule[] frags, and I get MEFlows from the MDocument.  I then take a subset of the Molecules in frags, fuse them into a single Molecule, create a new MDocument from that molecule, and then add to the new MDocument all the MEFlows whose endpoint MolAtoms are in the Molecules in the frags subset.  Finally, I export the MDocument to MRV format, and that's where JChem throws the error.  


In the example above, the second MEFlow gets the correct atom index for O when O is the source.  It does not get the correct atom index when O is the sink.  It seems to me you have a bug in the process that assigns MolAtom indices to MEFlow endpoints or the process that gets MolAtom indices from MEFlow endpoints.  

User 870ab5b546

07-05-2010 16:23:14

Here's one more bit of info: I added a line to MechSolver to convert MEFlowBasePoint to MAtomSetPoint in the MRV, and I'm still getting the same MolImporter error.


    static String correctMEFlowBasePoint(String mrv5_3) {
return mrv5_3.replaceAll("MEFlowBasePoint", "MAtomSetPoint");
} // correctMEFlowBasePoint

    public static Molecule getProducts(String reactants,
boolean fromMechCalculator)
throws MechError, MolFormatException {
reactants = Mechanism.correctMEFlowBasePoint(reactants);
debugPrint("MechSolver: reactants: \n", reactants);
final Molecule molecule = MolImporter.importMol(reactants);
static String correctMEFlowBasePoint(String mrv5_3) {
return mrv5_3.replaceAll("MEFlowBasePoint", "MAtomSetPoint");
} // correctMEFlowBasePoint
 

MechSolver: reactants: 
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4"
elementType="C O C Br"
formalCharge="0 -1 0 0"
x2="-7.315000057220459 -5.72687479019165 -5.726874828338623 -4.186874828338623"
y2="1.7806249856948853 1.7806249856948853 -2.4543750286102295 -2.4543750286102295"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a3 a4" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="-150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MAtomSetPoint atomRef="m1.a2" />
<MAtomSetPoint atomRefs="m1.a2 m1.a3" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o3" arcAngle="-250.19139621618717" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
<MAtomSetPoint atomRefs="m1.a4" />
</MEFlow>
</MDocument>
</cml>

java.lang.NullPointerException
at java.util.StringTokenizer.<init>(StringTokenizer.java:182)
at java.util.StringTokenizer.<init>(StringTokenizer.java:219)
at chemaxon.marvin.io.formats.cml.MrvImport.setAtomSetPoints(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvImport.endObjectReading(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvImport.readMDocument(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvImport.readMRV(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvImport.readDocument(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol0(Unknown Source)
at chemaxon.marvin.io.MRecordImporter.readMol(Unknown Source)
at chemaxon.formats.MolImporter.readMol(Unknown Source)
at chemaxon.formats.MolImporter.read(Unknown Source)
at chemaxon.formats.MolImporter.importMol(Unknown Source)
at chemaxon.formats.MolImporter.importMol(Unknown Source)
at com.prenhall.epoch.mechanisms.MechSolver.getProducts(MechSolver.java:66)

ChemAxon 12eab24e0a

11-05-2010 10:11:54

All of your examples which produced error by import are syntactically not correct. At the first:


MechSolver: reactants: 
<?xml version="1.0" ?>
<cml>
<MDocument>
<MEFlow id="o1" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a2" />
<MAtomSetPoint atomRefs="m1.a2 m1.a3" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
<MAtomSetPoint atomRefs="m1.a4" />
</MEFlow>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4"
elementType="C O C Br"
formalCharge="0 -1 0 0"
x2="-9.143750190734863 -7.603750190734863 -6.737500190734863 -5.197500190734863"
y2="8.036874771118164 8.036874771118164 4.76437520980835 4.76437520980835"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a3 a4" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>




The order of MEFlow declaration and MChemicalStruct declaration should be changed, like that:



<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
    <molecule molID="m1">
      <atomArray
          atomID="a1 a2 a3 a4"
          elementType="C O C Br"
          formalCharge="0 -1 0 0"
          x2="-9.143750190734863 -7.603750190734863 -6.737500190734863 -5.197500190734863"
          y2="8.036874771118164 8.036874771118164 4.76437520980835 4.76437520980835"
          />
      <bondArray>
        <bond atomRefs2="a1 a2" order="1" />
        <bond atomRefs2="a3 a4" order="1" />
      </bondArray>
    </molecule>
  </MChemicalStruct>
  <MEFlow id="o1" arcAngle="150.0" headSkip="0.15" headLength="0.5"
          headWidth="0.4" tailSkip="0.25">
    <MEFlowBasePoint atomRef="m1.a2" />
    <MAtomSetPoint atomRefs="m1.a2 m1.a3" weights="0.25 0.75" />
  </MEFlow>
  <MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.25"
          headLength="0.5" headWidth="0.4" tailSkip="0.15">
    <MAtomSetPoint atomRefs="m1.a3 m1.a4" />
    <MAtomSetPoint atomRefs="m1.a4" />
  </MEFlow>
</MDocument>
</cml>


At the example you've changed MEFlowBasePoint to MAtomSetPoint  you didn't changed atomRef to atomRefs. So an "s" is missing. I agree that this difference is strange, I also have to tell, user can define one and only one atom at MEFlowBasePoint, while user can define one or more atoms at MAtomSetPoint. The right input is:



<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4"
elementType="C O C Br"
formalCharge="0 -1 0 0"
x2="-7.315000057220459 -5.72687479019165 -5.726874828338623 -4.186874828338623"
y2="1.7806249856948853 1.7806249856948853 -2.4543750286102295 -2.4543750286102295"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a3 a4" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="-150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MAtomSetPoint atomRefs="m1.a2" />
<MAtomSetPoint atomRefs="m1.a2 m1.a3" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o3" arcAngle="-250.19139621618717" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a3 m1.a4" />
<MAtomSetPoint atomRefs="m1.a4" />
</MEFlow>
</MDocument>
</cml>


After all I couldn't find any error in MrvImport.


 


 




 


 

User 870ab5b546

11-05-2010 13:51:47










ehollo wrote:

All of your examples which produced error by import are syntactically not correct. At the first:


The order of MEFlow declaration and MChemicalStruct declaration should be changed, like that:


After all I couldn't find any error in MrvImport.



Well I got those MRVs directly from Marvin 5.3.2, so then the bug is in how the applet exports the MRV.

User 870ab5b546

12-05-2010 16:24:04

It's funny that you say that the MEFlows MUST be after the MChemicalStruct, because here is the source of a Marvin picture that I created in a previous version of Marvin (not sure which one) and that I am displaying right now in Marvin 5.3.2:


<?xml version="1.0" ?>
<cml>
<MDocument>
<MPolyline id="o1" headLength="0.8" headWidth="0.5">
<MRectanglePoint pos="5" rectRef="o3" />
<MRectanglePoint pos="7" rectRef="o2" />
</MPolyline>
<MRectangle id="o2">
<MPoint x="0.1443749964237213" y="3.994374990463257" />
<MPoint x="6.785624980926514" y="3.994374990463257" />
<MPoint x="6.785624980926514" y="-1.9249999523162842" />
<MPoint x="0.1443749964237213" y="-1.9249999523162842" />
</MRectangle>
<MRectangle id="o3">
<MPoint x="-8.854999542236328" y="3.9462499618530273" />
<MPoint x="-1.8287500143051147" y="3.9462499618530273" />
<MPoint x="-1.8287500143051147" y="-2.5506250858306885" />
<MPoint x="-8.854999542236328" y="-2.5506250858306885" />
</MRectangle>
<MEFlow id="o4" arcAngle="-254.995522631729" headSkip="0.25"
headLength="0.6" headWidth="0.5" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a2 m1.a5" />
<MAtomSetPoint atomRefs="m1.a2" />
</MEFlow>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9"
elementType="C N C C H N C C C"
formalCharge="0 1 0 0 0 0 0 0 0"
x2="-6.400625228881836 -5.0669461070538 -3.7332669852257645 -5.0669461070538 -3.579420334568635 3.031874895095825 1.69819577326779 4.365554016923861 3.0318748950958248"
y2="-0.5293750166893005 0.24062498331069937 -0.5293750166893005 1.7806249833106995 0.6392063127685813 1.106874942779541 0.33687494277954044 0.33687494277954144 2.646874942779541"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="1" />
<bond atomRefs2="a2 a4" order="1" />
<bond atomRefs2="a2 a5" order="1" />
<bond atomRefs2="a6 a7" order="1" />
<bond atomRefs2="a6 a8" order="1" />
<bond atomRefs2="a6 a9" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

Notice that the MEFlow comes before the MChemicalStruct.  So, either previous versions of Marvin were more flexible than the current version, or you have had this output bug for a long time.  But I never encountered this bug until Marvin 5.3, so I think that you have suddenly added restrictions on the MRV format.


In any case, I have created a workaround that modifies an MRV in which MEFlows come before the MChemicalStruct by moving them after it, and that also replaces "MEFlowBasePoint atomRef" with "MAtomSetPoint atomRefs".  But I really would prefer that you fix these bugs that you have introduced recently.  

User 870ab5b546

12-05-2010 16:33:52

Here's another interesting observation.  This MRV can be imported by Marvin 5.3.2 (note that the two MEFlows come before MChemicalStruct):


<?xml version="1.0" ?>
<cml>
<MDocument>
<MEFlow id="o1" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MAtomSetPoint atomRefs="m1.a10" />
<MAtomSetPoint atomRefs="m1.a10 m1.a5" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.25"
headLength="0.6" headWidth="0.5" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a2 m1.a5" />
<MAtomSetPoint atomRefs="m1.a2" />
</MEFlow>
<MRectangle id="o3">
<MPoint x="0.1443749964237213" y="3.994374990463257" />
<MPoint x="6.785624980926514" y="3.994374990463257" />
<MPoint x="6.785624980926514" y="-1.9249999523162842" />
<MPoint x="0.1443749964237213" y="-1.9249999523162842" />
</MRectangle>
<MRectangle id="o4">
<MPoint x="-8.854999542236328" y="3.9462499618530273" />
<MPoint x="-1.8287500143051147" y="3.9462499618530273" />
<MPoint x="-1.8287500143051147" y="-2.5506250858306885" />
<MPoint x="-8.854999542236328" y="-2.5506250858306885" />
</MRectangle>
<MPolyline id="o5" headLength="0.8" headWidth="0.5">
<MRectanglePoint pos="5" rectRef="o4" />
<MPoint x="0.1443749964237213" y="1.0346875190734863" />
</MPolyline>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10"
elementType="C N C C H N C C C O"
formalCharge="0 1 0 0 0 0 0 0 0 -1"
x2="-6.400625228881836 -5.0669461070538 -3.7332669852257645 -5.0669461070538 -3.579420334568635 3.031874895095825 1.69819577326779 4.365554016923861 3.0318748950958248 -4.427499771118164"
y2="-0.5293750166893005 0.24062498331069937 -0.5293750166893005 1.7806249833106995 0.6392063127685813 1.106874942779541 0.33687494277954044 0.33687494277954144 2.646874942779541 3.224374771118164"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="1" />
<bond atomRefs2="a2 a4" order="1" />
<bond atomRefs2="a2 a5" order="1" />
<bond atomRefs2="a6 a7" order="1" />
<bond atomRefs2="a6 a8" order="1" />
<bond atomRefs2="a6 a9" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

If I then look at the source again, I get this:


<?xml version="1.0" ?>
<cml>
<MDocument>
<MEFlow id="o1" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a10" />
<MAtomSetPoint atomRefs="m1.a10 m1.a5" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o2" arcAngle="-254.995522631729" headSkip="0.25"
headLength="0.6" headWidth="0.5" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a2 m1.a5" />
<MAtomSetPoint atomRefs="m1.a2" />
</MEFlow>
<MRectangle id="o3">
<MPoint x="0.1443749964237213" y="3.994374990463257" />
<MPoint x="6.785624980926514" y="3.994374990463257" />
<MPoint x="6.785624980926514" y="-1.9249999523162842" />
<MPoint x="0.1443749964237213" y="-1.9249999523162842" />
</MRectangle>
<MRectangle id="o4">
<MPoint x="-8.854999542236328" y="3.9462499618530273" />
<MPoint x="-1.8287500143051147" y="3.9462499618530273" />
<MPoint x="-1.8287500143051147" y="-2.5506250858306885" />
<MPoint x="-8.854999542236328" y="-2.5506250858306885" />
</MRectangle>
<MPolyline id="o5" headLength="0.8" headWidth="0.5">
<MRectanglePoint pos="5" rectRef="o4" />
<MPoint x="0.1443749964237213" y="1.0346875190734863" />
</MPolyline>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10"
elementType="C N C C H N C C C O"
formalCharge="0 1 0 0 0 0 0 0 0 -1"
x2="-6.400625228881836 -5.0669461070538 -3.7332669852257645 -5.0669461070538 -3.579420334568635 3.031874895095825 1.69819577326779 4.365554016923861 3.0318748950958248 -4.427499771118164"
y2="-0.5293750166893005 0.24062498331069937 -0.5293750166893005 1.7806249833106995 0.6392063127685813 1.106874942779541 0.33687494277954044 0.33687494277954144 2.646874942779541 3.224374771118164"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="1" />
<bond atomRefs2="a2 a4" order="1" />
<bond atomRefs2="a2 a5" order="1" />
<bond atomRefs2="a6 a7" order="1" />
<bond atomRefs2="a6 a8" order="1" />
<bond atomRefs2="a6 a9" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

And if I try to import this source without modifying it, I get "Cannot import molecule.  Error in line 50."  So Marvin 5.3.2 exports source code that it can't itself read!!!  


I think you have several bugs here involving import and export of MEFlows.

ChemAxon 12eab24e0a

12-05-2010 18:42:01

Dear Bob,



Thank you for these observations, we are working on the solution(s)
right now. You are probably  right on that there are several bugs
around this newly implemented MEFlowBasePoint. Notice that last time I
fixed two at a time...

And thank you for the patience!



Regards,

Ev

User 870ab5b546

13-05-2010 14:14:55

For those who are wrestling with these bugs as well, here is a workaround.  


    /** Workaround of bugs in Marvin 5.3. 
* @param mrv MRV from Marvin
* @return MEFlowBasePoint replaced with MAtomSetPoint, MEFlows moved to
* after structure
*/
public static String correctMRV(String mrv) {
String mod = mrv.replaceAll(
"MEFlowBasePoint atomRef", "MAtomSetPoint atomRefs");
// flows should come after structure description
final String BEGIN_STRUCT = "<MChemicalStruct";
final String END_STRUCT = "</MChemicalStruct>";
final String BEGIN_FLOW = "<MEFlow";
final String END_FLOW = "</MEFlow>";
while (true) {
final int beginStruct = mod.indexOf(BEGIN_STRUCT);
if (beginStruct < 0) break;
final String preStruct = mod.substring(0, beginStruct);
final int beginFlows = preStruct.indexOf(BEGIN_FLOW);
if (beginFlows < 0) break;
final int endStruct = mod.indexOf(END_STRUCT)
+ END_STRUCT.length() + 1; // past return character
final String struct = mod.substring(beginStruct, endStruct);
final String afterStruct = mod.substring(endStruct);
final int endFlows = preStruct.lastIndexOf(END_FLOW)
+ END_FLOW.length() + 1; // past return character
final String preFlowsPreStruct = preStruct.substring(0, beginFlows);
final String flows = preStruct.substring(beginFlows, endFlows);
final String afterFlowsPreStruct = preStruct.substring(endFlows);
final StringBuilder bld = new StringBuilder(mod.length());
bld.append(preFlowsPreStruct);
bld.append(afterFlowsPreStruct);
bld.append(struct);
bld.append(flows);
bld.append(afterStruct);
mod = bld.toString();
} // while true
return mod;
} // correctMRV

Note that the bugs mean both that Marvin 5.3 cannot read certain MRV documents that earlier versions of Marvin created and can read, and also that Marvin 5.3 cannot read certain MRV documents that it itself exported.


If you apply this method to a String before you subject it to MolImporter.importMol(), and you apply it to the string obtained from MDocument.exportToFormat("mrv"), all should work properly.  

ChemAxon 12eab24e0a

19-05-2010 09:43:03

Dear Bob,



I've fixed an NPE in MEFlowBasePoint,  so the  bug occurred during
MrvImport is disappeared. And I was no right about the ordering of the
MEFlow-s vs. MChemichalStruct, now mrvimport works in both case. What I
didn't change is "atomRef " to "atomRefs" in the mrv file. It is not a
bug, and if I do so, all of the mrv files which are already written
will give exception during import.

Unfortunately the latest release is just came out, so you have to wait
for the next one, which is coming out in 2 month, or rather earlier.
What is a pitty, because I'm not sure, if this fix is going to
eliminate your original problem about the -1 atomic indexes.



Thank you,

Regards,

Eva

User 870ab5b546

16-06-2010 02:32:20

So the fix will be in Marvin 5.3.4?  And I will no longer have to correct the MRV to avoid null pointer errors in import, export, or processing of electron-flow arrows?  

ChemAxon 12eab24e0a

16-06-2010 07:21:08

Hi Bob,


Yes, the fix will be in Marvin 5.3.4, and I hope so that everything will work properly. 


Regards,


Eva

User 870ab5b546

22-06-2010 15:03:18










ehollo wrote:

Hi Bob,


Yes, the fix will be in Marvin 5.3.4, and I hope so that everything will work properly. 


Regards,


Eva



Alas, it is not the case.  In Marvin 5.3.4, I am getting a MolExportException when I have an electron-flow arrow beginning at an atom:


MechStage.setStageMDoc: can't export stage MDocument:
document does not contain MolAtom@fb53f6[N] (0) in MAtomSetPoint
chemaxon.marvin.io.MolExportException: document does not contain MolAtom@fb53f6[N] (0) in MAtomSetPoint
at chemaxon.marvin.io.formats.cml.MrvExport.findMolAtomIds(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendPoint(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendMObject(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert0(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.MDocument.exportToObject(Unknown Source)
at chemaxon.struc.MDocument.exportToFormat(Unknown Source)
at com.prenhall.epoch.mechanisms.MechStage.setStageMDoc(MechStage.java:359)

User 870ab5b546

23-06-2010 02:10:50

And here's another exception that I obtained in a slightly different way, but again involving electron-flow arrows:


Processing Flow # 2: 
MechFlow.getAtoms: arrow terminus is bond.
Parent molecule is java.lang.IllegalArgumentException: The molecule doesn't contain the fi
rst atom of the bond
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.jav
a:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessor
Impl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at chemaxon.marvin.util.JavaLangUtil.newThrowable(Unknown Source)
at chemaxon.marvin.util.JavaLangUtil.newIllegalArgumentException(Unknown Source)
at chemaxon.struc.Molecule.toFormat(Unknown Source)
at com.prenhall.epoch.Utils.printMol(Utils.java:179)
at com.prenhall.epoch.Utils.printToLog(Utils.java:103)
at com.prenhall.epoch.Utils.printToLog(Utils.java:67)
at com.prenhall.epoch.mechanisms.MechFlow.debugPrint(MechFlow.java:18)
at com.prenhall.epoch.mechanisms.MechFlow.print(MechFlow.java:349)
at com.prenhall.epoch.mechanisms.MechSolver.getProducts(MechSolver.java:135)

The relevant code:


        final Molecule molecule = MolImporter.importMol(reactants);
molecule.dearomatize();
refMol = molecule; // ref for printing
final MDocument doc = molecule.getDocument();
final ArrayList<MechFlow> eFlows = new ArrayList<MechFlow>();
if (doc == null) {
Utils.alwaysPrint(SELF + "error: molecule "
+ "contains no MDocument (no flows)");
return new Molecule(); // return an empty molecule
} else for (int objNum = 0; objNum < doc.getObjectCount(); ++objNum) {
final MObject o = doc.getObject(objNum);
if (o instanceof MEFlow) eFlows.add(new MechFlow((MEFlow) o));
}
int flowNum = 0;
for (MechFlow eFlow : eFlows) {
debugPrint(SELF + "processing Flow # ", ++flowNum, ": ");
if (printFlowDetails) eFlow.print(refMol);
}

Class MechFlow:

void print(Molecule parent) {
final MolAtom[] srcAtoms = getSrcAtoms();
debugPrint(" Parent molecule is ", parent);
}

private static void debugPrint(Object... msg) {
Utils.printToLog(msg);
}

Class Utils:

public static void printToLog(Object[] msg) {
printToLog(msg, SMILES);
} // alwaysPrint(Object[], String)

public static void printToLog(Object[] msg, String format) {
for (Object obj : msg) {
if (obj == null) {
System.out.print("null");
} else if (obj instanceof MolAtom) {
printAtom((MolAtom) obj);
} else if (obj instanceof MolAtom[]) {
final MolAtom[] array = (MolAtom[]) obj;
boolean first = true;
for (Object arrayObj : array) {
if (first) first = false;
else System.out.print(".");
printAtom((MolAtom) arrayObj);
} // for each atom
} else if (obj instanceof Molecule) {
printMol((Molecule) obj, format);
....

The code works fine if I substitute all instances of "MEFlowBasePoint atomRef" in the MRV with "MAtomSetPoint atomRefs".

ChemAxon 12eab24e0a

24-06-2010 10:55:23

Dear Bob,


Thank you for the report, we are working on fixing the bug(s).


Regards,


Eva

ChemAxon 12eab24e0a

24-06-2010 16:10:31

Dear Bob,



I have some questions. First, can you send me the mrv files, what produces these bugs?

Second, You've written that you've got the following message:



chemaxon.marvin.io.MolExportException: document does not contain MolAtom@fb53f6[N] (0) in MAtomSetPoint


and you have written also that




The code works fine if I substitute all instances of "MEFlowBasePoint atomRef" in the MRV with "MAtomSetPoint atomRefs".


I see that these are different problems, so I would handle them separately, but still this is contradiction for me.

I went through  the export, import,  also the core classes, and I  have no idea, what it can be.


I just notice, that the second exception can be originated  from
SmilesExport, since that is the only Export module what gives such a message,
except that is a MolExportException. But why we are in the
SmilesExport? There are no electron-flows at all, am I right? I'm really confused already.



Sorry about these troubles,



Sincerely,

Eva

User 870ab5b546

24-06-2010 20:12:45

What happens is we import from Marvin an MRV document containing a multistage mechanism and break it up into individual MechStages, each of which contains some Molecules and the flow arrows touching them.  We then export the contents of each MechStage into an MDocument that we then use for processing.  The first error ("does not contain MolAtom[N] (0) in MAtomSetPoint") occurs in this code:


    public void setStageMDoc() {
final String SELF = "MechStage.setStageMDoc: ";
final Molecule fused = getFusedMolecule();
debugPrint(SELF + "creating MDocument with molecule:\n", fused);
stageMDoc = new MDocument(fused);
for (MechFlow flow : flows) {
debugPrint(SELF + "adding flow: ");
flow.print();
stageMDoc.addObject(flow.getMEFlow());
}
try {
stageXML = ChemUtils.correctMRV(stageMDoc.exportToFormat(MRV));
} catch (MolExportException e) {
Utils.alwaysPrint(SELF + "can't export stage MDocument:\n",
e.getMessage());
e.printStackTrace();
} // try
} // setStageMDoc()

when I try to export some of the Molecules and MEFlows that were originally imported from this MRV document that I created in Marvin 5.3.4:


<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray>
<atom id="a1" elementType="C"
x2="-4.550000190734863" y2="0.23333333432674408" />
<atom id="a2" elementType="Br"
x2="-3.0100001907348632" y2="0.23333333432674408" />
<atom id="a3" elementType="N"
x2="-8.341666221618652" y2="0.2916666567325592" />
<atom id="a4" elementType="N" formalCharge="1"
x2="2.799999952316284" y2="0.2916666567325592" />
<atom id="a5" elementType="C"
x2="4.339999952316284" y2="0.2916666567325592" />
<atom id="a6" elementType="Br" formalCharge="-1"
x2="7.699999809265137" y2="0.3499999940395355" />
</atomArray>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a4 a5" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MRectangle id="o2">
<MPoint x="-9.391666412353516" y="1.5166666507720947" />
<MPoint x="-2.0416667461395264" y="1.5166666507720947" />
<MPoint x="-2.0416667461395264" y="-1.1666666269302368" />
<MPoint x="-9.391666412353516" y="-1.1666666269302368" />
</MRectangle>
<MRectangle id="o3">
<MPoint x="1.0500000715255737" y="1.5166666358709335" />
<MPoint x="8.399999737739563" y="1.5166666358709335" />
<MPoint x="8.399999737739563" y="-1.166666641831398" />
<MPoint x="1.0500000715255737" y="-1.166666641831398" />
</MRectangle>
<MPolyline id="o4" headLength="0.8" headWidth="0.5">
<MRectanglePoint pos="5" rectRef="o2" />
<MRectanglePoint pos="7" rectRef="o3" />
</MPolyline>
<MEFlow id="o5" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MAtomSetPoint atomRefs="m1.a3" />
<MAtomSetPoint atomRefs="m1.a3 m1.a1" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o6" arcAngle="248.39738999999997" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a1 m1.a2" />
<MAtomSetPoint atomRefs="m1.a1" />
</MEFlow>
</MDocument>
</cml>

but NOT when I try to export some of the Molecules and MEFlows that were originally imported from this MRV document that I created in Marvin 5.2.6:


<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6"
elementType="C Br N N C Br"
formalCharge="0 0 0 1 0 -1"
x2="-4.550000190734863 -3.0100001907348632 -8.341666221618652 2.799999952316284 4.339999952316284 7.699999809265137"
y2="0.23333333432674408 0.23333333432674408 0.2916666567325592 0.2916666567325592 0.2916666567325592 0.3499999940395355"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a4 a5" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MRectangle id="o2">
<MPoint x="-9.391666412353516" y="1.5166666507720947" />
<MPoint x="-2.0416667461395264" y="1.5166666507720947" />
<MPoint x="-2.0416667461395264" y="-1.1666666269302368" />
<MPoint x="-9.391666412353516" y="-1.1666666269302368" />
</MRectangle>
<MRectangle id="o3">
<MPoint x="1.0500000715255737" y="1.5166666358709335" />
<MPoint x="8.399999737739563" y="1.5166666358709335" />
<MPoint x="8.399999737739563" y="-1.166666641831398" />
<MPoint x="1.0500000715255737" y="-1.166666641831398" />
</MRectangle>
<MPolyline id="o4" headLength="0.8" headWidth="0.5">
<MRectanglePoint pos="5" rectRef="o2" />
<MRectanglePoint pos="7" rectRef="o3" />
</MPolyline>
<MEFlow id="o5" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MAtomSetPoint atomRefs="m1.a3" />
<MAtomSetPoint atomRefs="m1.a3 m1.a1" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o6" arcAngle="248.39738999999997" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a1 m1.a2" />
<MAtomSetPoint atomRefs="m1.a1" />
</MEFlow>
</MDocument>
</cml>

If I use Marvin 5.2.6, then the second error ("The molecule doesn't contain the first atom of the bond") occurs later on, after I have imported the MRV document that I created in setStageMDoc().  That MRV looks like this:


MechSolver.getProducts: reactants: 
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3"
elementType="C Br N"
x2="-4.550000190734863 -3.0100001907348632 -8.341666221618652"
y2="0.23333333432674408 0.23333333432674408 0.2916666567325592"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
<MEFlow id="o2" arcAngle="150.0" headSkip="0.15" headLength="0.5"
headWidth="0.4" tailSkip="0.25">
<MEFlowBasePoint atomRef="m1.a3" />
<MAtomSetPoint atomRefs="m1.a3 m1.a1" weights="0.25 0.75" />
</MEFlow>
<MEFlow id="o3" arcAngle="248.39738999999997" headSkip="0.25"
headLength="0.5" headWidth="0.4" tailSkip="0.15">
<MAtomSetPoint atomRefs="m1.a1 m1.a2" />
<MAtomSetPoint atomRefs="m1.a1" />
</MEFlow>
</MDocument>
</cml>

If this information is insufficient, I will have to send you privately the classes and methods that parse the original MRV document from Marvin into MechStages. 


Again, whether I use Marvin 5.2.6 or Marvin 5.3.4, if I always correct any MRV generated by the Marvin GUI or by the API to replace "MEFlowBasePoint atomRef" with "MAtomSetPoint atomRefs", everything works fine. It seems to me that during the MRV parsing process,  the atom associated with the beginning of an electron-flow arrow is somehow becoming dissociated from the Molecule.   

ChemAxon 12eab24e0a

25-06-2010 18:10:45

Dear Bob,


I have fixed a part of the core class, but since I couldn't reproduce your exceptions (even if I've tried really hard) , I'm not sure that it will eliminate these exceptions, probably yes.


Thank you again,


Eva

User 870ab5b546

25-06-2010 18:30:05

If you can make the hopefully fixed version available to me for download, I can try it out.

ChemAxon 12eab24e0a

28-06-2010 11:06:31

Dear Bob,



we can send you a pre-release tomorrow. I would like to ask if the
beans are going to be ok for you or you would like to use applet as
well.



Thanks,

Eva

User 870ab5b546

28-06-2010 12:39:08

I need the applet.

User 870ab5b546

29-06-2010 02:07:45










ehollo wrote:

Dear Bob,


I have fixed a part of the core class, but since I couldn't reproduce your exceptions (even if I've tried really hard) , I'm not sure that it will eliminate these exceptions, probably yes.


Thank you again,


Eva



In JChem 5.3.5, the bugs still occur.

User 870ab5b546

29-06-2010 15:42:28

I downloaded jchem_5_3_2010-06-29_0106.zip as Tamas instructed me.  When I used the enclosed Marvin, the JSP page could not even acquire the MRV from Marvin:


        var molstruct = document.responseApplet.getMol('mrv');
alert('molstruct =\n' + molstruct);

 gave the alert,



molstruct =


If I changed back to Marvin 5.2.6, but compiled my Java classes with JChem 5.3.6pre, I got the same error as before.  


MechStage.setStageMDoc: can't export stage MDocument:
document does not contain MolAtom@14fe736[N] (0) in MAtomSetPoint
chemaxon.marvin.io.MolExportException: document does not contain MolAtom@14fe736[N] (0) in MAtomSetPoint
at chemaxon.marvin.io.formats.cml.MrvExport.findMolAtomIds(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendPoint(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendMObject(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert0(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.MDocument.exportToObject(Unknown Source)
at chemaxon.struc.MDocument.exportToFormat(Unknown Source)
at com.prenhall.epoch.mechanisms.MechStage.setStageMDoc(MechStage.java:363)

I'm going to send you code in a private email so you can try to reproduce it.

ChemAxon 7c2d26e5cf

01-07-2010 14:19:29

When you retrieved the structure from the applet (immediately after specificying applet code or after some delay)?


The applet needs time to initalize itself and loads structure that is defined in applet parameter. It is an asynchrone process, so msketch_end() returns before the aboves are completed.


If you get molecule immediately after msketch_end((), there is no guarantee that structure is already in the applet.


In this case JMSketch.getMol() returns with an empty structure.

User 870ab5b546

01-07-2010 14:22:35

I haven't changed any of the code involved in retrieving the structure from the applet.  When the applet initializes, it loads whatever structure we want it to load.  I modify the drawing by hand, then submit it.  The applet has long been initialized.

ChemAxon 12eab24e0a

06-07-2010 12:23:32

Dear Bob,

Sorry about the inconveniences, I'll deal with the problem later, as I've written in e-mail.

Thanks for your patience,

Eva

User 870ab5b546

17-07-2010 21:44:26

Any progress on this problem?

ChemAxon 12eab24e0a

19-07-2010 19:46:05

Sorry about that, we still have to investigate other problems, but this one is also in the list, it is not forgotten. 

Sincerely,

Eva

ChemAxon 990acf0dec

03-08-2010 12:14:21

Hi Bob,


We still could not reproduce the original problem here (although Eva spent a lot of time on it, but still could not compile your codes in their present form), and presently we have very low capacity due to the commit deadline of 5.4. This bug report will be further processed only after that, and therefore will probably be fixed only in 5.4.1.


Sorry for the inconveniences and thank you for your patience.


Best regards,


Akos

User 870ab5b546

03-08-2010 14:28:35

I have a workaround (modifying the MRV code directly), so the need is not extremely urgent.  But when you tackle this bug again, please contact me and tell me exactly what the problems are with getting it to compile.

ChemAxon 12eab24e0a

04-08-2010 08:51:38

All right, and thank you again!


Sincerely,


Eva

User 870ab5b546

17-08-2010 18:16:51

Unfortunately, my workaround stopped working when I upgraded to JChem 5.3.6, so I have had to downgrade back to JChem 5.3.3.  This is a very unfortunate development, because I needed another bugfix related to Reactor that you introduced in JChem 5.3.6.  


However, I believe I have managed to find a way to elicit the bug in a more constrained way.  I'm going to send you some Java classes that I believe should compile with the help of JChem 5.3.6 and some Apache commons packages (listed in Utils.java).  I've also given you a JSP file called testMechParse.jsp.  You should paste the following structure into testMechParse.jsp and press View Document.  Note that the XML delivered for stage 1 is null.  If you switch to JChem 5.3.3, stage 1 will not be null.  The log shows the following exception:


MechStage.setStageMDoc: can't export stage MDocument:
document does not contain MolAtom@736622[C] (0) in MAtomSetPoint
chemaxon.marvin.io.MolExportException: document does not contain MolAtom@736622[C] (0) in MAtomSetPoint
at chemaxon.marvin.io.formats.cml.MrvExport.findMolAtomIds(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendPoint(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.appendMObject(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert0(Unknown Source)
at chemaxon.marvin.io.formats.cml.MrvExport.convert(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.Molecule.exportToObject(Unknown Source)
at chemaxon.struc.MDocument.exportToObject(Unknown Source) at chemaxon.struc.MDocument.exportToFormat(Unknown Source)
at com.prenhall.epoch.mechanisms.MechStage.setStageMDoc(MechStage.java:362)
at com.prenhall.epoch.mechanisms.MechStage.getStageXML(MechStage.java:385)
at com.prenhall.epoch.mechanisms.MechData.printStages(MechData.java:115)

I cannot emphasize enough that this bug is present in JChem 5.3.6 but not JChem 5.3.3.  The bug is introduced during runtime, not compilation: I can use JChem 5.3.3 to compile and then use JChem 5.3.6 during runtime, and the bug occurs, but it does not occur in the reverse situation.


Please fix this bug ASAP.


<?xml version="1.0" ?>
<cml>
<MDocument>
<MTextBox id="o1" toption="NOROT" fontScale="10.0" halign="LEFT"
valign="TOP" autoSize="false">
<Field name="text"><![CDATA[{bold,size=9}(provide the missing structure)]]></Field>
<MPoint x="15.881250381469727" y="-7.314999580383301" />
<MPoint x="22.32999992370605" y="-7.314999580383301" />
<MPoint x="22.32999992370605" y="-8.675974675750734" />
<MPoint x="15.881250381469723" y="-8.675974675750734" />
</MTextBox>
<MTextBox id="o2" toption="NOROT" fontScale="10.0" halign="LEFT"
valign="TOP" autoSize="false">
<Field name="text"><![CDATA[{bold}(supply arrows)]]></Field>
<MPoint x="-0.4812504053115845" y="-7.411250114440918" />
<MPoint x="5.004999876022339" y="-7.411250114440918" />
<MPoint x="5.004999876022339" y="-8.229374885559082" />
<MPoint x="-0.4812504053115845" y="-8.229374885559082" />
</MTextBox>
<MTextBox id="o3" toption="NOROT" fontScale="10.0" halign="LEFT"
valign="TOP" autoSize="false">
<Field name="text"><![CDATA[Box 2]]></Field>
<MPoint x="26.180002212524414" y="-7.700000286102295" />
<MPoint x="28.24937629699707" y="-7.700000286102295" />
<MPoint x="28.24937629699707" y="-8.614376068115234" />
<MPoint x="26.180002212524414" y="-8.614376068115234" />
</MTextBox>
<MTextBox id="o4" toption="NOROT" fontScale="10.0" halign="LEFT"
valign="TOP" autoSize="false">
<Field name="text"><![CDATA[Box 1]]></Field>
<MPoint x="7.699999809265137" y="-7.844376087188721" />
<MPoint x="9.432499885559082" y="-7.844376087188721" />
<MPoint x="9.432499885559082" y="-8.566250324249268" />
<MPoint x="7.699999809265137" y="-8.566250324249268" />
</MTextBox>
<MPolyline id="o5" headLength="0.8" headWidth="0.5" tailFlags="1"
tailLength="0.8" tailWidth="0.5">
<MRectanglePoint pos="5" rectRef="o6" />
<MRectanglePoint pos="7" rectRef="o7" />
</MPolyline>
<MRectangle id="o6">
<MPoint x="-3.031874895095825" y="0.19249999523162842" />
<MPoint x="10.058124542236328" y="0.19249999523162842" />
<MPoint x="10.058124542236328" y="-8.999375343322754" />
<MPoint x="-3.031874895095825" y="-8.999375343322754" />
</MRectangle>
<MRectangle id="o7">
<MPoint x="15.49625051021576" y="0.21656247973442078" />
<MPoint x="28.586249947547913" y="0.21656247973442078" />
<MPoint x="28.586249947547913" y="-8.975312858819962" />
<MPoint x="15.49625051021576" y="-8.975312858819962" />
</MRectangle>
<MEFlow id="o8" arcAngle="-254.995522631729" headSkip="0.15"
headLength="0.5" headWidth="0.4" tailSkip="0.25">
<MAtomSetPoint atomRefs="m1.a3" />
<MAtomSetPoint atomRefs="m1.a2 m1.a3" />
</MEFlow>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10"
elementType="C C O C C C C O C C"
formalCharge="0 1 0 0 0 0 1 0 0 0"
x2="1.523311123251915 3.063311123251915 4.603311123251915 0.43436668022463176 0.43436668022463176 21.362165622059546 22.902165622059545 24.442165622059548 20.273221179032262 20.273221179032262"
y2="-4.06216287612915 -4.06216287612915 -4.06216287612915 -2.9732184331018674 -5.151107319156433 -4.084222316741943 -4.084222316741943 -4.084222316741943 -2.9952778737146604 -5.173166759769226"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="2" />
<bond atomRefs2="a1 a4" order="1" />
<bond atomRefs2="a1 a5" order="1" />
<bond atomRefs2="a6 a7" order="1" />
<bond atomRefs2="a7 a8" order="2" />
<bond atomRefs2="a6 a9" order="1" />
<bond atomRefs2="a6 a10" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

ChemAxon 990acf0dec

18-08-2010 12:19:30

Hi Bob,


It seems that many topics are related now, and I think it is better to wait until Eva is back next week.


Thank you for your patience.


Best regards,


Akos