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 = new OEMatchedPairAnalyzer();
        int recindex = 0;
        OEGraphMol mol = new OEGraphMol();
        while (oechem.OEReadMolecule(ifs, mol)) {
            ++recindex;

            int status = mmp.AddMol(mol, recindex);
            if (status != recindex) {
                oechem.OEThrow.Warning(recindex + ": molecule indexing error, status=" +
                        oemedchem.OEMatchedPairIndexStatusName(status));
            }
        }

        System.out.println("Index complete, matched pairs = " + mmp.NumMatchedPairs());

        // check for output filename with .mmpidx extension
        String mmpexport = itf.GetString("-output");
        if (!oemedchem.OEIsMatchedPairAnalyzerFileType(mmpexport))
            oechem.OEThrow.Info("Not a valid matched pair index output file, " + mmpexport);
        else if (!oemedchem.OEWriteMatchedPairAnalyzer(mmpexport, mmp))
            oechem.OEThrow.Fatal("Index serialization failed");
        else
            oechem.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 = new OEMatchedPairAnalyzer();
            // 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 = new OEMatchedPairAnalyzerOptions();
            // 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 = new OEMatchedPairAnalyzer(mmpOpts);