Molecule equality

ChemAxon fa971619eb

17-03-2006 12:42:57

I need to know if a molecule has changed. I open it in MarvinSketch as an editor and when I get if back I need to know whether the user has made any changes.


I don't see any Molecule.equals(Object o)


method. Is there anyting I can use for this? e.g.





Molecule origMol = ...;


Molecule newMol = origMol.clone();


MViewPane mvp = new MViewPane();


mvp.setEditable(2);


mvp.setM(0, newMol);





// the user possibly edits the mol





Molecule editedMol = mvp.getM(0);


if (editedMol.equals(origMol)) {


// mol changed so I need to do something


}








Thanks


Tim

ChemAxon a3d59b832c

17-03-2006 13:26:45

Hi Tim,





The most straightforward method would be to use class MolSearch with PERFECT search. (Included in JChem.)





http://www.chemaxon.com/jchem/doc/api/chemaxon/sss/search/MolSearch.html





It is not sensitive to coordinate changes or other editing actions that do not change the meaning of the molecule.





If it is not sufficient, I recommend comparing the sources got by
Code:
mol.toFormat("mrv")






Best Regards,


Szabolcs

ChemAxon 7c2d26e5cf

17-03-2006 13:31:49

Hi Tim,


I suggest you to listen PropertyChangeEvents in MViewPane. The viewer drops an event when the structure is modified in any cell.
Code:
propertyChange: name=doc0 value=chemaxon.struc.MDocument@1a99347



See the ViewEventTest example.

ChemAxon fa971619eb

20-03-2006 14:44:37

Szabolcs, Tamas,





Thanks for those suggstions.


The propertyChangeListener approach doesn't seem to be what I need. Events are fired even when the molecule is not edited. It seems related to when the molecule in one of the MViewPane cells is set, and a change appears to happen when the cell is double clicked to open MarvinSketch, even if MarvinSletch is immediately closed without making any changes.





Comparing the "mrv" format looks closer to what I need. Can String equality (String.equals()) be used here? Initial tests look like it can.


What I need is to know when the user has just opened MarvinSketch, but then quit without making any changes.





Tim

ChemAxon a3d59b832c

21-03-2006 11:03:52

tdudgeon wrote:
Comparing the "mrv" format looks closer to what I need. Can String equality (String.equals()) be used here? Initial tests look like it can.
Yes, I thought of that method.





Best regards,


Szabolcs