33#ifndef ENUMERATION_STRATEGY_H
34#define ENUMERATION_STRATEGY_H
37#include "../Reaction.h"
42#ifdef RDK_USE_BOOST_SERIALIZATION
43#include <boost/serialization/assume_abstract.hpp>
44#include <boost/serialization/vector.hpp>
46#include <boost/serialization/singleton.hpp>
47#include <boost/serialization/extended_type_info.hpp>
48#include <boost/serialization/shared_ptr.hpp>
58 :
public std::exception {
62 const char *
what() const noexcept
override {
return _msg.c_str(); }
75EnumerationTypes::RGROUPS getSizesFromBBs(
76 const std::vector<std::vector<T>> &bbs) {
78 for (
size_t i = 0; i < bbs.size(); ++i) {
79 sizes.push_back(bbs[i].size());
89 const std::vector<MOL_SPTR_VECT> &bbs);
132 static const boost::uint64_t EnumerationOverflow =
133 static_cast<boost::uint64_t
>(-1);
138 virtual const char *
type()
const {
return "EnumerationStrategyBase"; }
150 m_permutation.resize(m_permutationSizes.size());
153 std::fill(m_permutation.begin(), m_permutation.end(), 0);
155 initializeStrategy(reaction, building_blocks);
171 virtual operator bool()
const = 0;
192 bool skip(boost::uint64_t skipCount) {
193 for (boost::uint64_t i = 0; i < skipCount; ++i) {
203 m_permutation.resize(rgroups.size());
204 m_permutationSizes = rgroups;
206 std::fill(m_permutation.begin(), m_permutation.end(), 0);
210 friend class boost::serialization::access;
211 template <
class Archive>
212 void serialize(Archive &ar,
const unsigned int ) {
214 ar & m_permutationSizes;
215 ar & m_numPermutations;
218#ifdef RDK_USE_BOOST_SERIALIZATION
219BOOST_SERIALIZATION_ASSUME_ABSTRACT(EnumerationStrategyBase)
223#ifdef RDK_USE_BOOST_SERIALIZATION
pulls in the core RDKit functionality
This is a class for storing and applying general chemical reactions.
virtual EnumerationStrategyBase * copy() const =0
copy the enumeration strategy complete with current state
void initialize(const ChemicalReaction &reaction, const EnumerationTypes::BBS &building_blocks)
virtual const char * type() const
bool skip(boost::uint64_t skipCount)
virtual ~EnumerationStrategyBase()
virtual boost::uint64_t getPermutationIdx() const =0
Returns how many permutations have been processed by this strategy.
virtual void initializeStrategy(const ChemicalReaction &reaction, const EnumerationTypes::BBS &building_blocks)=0
EnumerationTypes::RGROUPS m_permutation
void internalInitialize(const EnumerationTypes::RGROUPS &rgroups)
boost::uint64_t getNumPermutations() const
EnumerationTypes::RGROUPS m_permutationSizes
const EnumerationTypes::RGROUPS & getPosition() const
The current position in the enumeration.
EnumerationStrategyBase()
virtual const EnumerationTypes::RGROUPS & next()=0
The current permutation {r1, r2, ...}.
class for flagging enumeration strategy errors
~EnumerationStrategyException() noexcept override=default
EnumerationStrategyException(const char *msg)
const char * what() const noexcept override
EnumerationStrategyException(std::string msg)
#define RDKIT_CHEMREACTIONS_EXPORT
std::vector< boost::uint64_t > RGROUPS
std::vector< MOL_SPTR_VECT > BBS
bool rdvalue_is(const RDValue_cast_t)
RDKIT_CHEMREACTIONS_EXPORT EnumerationTypes::RGROUPS getSizesFromReactants(const std::vector< MOL_SPTR_VECT > &bbs)
EnumerationTypes::RGROUPS getSizesFromBBs(const std::vector< std::vector< T > > &bbs)
Return the number of elements per input vector.
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
RDKIT_CHEMREACTIONS_EXPORT MOL_SPTR_VECT getReactantsFromRGroups(const std::vector< MOL_SPTR_VECT > &bbs, const EnumerationTypes::RGROUPS &rgroups)
RDKIT_CHEMREACTIONS_EXPORT boost::uint64_t computeNumProducts(const EnumerationTypes::RGROUPS &sizes)