converting mrv format to cml

User 956e0ca334

24-03-2015 09:25:40

Hi there,


I am sure this this an easy question, but I cannot seem to find the answer in the forums!


We are converting to Marvin JS from Marvin Vew/Sketch in applets.  In our old version we stored molecules from marvin view using:


document.MView.getM(0,'mol');


 


I have been storing these if the mrv format i.e.


 


Marvin 01081015462D
6 6 0 0 0 0 999 V2000
-1.3259 1.9152 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-2.0404 1.5027 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-2.0404 0.6777 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.3259 0.2652 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.6114 0.6777 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.6114 1.5027 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
2 3 2 0 0 0 0
3 4 1 0 0 0 0
4 5 2 0 0 0 0
5 6 1 0 0 0 0
1 6 2 0 0 0 0
M END


 


I would like to store them in the cml  which I generate in my new version using MarvinJS saved using the marvin.ImageExporter.mrvToDataUrl method.  E.g.


<cml><MDocument><MChemicalStruct><molecule molID="m1"><atomArray><atom id="a1" elementType="C" x2="-3.5417599999992513" y2="2.4984266543459195"/><atom id="a2" elementType="C" x2="-4.875306655997546" y2="1.7284266605059204"/><atom id="a3" elementType="C" x2="-4.875306655997546" y2="0.18824000616074654"/><atom id="a4" elementType="C" x2="-3.5417599999992513" y2="-0.5817599876792534"/><atom id="a5" elementType="C" x2="-2.208026677335787" y2="0.18824000616074654"/><atom id="a6" elementType="C" x2="-2.208026677335787" y2="1.7284266605059204"/><atom id="a7" elementType="Br" x2="-6.209002335645739" y2="2.4983979808080123"/><atom id="a8" elementType="Br" x2="-3.541806668719448" y2="4.038426653638787"/></atomArray><bondArray><bond atomRefs2="a1 a2" order="2"/><bond atomRefs2="a2 a3" order="1"/><bond atomRefs2="a3 a4" order="2"/><bond atomRefs2="a4 a5" order="1"/><bond atomRefs2="a5 a6" order="2"/><bond atomRefs2="a6 a1" order="1"/><bond atomRefs2="a2 a7" order="1"/><bond atomRefs2="a1 a8" order="1"/></bondArray></molecule></MChemicalStruct></MDocument></cml>


 


Could you give me a code snippet to do this?


 


Many thanks

ChemAxon 996dedebe0

24-03-2015 14:48:40

Dear Megan,


mrvToDataUrl() can create images from molecules. you cannot create CML with it.


 


In order to export molecules to CML in Marvin JS, you will need JChem webservice license too.

you only have to invoke exportStructure("cml") on Marvin JS if the molecule is properly set


you can start with this example: https://marvinjs-demo.chemaxon.com/latest/examples/example-getmol.html


. Or you can use JChem molconvert webservice directly: further details are available here: https://restdemo.chemaxon.com/apidocs/#stringMolExport .


 


I hope that helps.


Regards,


Janos Papdeak