Importing SMARTS into MSketchPane

User 6a6a0952c1

05-10-2012 09:11:06

I have a reaction represented in SMARTS. I wish to create a MSketchPane and load the smarts and show it as a reaction. The existing examples show adding a molecule and showing it. are there other ways of doing it? Please give me a sample piece of code. Thank you.

ChemAxon 5433b8e56b

05-10-2012 14:14:31

Hi,


you can use one of the setMol methods of the MSketchPane object. You can set the smarts string with specified import options, or you can use MolImporter to import the smarts string and set the Molecule to MSketchPane, or you can specify a file to open also.


I suggest to use the MSketchPane.setMol(String, String) method, the first parameter should be the smarts string, the second should be the molecule format and import options specification. If you have a smarts string, you can set "smarts" as the second parameter. The second parameter is relevant, because if it is specified, the format recognition is skipped.
If you need format recognition, then set the second parameter to null, or use the MSketchPane.setMol(String) method with the molecule source as the parameter.


I hope this helps, here you can find API documentation of the methods.


Regards,
Istvan