OEWriteMatchedPairAnalyzer

bool OEWriteMatchedPairAnalyzer(const std::string &fname, OEMatchedPairAnalyzer &mmpindex)
bool OEWriteMatchedPairAnalyzer(OEPlatform::oeostream &ofs, OEMatchedPairAnalyzer &mmpindex)

This function serializes the state of the OEMatchedPairAnalyzer instance argument to a file or stream as below:

  OEMatchedPairAnalyzer mmp;

  OEGraphMol mol;
  int recindex = 0;
  while (OEReadMolecule(ifs, mol))
  {
    ++recindex;
    int status = mmp.AddMol(mol, recindex);
    if (status != recindex)
      OEThrow.Warning("%d: molecule indexing error, status=%s",
                      recindex, OEMatchedPairIndexStatusName(status));
  }

  printf("Index complete, matched pairs = %d\n", mmp.NumMatchedPairs());

  // check for output filename with .mmpidx extension
  std::string mmpexport = itf.Get<std::string>("-output");
  if (!OEIsWriteableMatchedPairAnalyzer(mmpexport))
    OEThrow.Info("Not a valid matched pair index output file, %s", mmpexport.c_str());
  else if (!OEWriteMatchedPairAnalyzer(mmpexport, mmp))
    OEThrow.Fatal("Index serialization failed");
  else
    OEThrow.Info("Index serialization complete");

If the matched pair index information being exported is complete in the sense that additional structures are not intended to be added to the index upon a subsequent deserialization, significant savings in output file size is possible by suppressing the export of singleton nodes - those index nodes which do not contain any matched pairs. Conversely, if the exported index must be able to support adding additional structures to the index after deserialization, export compression should be avoided, otherwise significant matched pairs may be missed. To enable export compression (by default, disabled), see the following:

    // create analyzer class with defaults
    //   - compression option disabled by default
    OEMatchedPairAnalyzer mmpAnalyzer;
    // for serialization, enable export compression to
    //   remove singleton index nodes by modifying analyzer
    mmpAnalyzer.ModifyOptions(OEMatchedPairOptions::ExportCompression, 0);
    // create options class with defaults
    //   - compression option disabled by default
    OEMatchedPairAnalyzerOptions mmpOpts;
    // for serialization, enable export compression to
    //   remove singleton index nodes by modifying analyzer
    mmpOpts.SetOptions(OEMatchedPairOptions::Default |
                       OEMatchedPairOptions::ExportCompression);
    // create analyzer class with compression option enabled
    OEMatchedPairAnalyzer mmpAnalyzer(mmpOpts);