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> 47 namespace serialization {
49 template <
class Archive>
51 const unsigned int version) {
56 template <
class Archive>
58 const unsigned int version) {
60 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
62 std::int64_t pkl_count = molholder.
getMols().size();
65 for (
auto &mol : molholder.
getMols()) {
72 template <
class Archive>
74 const unsigned int version) {
76 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
78 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));
91 template <
class Archive,
class MolHolder>
92 void serialize_strings(Archive &ar, MolHolder &molholder,
93 const unsigned int version) {
95 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
96 ar &molholder.getMols();
99 template <
class Archive>
101 const unsigned int version) {
102 serialize_strings(ar, molholder, version);
105 template <
class Archive>
107 const unsigned int version) {
108 serialize_strings(ar, molholder, version);
111 template <
class Archive>
113 const unsigned int version) {
114 serialize_strings(ar, molholder, version);
117 template <
class Archive>
119 const unsigned int version) {
121 std::vector<std::string> pickles;
123 pickles.push_back(fp->toString());
128 template <
class Archive>
130 const unsigned int version) {
132 std::vector<std::string> pickles;
136 for (
size_t i = 0; i < fps.size(); ++i)
delete fps[i];
139 for (
auto &pkl : pickles) {
144 template <
class Archive>
146 const unsigned int version) {
148 ar &boost::serialization::base_object<RDKit::FPHolderBase>(pattern_holder);
151 template <
class Archive>
152 void registerSubstructLibraryTypes(Archive &ar) {
153 ar.register_type(static_cast<RDKit::MolHolder *>(NULL));
154 ar.register_type(static_cast<RDKit::CachedMolHolder *>(NULL));
155 ar.register_type(static_cast<RDKit::CachedSmilesMolHolder *>(NULL));
156 ar.register_type(static_cast<RDKit::CachedTrustedSmilesMolHolder *>(NULL));
157 ar.register_type(static_cast<RDKit::PatternHolder *>(NULL));
160 template <
class Archive>
162 const unsigned int version) {
164 registerSubstructLibraryTypes(ar);
169 template <
class Archive>
171 const unsigned int version) {
173 registerSubstructLibraryTypes(ar);
static void pickleMol(const ROMol *mol, std::ostream &ss)
pickles a molecule and sends the results to stream ss
Concrete class that holds molecules in memory.
boost::shared_ptr< MolHolderBase > & getMolHolder()
Get the underlying molecule holder implementation.
Concrete class that holds trusted smiles strings in memory.
Base FPI for the fingerprinter used to rule out impossible matches.
boost::shared_ptr< FPHolderBase > & getFpHolder()
Get the underlying molecule holder implementation.
Base class API for holding molecules to substructure search.
std::vector< ExplicitBitVect * > & getFingerprints()
#define RDUNUSED_PARAM(x)
std::vector< boost::shared_ptr< ROMol > > & getMols()
Concrete class that holds binary cached molecules in memory.
Uses the pattern fingerprinter to rule out matches.
a class for bit vectors that are densely occupied
void resetHolders()
access required for serialization
Concrete class that holds smiles strings in memory.
Substructure Search a library of molecules.