Add Molecule in MSketch

User 1c420bf027

24-05-2011 10:47:01

I have one instance of Msketch and one instance of MView with a variable number of cells on one html.


I would like to add the content of a specific cell into the Msketch instance upon a mouse event on the respective cell.


Currently, I have two problems:


1) is there a function like addMol; currently I used setMol, but that overwrites the content of the MSketch.


2) my listenmouseevent only works in the first cell of the MView applet, but not in any other cell.


 


Best regards andreas

ChemAxon 7c2d26e5cf

26-05-2011 12:14:33

There is not a simple way to assigning compound to an existing molecule in the specified cell. I can recommend the following procedure. It requires also the Marvin Beans API.


1. Get the content of the specified cell that you would like to refresh, from the applet: JMView.getM(int,String)


2. Get the drawn compound from the sketcher applet: JMSketch.getMol(int,String)


3. Send both structure to the server where you can create Molecule objects from the molecule sources and join one of them to the other with the help of the Marvin Beans API:


Molecule moleculeFromSketch = MolImporter.importMol(moleculeFromSketchString);
Molecule moleculeFromView = MolImporter.importMol(moleculeFromViewString);
moleculeFromView.fuse(moleculeFromSketch);

MolImporter.importMol(String)


MoleculeGraph.fuse(MoleculeGraph)


4. Export the new molecule into MRV format: Molecule.toFormat(String)


5.Send the given molecule source back to the browser.


6. Import the new molecule source into the desired cell of the applet: JMView.setM(int,String)


About listenmousevent issue: Can you send an example?

User 1c420bf027

27-05-2011 07:41:19

Thank you for your suggestions, that was more or less the work-around that I figured out in the meantime. I was just creating a SMILES expression from the sketch and the View panel (getMol) and put it back in the Sketch panel.


 


I think in future I will try to include the fuse function.


 


btw:


My problems with the mouseover event happens for this code



marvin_jvm = "plugin"; // "builtin" or "plugin"

    mview_name = "MV_Disp";
    //mview_mayscript=true;
    mview_begin("./marvin/", 500, 500);
    mview_param('rows',4);
    mview_param('cols',4);
    mview_param("border", "1");
    mview_param("layoutH", ":4:1:L:0:0:1:1:");
    mview_param("cell0", ":Templates:");
    mview_param("layout",":1:2:"
    +"M:0:0:1:1:"
    +"L:0:0:");
    mview_param("listenmouseevent" , "true")
    mview_end();



Regards


Andreas

ChemAxon 7c2d26e5cf

31-05-2011 12:53:03

Thanks for the code example.


We are going to check it.