Validate SMILES String with MarvinSketcher?

User 60b60eaf80

05-12-2008 13:39:25

Hi,





is there a way to validate a SMILES string with the marvin Sketcher applet?





Currently the applet throws an exception when the smiles is invalid. this is not really nice for website integration.





if there is no way to validate the string, is there a way to deactivate the exception?





greetings


martin

ChemAxon 7c2d26e5cf

08-12-2008 10:26:04

In current Marvin, there is no way to switch off error message by wrong smiles.


I can suggest you the following solution:


Check SMILES validity by server side with the Marvin Beans API. Read SMILES with chemaxon.formats.MolImporter. If MolImporter does not throw exception, the SMILES is valid, in this case, you can pass it to the applet.

User 60b60eaf80

09-12-2008 15:44:37

thanks for the reply





but checking it server side is no option, as we are implementing a textfield that is drawing the smiles (via marvin sketch) directly after the user hits a key - sending this back to the server and upload it onto the client again is a lot of traffic.





a client side check would be really sweet..





i'm searching something like this:


Code:
boolean MarvinSketch.checkSmiles(String smiles);






thanks for your help

ChemAxon 7c2d26e5cf

11-12-2008 17:10:13

Currently, there is no such method in the Marvin Applets API that would be suitable for you: JMSketch.checkSMILES(String). We do not plan to implement this function.


If you like to check SMILES on client side, I suggest you to write your own applet to do that with the help of the Marvin Beans API.


Pass the SMILES to this new applet that checks molecule validity with the MolImporter class. If the following code does not throw exception, it means that the given source represent a valid molecule (SMILES).





Code:
ByteArrayInputStream bin = new ByteArrayInputStream(smilesstr.getBytes());


try {


    MolImporter importer = new MolImporter(bin);


    Molecule mol = importer.read();


} catch(IOException ioex) {


    // invalid molecule


}



Since you use only the molecule importer from the API, the MarvinBeans.jar is enough for you from the Marvin Beans package.

User 60b60eaf80

15-12-2008 13:22:21

thank you very much - i will give it a try