bool OECreateMolDatabaseIdx(const std::string &databaseFileName) bool OECreateMolDatabaseIdx(const std::string &databaseFileName, const std::string &indexFileName)
Creates an index file parallel to the file named by databaseFileName to improve the performance of OEMolDatabase.Open as described by the Index Files section. If OEMolDatabase.Open detects the presence of a parallel .idx file, the file position offsets will be read from the .idx file instead of having to stream the entire file off of disk to find the offsets during the call to OEMolDatabase.Open.
The index file name created is based upon the databaseFileName passed, optionally accounting for .gz. The following table demonstrates the pattern used to create index file names:
|Database File Name||Index File Name|
The overload of the function that takes an indexFileName will write the index to that file name instead.
Returns false if the function fails to create the index file for any reason, e.g., unable to open the file specified by databaseFileName.
Listing 1: Creates an index file
ifname = "drugs.sdf" idxfname = oechem.OEGetMolDatabaseIdxFileName(ifname) if not os.path.exists(idxfname): if not oechem.OECreateMolDatabaseIdx(ifname): oechem.OEThrow.Warning("Unable to create %s molecule index file" % idxfname)
.idx files can be concatenated together. Care must be taken to concatenate the corresponding database files together in the exact same order.