36#ifndef RD_REACTION_H_17Aug2006
37#define RD_REACTION_H_17Aug2006
49 :
public std::exception {
56 const char *
what() const noexcept
override {
return _msg.c_str(); }
126 RDProps::operator=(other);
127 df_needsInit = other.df_needsInit;
128 df_implicitProperties = other.df_implicitProperties;
129 m_reactantTemplates.clear();
130 m_reactantTemplates.reserve(other.m_reactantTemplates.size());
131 for (
ROMOL_SPTR reactant_template : other.m_reactantTemplates) {
132 m_reactantTemplates.emplace_back(
new RWMol(*reactant_template));
134 m_productTemplates.clear();
135 m_productTemplates.reserve(other.m_productTemplates.size());
136 for (
ROMOL_SPTR product_template : other.m_productTemplates) {
137 m_productTemplates.emplace_back(
new RWMol(*product_template));
139 m_agentTemplates.clear();
140 m_agentTemplates.reserve(other.m_agentTemplates.size());
141 for (ROMOL_SPTR agent_template : other.m_agentTemplates) {
142 m_agentTemplates.emplace_back(
new RWMol(*agent_template));
144 d_substructParams = other.d_substructParams;
153 if (
this != &other) {
165 this->df_needsInit =
true;
166 this->m_reactantTemplates.push_back(mol);
167 return rdcast<unsigned int>(this->m_reactantTemplates.size());
176 this->m_agentTemplates.push_back(mol);
177 return rdcast<unsigned int>(this->m_agentTemplates.size());
186 this->m_productTemplates.push_back(mol);
187 return rdcast<unsigned int>(this->m_productTemplates.size());
198 bool moveToAgentTemplates =
true,
209 bool moveToAgentTemplates =
true,
232 const MOL_SPTR_VECT reactants,
unsigned int numProducts = 1000)
const;
241 ROMOL_SPTR reactant,
unsigned int reactantTemplateIdx)
const;
257 return this->m_reactantTemplates;
263 return this->m_reactantTemplates.begin();
266 return this->m_reactantTemplates.end();
270 return this->m_productTemplates.begin();
273 return this->m_productTemplates.end();
277 return this->m_agentTemplates.begin();
280 return this->m_agentTemplates.end();
284 return this->m_reactantTemplates.begin();
287 return this->m_reactantTemplates.end();
291 return this->m_productTemplates.begin();
294 return this->m_productTemplates.end();
298 return this->m_agentTemplates.begin();
301 return this->m_agentTemplates.end();
304 return rdcast<unsigned int>(this->m_reactantTemplates.size());
307 return rdcast<unsigned int>(this->m_productTemplates.size());
310 return rdcast<unsigned int>(this->m_agentTemplates.size());
340 bool validate(
unsigned int &numWarnings,
unsigned int &numErrors,
341 bool silent =
false)
const;
369 return d_substructParams;
374 bool df_needsInit{
true};
375 bool df_implicitProperties{
false};
376 MOL_SPTR_VECT m_reactantTemplates, m_productTemplates, m_agentTemplates;
377 SubstructMatchParameters d_substructParams;
386 std::vector<unsigned int> &which,
bool stopAtFirstMatch =
false);
400 std::vector<unsigned int> &which,
bool stopAtFirstMatch =
false);
471 const std::string &propName,
472 std::vector<std::vector<std::pair<unsigned int, std::string>>>
473 *reactantLabels =
nullptr);
508 bool canonOrient =
false,
unsigned int nFlipsPerSample = 0,
509 unsigned int nSamples = 0,
int sampleSeed = 0,
510 bool permuteDeg4Nodes =
false);
pulls in the core RDKit functionality
used to indicate an error in the chemical reaction engine
const char * what() const noexcept override
get the error message
ChemicalReactionException(const char *msg)
construct with an error message
ChemicalReactionException(const std::string msg)
construct with an error message
~ChemicalReactionException() noexcept override=default
This is a class for storing and applying general chemical reactions.
unsigned int addProductTemplate(ROMOL_SPTR mol)
Adds a new product template.
SubstructMatchParameters & getSubstructParams()
unsigned int addAgentTemplate(ROMOL_SPTR mol)
Adds a new agent template.
unsigned int addReactantTemplate(ROMOL_SPTR mol)
Adds a new reactant template.
unsigned int getNumAgentTemplates() const
const SubstructMatchParameters & getSubstructParams() const
bool getImplicitPropertiesFlag() const
unsigned int getNumReactantTemplates() const
ChemicalReaction & operator=(const ChemicalReaction &other)
ChemicalReaction(const std::string &binStr)
construct a reaction from a pickle string
MOL_SPTR_VECT::iterator beginProductTemplates()
void removeUnmappedReactantTemplates(double thresholdUnmappedAtoms=0.2, bool moveToAgentTemplates=true, MOL_SPTR_VECT *targetVector=nullptr)
MOL_SPTR_VECT::const_iterator beginProductTemplates() const
void initReactantMatchers(bool silent=false)
initializes our internal reactant-matching datastructures.
std::vector< MOL_SPTR_VECT > runReactants(const MOL_SPTR_VECT reactants, unsigned int numProducts=1000) const
Runs the reaction on a set of reactants.
const MOL_SPTR_VECT & getReactants() const
MOL_SPTR_VECT::const_iterator endReactantTemplates() const
void setImplicitPropertiesFlag(bool val)
const MOL_SPTR_VECT & getAgents() const
MOL_SPTR_VECT::iterator endProductTemplates()
unsigned int getNumProductTemplates() const
MOL_SPTR_VECT::const_iterator endProductTemplates() const
bool isInitialized() const
ChemicalReaction(const ChemicalReaction &other)
MOL_SPTR_VECT::const_iterator beginAgentTemplates() const
void removeAgentTemplates(MOL_SPTR_VECT *targetVector=nullptr)
std::vector< MOL_SPTR_VECT > runReactant(ROMOL_SPTR reactant, unsigned int reactantTemplateIdx) const
Runs a single reactant against a single reactant template.
MOL_SPTR_VECT::const_iterator beginReactantTemplates() const
const MOL_SPTR_VECT & getProducts() const
bool runReactant(RWMol &reactant, bool removeUnmatchedAtoms=true) const
Runs a single reactant in place (the reactant is modified)
MOL_SPTR_VECT::iterator beginReactantTemplates()
MOL_SPTR_VECT::iterator endAgentTemplates()
MOL_SPTR_VECT::iterator beginAgentTemplates()
MOL_SPTR_VECT::iterator endReactantTemplates()
void removeUnmappedProductTemplates(double thresholdUnmappedAtoms=0.2, bool moveToAgentTemplates=true, MOL_SPTR_VECT *targetVector=nullptr)
MOL_SPTR_VECT::const_iterator endAgentTemplates() const
bool validate(unsigned int &numWarnings, unsigned int &numErrors, bool silent=false) const
RWMol is a molecule class that is intended to be edited.
handles pickling (serializing) reactions
#define RDKIT_CHEMREACTIONS_EXPORT
std::vector< INT_VECT > VECT_INT_VECT
RDKIT_CHEMREACTIONS_EXPORT bool isMoleculeAgentOfReaction(const ChemicalReaction &rxn, const ROMol &mol, unsigned int &which)
RDKIT_CHEMREACTIONS_EXPORT bool isMoleculeReactantOfReaction(const ChemicalReaction &rxn, const ROMol &mol, std::vector< unsigned int > &which, bool stopAtFirstMatch=false)
RDKIT_CHEMREACTIONS_EXPORT VECT_INT_VECT getReactingAtoms(const ChemicalReaction &rxn, bool mappedAtomsOnly=false)
RDKIT_CHEMREACTIONS_EXPORT bool isMoleculeProductOfReaction(const ChemicalReaction &rxn, const ROMol &mol, std::vector< unsigned int > &which, bool stopAtFirstMatch=false)
boost::shared_ptr< ROMol > ROMOL_SPTR
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
RDKIT_CHEMREACTIONS_EXPORT void addRecursiveQueriesToReaction(ChemicalReaction &rxn, const std::map< std::string, ROMOL_SPTR > &queries, const std::string &propName, std::vector< std::vector< std::pair< unsigned int, std::string > > > *reactantLabels=nullptr)
add the recursive queries to the reactants of a reaction