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>
55 template <
class Archive>
57 const unsigned int version) {
59 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
61 std::int64_t pkl_count = molholder.
getMols().size();
64 for (
auto &mol : molholder.
getMols()) {
71 template <
class Archive>
73 const unsigned int version) {
75 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
77 std::vector<boost::shared_ptr<RDKit::ROMol>> &mols = molholder.
getMols();
80 std::int64_t pkl_count = -1;
83 for (std::int64_t i = 0; i < pkl_count; ++i) {
86 mols.push_back(boost::make_shared<RDKit::ROMol>(pkl));
90 template <
class Archive,
class MolHolder>
91 void serialize_strings(Archive &ar, MolHolder &molholder,
92 const unsigned int version) {
94 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
95 ar &molholder.getMols();
98 template <
class Archive>
100 const unsigned int version) {
101 serialize_strings(ar, molholder, version);
104 template <
class Archive>
106 const unsigned int version) {
107 serialize_strings(ar, molholder, version);
110 template <
class Archive>
112 const unsigned int version) {
113 serialize_strings(ar, molholder, version);
116 template <
class Archive>
118 const unsigned int version) {
120 std::vector<std::string> pickles;
122 pickles.push_back(fp->toString());
127 template <
class Archive>
129 const unsigned int version) {
131 std::vector<std::string> pickles;
135 for (
size_t i = 0; i < fps.size(); ++i)
delete fps[i];
138 for (
auto &pkl : pickles) {
143 template <
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 &) {
160 template <
class Archive>
162 const unsigned int version) {
164 ar &boost::serialization::base_object<RDKit::FPHolderBase>(pattern_holder);
168 template <
class Archive>
170 const unsigned int) {
173 template <
class Archive>
175 const unsigned int) {
176 ar &boost::serialization::base_object<RDKit::KeyHolderBase>(key_holder);
181 template <
class Archive>
182 void registerSubstructLibraryTypes(Archive &ar) {
192 template <
class Archive>
194 const unsigned int version) {
196 registerSubstructLibraryTypes(ar);
203 template <
class Archive>
205 const unsigned int version) {
207 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