chemaxon.reaction
Class Reaction

java.lang.Object
  extended by chemaxon.reaction.Reaction
All Implemented Interfaces:
java.io.Serializable

public class Reaction
extends java.lang.Object
implements java.io.Serializable

Stores reaction data. The reaction data consists of:

Stores connection data read from the reaction equation.

Since:
JChem 3.0
Version:
5.0.3 03/19/2008
Author:
Nora Mate, Zsolt Mohacsi
See Also:
Serialized Form

Field Summary
static int ALL_SIDE
          Reactant and product sides of the reaction molecule
protected  int bcount
          Number of changed bonds.
static int DATA_ALL
          Required data: all.
static int DATA_ATOMS
          Required data: atom data.
static int DATA_BONDS
          Required data: bond data.
static int DATA_DOUBLE_BOND_STEREO
          Required data: double bond stereo.
static int DATA_PARITY
          Required data: parity.
protected  int[] emaps
          End map numbers: bond atom2.
protected static int LEN
          Default array length.
protected  int[] map2map
          Identical maps.
protected  int[] map2pindex
          Map number -> product index array.
protected  int[] map2rindex
          Map number -> reactant index array.
protected  int[] map2stereo
          Map -> reaction stereo info array.
protected static int MAXMAPS
          Maximal number of map values.
protected  java.util.ArrayList patomprops
          Atom objects for storing product atom properties.
protected  int[] pbondtypes
          Product bond types.
protected  java.util.ArrayList pcistrans
          Stores double bond stereo info (product-side).
protected  int[] pindex2map
          Product index -> map number array.
protected  java.util.ArrayList pparities
          Stores parity info (product-side).
static int PRODUCT_SIDE
          Product side of the reaction molecule
protected static int PROP_CHARGE
          Constant: charge atom property.
protected static int PROP_HCOUNT
          Constant: hydrogen count atom property.
protected static int PROP_RADICAL
          Constant: radical atom property.
protected static int PROP_STGRP
          Constant: enhanced stereo atom property.
protected  int[] proptypes
          Property types corresponding to 'ratomprops', 'patomprops'.
protected  java.util.ArrayList ratomprops
          Atom objects for storing reactant atom properties.
protected  int[] rbondtypes
          Reactant bond types.
protected  java.util.ArrayList rcistrans
          Stores double bond stereo info (reactant-side).
static int REACTANT_SIDE
          Reactant side of the reaction molecule
protected  int[] rindex2map
          Reactant index -> map number array.
protected  ChemJEP rjep
          The JEP object that evaluates the reactivity (acceptance) rule.
protected  java.util.ArrayList rparities
          Stores parity info (reactant-side).
protected  RxnMolecule rxn
          The reaction molecule.
protected  ChemJEP sjep
          The JEP object that evaluates the selectivity (measure) rule.
protected  int[] smaps
          Start map numbers: bond atom1.
protected  double[] tolerances
          The tolerance value corresponding to the selectivity rule.
 
Constructor Summary
Reaction()
          Default constructor.
Reaction(java.lang.String id)
          Constructor.
 
Method Summary
protected  int getBaseMap(int map)
          Returns the base map corresponding to the given map.
 int[] getChangingAtoms(boolean all, int side)
          Returns the indexes of changing atoms.
 int[][] getChangingBondData(boolean all)
          Returns changing bond data.
protected  java.lang.String getFID()
          Deprecated. Not used.
 java.lang.String getID()
          Returns the reaction ID.
protected  Molecule getProduct(int i)
          Returns the i-th product.
protected  MolAtom getProductAtom(int i)
          Returns the i-th atom existing only on the product side.
protected  int getProductAtomCount()
          Returns the number of atoms existing only on the product side.
protected  int getProductCount()
          Returns the number of products.
protected  Molecule[] getProducts()
          Returns the reaction products.
 Molecule getReactant(int i)
          Returns the i-th reactant.
protected  MolAtom getReactantAtom(int i)
          Returns the i-th atom existing only on the reactant side.
protected  int getReactantAtomCount()
          Returns the number of atoms existing only on the reactant side.
 int getReactantCount()
          Returns the number of reactants.
protected  Molecule[] getReactants()
          Returns the reaction reactants.
static java.lang.String getReactivity(java.lang.String reactivity, java.lang.String exclude)
          Returns reactivity combined with exclude condition.
static double[] getTolerances(java.lang.String tolerances)
          Returns double[] created from ";" separated list of real numbers.
 void setFID(java.lang.String fid)
          Deprecated. Not used.
 void setReaction(Molecule mol)
          Sets the reaction molecule representing the reaction equation.
 void setReaction(Molecule mol, boolean fuse)
          Sets the reaction molecule representing the reaction equation.
 void setReaction(Molecule mol, boolean fuse, boolean skipMappingCheck)
          Sets the reaction molecule representing the reaction equation.
 void setReactivityRule(java.lang.String rule, Evaluator evaluator)
          Sets the reactivity (acceptance) rule.
 void setRequiredData(int data)
          Sets the required data to be stored.
 void setSelectivityRule(java.lang.String rule, double[] tolerances, Evaluator evaluator)
          Sets the selectivity rule with tolerance.
 void setSelectivityRule(java.lang.String rule, Evaluator evaluator)
          Deprecated. Use setSelectivityRule(String, double[], Evaluator) or setSelectivityRule(String, String, Evaluator) and set tolerances parameter to null
 void setSelectivityRule(java.lang.String rule, java.lang.String tolerances, Evaluator evaluator)
          Sets the selectivity rule with tolerance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXMAPS

protected static final int MAXMAPS
Maximal number of map values.

See Also:
Constant Field Values

LEN

protected static final int LEN
Default array length.

See Also:
Constant Field Values

PROP_CHARGE

protected static final int PROP_CHARGE
Constant: charge atom property.

See Also:
Constant Field Values

PROP_RADICAL

protected static final int PROP_RADICAL
Constant: radical atom property.

See Also:
Constant Field Values

PROP_STGRP

protected static final int PROP_STGRP
Constant: enhanced stereo atom property.

See Also:
Constant Field Values

PROP_HCOUNT

protected static final int PROP_HCOUNT
Constant: hydrogen count atom property.

See Also:
Constant Field Values

REACTANT_SIDE

public static final int REACTANT_SIDE
Reactant side of the reaction molecule

See Also:
Constant Field Values

PRODUCT_SIDE

public static final int PRODUCT_SIDE
Product side of the reaction molecule

See Also:
Constant Field Values

ALL_SIDE

public static final int ALL_SIDE
Reactant and product sides of the reaction molecule

See Also:
Constant Field Values

DATA_ATOMS

public static final int DATA_ATOMS
Required data: atom data.

See Also:
Constant Field Values

DATA_BONDS

public static final int DATA_BONDS
Required data: bond data.

See Also:
Constant Field Values

DATA_PARITY

public static final int DATA_PARITY
Required data: parity.

See Also:
Constant Field Values

DATA_DOUBLE_BOND_STEREO

public static final int DATA_DOUBLE_BOND_STEREO
Required data: double bond stereo.

See Also:
Constant Field Values

DATA_ALL

public static final int DATA_ALL
Required data: all.

See Also:
Constant Field Values

rxn

protected RxnMolecule rxn
The reaction molecule.


rjep

protected ChemJEP rjep
The JEP object that evaluates the reactivity (acceptance) rule.


sjep

protected ChemJEP sjep
The JEP object that evaluates the selectivity (measure) rule.


tolerances

protected double[] tolerances
The tolerance value corresponding to the selectivity rule.


map2map

protected int[] map2map
Identical maps.


smaps

protected int[] smaps
Start map numbers: bond atom1.


emaps

protected int[] emaps
End map numbers: bond atom2.


rbondtypes

protected int[] rbondtypes
Reactant bond types.


pbondtypes

protected int[] pbondtypes
Product bond types.


bcount

protected int bcount
Number of changed bonds.


proptypes

protected int[] proptypes
Property types corresponding to 'ratomprops', 'patomprops'.


ratomprops

protected java.util.ArrayList ratomprops
Atom objects for storing reactant atom properties.


patomprops

protected java.util.ArrayList patomprops
Atom objects for storing product atom properties.


map2stereo

protected int[] map2stereo
Map -> reaction stereo info array.


map2rindex

protected int[] map2rindex
Map number -> reactant index array. Shows which reactant a given atom map belongs to. The product index is set to -1 if the mapped atom exists only on the product side.


map2pindex

protected int[] map2pindex
Map number -> product index array. Shows which product a given atom map belongs to. The product index is set to -1 if the mapped atom exists only on the reactant side.


rindex2map

protected int[] rindex2map
Reactant index -> map number array. Shows a representative map number from the reactant.


pindex2map

protected int[] pindex2map
Product index -> map number array. Shows a representative map number from the product.


rparities

protected java.util.ArrayList rparities
Stores parity info (reactant-side). Stores reactant-side parity-info in int[7] arrays. 0: central atom map 1-4: ligand atom maps 5: parity sign 6: parity


pparities

protected java.util.ArrayList pparities
Stores parity info (product-side). Stores product-side parity-info in int[7] arrays. 0: central atom map 1-4: ligand atom maps 5: parity sign 6: parity


rcistrans

protected java.util.ArrayList rcistrans
Stores double bond stereo info (reactant-side). Stores reactant-side reaction stereo2 (cis/trans) info in int[5] arrays. 0-3: the A1-A2=A3-A4 atom maps 4: the cis/trans constant

See Also:
StereoConstants.CIS, StereoConstants.TRANS, StereoConstants.CTUNSPEC

pcistrans

protected java.util.ArrayList pcistrans
Stores double bond stereo info (product-side). Stores product-side reaction stereo2 (cis/trans) info in int[5] arrays. 0-3: the A1-A2=A3-A4 atom maps 4: the cis/trans constant

See Also:
StereoConstants.CIS, StereoConstants.TRANS, StereoConstants.CTUNSPEC
Constructor Detail

Reaction

public Reaction()
Default constructor.


Reaction

public Reaction(java.lang.String id)
Constructor.

Parameters:
id - is the reaction ID
Method Detail

setRequiredData

public void setRequiredData(int data)
Sets the required data to be stored. Default: DATA_ALL.

Parameters:
data - is the required data, an OR-ed combination of the DATA_ constants (e.g. DATA_ATOMS | DATA_BONDS)
Since:
JChem 3.2
See Also:
DATA_ATOMS, DATA_BONDS, DATA_PARITY, DATA_DOUBLE_BOND_STEREO

getChangingBondData

public int[][] getChangingBondData(boolean all)
Returns changing bond data. The DATA_BONDS flag should be set to get this result (see setRequiredData(int)). By default, all flags are set. Format: an array of int[6] elements. If we denote one such int[6] element by 'b' then:

Parameters:
all - is true if all changing bonds should be returned, false if bonds between orphan/widow atoms should be excluded
Returns:
the changing bond data
Since:
JChem 3.2

getChangingAtoms

public int[] getChangingAtoms(boolean all,
                              int side)
Returns the indexes of changing atoms. Changing atoms: atom existing only on the reactant or the product side, atoms having changing bonds, and atoms having changing properties (e.g. charge). The DATA_BONDS flag should be set to include atoms having changing bonds and the DATA_ATOMS flag should be set to include atoms having changing atom properties (see setRequiredData(int)). By default, all flags are set.

Parameters:
all - is true if all changing atoms should be returned, false if orphan/widow atoms with only orphan/widow neighbours should be excluded
side -
Returns:
the changing atom indexes
Since:
JChem 3.2

getReactivity

public static java.lang.String getReactivity(java.lang.String reactivity,
                                             java.lang.String exclude)
Returns reactivity combined with exclude condition. Example:
 reactivity && !exclude

Parameters:
reactivity - is the reactivity rule
exclude - is the exclude rule
Returns:
the combined rectivity rule

getTolerances

public static double[] getTolerances(java.lang.String tolerances)
                              throws ReactionException
Returns double[] created from ";" separated list of real numbers. Empty string in the list is converted to Reactor.DEF_TOLERANCE.

Parameters:
tolerances - is the string: ";" separated list of real numbers
Returns:
the corresponding double[]
Throws:
ReactionException - on format error

setReactivityRule

public void setReactivityRule(java.lang.String rule,
                              Evaluator evaluator)
                       throws ReactionException
Sets the reactivity (acceptance) rule. This is a boolean condition which evaluates to true precisely if the products should be accepted. Evaluation of the reactivity rule precedes the evaluation of the selectivity rule set by setSelectivityRule(String, Evaluator).

Parameters:
rule - is the rule chemical terms string
evaluator - is the evaluator object
Throws:
ReactionException - on parse error
Since:
JChem 2.3

setSelectivityRule

public void setSelectivityRule(java.lang.String rule,
                               Evaluator evaluator)
                        throws ReactionException
Deprecated. Use setSelectivityRule(String, double[], Evaluator) or setSelectivityRule(String, String, Evaluator) and set tolerances parameter to null

Sets the selectivity rule with default tolerance Reactor.DEF_TOLERANCE. This rule is used to sort product sets by decreasing evaluation order, that is, the product set with the largest evaluation result will be returned first by Reactor.react(). The tolerance value is used to filter product sets based on their selectivity compared to the maximal selectivity: a product set is accepted only if the difference between the maximum selectivity and its selectivity is not greater than the specified tolerance. The default tolerance is set such that only values that are approximately equal to the maximum are accepted.

Parameters:
rule - is the rule chemical terms string
evaluator - is the evaluator object
Throws:
ReactionException - on parse error
Since:
JChem 2.3

setSelectivityRule

public void setSelectivityRule(java.lang.String rule,
                               java.lang.String tolerances,
                               Evaluator evaluator)
                        throws ReactionException
Sets the selectivity rule with tolerance. If tolerances parameter is null then default tolerance (Reactor.DEF_TOLERANCE) is used. This rule is used to sort product sets by decreasing evaluation order, that is, the product set with the largest evaluation result will be returned first by Reactor.react(). The tolerance value is used to filter product sets based on their selectivity compared to the maximal selectivity: a product set is accepted only if the difference between the maximum selectivity and its selectivity is not greater than the specified tolerance.

Parameters:
rule - is the rule chemical terms string, items separated by ";"
evaluator - is the evaluator object
tolerances - is the selectivity acceptance tolerance string, items separated by ";". If null then Reactor.DEF_TOLERANCE is used.
Throws:
ReactionException - on parse error
Since:
JChem 2.3

setSelectivityRule

public void setSelectivityRule(java.lang.String rule,
                               double[] tolerances,
                               Evaluator evaluator)
                        throws ReactionException
Sets the selectivity rule with tolerance. If tolerances parameter is null then default tolerance (Reactor.DEF_TOLERANCE) is used. This rule is used to sort product sets by decreasing evaluation order, that is, the product set with the largest evaluation result will be returned first by Reactor.react(). The tolerance value is used to filter product sets based on their selectivity compared to the maximal selectivity: a product set is accepted only if the difference between the maximum selectivity and its selectivity is not greater than the specified tolerance.

Parameters:
rule - is the rule chemical terms string, items separated by ";"
evaluator - is the evaluator object
tolerances - is the selectivity acceptance tolerance array. If null then Reactor.DEF_TOLERANCE is used.
Throws:
ReactionException - on parse error
Since:
JChem 2.3

getID

public java.lang.String getID()
Returns the reaction ID.

Returns:
the reaction ID

setFID

public void setFID(java.lang.String fid)
Deprecated. Not used.

Sets the fragmentation ID.

Parameters:
fid - is the fragmentation ID

getFID

protected java.lang.String getFID()
Deprecated. Not used.

Returns fragmentation ID.

Returns:
fragmentation ID

getReactant

public Molecule getReactant(int i)
Returns the i-th reactant.

Parameters:
i - is the reactant index
Returns:
the i-th reactant

getReactants

protected Molecule[] getReactants()
Returns the reaction reactants.

Returns:
the reaction reactants

getReactantCount

public int getReactantCount()
Returns the number of reactants.

Returns:
the number of reactants

getProduct

protected Molecule getProduct(int i)
Returns the i-th product.

Parameters:
i - is the product index
Returns:
the i-th product

getProducts

protected Molecule[] getProducts()
Returns the reaction products.

Returns:
the reaction products

getProductCount

protected int getProductCount()
Returns the number of products.

Returns:
the number of products

getProductAtomCount

protected int getProductAtomCount()
Returns the number of atoms existing only on the product side.

Returns:
the number of atoms existing only on the product side

getProductAtom

protected MolAtom getProductAtom(int i)
Returns the i-th atom existing only on the product side.

Parameters:
i - is the atom index
Returns:
the i-th atom existing only on the product side

getReactantAtomCount

protected int getReactantAtomCount()
Returns the number of atoms existing only on the reactant side.

Returns:
the number of atoms existing only on the reactant side

getReactantAtom

protected MolAtom getReactantAtom(int i)
Returns the i-th atom existing only on the reactant side.

Parameters:
i - is the atom index
Returns:
the i-th atom existing only on the reactant side

setReaction

public void setReaction(Molecule mol)
                 throws ReactionException
Sets the reaction molecule representing the reaction equation. Reaction has to be mapped in changing style.

Parameters:
mol - is the reaction molecule
Throws:
ReactionException - on error (standardization, mapping, ...)

setReaction

public void setReaction(Molecule mol,
                        boolean fuse)
                 throws ReactionException
Sets the reaction molecule representing the reaction equation. Reaction has to be mapped in changing style.

Parameters:
mol - is the reaction molecule
fuse - is true if reaction reactants / products should be fused to form a 1-reactant 1-product molecule used in Standardizer and Reactor transform mode (see Reactor.setTransform(boolean))
Throws:
ReactionException - on error (standardization, mapping, ...)

setReaction

public void setReaction(Molecule mol,
                        boolean fuse,
                        boolean skipMappingCheck)
                 throws ReactionException
Sets the reaction molecule representing the reaction equation. Reaction has to be mapped in changing style.

Parameters:
mol - is the reaction molecule
fuse - is true if reaction reactants / products should be fused to form a 1-reactant 1-product molecule used in Standardizer and Reactor transform mode (see Reactor.setTransform(boolean))
skipMappingCheck - if true reaction mapping will not be checked
Throws:
ReactionException - on error (standardization, mapping, ...)
Since:
JChem 5.0

getBaseMap

protected int getBaseMap(int map)
Returns the base map corresponding to the given map. This is the map itself for unique maps, the original map in the reaction corresponding to the map otherwise.

Parameters:
map - is the map
Returns:
the base map, -1 for non-existing reaction maps