![]() |
RDKit
Open-source cheminformatics and machine learning.
|
This is a class for storing and applying general chemical reactions. More...
#include <Reaction.h>
Public Member Functions | |
ChemicalReaction () | |
ChemicalReaction (const std::string &binStr) | |
construct a reaction from a pickle string | |
ChemicalReaction (const ChemicalReaction &other) | |
ChemicalReaction & | operator= (const ChemicalReaction &other) |
unsigned int | addReactantTemplate (ROMOL_SPTR mol) |
Adds a new reactant template. | |
unsigned int | addAgentTemplate (ROMOL_SPTR mol) |
Adds a new agent template. | |
unsigned int | addProductTemplate (ROMOL_SPTR mol) |
Adds a new product template. | |
void | removeUnmappedReactantTemplates (double thresholdUnmappedAtoms=0.2, bool moveToAgentTemplates=true, MOL_SPTR_VECT *targetVector=nullptr) |
void | removeUnmappedProductTemplates (double thresholdUnmappedAtoms=0.2, bool moveToAgentTemplates=true, MOL_SPTR_VECT *targetVector=nullptr) |
void | removeAgentTemplates (MOL_SPTR_VECT *targetVector=nullptr) |
std::vector< MOL_SPTR_VECT > | runReactants (const MOL_SPTR_VECT reactants, unsigned int numProducts=1000) const |
Runs the reaction on a set of reactants. | |
std::vector< MOL_SPTR_VECT > | runReactant (ROMOL_SPTR reactant, unsigned int reactantTemplateIdx) const |
Runs a single reactant against a single reactant template. | |
bool | runReactant (RWMol &reactant, bool removeUnmatchedAtoms=true) const |
Runs a single reactant in place (the reactant is modified) | |
const MOL_SPTR_VECT & | getReactants () const |
const MOL_SPTR_VECT & | getAgents () const |
const MOL_SPTR_VECT & | getProducts () const |
MOL_SPTR_VECT::const_iterator | beginReactantTemplates () const |
MOL_SPTR_VECT::const_iterator | endReactantTemplates () const |
MOL_SPTR_VECT::const_iterator | beginProductTemplates () const |
MOL_SPTR_VECT::const_iterator | endProductTemplates () const |
MOL_SPTR_VECT::const_iterator | beginAgentTemplates () const |
MOL_SPTR_VECT::const_iterator | endAgentTemplates () const |
MOL_SPTR_VECT::iterator | beginReactantTemplates () |
MOL_SPTR_VECT::iterator | endReactantTemplates () |
MOL_SPTR_VECT::iterator | beginProductTemplates () |
MOL_SPTR_VECT::iterator | endProductTemplates () |
MOL_SPTR_VECT::iterator | beginAgentTemplates () |
MOL_SPTR_VECT::iterator | endAgentTemplates () |
unsigned int | getNumReactantTemplates () const |
unsigned int | getNumProductTemplates () const |
unsigned int | getNumAgentTemplates () const |
void | initReactantMatchers (bool silent=false) |
initializes our internal reactant-matching datastructures. | |
bool | isInitialized () const |
bool | validate (unsigned int &numWarnings, unsigned int &numErrors, bool silent=false) const |
bool | getImplicitPropertiesFlag () const |
void | setImplicitPropertiesFlag (bool val) |
const SubstructMatchParameters & | getSubstructParams () const |
SubstructMatchParameters & | getSubstructParams () |
![]() | |
RDProps () | |
RDProps (const RDProps &rhs) | |
RDProps & | operator= (const RDProps &rhs) |
RDProps (RDProps &&o) noexcept=default | |
RDProps & | operator= (RDProps &&rhs) noexcept=default |
void | clear () |
const Dict & | getDict () const |
gets the underlying Dictionary | |
Dict & | getDict () |
STR_VECT | getPropList (bool includePrivate=true, bool includeComputed=true) const |
returns a list with the names of our properties | |
template<typename T > | |
void | setProp (const std::string &key, T val, bool computed=false) const |
sets a property value | |
template<typename T > | |
void | getProp (const std::string &key, T &res) const |
allows retrieval of a particular property value | |
template<typename T > | |
T | getProp (const std::string &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename T > | |
bool | getPropIfPresent (const std::string &key, T &res) const |
bool | hasProp (const std::string &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void | clearProp (const std::string &key) const |
clears the value of a property | |
void | clearComputedProps () const |
clears all of our computed properties | |
void | updateProps (const RDProps &source, bool preserveExisting=false) |
update the properties from another | |
Friends | |
class | ReactionPickler |
Additional Inherited Members | |
![]() | |
Dict | d_props |
This is a class for storing and applying general chemical reactions.
basic usage will be something like:
ChemicalReaction rxn; rxn.addReactantTemplate(r1); rxn.addReactantTemplate(r2); rxn.addProductTemplate(p1); rxn.initReactantMatchers(); MOL_SPTR_VECT prods; for(MOL_SPTR_VECT::const_iterator r1It=reactantSet1.begin(); r1It!=reactantSet1.end();++r1It;){ for(MOL_SPTR_VECT::const_iterator r2It=reactantSet2.begin(); r2It!=reactantSet2.end();++r2It;){ MOL_SPTR_VECT rVect(2); rVect[0] = *r1It; rVect[1] = *r2It; std::vector<MOL_SPTR_VECT> lprods; lprods = rxn.runReactants(rVect); for(std::vector<MOL_SPTR_VECT>::const_iterator lpIt=lprods.begin(); lpIt!=lprods.end();++lpIt){ // we know this is a single-product reaction: prods.push_back((*lpIt)[0]); } } }
NOTES:
std::string smi="[O:1]>>[N:1]"; ChemicalReaction *rxn = RxnSmartsToChemicalReaction(smi); rxn->initReactantMatchers(); MOL_SPTR_VECT reacts; reacts.clear(); smi = "OCO"; ROMol *mol = SmilesToMol(smi); reacts.push_back(ROMOL_SPTR(mol)); std::vector<MOL_SPTR_VECT> prods; prods = rxn->runReactants(reacts); // here prods has two entries, because there are two Os in the // reactant. reacts[0]->getAtomWithIdx(0)->setProp(common_properties::_protected,1); prods = rxn->runReactants(reacts); // here prods only has one entry, the reaction at atom 0 // has been blocked by the _protected property
Definition at line 121 of file Reaction.h.
|
inline |
Definition at line 148 of file Reaction.h.
RDKit::ChemicalReaction::ChemicalReaction | ( | const std::string & | binStr | ) |
construct a reaction from a pickle string
|
inline |
Definition at line 151 of file Reaction.h.
|
inline |
Adds a new agent template.
Definition at line 175 of file Reaction.h.
References rdcast.
|
inline |
Adds a new product template.
Definition at line 185 of file Reaction.h.
References rdcast.
|
inline |
Adds a new reactant template.
Definition at line 164 of file Reaction.h.
References rdcast.
|
inline |
Definition at line 297 of file Reaction.h.
|
inline |
Definition at line 276 of file Reaction.h.
|
inline |
Definition at line 290 of file Reaction.h.
|
inline |
Definition at line 269 of file Reaction.h.
|
inline |
Definition at line 283 of file Reaction.h.
|
inline |
Definition at line 262 of file Reaction.h.
|
inline |
Definition at line 300 of file Reaction.h.
|
inline |
Definition at line 279 of file Reaction.h.
|
inline |
Definition at line 293 of file Reaction.h.
|
inline |
Definition at line 272 of file Reaction.h.
|
inline |
Definition at line 286 of file Reaction.h.
|
inline |
Definition at line 265 of file Reaction.h.
|
inline |
Definition at line 259 of file Reaction.h.
|
inline |
returns whether or not the reaction uses implicit properties on the product atoms
This toggles whether or not unspecified atomic properties in the products are considered to be implicit and should be copied from the actual reactants. This is necessary due to a semantic difference between the "reaction SMARTS" approach and the MDL RXN approach: In "reaction SMARTS", this reaction: [C:1]-[Br:2].[O-:3]>>[C:1]-[O:3].[Br-:2] applied to [CH4+]Br should yield [CH4+]O Something similar drawn in an rxn file, and applied to [CH4+]Br should yield [CH3]O. In rxn there is no charge on the product C because nothing is specified in the rxn file; in "SMARTS" the charge from the actual reactants is not removed because no charge is specified in the reaction.
Definition at line 363 of file Reaction.h.
|
inline |
Definition at line 309 of file Reaction.h.
References rdcast.
|
inline |
Definition at line 306 of file Reaction.h.
References rdcast.
|
inline |
Definition at line 303 of file Reaction.h.
References rdcast.
|
inline |
Definition at line 260 of file Reaction.h.
|
inline |
Definition at line 256 of file Reaction.h.
|
inline |
Definition at line 371 of file Reaction.h.
|
inline |
Definition at line 368 of file Reaction.h.
void RDKit::ChemicalReaction::initReactantMatchers | ( | bool | silent = false | ) |
initializes our internal reactant-matching datastructures.
This must be called after adding reactants and before calling runReactants.
silent | If this bool is true, no messages will be logged during the validation. By default, validation problems are reported to the warning and error logs depending on their severity. |
Referenced by RDKit::EnumerateLibraryBase::EnumerateLibraryBase().
|
inline |
Definition at line 324 of file Reaction.h.
|
inline |
Definition at line 152 of file Reaction.h.
void RDKit::ChemicalReaction::removeAgentTemplates | ( | MOL_SPTR_VECT * | targetVector = nullptr | ) |
Removes the agent templates from a reaction if a pointer to a molecule vector is provided the agents are stored therein.
void RDKit::ChemicalReaction::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 below a given threshold
By default the removed products templates were attached to the agent templates. An alternative will be to provide a pointer to a molecule vector where these products should be saved.
void RDKit::ChemicalReaction::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 below a given threshold
By default the removed reactant templates were attached to the agent templates. An alternative will be to provide a pointer to a molecule vector where these reactants should be saved.
std::vector< MOL_SPTR_VECT > RDKit::ChemicalReaction::runReactant | ( | ROMOL_SPTR | reactant, |
unsigned int | reactantTemplateIdx ) const |
Runs a single reactant against a single reactant template.
reactant | The single reactant to use |
reactantTemplateIdx | the reactant template to target in the reaction |
bool RDKit::ChemicalReaction::runReactant | ( | RWMol & | reactant, |
bool | removeUnmatchedAtoms = true ) const |
Runs a single reactant in place (the reactant is modified)
This is only useable with reactions which have a single reactant and product and where no atoms are added in the product.
reactant | The single reactant to use |
removeUnmatchedAtoms | toggles whether or not atoms from the reactant which do not match template atoms are removed. |
std::vector< MOL_SPTR_VECT > RDKit::ChemicalReaction::runReactants | ( | const MOL_SPTR_VECT | reactants, |
unsigned int | numProducts = 1000 ) const |
Runs the reaction on a set of reactants.
reactants | the reactants to be used. The length of this must be equal to this->getNumReactantTemplates() |
maxProducts | if non zero, the maximum number of products to generate before stopping. If hit a warning will be generated. |
We return a vector of vectors of products because each individual template may map multiple times onto its reactant. This leads to multiple possible result sets.
|
inline |
sets the implicit properties flag. See the documentation for getImplicitProertiesFlag() for a discussion of what this means.
Definition at line 366 of file Reaction.h.
bool RDKit::ChemicalReaction::validate | ( | unsigned int & | numWarnings, |
unsigned int & | numErrors, | ||
bool | silent = false ) const |
validates the reactants and products to make sure the reaction seems "reasonable"
numWarnings | used to return the number of validation warnings |
numErrors | used to return the number of validation errors |
silent | If this bool is true, no messages will be logged during the validation. By default, validation problems are reported to the warning and error logs depending on their severity. |
|
friend |
Definition at line 122 of file Reaction.h.