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> 49 namespace serialization {
51 template <
class Archive>
57 template <
class Archive>
59 const unsigned int version) {
61 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
63 std::int64_t pkl_count = molholder.
getMols().size();
66 for(
auto &mol: molholder.
getMols()) {
73 template <
class Archive>
75 const unsigned int version) {
77 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
79 std::vector<boost::shared_ptr<RDKit::ROMol>> &mols = molholder.
getMols();
82 std::int64_t pkl_count = -1;
85 for(std::int64_t i = 0; i<pkl_count; ++i) {
88 mols.push_back(boost::make_shared<RDKit::ROMol>(pkl));
92 template<
class Archive,
class MolHolder>
93 void serialize_strings(Archive &ar, MolHolder &molholder,
94 const unsigned int version) {
96 ar &boost::serialization::base_object<RDKit::MolHolderBase>(molholder);
97 ar &molholder.getMols();
100 template <
class Archive>
102 const unsigned int version) {
103 serialize_strings(ar, molholder, version);
106 template <
class Archive>
108 const unsigned int version) {
109 serialize_strings(ar, molholder, version);
112 template <
class Archive>
114 const unsigned int version) {
115 serialize_strings(ar, molholder, version);
118 template <
class Archive>
120 const unsigned int version) {
122 std::vector<std::string> pickles;
124 pickles.push_back(fp->toString());
129 template <
class Archive>
131 const unsigned int version) {
133 std::vector<std::string> pickles;
137 for (
size_t i = 0; i < fps.size(); ++i)
delete fps[i];
140 for(
auto &pkl: pickles) {
145 template <
class Archive>
147 const unsigned int version) {
149 ar &boost::serialization::base_object<RDKit::FPHolderBase>(pattern_holder);
152 template <
class Archive>
153 void registerSubstructLibraryTypes(Archive &ar) {
154 ar.register_type(static_cast<RDKit::MolHolder *>(NULL));
155 ar.register_type(static_cast<RDKit::CachedMolHolder *>(NULL));
156 ar.register_type(static_cast<RDKit::CachedSmilesMolHolder *>(NULL));
157 ar.register_type(static_cast<RDKit::CachedTrustedSmilesMolHolder *>(NULL));
158 ar.register_type(static_cast<RDKit::PatternHolder *>(NULL));
162 template <
class Archive>
164 const unsigned int version) {
166 registerSubstructLibraryTypes(ar);
171 template <
class Archive>
173 const unsigned int version) {
175 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.