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>
48 namespace serialization {
50 template <
class Archive>
53 template <
class Archive>
55 const unsigned int version) {
56 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
59 std::int64_t pkl_count = molholder.
getMols().size();
62 for (
auto &mol : molholder.
getMols()) {
72 template <
class Archive>
74 const unsigned int version) {
75 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
77 std::vector<boost::shared_ptr<RDKit::ROMol>> &mols = molholder.
getMols();
81 std::int64_t pkl_count = -1;
84 for (std::int64_t i = 0; i < pkl_count; ++i) {
87 mols.push_back(boost::make_shared<RDKit::ROMol>(pkl));
94 template <
class Archive,
class MolHolder>
95 void serialize_strings(Archive &ar, MolHolder &molholder,
96 const unsigned int version) {
98 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
99 ar &molholder.getMols();
102 template <
class Archive>
104 const unsigned int version) {
105 serialize_strings(ar, molholder, version);
108 template <
class Archive>
110 const unsigned int version) {
111 serialize_strings(ar, molholder, version);
114 template <
class Archive>
116 const unsigned int version) {
117 serialize_strings(ar, molholder, version);
120 template <
class Archive>
122 const unsigned int version) {
124 std::vector<std::string> pickles;
126 pickles.push_back(fp->toString());
131 template <
class Archive>
133 const unsigned int version) {
135 std::vector<std::string> pickles;
139 for (
size_t i = 0; i < fps.size(); ++i) {
144 for (
auto &pkl : pickles) {
149 template <
class Archive>
151 const unsigned int version) {
153 ar &boost::serialization::base_object<RDKit::FPHolderBase>(pattern_holder);
154 if (Archive::is_saving::value &&
157 }
else if (Archive::is_loading::value) {
160 }
catch (boost::archive::archive_exception &) {
166 template <
class Archive>
168 const unsigned int version) {
170 ar &boost::serialization::base_object<RDKit::FPHolderBase>(pattern_holder);
174 template <
class Archive>
177 template <
class Archive>
179 const unsigned int) {
180 ar &boost::serialization::base_object<RDKit::KeyHolderBase>(key_holder);
185 template <
class Archive>
186 void registerSubstructLibraryTypes(Archive &ar) {
196 template <
class Archive>
198 const unsigned int version) {
200 registerSubstructLibraryTypes(ar);
207 template <
class Archive>
209 const unsigned int version) {
211 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
static unsigned int defaultNumBits()
const unsigned int & getNumBits() const
Substructure Search a library of molecules.
boost::shared_ptr< MolHolderBase > & getMolHolder()
Get the underlying molecule holder implementation.
boost::shared_ptr< KeyHolderBase > & getKeyHolder()
Get the underlying molecule holder implementation.
boost::shared_ptr< FPHolderBase > & getFpHolder()
Get the underlying molecule holder implementation.
const std::vector< unsigned int > & getSearchOrder() const
void resetHolders()
access required for serialization