Which API for Marvin 4.0 should be used for SMILES->Molec

User 05a0a0ba3d

28-04-2006 01:32:27

Which API for Marvin 4.0 should be used for SMILES->Molecule


conversion?





I have seen several references (both on the forums and in


the documentation) to MolImporter; however, I have not been


able to find that class. Does it exist in Marvin 4.0?





In summary, what I am looking for is this:





String smiles = "CC"; // some SMILES string


Molecule mol = GetMoleculeFromSmiles(smiles);





It is the GetMoleculeFromSmiles() that I am looking for.





Thanks!

User f359e526a1

28-04-2006 06:10:56

If you have a file with SMILES strings, probably the best is to use MolImporter that is at http://www.chemaxon.com/marvin/doc/api/index.html (Javadoc) . I included a small sample SmilesImp.java as an attachment . Use it as "java SmilesImp infile.smi" Also check http://www.chemaxon.com/marvin/doc/user/smiles-doc.html MolImporter can be used for other file types as well not only for SMILES.

User 05a0a0ba3d

08-07-2006 02:15:58

I have some Java code that looks like this:





StringBuffer pngSpecs = new StringBuffer("png:");


pngSpecs.append("w" + (new Integer(width)).toString() + ",");


pngSpecs.append("h" + (new Integer(height)).toString());





// Use Marvin to create PNG image of molecule.


Molecule molecule = MolImporter.importMol(smiles);


byte[] pngData = (byte[])molecule.toObject(pngSpecs.toString());





Sometimes in the server log, I notice these exceptions:





java.lang.IllegalArgumentException: Cannot export in unknown format "png:w324,h200"


at chemaxon.struc.Molecule.toObject(Molecule.java:966)


at com.cdd.services.GetMoleculeImage.doGet(Unknown Source)





The format "png:w324,h200" usually works. Why is this exception


happening?





Thanks,


Charlie

ChemAxon 7c2d26e5cf

11-07-2006 10:44:50

I have checked the latest Marvin (4.0.6). But I have not managed to reproduce this exception. Can you show me a molecule where Molecule.toObject(...) throws this IllegalArgumentException?

ChemAxon 7c2d26e5cf

11-07-2006 11:13:53

This exception should be thrown if Java can not load in proper export module (chemaxon/marvin/modules/PngExport.class).


Since MarvinBeans.jar includes the above class, Java should find it unless you have modified the content of MarvinBeans.jar.





Have you got a display on your server machine? Image export can fail if OS run without graphical interface.


In the following topic, you can read what you should do in this case:


http://www.chemaxon.com/forum/ftopic73.html