Chemical Data Processing Library Python API - Version 1.4.0
Classes | Public Member Functions | Static Public Member Functions | Properties | List of all members
CDPL.Chem.Reaction Class Reference

Abstract base class for chemical reactions composed of role-tagged reaction components of type Chem.Molecule. More...

+ Inheritance diagram for CDPL.Chem.Reaction:

Classes

class  ComponentSequence
 

Public Member Functions

None __init__ ()
 Initializes the Reaction instance.
 
None clear ()
 Removes all components and clears all properties of the reaction.
 
Molecule addComponent (int role)
 Creates a new reaction component with the specified role. More...
 
bool containsComponent (Molecule mol)
 Tells whether the specified molecule is a component of this reaction. More...
 
int getComponentRole (Molecule mol)
 Returns the reaction role of the specified component. More...
 
int getComponentIndex (Molecule mol)
 Returns the index of the specified reaction component. More...
 
int getNumComponents (int role)
 Returns the number of reaction components with the specified role. More...
 
int getNumComponents ()
 Returns the total number of reaction components. More...
 
Molecule getComponent (int idx, int role)
 Returns a reference to the reaction component at index idx in the list of components with the specified role. More...
 
Molecule getComponent (int idx)
 Returns a reference to the reaction component at index idx. More...
 
None removeComponents (int role)
 Removes all components with the specified role. More...
 
None removeComponent (int idx, int role)
 Removes the reaction component at index idx in the list of components with the specified role. More...
 
None removeComponent (int idx)
 Removes the reaction component at the specified index. More...
 
None swapComponentRoles (int role1, int role2)
 Swaps the reaction roles of the component sets specified by role1 and role2. More...
 
Reaction clone ()
 Creates a deep copy of the current reaction state. More...
 
None copy (Reaction rxn)
 Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn. More...
 
Reaction assign (Reaction rxn)
 Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn. More...
 
ComponentSequence getReactants ()
 
ComponentSequence getAgents ()
 
ComponentSequence getProducts ()
 
None invokeCopyPostprocessingFunctions (Reaction src_rxn)
 Invokes all registered copy postprocessing functions with self as the target and src_rxn as the source reaction. More...
 
tuple __getstate__ ()
 
Base.Any __getitem__ (Base.LookupKey key)
 
Molecule __getitem__ (int idx)
 
bool __contains__ (Base.LookupKey key)
 Returns the result of the membership test operation key in self. More...
 
bool __contains__ (Molecule mol)
 Returns the result of the membership test operation mol in self. More...
 
None __setitem__ (Base.LookupKey key, Base.Any value)
 
bool __delitem__ (Base.LookupKey key)
 
None __delitem__ (int idx)
 
int __len__ ()
 
- Public Member Functions inherited from CDPL.Base.PropertyContainer
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
int getNumProperties ()
 Returns the number of property entries. More...
 
Any getPropertyOrDefault (LookupKey key, Any def_value)
 
list getPropertyKeys ()
 
list getPropertyValues ()
 
list getProperties ()
 Returns a reference to itself. More...
 
None setProperty (LookupKey key, Any value)
 
bool removeProperty (LookupKey key)
 Clears the value of the property specified by key. More...
 
Any getProperty (LookupKey key, bool throw_=False)
 Returns the value of the property specified by key. More...
 
bool isPropertySet (LookupKey key)
 Tells whether or not a value has been assigned to the property specified by key. More...
 
None clearProperties ()
 Clears all property values.
 
None addProperties (PropertyContainer cntnr)
 Adds the property value entries in the PropertyContainer instance cntnr. More...
 
None copyProperties (PropertyContainer cntnr)
 Replaces the current set of properties by a copy of the entries in cntnr. More...
 
None swap (PropertyContainer cntnr)
 Exchanges the properties of this container with the properties of the container cntnr. More...
 
Any __getitem__ (LookupKey key)
 Returns the value of the property specified by key. More...
 
bool __contains__ (LookupKey key)
 Returns the result of the membership test operation key in self. More...
 
None __setitem__ (LookupKey key, Any value)
 
bool __delitem__ (LookupKey key)
 

Static Public Member Functions

None registerCopyPostprocessingFunction (VoidMoleculeMolecularGraphFunctor func)
 Registers a global postprocessing function invoked after every reaction copy operation. More...
 

Properties

 reactants = property(getReactants)
 
 agents = property(getAgents)
 
 products = property(getProducts)
 
 numComponents = property(getNumComponents)
 
- Properties inherited from CDPL.Base.PropertyContainer
 objectID = property(getObjectID)
 
 propertyKeys = property(getPropertyKeys)
 
 propertyValues = property(getPropertyValues)
 
 properties = property(getProperties)
 
 numProperties = property(getNumProperties)
 

Detailed Description

Abstract base class for chemical reactions composed of role-tagged reaction components of type Chem.Molecule.

Each component carries a reaction role that is specified by one of the constants declared in namespace Chem.ReactionRole. Reaction roles divide the components into three different subsets: reactants, agents/catalysts and products. For component management/access the methods getComponentRole(), getNumComponents(), getComponent(), getComponentsBegin() and getComponentsEnd() are available. For reaction editing the methods addComponent(), removeComponent(), swapComponentRoles() and clear(). The method clone() allows the creation of polymorphic deep copies and reaction properties can be stored/retrieved via the methods of the Base.PropertyContainer base class.

Member Function Documentation

◆ addComponent()

Molecule CDPL.Chem.Reaction.addComponent ( int  role)

Creates a new reaction component with the specified role.

Parameters
roleThe reaction role of the new component (see namespace Chem.ReactionRole).
Returns
A reference to the newly created component molecule.
Exceptions
Base.ValueErrorif the value of role is not Chem.ReactionRole.REACTANT, Chem.ReactionRole.AGENT or Chem.ReactionRole.PRODUCT.

Reimplemented in CDPL.Chem.BasicReaction.

◆ containsComponent()

bool CDPL.Chem.Reaction.containsComponent ( Molecule  mol)

Tells whether the specified molecule is a component of this reaction.

Parameters
molThe molecule to look for.
Returns
True if the specified molecule is a component of this reaction, and False otherwise.

◆ getComponentRole()

int CDPL.Chem.Reaction.getComponentRole ( Molecule  mol)

Returns the reaction role of the specified component.

If the specified molecule is not a component of this reaction, Chem.ReactionRole.NONE will be returned.

Parameters
molThe component for which to return the reaction role.
Returns
The reaction role of the component (see namespace Chem.ReactionRole).

◆ getComponentIndex()

int CDPL.Chem.Reaction.getComponentIndex ( Molecule  mol)

Returns the index of the specified reaction component.

Parameters
molThe component for which to return the index.
Returns
The zero-based index of the specified reaction component.
Exceptions
Base.ItemNotFoundif the specified molecule is not a component of this reaction.

◆ getNumComponents() [1/2]

int CDPL.Chem.Reaction.getNumComponents ( int  role)

Returns the number of reaction components with the specified role.

Parameters
roleThe reaction role (see namespace Chem.ReactionRole).
Returns
The number of reaction components with the specified role.
Exceptions
Base.ValueErrorif the value of role is not equal to Chem.ReactionRole.REACTANT, Chem.ReactionRole.AGENT or Chem.ReactionRole.PRODUCT.

◆ getNumComponents() [2/2]

int CDPL.Chem.Reaction.getNumComponents ( )

Returns the total number of reaction components.

Returns
The total number of reaction components.

◆ getComponent() [1/2]

Molecule CDPL.Chem.Reaction.getComponent ( int  idx,
int  role 
)

Returns a reference to the reaction component at index idx in the list of components with the specified role.

Parameters
idxThe zero-based index of the reaction component to return.
roleA flag indicating the reaction role of the component (see namespace Chem.ReactionRole).
Returns
A reference to the reaction component with the specified role and index.
Exceptions
Base.IndexErrorif idx is not in the range [0, getNumComponents(role)). Base.ValueError if the value of role is not equal to Chem.ReactionRole.REACTANT, Chem.ReactionRole.AGENT or Chem.ReactionRole.PRODUCT.

◆ getComponent() [2/2]

Molecule CDPL.Chem.Reaction.getComponent ( int  idx)

Returns a reference to the reaction component at index idx.

Parameters
idxThe zero-based index of the reaction component to return.
Returns
A reference to the reaction component at the specified index.
Exceptions
Base.IndexErrorif idx is not in the range [0, getNumComponents()).

◆ removeComponents()

None CDPL.Chem.Reaction.removeComponents ( int  role)

Removes all components with the specified role.

Parameters
roleThe reaction role of the components to remove (see namespace Chem.ReactionRole).
Exceptions
Base.ValueErrorif the value of role is not Chem.ReactionRole.REACTANT, Chem.ReactionRole.AGENT or Chem.ReactionRole.PRODUCT.

◆ removeComponent() [1/2]

None CDPL.Chem.Reaction.removeComponent ( int  idx,
int  role 
)

Removes the reaction component at index idx in the list of components with the specified role.

Parameters
idxThe zero-based index of the component to remove.
roleThe reaction role of the component (see namespace Chem.ReactionRole).
Exceptions
Base.IndexErrorif idx is not in the range [0, getNumComponents(role)). Base.ValueError if the value of role is not Chem.ReactionRole.REACTANT, Chem.ReactionRole.AGENT or Chem.ReactionRole.PRODUCT.

◆ removeComponent() [2/2]

None CDPL.Chem.Reaction.removeComponent ( int  idx)

Removes the reaction component at the specified index.

Parameters
idxThe zero-based index of the component to remove.
Exceptions
Base.IndexErrorif idx is not in the range [0, getNumComponents()).

◆ swapComponentRoles()

None CDPL.Chem.Reaction.swapComponentRoles ( int  role1,
int  role2 
)

Swaps the reaction roles of the component sets specified by role1 and role2.

If role1 is equal to role2, the method has no effect.

Parameters
role1The reaction role of the first component set (see namespace Chem.ReactionRole).
role2The reaction role of the second component set (see namespace Chem.ReactionRole).
Exceptions
Base.ValueErrorif the value of role1 and/or role2 is not equal to Chem.ReactionRole.REACTANT, Chem.ReactionRole.AGENT or Chem.ReactionRole.PRODUCT.

◆ clone()

Reaction CDPL.Chem.Reaction.clone ( )

Creates a deep copy of the current reaction state.

Returns
A smart reference to the copy of the reaction.

◆ copy()

None CDPL.Chem.Reaction.copy ( Reaction  rxn)

Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn.

Parameters
rxnThe reaction to copy.

Reimplemented in CDPL.Chem.BasicReaction.

◆ assign()

Reaction CDPL.Chem.Reaction.assign ( Reaction  rxn)

Replaces the current set of reaction components and properties by a copy of the components and properties of the reaction rxn.

Internally calls copy() to perform the actual work.

Parameters
rxnThe reaction to copy.
Returns
self

Reimplemented in CDPL.Chem.BasicReaction.

◆ registerCopyPostprocessingFunction()

None CDPL.Chem.Reaction.registerCopyPostprocessingFunction ( VoidMoleculeMolecularGraphFunctor  func)
static

Registers a global postprocessing function invoked after every reaction copy operation.

Parameters
funcThe function to register.

◆ invokeCopyPostprocessingFunctions()

None CDPL.Chem.Reaction.invokeCopyPostprocessingFunctions ( Reaction  src_rxn)

Invokes all registered copy postprocessing functions with self as the target and src_rxn as the source reaction.

Parameters
src_rxnThe source reaction the copy was made from.

◆ __contains__() [1/2]

bool CDPL.Chem.Reaction.__contains__ ( Base.LookupKey  key)

Returns the result of the membership test operation key in self.

Parameters
keyThe value to test for membership.
Returns
The result of the membership test operation.

◆ __contains__() [2/2]

bool CDPL.Chem.Reaction.__contains__ ( Molecule  mol)

Returns the result of the membership test operation mol in self.

Parameters
molThe value to test for membership.
Returns
The result of the membership test operation.