Class Reaction

java.lang.Object
org.openscience.cdk.silent.ChemObject
org.openscience.cdk.silent.Reaction
All Implemented Interfaces:
Serializable, Cloneable, Iterable<IAtomContainer>, ICDKObject, IChemObject, IReaction

public class Reaction extends ChemObject implements Serializable, IReaction, Cloneable
Represents the idea of a chemical reaction. The reaction consists of a set of reactants and a set of products.

The class mostly represents abstract reactions, such as 2D diagrams, and is not intended to represent reaction trajectories. Such can better be represented with a ChemSequence.

Author:
Egon Willighagen <elw38@cam.ac.uk>
See Also:
Keywords:
reaction
Created on:
2003-02-13
  • Field Details

  • Constructor Details

    • Reaction

      public Reaction()
      Constructs an empty, forward reaction.
  • Method Details

    • getReactantCount

      public int getReactantCount()
      Returns the number of reactants in this reaction.
      Specified by:
      getReactantCount in interface IReaction
      Returns:
      The number of reactants in this reaction
    • getProductCount

      public int getProductCount()
      Returns the number of products in this reaction.
      Specified by:
      getProductCount in interface IReaction
      Returns:
      The number of products in this reaction
    • getAgentCount

      public int getAgentCount()
      Returns the number of agents in this reaction.
      Specified by:
      getAgentCount in interface IReaction
      Returns:
      The number of agents in this reaction
    • getReactants

      public IAtomContainerSet getReactants()
      Returns a MoleculeSet containing the reactants in this reaction.
      Specified by:
      getReactants in interface IReaction
      Returns:
      A MoleculeSet containing the reactants in this reaction
      See Also:
    • setReactants

      public void setReactants(IAtomContainerSet setOfMolecules)
      Assigns a MoleculeSet to the reactants in this reaction.
      Specified by:
      setReactants in interface IReaction
      Parameters:
      setOfMolecules - The new set of reactants
      See Also:
    • getProducts

      public IAtomContainerSet getProducts()
      Returns a MoleculeSet containing the products of this reaction.
      Specified by:
      getProducts in interface IReaction
      Returns:
      A MoleculeSet containing the products in this reaction
      See Also:
    • setProducts

      public void setProducts(IAtomContainerSet setOfMolecules)
      Assigns a MoleculeSet to the products of this reaction.
      Specified by:
      setProducts in interface IReaction
      Parameters:
      setOfMolecules - The new set of products
      See Also:
    • getAgents

      public IAtomContainerSet getAgents()
      Returns a MoleculeSet containing the agents in this reaction.
      Specified by:
      getAgents in interface IReaction
      Returns:
      A MoleculeSet containing the agents in this reaction
      See Also:
    • mappings

      public Iterable<IMapping> mappings()
      Returns the mappings between the reactant and the product side.
      Specified by:
      mappings in interface IReaction
      Returns:
      An Iterator to the Mappings.
      See Also:
    • addReactant

      public void addReactant(IAtomContainer reactant)
      Adds a reactant to this reaction.
      Specified by:
      addReactant in interface IReaction
      Parameters:
      reactant - Molecule added as reactant to this reaction
      See Also:
    • addAgent

      public void addAgent(IAtomContainer agent)
      Adds an agent to this reaction.
      Specified by:
      addAgent in interface IReaction
      Parameters:
      agent - Molecule added as agent to this reaction
      See Also:
    • addReactant

      public void addReactant(IAtomContainer reactant, Double coefficient)
      Adds a reactant to this reaction with a stoichiometry coefficient.
      Specified by:
      addReactant in interface IReaction
      Parameters:
      reactant - Molecule added as reactant to this reaction
      coefficient - Stoichiometry coefficient for this molecule
      See Also:
    • addProduct

      public void addProduct(IAtomContainer product)
      Adds a product to this reaction.
      Specified by:
      addProduct in interface IReaction
      Parameters:
      product - Molecule added as product to this reaction
      See Also:
    • addProduct

      public void addProduct(IAtomContainer product, Double coefficient)
      Adds a product to this reaction.
      Specified by:
      addProduct in interface IReaction
      Parameters:
      product - Molecule added as product to this reaction
      coefficient - Stoichiometry coefficient for this molecule
      See Also:
    • getReactantCoefficient

      public Double getReactantCoefficient(IAtomContainer reactant)
      Returns the stoichiometry coefficient of the given reactant.
      Specified by:
      getReactantCoefficient in interface IReaction
      Parameters:
      reactant - Reactant for which the coefficient is returned.
      Returns:
      -1, if the given molecule is not a product in this Reaction
      See Also:
    • getProductCoefficient

      public Double getProductCoefficient(IAtomContainer product)
      Returns the stoichiometry coefficient of the given product.
      Specified by:
      getProductCoefficient in interface IReaction
      Parameters:
      product - Product for which the coefficient is returned.
      Returns:
      -1, if the given molecule is not a product in this Reaction
      See Also:
    • setReactantCoefficient

      public boolean setReactantCoefficient(IAtomContainer reactant, Double coefficient)
      Sets the coefficient of a a reactant to a given value.
      Specified by:
      setReactantCoefficient in interface IReaction
      Parameters:
      reactant - Reactant for which the coefficient is set
      coefficient - The new coefficient for the given reactant
      Returns:
      true if Molecule has been found and stoichiometry has been set.
      See Also:
    • setProductCoefficient

      public boolean setProductCoefficient(IAtomContainer product, Double coefficient)
      Sets the coefficient of a a product to a given value.
      Specified by:
      setProductCoefficient in interface IReaction
      Parameters:
      product - Product for which the coefficient is set
      coefficient - The new coefficient for the given product
      Returns:
      true if Molecule has been found and stoichiometry has been set.
      See Also:
    • getReactantCoefficients

      public Double[] getReactantCoefficients()
      Returns an array of double with the stoichiometric coefficients of the reactants.
      Specified by:
      getReactantCoefficients in interface IReaction
      Returns:
      An array of double's containing the coefficients of the reactants
      See Also:
    • getProductCoefficients

      public Double[] getProductCoefficients()
      Returns an array of double with the stoichiometric coefficients of the products.
      Specified by:
      getProductCoefficients in interface IReaction
      Returns:
      An array of double's containing the coefficients of the products
      See Also:
    • setReactantCoefficients

      public boolean setReactantCoefficients(Double[] coefficients)
      Sets the coefficients of the reactants.
      Specified by:
      setReactantCoefficients in interface IReaction
      Parameters:
      coefficients - An array of double's containing the coefficients of the reactants
      Returns:
      true if coefficients have been set.
      See Also:
    • setProductCoefficients

      public boolean setProductCoefficients(Double[] coefficients)
      Sets the coefficient of the products.
      Specified by:
      setProductCoefficients in interface IReaction
      Parameters:
      coefficients - An array of double's containing the coefficients of the products
      Returns:
      true if coefficients have been set.
      See Also:
    • setDirection

      public void setDirection(IReaction.Direction direction)
      Sets the direction of the reaction.
      Specified by:
      setDirection in interface IReaction
      Parameters:
      direction - The new reaction direction
      See Also:
    • getDirection

      public IReaction.Direction getDirection()
      Returns the direction of the reaction.
      Specified by:
      getDirection in interface IReaction
      Returns:
      The direction of this reaction (FORWARD, BACKWARD or BIDIRECTIONAL).
      See Also:
    • addMapping

      public void addMapping(IMapping mapping)
      Adds a mapping between the reactant and product side to this Reaction.
      Specified by:
      addMapping in interface IReaction
      Parameters:
      mapping - Mapping to add.
      See Also:
    • removeMapping

      public void removeMapping(int pos)
      Removes a mapping between the reactant and product side to this Reaction.
      Specified by:
      removeMapping in interface IReaction
      Parameters:
      pos - Position of the Mapping to remove.
      See Also:
    • getMapping

      public IMapping getMapping(int pos)
      Retrieves a mapping between the reactant and product side to this Reaction.
      Specified by:
      getMapping in interface IReaction
      Parameters:
      pos - Position of Mapping to get.
      Returns:
      the mapping identified by the specified position
    • getMappingCount

      public int getMappingCount()
      Get the number of mappings between the reactant and product side to this Reaction.
      Specified by:
      getMappingCount in interface IReaction
      Returns:
      Number of stored Mappings.
    • toString

      public String toString()
      Returns a one line string representation of this Atom. Methods is conform RFC #9.
      Specified by:
      toString in interface IChemObject
      Overrides:
      toString in class Object
      Returns:
      The string representation of this Atom
    • clone

      public Object clone() throws CloneNotSupportedException
      Clones this Reaction and its content.
      Specified by:
      clone in interface IChemObject
      Overrides:
      clone in class ChemObject
      Returns:
      The cloned object
      Throws:
      CloneNotSupportedException - if the IChemObject cannot be cloned