Marvin JS cd_structure

User eda6f877b4

11-09-2014 18:40:01

I am porting from MarvinView to Marvin JS. I need to load a structure from the database stored in standard structure table.


With the MarvinView reading the cd_structure from the db, this could be parsed directly. As I see Marvin JS only displays MOL or MRV format.


What is the recommended approach for this scenario..?


(using jchem for .net)

ChemAxon 7c2d26e5cf

12-09-2014 08:55:47

You can use the importStructureFormat(String, String) function to load molecule into the Marvin JS editor.


If JChem WS is installed, you can use not only MDL molfile and MRV but other chemical formats too.


The getSupportedFormats() gives hints which chemical formats are accepted in the current context.


The following examples demonstrate who to import various molecule source into Marvin JS:


https://marvinjs-demo.chemaxon.com/latest/examples/example-setmol.html


https://marvinjs-demo.chemaxon.com/latest/examples/demo.html

User eda6f877b4

12-09-2014 09:05:47

Hi Tamas,


Greatly appreciate your answers here!


I am familiar with the function importStructure("mol", s);


If I want to import the data stored in cd_structure into the sketcher, is it correct that this can only be done if the WS is installed..?


(I don't have the WS currently..)


So my alternative here would be to select the cd_structure from db convert to mol and the import this into the sketcher. (is that not correct?)


If yes, I was just wanting an example of performing the conversion from db stored data to the mol format.

ChemAxon 7c2d26e5cf

12-09-2014 10:31:04

I recommend to install JChem WS.


Do all compounds present in the same format in cd_structure?


If yes, you do not need extra step, just call importStructure function with the right format parameter.


E.g.: importStructure("smiles", s)


If no, I guess you can do this conversion on the fly with JChem WS when you retrieve records.


Please, consult with the manual of JChem WS or post to the JChem WS forum to get further info about JChem WS.

User eda6f877b4

12-09-2014 10:54:50

Hi Tamas:


I realize that the WS solution would be the best, but for now that is not an option :-(


 


I have pasted below here the generated JS code for the final page:


var marvinSketcherInstance;


var lastMol = "C1CCC(CC1)P(C1CCCCC1)C1CCCCC1.Cc1cc(C)c(N2CCN(C2=[Ru](Cl)(Cl)=Cc2ccccc2)c2c(C)cc(C)cc2C)c(C)c1";


var showSketcher = true;




$(document).ready(function () {


if (showSketcher) {


MarvinJSUtil.getEditor("#sketch").then(function (sketcherInstance) {


marvinSketcherInstance = sketcherInstance;


if (lastMol) {


//Import mol


marvinSketcherInstance.importStructure("smiles", lastMol).catch(function (error) {


alert(error);


});


}


initControl();


}, function (error) {


alert("Cannot retrieve sketcher instance:" + error);


});


}


});


 


Doing this the sketcher is loading without any problems but the canvas is blank and not displaying my structure..

ChemAxon 7c2d26e5cf

12-09-2014 11:11:13

If JChem WS is not installed, SMILES import will not work.


In this case, you can pass structures in mol (MDL molfile v2000) or in mrv format:


marvinSketcherInstance.importStructure("mol", lastMol)


 


marvinSketcherInstance.importStructure("mrv", lastMol)

User eda6f877b4

12-09-2014 11:30:57

OK.


Do you have an API example on stock for converting from cd_structure -> mol or mrv..?


Dann

ChemAxon d4fff15f08

15-09-2014 14:23:03

Hi Dann,


 


Unfortunately we don't have a snippet for this, but you can compose a working code quite easy using the MolExporter class's exportToFormat method see: 


https://www.chemaxon.com/marvin/help/developer/beans/api/chemaxon/formats/MolExporter.html#exportToFormat(chemaxon.struc.Molecule, java.lang.String)


 


Please let us know if you have any problem implementing it.


 


Best regards,


Norbert

User eda6f877b4

16-09-2014 07:18:50

Hi Both,


Thanks for the help. I am all set with Marvin JS !


BR


Dann