Class Reactor

java.lang.Object
chemaxon.reaction.Reactor
All Implemented Interfaces:
chemaxon.license.Licensable

@PublicApi public class Reactor extends Object implements chemaxon.license.Licensable
Executes a chemical reaction: creates products from reactants with reaction center data. If the reaction centers have not yet been searched for, uses substructure search to find and (optionally) store them. Provides API to single reaction processing.

See the documentation for details.

An example usage of the API:

 // create Reactor
 Reactor reactor = new Reactor();

 // set the reaction ('rxmol' is the reaction molecule)
 // reaction rules are read from RDF/MRV tags
 reactor.setReaction(rxmol);

 // set the reactants
 reactor.setReactants(reactants);

 // get the results
 Molecule[] products;
 while ((products = reactor.react()) != null) {
     // export result molecules
     for (Molecule product : products) {
      exporter.write(product);
     }
 }
 

Another example with reaction rules and reaction output:

 // create Reactor
 Reactor reactor = new Reactor();

 // set the reaction
 // ('rxmol' is the reaction molecule,
 // 'rid' is the reaction ID
 // 'reactivity' is the reactivity rule,
 // 'selectivity' is the selectivity rule
 // 'tolerances' is the tolerance string)
 reactor.setReaction(rxmol, rid, reactivity, selectivity, tolerances);

 // set Reactor options
 reactor.setResultType(Reactor.REACTION_OUTPUT);
 reactor.setRatio(new int[] { 1, 2 });

 // set the reactants
 reactor.setReactants(reactants);

 // get the results
 Molecule[] result;
 while ((result = reactor.react()) != null) {
     // export result (reaction molecule)
     for (Molecule rxn : result) {
      exporter.write(rxn);
     }
 };
 
Since:
JChem 3.0
See Also:
  • Field Details

    • PRODUCT_OUTPUT

      public static final int PRODUCT_OUTPUT
      Output type: products.
      See Also:
    • REACTION_OUTPUT

      public static final int REACTION_OUTPUT
      Output type: reaction.
      See Also:
    • FUSED_REACTION_OUTPUT

      public static final int FUSED_REACTION_OUTPUT
      Output type: fused reaction output.
      See Also:
    • NO_DUPLICATE_FILTERING

      public static final int NO_DUPLICATE_FILTERING
      No duplicate product list filtering
      See Also:
    • ORDER_SENSITIVE_DUPLICATE_FILTERING

      public static final int ORDER_SENSITIVE_DUPLICATE_FILTERING
      Order sensitive duplicate product list filtering
      See Also:
    • ORDER_INSENSITIVE_DUPLICATE_FILTERING

      public static final int ORDER_INSENSITIVE_DUPLICATE_FILTERING
      Order insensitive duplicate product list filtering
      See Also:
    • MAPPING_STYLE_NONE

      public static final int MAPPING_STYLE_NONE
      Output reaction mapping style: none.
      See Also:
    • MAPPING_STYLE_CHANGING

      public static final int MAPPING_STYLE_CHANGING
      Output reaction mapping style: changing (Chemaxon).
      See Also:
    • MAPPING_STYLE_COMPLETE

      public static final int MAPPING_STYLE_COMPLETE
      Output reaction mapping style: complete.
      See Also:
    • MAPPING_STYLE_MATCHING

      public static final int MAPPING_STYLE_MATCHING
      Output reaction mapping style: matching (Daylight).
      See Also:
    • IGNORE_REACTIVITY

      public static final int IGNORE_REACTIVITY
      No-rule type: ignore reactivity rule.
      See Also:
    • IGNORE_SELECTIVITY

      public static final int IGNORE_SELECTIVITY
      No-rule type: ignore selectivity rule.
      See Also:
    • IGNORE_TOLERANCE

      public static final int IGNORE_TOLERANCE
      No-rule type: ignore selectivity tolerance.
      See Also:
    • DEF_TOLERANCE

      public static final double DEF_TOLERANCE
      The default tolerance.
      See Also:
    • MINOR_PRODUCT_TAG

      public static final String MINOR_PRODUCT_TAG
      See Also:
  • Constructor Details

    • Reactor

      public Reactor()
      Default constructor.
  • Method Details

    • setLicenseEnvironment

      public void setLicenseEnvironment(String env)
      For internal use only.
      Specified by:
      setLicenseEnvironment in interface chemaxon.license.Licensable
      Parameters:
      env - the license environment
    • getReactionID

      public String getReactionID()
      Returns the reaction ID. For internal use only.
      Returns:
      the reaction ID
      Since:
      JChem 2.3
    • setIgnoreRules

      public void setIgnoreRules(int type)
      Ignore reaction rules:
      Parameters:
      type - is the rule type(s) to be ignored (see above)
      Since:
      JChem 2.3
    • setSingle

      public void setSingle(boolean single)
      Process unambiguous reactions only, where each reactant has a single reaction site. If there is more than one reaction site in a reactant then null is returned by react() method. The default is false (non-single mode).
      Parameters:
      single - is true if single mode
      Since:
      JChem 2.3
    • isSingle

      public boolean isSingle()
      Returns true if single mode is set.
      Returns:
      true if single mode
      Since:
      JChem 2.3
      See Also:
    • setShowUnsuccessfulReactions

      public void setShowUnsuccessfulReactions(boolean showUnsuccessfulReactions)
      Sets if unsuccessful reactions (reactions which do not result products) should be shown in output. If true, then unsuccessful reactions will be shown with empty products side in the output. This options works only in case of REACTION_OUTPUT.
      Parameters:
      showUnsuccessfulReactions - if true, then unsuccessful reactions will be shown with empty products side in the output
      Since:
      JChem 5.3.2
      See Also:
    • setDuplicateFiltering

      public void setDuplicateFiltering(int duplicateFilteringMethod)
      Sets duplicate product list filtering. Available filtering methods:

      The default is ORDER_SENSITIVE_DUPLICATE_FILTERING. Note that skipping duplicate product list filtering increases efficiency therefore it is wise to set this parameter to NO_DUPLICATE_FILTERING if duplicates do not matter (e.g. if only the first product list is queried by calling react() only once).

      Parameters:
      duplicateFilteringMethod - is the filtering method
      Since:
      JChem 5.0.1
    • setMaxNumberOfProductSets

      public void setMaxNumberOfProductSets(int pieces)
      Sets the maximum number of products sets to be returned for one reactant set. Set -1 to return all product sets. (default: return all product sets)
      Parameters:
      pieces - is the maximum number of products set to be returned for one reactant set
      Since:
      JChem 5.0
    • setProductIndexes

      public void setProductIndexes(int[] inds)
      Sets the product indexes (1-based) to be returned (default: null - all products).
      Parameters:
      inds - is the 1-based product index array, null for all products
      Since:
      JChem 2.2
    • setResultType

      public void setResultType(int type)
      Sets the result type.

      Available types:

      • PRODUCT_OUTPUT: products molecules are returned. Each call to react() method returns the next product set.
      • REACTION_OUTPUT: reactants -> products reaction is returned. Each call to react() method returns a reaction containing the next product set.
      • FUSED_REACTION_OUTPUT: reactants -> products reaction is returned, with all possible products on the right side. react() method should only be called once; further react() calls will return null.

      In case of REACTION_OUTPUT and FUSED_REACTION_OUTPUT the Molecule[] array returned by react() method will contain the reactants -> products reaction as RxnMolecule.

      Setting the result type restarts processing of the current reactant set - next call to react() will return the first product set.

      Default: PRODUCT_OUTPUT

      Parameters:
      type - is the result type
      Since:
      JChem 5.0
    • setOutputReactionMappingStyle

      public void setOutputReactionMappingStyle(int style)
      Sets the output reaction's mapping style. Available styles: Default: MAPPING_STYLE_NONE
      Parameters:
      style - is the output reaction's mapping style
      Since:
      JChem 3.2
    • setReactionCenterMarkEnabled

      public void setReactionCenterMarkEnabled(boolean enabled)
      Sets whether the bonds of the reaction center on the output should be marked with the following bond marks:

      NOTE: Only works for reaction output! Fused reaction and product output does not support reaction center mark.

      Parameters:
      enabled - whether the reaction center on the output should be marked
      Since:
      5.12
    • setStandardizer

      public void setStandardizer(Standardizer standardizer)
      Sets the reactant standardizer object.
      Parameters:
      standardizer - is the reactant standardizer object
    • getStandardizer

      public Standardizer getStandardizer()
      Returns the reactant standardizer object.
      Returns:
      the reactant standardizer object
    • setIgnoreReactionDefinedStandardizer

      public void setIgnoreReactionDefinedStandardizer(boolean ignore)
      Sets to ignore the standardization defined in the STANDARDIZATION RDF/MRV tag of the reaction molecule.
      Parameters:
      ignore - if true reaction defined standardization is ignored
      Since:
      JChem 3.2
    • setReverse

      public void setReverse(boolean reverse)
      Sets the "reverse" property: true if the reaction is to be processed in reversed direction, that is, the product and reactant sides are swapped. Default: false. Should be called before calling setReactants(Molecule[]).
      Parameters:
      reverse - is true if reversed reaction
    • isReverse

      public boolean isReverse()
      Returns true if the reaction is to be processed in reversed direction.
      Returns:
      whether the reaction is to be processed in reversed direction
    • setSearchOptions

      public void setSearchOptions(String searchOptions)
      Modifies the default search options used by the Reactor engine. Only the specified search options will be modified, others will remain default. Note: modifying the default search options is required in very special cases only. Do not modify the search options, unless you are absolutely aware what you are doing!
      Parameters:
      searchOptions - is the search options string
      Since:
      JChem 5.3
      See Also:
    • setGenerateMinorProducts

      public void setGenerateMinorProducts(boolean generateMinorProducts)
      If set then products lists are not filtered out by the selectivity rule, but they are tagged as minor products. The added SDF property (tag) in minor products is named MINOR_PRODUCT_TAG, its value is "true". In case of product output the generated products are tagged, in case of reaction output the output reaction is tagged. The option has no effect in fused reaction output mode.

      For internal use only.

      Parameters:
      generateMinorProducts - if true then minor products are generated
      Since:
      JChem 5.10
    • isGenerateMinorProducts

      public boolean isGenerateMinorProducts()
      Returns true if minor products are generated.
      Returns:
      true if minor products are generated
      Since:
      JChem 5.10
      See Also:
    • setReactionIDPropertyName

      public void setReactionIDPropertyName(String reactionIDProp)
      Sets the reaction ID property (RDF/MRV tag) name.
      Parameters:
      reactionIDProp - is the reaction ID property name
      Since:
      JChem 3.1.6
    • getReactionIDPropertyName

      public String getReactionIDPropertyName()
      Returns the reaction ID property (RDF/MRV tag) name.
      Returns:
      the reaction ID property (RDF/MRV tag) name
      Since:
      JChem 5.5
    • setComponentIDPropertyNames

      public void setComponentIDPropertyNames(String reactantIDProp, String productIDProp)
      Sets reactant/product ID property (SDF/MRV tag) names.
      Parameters:
      reactantIDProp - is the reactant ID property name
      productIDProp - is the product ID property name
      Since:
      JChem 3.1.6
    • setComponentIDPropertyNames

      public void setComponentIDPropertyNames(String[] reactantIDProps, String[] productIDProps)
      Sets reactant/product ID property (SDF/MRV tag) names.
      Parameters:
      reactantIDProps - is the reactant ID property name array
      productIDProps - is the product ID property name array
      Since:
      JChem 3.1.6
    • setCopyAllReactantProperties

      public void setCopyAllReactantProperties(boolean c)
      Sets to copy all reactant properties to output products/reactions.
      Parameters:
      c - if true then all properties will be copied
      Since:
      JChem 5.5
    • setCopyReactantProperties

      public void setCopyReactantProperties(String[][] reactantPropertiesToCopy)
      Sets the reactant properties which should be copied to output products/reactions.
      • reactantPropertiesToCopy[i][j]: the j-th property name of the i-th reactant
      Parameters:
      reactantPropertiesToCopy - the properties to be copied
      Since:
      JChem 5.5
    • setCopyReactantProperties

      public void setCopyReactantProperties(Map<String,String> patternBasedProperties)
      Sets the reactant properties which should created in output products/reactions, based on a pattern. Contains <target property name, property pattern> pairs, where the property pattern is an instance of ((*#{.})+)* where
      • text may contain any string except "#{" and ".." tokens
      • moleculeID is a string that has a numeric postfix optionally:
        • Non-numeric postfix: The reaction is the selected molecule
        • Numeric postfix: index of a reactant (indexing starts from 1)
        • propertyID a property of the molecule identified by the moleculeID (Case sensitive)
        Examples of pattern:
        • Name list: #{R1.NAME}, #{R2.NAME}, #{R3.NAME}
        • LogP values of reactants: 1st: #{reactant1.LOGP}, 2nd: #{reactant2.LOGP}
        • #{Reaction.ID}(#{mol1.ID}, #{mol2.ID}, #{mol3.ID})
        • #{Reaction.ID}(#{R1.corp_ID}, #{R2.NAME}, #{R3.corp_ID}, #{R4.ID})
      Parameters:
      patternBasedProperties - <targetPropertyName,pattern> pairs
      Since:
      JChem 5.7
    • setCopyReactantProperties

      public void setCopyReactantProperties(String[][] sourceProperties, String[][] targetProperties)
      Sets the reactant properties which should be copied to output products/reactions.
      • sourceProperties[i][j]: the j-th property name of the i-th reactant
      • targetProperties[i][j]: the j-th property name of the i-th product
      Parameters:
      sourceProperties - the properties to be copied
      targetProperties - the target properties
      Since:
      JChem 5.5
    • setRatio

      public void setRatio(int[] ratio)

      Sets the ratio of the reactants. The length of the ratio array should be equal with the number of reactants in the reaction. If there are more than one reactants in the reaction, then one of the reactant ratios should be 1.

      Setting the ratio restarts processing of the current reactant set - next call to react() will return the first product set.

      Parameters:
      ratio - is the ratio array
      Since:
      JChem 5.3
    • setReaction

      public void setReaction(Molecule rxmol) throws ReactionException
      Sets the reaction with reaction rules set in RDF/MRV tags REACTIVITY, EXCLUDE, SELECTIVITY, TOLERANCE. Also sets the reactant standardizer defined in the STANDARDIZATION RDF/MRV tag.
      Parameters:
      rxmol - is the reaction molecule
      Throws:
      ReactionException - on error
      Since:
      JChem 2.3
      See Also:
    • setReaction

      public void setReaction(Molecule rxmol, String rid) throws ReactionException
      Sets the reaction with reaction rules set in RDF/MRV tags REACTIVITY, EXCLUDE, SELECTIVITY, TOLERANCE. Also sets the reactant standardizer defined in the STANDARDIZATION RDF/MRV tag.
      Parameters:
      rxmol - is the reaction molecule
      rid - is the reaction ID
      Throws:
      ReactionException - on error
      Since:
      JChem 5.3
      See Also:
    • setReaction

      public void setReaction(Molecule rxmol, String rid, String reactivity, String selectivity, String tolerances) throws ReactionException
      Sets the reaction and the reaction rules. Rules can be set to null which means that the rule is not set. Selectivity tolerance is set to the default value: DEF_TOLERANCE if not specified in the Tolerance property. Also sets the reactant standardizer defined in the STANDARDIZATION RDF/MRV tag of the reaction molecule.
      Parameters:
      rxmol - is the reaction molecule
      rid - is the reaction ID
      reactivity - is the reactivity rule
      selectivity - is the selectivity rule
      tolerances - is the tolerance string
      Throws:
      ReactionException - on error
      Since:
      JChem 3.1.6
      See Also:
    • setReaction

      public void setReaction(Molecule rxmol, String rid, String reactivity, String selectivity, double[] tolerances) throws ReactionException
      Sets the reaction and the reaction rules. Rules can be set to null which means that the rule is not set. Also sets the reactant standardizer defined in the STANDARDIZATION RDF/MRV tag of the reaction molecule.
      Parameters:
      rxmol - is the reaction molecule
      rid - is the reaction ID
      reactivity - is the reactivity rule
      selectivity - is the selectivity rule
      tolerances - is the selectivity tolerance array (one for each selectivity rule, null for taking the default tolerance DEF_TOLERANCE for each rule)
      Throws:
      ReactionException - on error
      Since:
      JChem 3.1.6
      See Also:
    • getReaction

      public RxnMolecule getReaction()
      Returns the reaction. The returned reaction is the reaction used internally for reaction processing, it can be different from the input reaction (different reaction maps, R-groups, etc).
      Returns:
      the reaction
      Since:
      JChem 5.5
    • setReactionString

      public void setReactionString(String str) throws ReactionException
      Sets the reaction and optionally the reaction rules specified in a string. The reaction is specified in reaction SMARTS format, the reaction rules are preceded by a prefix denoting the rule type:
      • r: denotes the reactivity rule
      • s: denotes the selectivity rule(s) separated by ";"
      • t: denotes the selectivity tolerance(s) separated by ";"
      In the simplest case the string is the reaction SMARTS string itself and no reaction rules are specified. Example:
       [Cl:4][C:3]=O.[#7:2][H:1]>>[#7:2][C:3]=O.[Cl:4][H:1]
       
      Rules can be added with the type prefixes described above, items separated by "..". Example:
       [Cl:4][C:3]=O.[#7:2][H:1]>>[#7:2][C:3]=O.[Cl:4][H:1]..r:charge(ratom(4)) > 1.2..s:tpsa(product(0))..t:0.5
       
      Parameters:
      str - is the reaction configuration string described above
      Throws:
      ReactionException - on configuration error
      Since:
      JChem 2.3
    • setReactionString

      public void setReactionString(String str, String rid) throws ReactionException
      Sets the reaction and optionally the reaction rules specified in a string. The reaction is specified in reaction SMARTS format, the reaction rules are preceded by a prefix denoting the rule type:
      • r: denotes the reactivity rule
      • s: denotes the selectivity rule(s) separated by ";"
      • t: denotes the selectivity tolerance(s) separated by ";"
      In the simplest case the string is the reaction SMARTS string itself and no reaction rules are specified. Example:
       [Cl:4][C:3]=O.[#7:2][H:1]>>[#7:2][C:3]=O.[Cl:4][H:1]
       
      Rules can be added with the type prefixes described above, items separated by "..". Example:
       [Cl:4][C:3]=O.[#7:2][H:1]>>[#7:2][C:3]=O.[Cl:4][H:1]..r:charge(ratom(4)) > 1.2..s:tpsa(product(0))..t:0.5
       
      Parameters:
      str - is the reaction configuration string described above
      rid - is the reaction ID
      Throws:
      ReactionException - on configuration error
      Since:
      JChem 3.1.6
    • getReactantCount

      public int getReactantCount()
      Returns the number of reactants.
      Returns:
      the number of reactants
    • getProductCount

      public int getProductCount()
      Returns the number of products.
      Returns:
      the number of products
    • getReactionReactant

      public Molecule getReactionReactant(int i)
      Returns a reaction reactant.
      Parameters:
      i - is the reactant index
      Returns:
      a reaction reactant
      Since:
      JChem 3.1
    • getReactionProduct

      public Molecule getReactionProduct(int i)
      Returns a reaction product.
      Parameters:
      i - is the reactant index
      Returns:
      a reaction product
      Since:
      JChem 3.1
    • getReactants

      public Molecule[] getReactants()
      Returns the input reactants.
      Returns:
      the input reactants
      Since:
      JChem 5.5
    • restart

      public void restart()
      Restarts the reactor: the following call to react() will return the first product set.
    • setReactants

      public void setReactants(Molecule[] mols) throws ReactionException
      Sets the reactants. The reaction should be set before calling this method.
      Parameters:
      mols - is the reactant array
      Throws:
      ReactionException - if setting the reactants fails
    • react

      public Molecule[] react() throws ReactionException
      Performs the reaction. Returns the next product list, or null if there are no more product lists. Product lists are ordered according to priority if a selectivity rule is specified.

      In single mode, returns only single results, that is, returns null if here are more than one product lists (see setSingle(boolean)).

      The reaction should be set beforehand.

      The reactants should be set beforehand by setReactants(Molecule[]).

      Returns:
      the next product list, or null if there are no more product lists
      Throws:
      ReactionException - on reaction processing error
    • isLicensed

      public boolean isLicensed()
      Specified by:
      isLicensed in interface chemaxon.license.Licensable
    • getReactionMap

      public Map<MolAtom,AtomIdentifier> getReactionMap()
      Gets the mapping for the last performed reaction. For each atoms of the output molecules, that has a map in the input molecules' atoms there is an entry in this map.
      For each entry atom the is an AtomIdentifier containing information on the: The map is filled when the ReactionResultEnumerator.react() method is called.
      NOTE: If the map does not contain an atom of the result as key, the atom is added to the result during the reaction process
      Returns:
      the mapping for the last performed reaction
      Since:
      5.11