is Editing theProperties table using SQL backward compatible

User 6686efeff7

29-01-2009 15:59:52

Hi








I am writing some components to integrate JChem with a text mining tool. I need to set the standardizer configuration file programatically, currently I am thinking of using SQL statements to insert the necessary values into the JChemProperties table. It makes assumptions about the table name, table-field names and data types used to store values in the table. My question is will this approach be backward compatible or do you already have a Java API for doing this kind of stuff














Thanks





Wiraj

ChemAxon 9c0afc9aaf

29-01-2009 17:24:38

Hi Wiraj,





In general we do not recommend editing or creating the property table or any other table of the JChem system by other means than the JChem API (or the applications).





The only exception is the user-defined data fields in the structure tables, those are safe to modify by SQL.


(And of course plain tables with a cartridge index on them)





We cannot guarantee backward compatibility either.





When you create a structure table with UpdateHandler (again only use our API or programs for this):





http://www.chemaxon.com/jchem/doc/api/chemaxon/jchem/db/UpdateHandler.html#createStructureTable(chemaxon.util.ConnectionHandler,%20chemaxon.jchem.db.StructureTableOptions)





You can set the standardizer configuration in the StructureTableOptions object:





http://www.chemaxon.com/jchem/doc/api/chemaxon/jchem/db/StructureTableOptions.html#standardizerConfig





Best regards,





Szilard

User 6686efeff7

30-01-2009 10:50:45

Hi





I did as you suggested however I am getting the following stack trace on my console








* Stack Trace





chemaxon.reaction.StandardizerException: Could not read reaction: C:\Documents and Settings\wbibile\My Documents\test jchem\standardizer-config.xml


Caused by:


Could not read file or structure string: C:\Documents and Settings\wbibile\My Documents\test jchem\standardizer-config.xml


Cannot recognize format (?)


Unrecognized file contents:


C:\Documents and Settings\wbibile\My Documents\test jchem\standardizer-config.xml


    at chemaxon.reaction.StandardizerConfiguration.read(StandardizerConfiguration.java:649)


    at chemaxon.reaction.StandardizerConfiguration.read(StandardizerConfiguration.java:68)


    at chemaxon.reaction.Standardizer.(Standardizer.java:398)


    at chemaxon.jchem.db.TableInfo.getStandardizers(TableInfo.java:1341)


    at chemaxon.jchem.db.TableInfo.getStandardizer(TableInfo.java:1321)


    at chemaxon.jchem.db.UpdateHandler.getStandardizer(UpdateHandler.java:1006)


    at chemaxon.jchem.db.UpdateHandler.initFields(UpdateHandler.java:533)


    at chemaxon.jchem.db.UpdateHandler.init(UpdateHandler.java:435)


    at jchemtest.CreateDatabase.updateTable(CreateDatabase.java:89)


    at jchemtest.CreateDatabase.main(CreateDatabase.java:40)


Caused by: java.io.IOException: Could not read file or structure string: C:\Documents and Settings\wbibile\My Documents\test jchem\standardizer-config.xml


Cannot recognize format (?)


Unrecognized file contents:


C:\Documents and Settings\wbibile\My Documents\test jchem\standardizer-config.xml


    at chemaxon.util.ConfigUtils.getMolImporter(ConfigUtils.java:339)


    at chemaxon.util.ConfigUtils.getMolecule(ConfigUtils.java:209)


    at chemaxon.util.ConfigUtils.getQueryMolecule(ConfigUtils.java:174)


    at chemaxon.reaction.StandardizerConfiguration.read(StandardizerConfiguration.java:646)


    ... 9 more


chemaxon.jchem.db.UpdateHandlerException: Invalid standardizer configuration


    at chemaxon.jchem.db.UpdateHandler.getStandardizer(UpdateHandler.java:1013)


    at chemaxon.jchem.db.UpdateHandler.initFields(UpdateHandler.java:533)


    at chemaxon.jchem.db.UpdateHandler.init(UpdateHandler.java:435)


    at jchemtest.CreateDatabase.updateTable(CreateDatabase.java:89)


    at jchemtest.CreateDatabase.main(CreateDatabase.java:40)


Exception in thread "main" java.sql.SQLException: Invalid standardizer configuration


    at chemaxon.jchem.db.UpdateHandler.initFields(UpdateHandler.java:536)


    at chemaxon.jchem.db.UpdateHandler.init(UpdateHandler.java:435)


    at jchemtest.CreateDatabase.updateTable(CreateDatabase.java:89)


    at jchemtest.CreateDatabase.main(CreateDatabase.java:40)






* The code that sets the standardizer settings is








        String filePath = "C:\\Documents and Settings\\wbibile\\My Documents\\test jchem\\standardizer-config.xml";


        File f = new File( filePath );


        assert ( f.exists() ):"file"+f.getAbsolutePath()+" not found";


        assert( f.getAbsolutePath().equals( filePath )):"file path expected "+filePath+" actual "+f.getAbsolutePath();


        tableOptions.standardizerConfig = filePath;


        UpdateHandler.createStructureTable(ch, tableOptions);









* The standardizer config file was created using the JChem application StandardizationEditor ( the file generated is attached )





* The version of JChem I am using is 5.1.2





* The Jars for JChem was loaded from C:\Program Files\ChemAxon\JChem\lib\jchem.jar





Could you point me at what I am doing wrong here








Thanks





Wiraj

ChemAxon 9c0afc9aaf

30-01-2009 16:21:32

Hi,





The standardizer configuration you should specify is the configuration string itself, not a file name.





So you should read the file contents and pass that on as a String.





Best regards,





Szilard

User 6686efeff7

30-01-2009 16:45:48

Hi Szilard





Thanks for that, it wasn't clear in the docs as to what was expected and the exception error message said





Cannot recognize format (?)


Unrecognized file contents:
<<-- This


Which lead me to believe that the file name was a valid argument. Anyway problem resolved








Thanks





Wiraj

ChemAxon 9c0afc9aaf

30-01-2009 18:30:46

Hi,





Standardizer configurations may refer to external reaction structure files, probably the parser tried to read the specified xml file as a reaction.





We made the apidoc text more explicit for future versions.





Szilard