32#ifndef RDK_SUBSTRUCT_LIBRARY_SERIALIZATION
33#define RDK_SUBSTRUCT_LIBRARY_SERIALIZATION
35#ifdef RDK_USE_BOOST_SERIALIZATION
37#include <boost/archive/text_oarchive.hpp>
38#include <boost/archive/text_iarchive.hpp>
39#include <boost/serialization/vector.hpp>
40#include <boost/serialization/shared_ptr.hpp>
41#include <boost/archive/archive_exception.hpp>
48namespace serialization {
50template <
class Archive>
53template <
class Archive>
55 const unsigned int version) {
57 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
59 std::int64_t pkl_count = molholder.
getMols().size();
62 for (
auto &mol : molholder.
getMols()) {
69template <
class Archive>
71 const unsigned int version) {
73 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
75 std::vector<boost::shared_ptr<RDKit::ROMol>> &mols = molholder.
getMols();
78 std::int64_t pkl_count = -1;
81 for (std::int64_t i = 0; i < pkl_count; ++i) {
84 mols.push_back(boost::make_shared<RDKit::ROMol>(pkl));
88template <
class Archive,
class MolHolder>
89void serialize_strings(Archive &ar, MolHolder &molholder,
90 const unsigned int version) {
92 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
93 ar &molholder.getMols();
96template <
class Archive>
98 const unsigned int version) {
99 serialize_strings(ar, molholder, version);
102template <
class Archive>
104 const unsigned int version) {
105 serialize_strings(ar, molholder, version);
108template <
class Archive>
110 const unsigned int version) {
111 serialize_strings(ar, molholder, version);
114template <
class Archive>
116 const unsigned int version) {
118 std::vector<std::string> pickles;
120 pickles.push_back(fp->toString());
125template <
class Archive>
127 const unsigned int version) {
129 std::vector<std::string> pickles;
133 for (
size_t i = 0; i < fps.size(); ++i) {
138 for (
auto &pkl : pickles) {
143template <
class Archive>
145 const unsigned int version) {
147 ar &boost::serialization::base_object<RDKit::FPHolderBase>(pattern_holder);
148 if (Archive::is_saving::value &&
151 }
else if (Archive::is_loading::value) {
154 }
catch (boost::archive::archive_exception &) {
160template <
class Archive>
162 const unsigned int version) {
164 ar &boost::serialization::base_object<RDKit::FPHolderBase>(pattern_holder);
168template <
class Archive>
171template <
class Archive>
173 const unsigned int) {
174 ar &boost::serialization::base_object<RDKit::KeyHolderBase>(key_holder);
179template <
class Archive>
180void registerSubstructLibraryTypes(Archive &ar) {
190template <
class Archive>
192 const unsigned int version) {
194 registerSubstructLibraryTypes(ar);
201template <
class Archive>
203 const unsigned int version) {
205 registerSubstructLibraryTypes(ar);
#define RDUNUSED_PARAM(x)
a class for bit vectors that are densely occupied
Concrete class that holds binary cached molecules in memory.
Concrete class that holds smiles strings in memory.
Concrete class that holds trusted smiles strings in memory.
Base FPI for the fingerprinter used to rule out impossible matches.
std::vector< ExplicitBitVect * > & getFingerprints()
std::vector< std::string > & getKeys()
std::string & getPropName()
Base class API for holding molecules to substructure search.
Concrete class that holds molecules in memory.
std::vector< boost::shared_ptr< ROMol > > & getMols()
static void pickleMol(const ROMol *mol, std::ostream &ss)
pickles a molecule and sends the results to stream ss
const unsigned int & getNumBits() const
static unsigned int defaultNumBits()
Substructure Search a library of molecules.
boost::shared_ptr< MolHolderBase > & getMolHolder()
Get the underlying molecule holder implementation.
boost::shared_ptr< FPHolderBase > & getFpHolder()
Get the underlying molecule holder implementation.
boost::shared_ptr< KeyHolderBase > & getKeyHolder()
Get the underlying molecule holder implementation.
const std::vector< unsigned int > & getSearchOrder() const
void resetHolders()
access required for serialization