17#ifndef RD_MOLBUNDLE_AUG2017
18#define RD_MOLBUNDLE_AUG2017
25#include <boost/smart_ptr.hpp>
28#ifdef RDK_USE_BOOST_SERIALIZATION
30#include <boost/serialization/vector.hpp>
31#include <boost/serialization/shared_ptr.hpp>
32#include <boost/serialization/split_member.hpp>
33#include <boost/archive/text_oarchive.hpp>
34#include <boost/archive/text_iarchive.hpp>
35#include <boost/archive/archive_exception.hpp>
47#ifdef RDK_USE_BOOST_SERIALIZATION
71 virtual const std::vector<boost::shared_ptr<ROMol>> &
getMols()
const {
87 virtual const boost::shared_ptr<ROMol>
getMol(
size_t idx)
const {
88 if (idx >=
d_mols.size()) {
94 virtual const boost::shared_ptr<ROMol>
operator[](
size_t idx)
const {
100#ifndef RDK_USE_BOOST_SERIALIZATION
104 boost::archive::text_oarchive
ar(
ss);
110 std::stringstream
ss;
116#ifndef RDK_USE_BOOST_SERIALIZATION
120 boost::archive::text_iarchive
ar(
ss);
126 std::stringstream
ss(text);
130#ifdef RDK_USE_BOOST_SERIALIZATION
132 template <
class Archive>
135 std::vector<std::string>
pkls;
136 for (
const auto &mol :
d_mols) {
144 template <
class Archive>
148 std::vector<std::string>
pkls;
159 std::vector<boost::shared_ptr<ROMol>>
d_mols;
189 if (
nmol->getNumAtoms() !=
d_mols[0]->getNumAtoms()) {
191 "all molecules in a bundle must have the same number of atoms");
194 if (
nmol->getNumBonds() !=
d_mols[0]->getNumBonds()) {
196 "all molecules in a bundle must have the same number of bonds");
#define RDUNUSED_PARAM(x)
#define PRECONDITION(expr, mess)
Class to allow us to throw an IndexError from C++ and have it make it back to Python.
FixedMolSizeMolBundle(const FixedMolSizeMolBundle &other)
copy constructor
~FixedMolSizeMolBundle() override=default
size_t addMol(boost::shared_ptr< ROMol > nmol) override
MolBundle contains a collection of related ROMols.
std::vector< boost::shared_ptr< ROMol > > d_mols
virtual const boost::shared_ptr< ROMol > operator[](size_t idx) const
returns a particular molecule from the bundle
virtual size_t size() const
returns the number of molecules from the bundle
virtual bool empty() const
returns whether or not the bundle is empty
MolBundle(const MolBundle &other)
copy constructor
MolBundle(const std::string &pkl)
void toStream(std::ostream &ss) const
serializes (pickles) to a stream
void initFromString(const std::string &text)
initializes from a string pickle
virtual const std::vector< boost::shared_ptr< ROMol > > & getMols() const
returns our molecules
virtual const boost::shared_ptr< ROMol > getMol(size_t idx) const
returns a particular molecule in the bundle
void initFromStream(std::istream &ss)
initializes from a stream pickle
MolBundle & operator=(const MolBundle &other)=default
std::string serialize() const
returns a string with a serialized (pickled) representation
virtual size_t addMol(boost::shared_ptr< ROMol > nmol)
adds a new molecule and returns the total number of molecules
static void pickleMol(const ROMol *mol, std::ostream &ss)
pickles a molecule and sends the results to stream ss
Class to allow us to throw a ValueError from C++ and have it make it back to Python.
bool MolBundleCanSerialize()
bool rdvalue_is(const RDValue_cast_t)
boost::shared_ptr< ROMol > ROMOL_SPTR