OECreateMolDatabaseIdx

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

database.oeb

database.oeb.idx

database.oeb.gz

database.oeb.idx.gz

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.

Example

Listing 1: Creates an index file

  const string ifname = "drugs.sdf";
  const string idxfname = OEGetMolDatabaseIdxFileName(ifname);

  if (!OEFileExists(idxfname))
  {
    if (!OECreateMolDatabaseIdx(ifname))
      OEThrow.Warning("Unable to create %s molecule index file", idxfname.c_str());
  }
  OEThrow.Info("Using %s index molecule file", idxfname.c_str());

Note

.idx files can be concatenated together. Care must be taken to concatenate the corresponding database files together in the exact same order.