User c1ce6b3d19
11-12-2010 12:57:08
A User would like to insert Markush structures and patent numbers from .vmn (Markush DARC format) file.
There are a large number of .vmn files each holding a markush
structure. These molecules need to be added to a database table and an
additional table column (e.g. "patent_no") added to hold the patent
number. Most likely you want to use the JChem API. There may be a few
ways to do this and using the UpdateHandler class is a good way.
The example uses the following classes: ConnectionHandler, Structure Table Options, and Update Handler.
- ConnectionHandler is used to open a connection to the database. Connection information and examples can be found here.
- StructureTableOptions is used to set the options for a new markush table.
- UpdateHandler is used to create a new table, and add a new markush structure and insert the patent number into an additional column.
// Database table name to be created
String markushTableName = "myMarkushLibrary";// Additional column to be created
String patentNumberColumn = "patent_no";
...
//Open a connection to your database
ConnectionHandler conh = new ConnectionHandler();
conh.setDriver("oracle.jdbc.driver.OracleDriver");
conh.setUrl("jdbc:oracle:thin:@inhale:1521:demodb");
conh.setLoginName("INTERNAL");
conh.setPassword("oracle");
conh.connect();
//Create a new Markush Library table if one does not exist.
StructureTableOptions sto = new StructureTableOptions();
sto.name = markushTableName;
sto.tableType = StructureTableOptions. TABLE_TYPE_MARKUSH_LIBRARIES;
UpdateHandler uhCreate = new UpdateHandler();
try{
uhCreate.createStructureTable(conh, sto);
} finally {
uhCreate.close();
}
//Read in from a vmn file. This section may need to be repeated inside a for loop to read all vmn files.
String filename = //the file name
String patentNumber = // the patent number parsed from the file name.
byte[] vmnBinary = //the binary structure data read from the file.
UpdateHandler uh = new UpdateHandler(conh,
UpdateHandler.INSERT, markushTableName, patentNumberColumn);
try {
uh.setStructure(vmnBinary);
//This sets the parsed patent number into the patent Number column.
uh.setValueForAdditionalColumn(1, patentNumber);
uh.execute();
} finally {
uh.close();
}
...