Calling elemental analyser functions from within msketch

User e9b312fb05

05-09-2005 05:16:08

Hi,








I need some help on the elemental analyser functions. For now I use





function submitstructure()


{


var s = document.MSketch.getMol("mol");


s = unix2local(s);


document.structure.molfile.value = s;


}





to post the structure drawn to some cgi using a hidden input called molfile in a form called structure. Now I'd like to post also the molecular weight and formula and tried to use the getFormula() call like





function submitstructure()


{


var s = document.MSketch.getMol("mol");


var f = document.MSketch.getFormula();


s = unix2local(s);


document.structure.molfile.value = s;


document.structure.formula.value = f;


}





but this doesn't work. So my question is how to call the getFormula() or getMass() functions from within msketch like I tried in the code above.





Thanks, Paul

ChemAxon 7c2d26e5cf

06-09-2005 16:23:40

(J)MSketch.getFormula method doesn't exist.


From JavaScript, methods of calculator plugins are not accessible.


Molecule weight and other calculations should be done on the server side.


I can imagine it by the following way:


1. Get the molecule from the applet.


2. Post it to the server to calculate its molweight.


3. Send back the result to the browser.





On the server side, you can use JSP to process posted data and send back the result to the browser in html format.


You can use both Marvin Beans or JChem API in your JSP code to calculate mol weight and molecule formula.

User e9b312fb05

06-09-2005 16:36:29

That's too bad as it would require the server side to run java. Unfortunately I can't get my headless server to work with java. I keep getting errors initializing the HPI library.





So, does the tools menu in MSketch actually access java tools on the server side? It would be nice to integrate the free elemental analyser functions into MSketch. How do you think about this?








Paul

ChemAxon 7c2d26e5cf

06-09-2005 18:22:56

Quote:
It would be nice to integrate the free elemental analyser functions into MSketch. How do you think about this?
We will implement functions for getting the formula of the molecule and calculating molweight.

User e9b312fb05

06-09-2005 18:34:19

Sounds great!








Will it take a long time? I'm asking because I might postpone my current project that will rely on retrieving this information using the msketch javascript interface.








Thanks so far for your help! :-)

ChemAxon 7c2d26e5cf

07-09-2005 12:01:50

I don't know when will be the next release.


But I can send you a pre-release when your required features are implemented. I think we can do it in a few days.

User e9b312fb05

07-09-2005 13:02:07

That would be very kind of You. Thanks for Your cooperation!

User e9b312fb05

19-09-2005 20:11:42

So Tamas. Did You find time to include the EA functions into Marvin Sketch?








Paul

ChemAxon 7c2d26e5cf

20-09-2005 13:14:32

I hope we can release the new Marvin this week that already includes the required methods.

User e9b312fb05

20-09-2005 13:34:41

I'll be watching Your site... :-)

User e103a02d82

30-11-2006 14:39:49

I'm developing a simple inventory view in Ruby on Rails and therefore need to access the molecular mass from the applet not the server.





IS this issue now resolved in the latest marvin?





I need to get the mass and formula from Marvin Sketch from JavaScript in the webpage.

User e103a02d82

30-11-2006 14:48:50

Code example for your comment.





<div class="form-element">


<label for="compound_mass">Mass</label>


<div class="MassLinkedField"><input id="compound_mass" name="compound[mass]" onBlur="this.value = document.MSketch.getMass()" size="10" type="text" /></div>


</div>





<div class="form-element">


<label for="compound_smiles">Smiles</label>


<input id="compound_smiles" name="compound[smiles]" size="30" type="text" value="CCc1c(CC(C)NC)ccc(O)c1C" />


</div>

User e103a02d82

30-11-2006 19:11:03

OK found it





MSketch.getMolMass()





MSketch.getMolFormula()





Was in release 4.0.2 onwards...

ChemAxon 7c2d26e5cf

30-11-2006 19:24:32

I'm glad that you have managed to find the answer. :-)