34 #ifndef RD_REACTION_H_17Aug2006
35 #define RD_REACTION_H_17Aug2006
43 class ReactionPickler;
47 :
public std::exception {
54 const char *
what() const noexcept
override {
return _msg.c_str(); };
125 df_needsInit = other.df_needsInit;
126 df_implicitProperties = other.df_implicitProperties;
130 m_reactantTemplates.push_back(
ROMOL_SPTR(reactant));
135 m_productTemplates.push_back(
ROMOL_SPTR(product));
140 m_agentTemplates.push_back(
ROMOL_SPTR(agent));
153 this->df_needsInit =
true;
154 this->m_reactantTemplates.push_back(mol);
155 return rdcast<unsigned int>(this->m_reactantTemplates.size());
164 this->m_agentTemplates.push_back(mol);
165 return rdcast<unsigned int>(this->m_agentTemplates.size());
174 this->m_productTemplates.push_back(mol);
175 return rdcast<unsigned int>(this->m_productTemplates.size());
186 bool moveToAgentTemplates =
true,
197 bool moveToAgentTemplates =
true,
220 const MOL_SPTR_VECT reactants,
unsigned int numProducts = 1000)
const;
229 ROMOL_SPTR reactant,
unsigned int reactantTemplateIdx)
const;
232 return this->m_reactantTemplates;
238 return this->m_reactantTemplates.begin();
241 return this->m_reactantTemplates.end();
245 return this->m_productTemplates.begin();
248 return this->m_productTemplates.end();
252 return this->m_agentTemplates.begin();
255 return this->m_agentTemplates.end();
259 return this->m_reactantTemplates.begin();
262 return this->m_reactantTemplates.end();
266 return this->m_productTemplates.begin();
269 return this->m_productTemplates.end();
273 return this->m_agentTemplates.begin();
276 return this->m_agentTemplates.end();
279 return rdcast<unsigned int>(this->m_reactantTemplates.size());
282 return rdcast<unsigned int>(this->m_productTemplates.size());
285 return rdcast<unsigned int>(this->m_agentTemplates.size());
315 bool validate(
unsigned int &numWarnings,
unsigned int &numErrors,
316 bool silent =
false)
const;
344 bool df_needsInit{
true};
345 bool df_implicitProperties{
false};
346 MOL_SPTR_VECT m_reactantTemplates, m_productTemplates, m_agentTemplates;
347 ChemicalReaction &operator=(
const ChemicalReaction &);
435 const std::string &propName,
436 std::vector<std::vector<std::pair<unsigned int, std::string>>>
437 *reactantLabels =
nullptr);
472 bool canonOrient =
false,
unsigned int nFlipsPerSample = 0,
473 unsigned int nSamples = 0,
int sampleSeed = 0,
474 bool permuteDeg4Nodes =
false);
pulls in the core RDKit functionality
used to indicate an error in the chemical reaction engine
ChemicalReactionException(const char *msg)
construct with an error message
ChemicalReactionException(const std::string msg)
construct with an error message
~ChemicalReactionException() noexcept
const char * what() const noexcept override
get the error message
This is a class for storing and applying general chemical reactions.
unsigned int addProductTemplate(ROMOL_SPTR mol)
Adds a new product template.
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
bool getImplicitPropertiesFlag() const
std::vector< MOL_SPTR_VECT > runReactants(const MOL_SPTR_VECT reactants, unsigned int numProducts=1000) const
Runs the reaction on a set of reactants.
unsigned int getNumReactantTemplates() const
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)
Removes the reactant templates from a reaction if atom mapping ratio is.
const MOL_SPTR_VECT & getProducts() const
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 beginProductTemplates() const
void initReactantMatchers(bool silent=false)
initializes our internal reactant-matching datastructures.
MOL_SPTR_VECT::const_iterator endReactantTemplates() const
void setImplicitPropertiesFlag(bool val)
MOL_SPTR_VECT::iterator endProductTemplates()
unsigned int getNumProductTemplates() const
const MOL_SPTR_VECT & getAgents() const
const MOL_SPTR_VECT & getReactants() 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)
MOL_SPTR_VECT::const_iterator beginReactantTemplates() const
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)
Removes the product templates from a reaction if its atom mapping ratio is.
MOL_SPTR_VECT::const_iterator endAgentTemplates() const
bool validate(unsigned int &numWarnings, unsigned int &numErrors, bool silent=false) const
validates the reactants and products to make sure the reaction seems
handles pickling (serializing) reactions
#define RDKIT_CHEMREACTIONS_EXPORT
RDKIT_CHEMREACTIONS_EXPORT void compute2DCoordsForReaction(RDKit::ChemicalReaction &rxn, double spacing=2.0, bool updateProps=true, bool canonOrient=false, unsigned int nFlipsPerSample=0, unsigned int nSamples=0, int sampleSeed=0, bool permuteDeg4Nodes=false)
Generate 2D coordinates (a depiction) for a reaction.
RDKIT_CHEMREACTIONS_EXPORT bool isMoleculeProductOfReaction(const ChemicalReaction &rxn, const ROMol &mol, unsigned int &which)
std::vector< INT_VECT > VECT_INT_VECT
RDKIT_CHEMREACTIONS_EXPORT bool isMoleculeAgentOfReaction(const ChemicalReaction &rxn, const ROMol &mol, unsigned int &which)
RDKIT_CHEMREACTIONS_EXPORT VECT_INT_VECT getReactingAtoms(const ChemicalReaction &rxn, bool mappedAtomsOnly=false)
boost::shared_ptr< ROMol > ROMOL_SPTR
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
std::vector< boost::shared_ptr< ROMol > > MOL_SPTR_VECT
RDKIT_CHEMREACTIONS_EXPORT bool isMoleculeReactantOfReaction(const ChemicalReaction &rxn, const ROMol &mol, unsigned int &which)