User 646de8ab9c
11-12-2014 10:29:28
Hi everyone,
I want to show images of chemical reactions from rxn data format stored in a DB. Thus, based on your examples of scripts, I need the equivalent function of molToDataUrl but for reactions : rxnDataToUrl.
Is this function exist?
Or is an other way exist to show reactions images whitout using a marvinSketcherInstance?
Thanks,
Lionel
ChemAxon 996dedebe0
12-12-2014 12:21:53
User 646de8ab9c
12-12-2014 13:08:05
Hello Janos,
I am sorry but I do not understand which javascript function I have to use to convert rxn into mrv data. In jsdoc.html I do not find any "marvin.molconverter()" like function.
Regards,
Lionel
ChemAxon 996dedebe0
12-12-2014 14:59:28
ChemAxon 7c2d26e5cf
12-12-2014 15:19:00
As my colleague mentioned, our ImageExporter API accepts only MDL molfile and MRV strings.
Marvin JS API does not provide any converter function among various chemical file formats.
To convert RXN to MRV, you need some extra code in your application. You can do it both on client or on server side:
- server side solution - insert the converter logic into your backend code:transform RXN source to MRV with the help of Marvin Beans API before you send it to the client.
http://www.chemaxon.com/marvin/help/developer/beans/api/chemaxon/formats/MolConverter.html
- client side solution: insert an extra hook into your client side JavaScript code: send the RXN source to the JChem WS to convert it to MRV. I guess that the Simple Format Conversion service can be ideal for you:
https://restdemo.chemaxon.com/apidocs/#stringMolExport
After you got the MRV source, you can already use the marvin.ImageExporter.mrvToDataUrl function of Marvin JS API to create image data uri from MRV.
https://marvinjs-demo.chemaxon.com/latest/jsdoc.html
User 646de8ab9c
12-12-2014 17:10:45
Janos, Tamas,
Thanks for your replies.
As in the server side solution it seems that the input data should be in a file, I prefer to test the second solution on the client side where it seems I can use variables for rxn data.
I tried solution 2 with the following code:
$.ajax({
type: "POST",
url: :"http://srvmodel/webservices2/rest-v0/util/calculate/molExport",
data: JSON.stringify({
"structure": "CCCCC",
"inputFormat": "rxn",
"parameters": "mrv"
}),
contentType: "application/json",
dataType: "json"
}).done(function(data){alert(data);}).fail(function(){alert("ERROR");});
In all cases (even with the stringMolExport webservice, I obtain the alert "ERROR".
Do I have an error in my code?
Regards,
Lionel
User 646de8ab9c
16-12-2014 17:31:49
Up.
I am bugging with the use of the webservices through javascript. Can you say me if the code is ok?
thansk in advance,
Lionel
ChemAxon 7c2d26e5cf
22-12-2014 10:59:33
Please, see the following example:
https://marvinjs-demo.chemaxon.com/6.2/examples/example-molconvert.html
It demonstrates how to use MolConvert WS via Ajax and how to pass its result to the sketcher.
In your code sniplet, the input format is wrong. Meanwhile the input string is a SMILES, you specified input format as "rxn" (instead of "smiles").
In your JSON response data, you can refer the molecule source like this:
data['structure']
User 646de8ab9c
07-01-2015 17:13:59
Tamas,
Thanks for your help. It work perfectly!
Lionel