Few Questions

User 478d103dc9

09-04-2013 00:38:24

Hi,


I'm unable to find the code examples to do the following


1. Read molecular value(smile) from the editor. Similar to
MarvinSketch call
 document.MSketch.getMol('cxsmiles:u')


2. Clear/set empty the value in the sketch canvas. Similar to MarvinSketch call document.MSketch.setMol("")


Thanks

ChemAxon 6c76bc6409

09-04-2013 06:53:58

Hi Igor,


1. Marvin for Javascript uses the webservice component for formats other than MOL and MRV. To get the SMILES code, you need to do something like this:


var mrv = marvin.sketch.exportAsMrv();
$.ajax({
url: webservicesBaseUrl + '/rest-v0/util/calculate/stringMolExport',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
parameters: 'smiles',
structure: mrv
})
}).done(function(data) {
var smiles = data;
}).fail(function() {
//converting failed
});

2. It's pretty much the same in Marvin for JavaScript, only the function name is different. Though currently you get an error if you try to set "", so as a workaround I recommend an empty MRV document like so:


marvin.sketch.importAsMrv("<cml/>");


Andras

User 478d103dc9

09-04-2013 14:13:19










astracz wrote:

Hi Igor,


1. Marvin for Javascript uses the webservice component for formats other than MOL and MRV. To get the SMILES code, you need to do something like this:


var mrv = marvin.sketch.exportAsMrv();
$.ajax({
url: webservicesBaseUrl + '/rest-v0/util/calculate/stringMolExport',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
parameters: 'smiles',
structure: mrv
})
}).done(function(data) {
var smiles = data;
}).fail(function() {
//converting failed
});

2. It's pretty much the same in Marvin for JavaScript, only the function name is different. Though currently you get an error if you try to set "", so as a workaround I recommend an empty MRV document like so:


marvin.sketch.importAsMrv("<cml/>");


Andras



Hi Andras,


Corrrect me if i'm wrong, but in order to do #1, this has to be done frst: http://www.chemaxon.com/webservices/adminGuide.html#installation ?


Your solution for #2 seems to be working


Thanks

ChemAxon 6c76bc6409

09-04-2013 15:02:26

Hi Igor!


Actually, you need the new web services package, which can be downloaded from here, and its install guide is on this page as well:


http://www.chemaxon.com/download/marvin/for-javascript/


Andras