@PublicAPI public class Reactor extends java.lang.Object implements chemaxon.license.Licensable, java.io.Serializable
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); } };
ConcurrentReactorProcessor
,
Serialized FormModifier and Type | Field and Description |
---|---|
static double |
DEF_TOLERANCE
The default tolerance.
|
static int |
FUSED_REACTION_OUTPUT
Output type: fused reaction output.
|
static int |
IGNORE_REACTIVITY
No-rule type: ignore reactivity rule.
|
static int |
IGNORE_SELECTIVITY
No-rule type: ignore selectivity rule.
|
static int |
IGNORE_TOLERANCE
No-rule type: ignore selectivity tolerance.
|
static int |
MAPPING_STYLE_CHANGING
Output reaction mapping style: changing (ChemAxon).
|
static int |
MAPPING_STYLE_COMPLETE
Output reaction mapping style: complete.
|
static int |
MAPPING_STYLE_MATCHING
Output reaction mapping style: matching (Daylight).
|
static int |
MAPPING_STYLE_NONE
Output reaction mapping style: none.
|
static java.lang.String |
MINOR_PRODUCT_TAG |
static int |
NO_DUPLICATE_FILTERING
No duplicate product list filtering
|
static int |
ORDER_INSENSITIVE_DUPLICATE_FILTERING
Order insensitive duplicate product list filtering
|
static int |
ORDER_SENSITIVE_DUPLICATE_FILTERING
Order sensitive duplicate product list filtering
|
static int |
PRODUCT_OUTPUT
Output type: products.
|
static int |
REACTION_OUTPUT
Output type: reaction.
|
Constructor and Description |
---|
Reactor()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getProductCount()
Returns the number of products.
|
int |
getReactantCount()
Returns the number of reactants.
|
Molecule[] |
getReactants()
Returns the input reactants.
|
RxnMolecule |
getReaction()
Returns the reaction.
|
java.lang.String |
getReactionID()
Returns the reaction ID.
|
java.lang.String |
getReactionIDPropertyName()
Returns the reaction ID property (RDF/MRV tag) name.
|
java.util.Map<MolAtom,AtomIdentifier> |
getReactionMap()
Gets the mapping for the last performed reaction.
|
Molecule |
getReactionProduct(int i)
Returns a reaction product.
|
Molecule |
getReactionReactant(int i)
Returns a reaction reactant.
|
Standardizer |
getStandardizer()
Returns the reactant standardizer object.
|
boolean |
isGenerateMinorProducts()
Returns
true if minor products are generated. |
boolean |
isLicensed() |
boolean |
isReverse()
Returns
true if the reaction is to be processed in reversed direction. |
boolean |
isSingle()
Returns
true if single mode is set. |
Molecule[] |
react()
Performs the reaction.
|
void |
restart()
Restarts the reactor: the following call to
react()
will return the first product set. |
void |
setComponentIDPropertyNames(java.lang.String[] reactantIDProps,
java.lang.String[] productIDProps)
Sets reactant/product ID property (SDF/MRV tag) names.
|
void |
setComponentIDPropertyNames(java.lang.String reactantIDProp,
java.lang.String productIDProp)
Sets reactant/product ID property (SDF/MRV tag) names.
|
void |
setCopyAllReactantProperties(boolean c)
Sets to copy all reactant properties to output products/reactions.
|
void |
setCopyReactantProperties(java.util.Map<java.lang.String,java.lang.String> patternBasedProperties)
Sets the reactant properties which should created in output
products/reactions, based on a pattern.
|
void |
setCopyReactantProperties(java.lang.String[][] reactantPropertiesToCopy)
Sets the reactant properties which should be copied to output products/reactions.
|
void |
setCopyReactantProperties(java.lang.String[][] sourceProperties,
java.lang.String[][] targetProperties)
Sets the reactant properties which should be copied to output products/reactions.
|
void |
setDuplicateFiltering(int duplicateFilteringMethod)
Sets duplicate product list filtering.
|
void |
setGenerateMinorProducts(boolean generateMinorProducts)
If set then products lists are not filtered out by the selectivity rule,
but they are tagged as minor products.
|
void |
setIgnoreReactionDefinedStandardizer(boolean ignore)
Sets to ignore the standardization defined in the
STANDARDIZATION RDF/MRV tag of the reaction molecule. |
void |
setIgnoreRules(int type)
Ignore reaction rules:
0 : apply both rules (default)
IGNORE_REACTIVITY : ignore reactivity rule
IGNORE_SELECTIVITY : ignore selectivity rule
IGNORE_TOLERANCE : ignore selectivity tolerance
IGNORE_REACTIVITY | IGNORE_SELECTIVITY :
ignore both rules
IGNORE_REACTIVITY | IGNORE_TOLERANCE :
ignore reactivity rule and selectivity tolerance
|
void |
setLicenseEnvironment(java.lang.String env)
For internal use only.
|
void |
setMaxNumberOfProductSets(int pieces)
Sets the maximum number of products sets to be returned for one reactant set.
|
void |
setOutputReactionMappingStyle(int style)
Sets the output reaction's mapping style.
|
void |
setProductIndexes(int[] inds)
Sets the product indexes (1-based) to be returned
(default:
null - all products). |
void |
setRatio(int[] ratio)
Sets the ratio of the reactants.
|
void |
setReactants(Molecule[] mols)
Sets the reactants.
|
void |
setReaction(Molecule rxmol)
Sets the reaction with reaction rules set in RDF/MRV tags
REACTIVITY , EXCLUDE , SELECTIVITY , TOLERANCE . |
void |
setReaction(Molecule rxmol,
java.lang.String rid)
Sets the reaction with reaction rules set in RDF/MRV tags
REACTIVITY , EXCLUDE , SELECTIVITY , TOLERANCE . |
void |
setReaction(Molecule rxmol,
java.lang.String rid,
java.lang.String reactivity,
java.lang.String selectivity,
double[] tolerances)
Sets the reaction and the reaction rules.
|
void |
setReaction(Molecule rxmol,
java.lang.String rid,
java.lang.String reactivity,
java.lang.String selectivity,
java.lang.String tolerances)
Sets the reaction and the reaction rules.
|
void |
setReactionCenterMarkEnabled(boolean enabled)
Sets whether the bonds of the reaction center on the output should be
marked with the following bond marks:
MolBond.RC_MAKE_OR_BREAK for bonds that are created or broken
during the reaction
MolBond.RC_CHANGE for bonds that are changed (type and/or one
ligand change)
|
void |
setReactionIDPropertyName(java.lang.String reactionIDProp)
Sets the reaction ID property (RDF/MRV tag) name.
|
void |
setReactionString(java.lang.String str)
Sets the reaction and optionally the reaction rules
specified in a string.
|
void |
setReactionString(java.lang.String str,
java.lang.String rid)
Sets the reaction and optionally the reaction rules
specified in a string.
|
void |
setResultType(int type)
Sets the result type.
|
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. |
void |
setSearchOptions(java.lang.String searchOptions)
Modifies the default search options used by the Reactor engine.
|
void |
setShowUnsuccessfulReactions(boolean showUnsuccessfulReactions)
Sets if unsuccessful reactions (reactions which do not result products) should be shown in output.
|
void |
setSingle(boolean single)
Process unambiguous reactions only, where each reactant has a single reaction site.
|
void |
setStandardizer(Standardizer standardizer)
Sets the reactant standardizer object.
|
public static final int PRODUCT_OUTPUT
public static final int REACTION_OUTPUT
public static final int FUSED_REACTION_OUTPUT
public static final int NO_DUPLICATE_FILTERING
public static final int ORDER_SENSITIVE_DUPLICATE_FILTERING
public static final int ORDER_INSENSITIVE_DUPLICATE_FILTERING
public static final int MAPPING_STYLE_NONE
public static final int MAPPING_STYLE_CHANGING
public static final int MAPPING_STYLE_COMPLETE
public static final int MAPPING_STYLE_MATCHING
public static final int IGNORE_REACTIVITY
public static final int IGNORE_SELECTIVITY
public static final int IGNORE_TOLERANCE
public static final double DEF_TOLERANCE
public static final java.lang.String MINOR_PRODUCT_TAG
public void setLicenseEnvironment(java.lang.String env)
setLicenseEnvironment
in interface chemaxon.license.Licensable
env
- the license environmentpublic java.lang.String getReactionID()
public void setIgnoreRules(int type)
0
: apply both rules (default)
IGNORE_REACTIVITY
: ignore reactivity rule
IGNORE_SELECTIVITY
: ignore selectivity rule
IGNORE_TOLERANCE
: ignore selectivity tolerance
IGNORE_REACTIVITY
| IGNORE_SELECTIVITY
:
ignore both rules
IGNORE_REACTIVITY
| IGNORE_TOLERANCE
:
ignore reactivity rule and selectivity tolerance
type
- is the rule type(s) to be ignored (see above)public void setSingle(boolean single)
null
is returned
by react()
method.
The default is false
(non-single mode).single
- is true
if single modepublic boolean isSingle()
true
if single mode is set.true
if single modesetSingle(boolean)
public void setShowUnsuccessfulReactions(boolean showUnsuccessfulReactions)
REACTION_OUTPUT
.showUnsuccessfulReactions
- if true, then unsuccessful reactions will be shown with empty products
side in the outputsetResultType(int)
public void setDuplicateFiltering(int duplicateFilteringMethod)
NO_DUPLICATE_FILTERING
: no duplicate filtering
ORDER_SENSITIVE_DUPLICATE_FILTERING
: order sensitive duplicate filtering
ORDER_INSENSITIVE_DUPLICATE_FILTERING
: order insensitive duplicate filtering
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).
duplicateFilteringMethod
- is the filtering methodpublic void setMaxNumberOfProductSets(int pieces)
-1
to return all product sets.
(default: return all product sets)pieces
- is the maximum number of products set to be returned for one reactant setpublic void setProductIndexes(int[] inds)
null
- all products).inds
- is the 1-based product index array, null
for all productspublic void setResultType(int 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
type
- is the result typepublic void setOutputReactionMappingStyle(int style)
MAPPING_STYLE_NONE
style
- is the output reaction's mapping stylepublic void setReactionCenterMarkEnabled(boolean enabled)
MolBond.RC_MAKE_OR_BREAK
for bonds that are created or broken
during the reactionMolBond.RC_CHANGE
for bonds that are changed (type and/or one
ligand change)NOTE: Only works for reaction output! Fused reaction and product output does not support reaction center mark.
enabled
- whether the reaction center on the output should be markedpublic void setStandardizer(Standardizer standardizer)
standardizer
- is the reactant standardizer objectpublic Standardizer getStandardizer()
public void setIgnoreReactionDefinedStandardizer(boolean ignore)
STANDARDIZATION
RDF/MRV tag of the reaction molecule.ignore
- if true
reaction defined standardization is ignoredpublic void setReverse(boolean reverse)
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[])
.reverse
- is true if reversed reactionpublic boolean isReverse()
true
if the reaction is to be processed in reversed direction.public void setSearchOptions(java.lang.String searchOptions)
searchOptions
- is the search options stringSearchOptions.setOptions(String)
public void setGenerateMinorProducts(boolean generateMinorProducts)
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.
generateMinorProducts
- if true
then minor products are
generatedpublic boolean isGenerateMinorProducts()
true
if minor products are generated.true
if minor products are generatedsetGenerateMinorProducts(boolean)
public void setReactionIDPropertyName(java.lang.String reactionIDProp)
reactionIDProp
- is the reaction ID property namepublic java.lang.String getReactionIDPropertyName()
public void setComponentIDPropertyNames(java.lang.String reactantIDProp, java.lang.String productIDProp)
reactantIDProp
- is the reactant ID property nameproductIDProp
- is the product ID property namepublic void setComponentIDPropertyNames(java.lang.String[] reactantIDProps, java.lang.String[] productIDProps)
reactantIDProps
- is the reactant ID property name arrayproductIDProps
- is the product ID property name arraypublic void setCopyAllReactantProperties(boolean c)
c
- if true
then all properties will be copiedpublic void setCopyReactantProperties(java.lang.String[][] reactantPropertiesToCopy)
reactantPropertiesToCopy
- the properties to be copiedpublic void setCopyReactantProperties(java.util.Map<java.lang.String,java.lang.String> patternBasedProperties)
patternBasedProperties
- public void setCopyReactantProperties(java.lang.String[][] sourceProperties, java.lang.String[][] targetProperties)
sourceProperties
- the properties to be copiedtargetProperties
- the target propertiespublic 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.
ratio
- is the ratio arraypublic void setReaction(Molecule rxmol) throws ReactionException
REACTIVITY
, EXCLUDE
, SELECTIVITY
, TOLERANCE
.
Also sets the reactant standardizer defined in the STANDARDIZATION
RDF/MRV tag.rxmol
- is the reaction moleculeReactionException
- on errorsetIgnoreReactionDefinedStandardizer(boolean)
public void setReaction(Molecule rxmol, java.lang.String rid) throws ReactionException
REACTIVITY
, EXCLUDE
, SELECTIVITY
, TOLERANCE
.
Also sets the reactant standardizer defined in the STANDARDIZATION
RDF/MRV tag.rxmol
- is the reaction moleculerid
- is the reaction IDReactionException
- on errorsetIgnoreReactionDefinedStandardizer(boolean)
public void setReaction(Molecule rxmol, java.lang.String rid, java.lang.String reactivity, java.lang.String selectivity, java.lang.String tolerances) throws ReactionException
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.rxmol
- is the reaction moleculerid
- is the reaction IDreactivity
- is the reactivity ruleselectivity
- is the selectivity ruletolerances
- is the tolerance stringReactionException
- on errorsetIgnoreReactionDefinedStandardizer(boolean)
public void setReaction(Molecule rxmol, java.lang.String rid, java.lang.String reactivity, java.lang.String selectivity, double[] tolerances) throws ReactionException
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.rxmol
- is the reaction moleculerid
- is the reaction IDreactivity
- is the reactivity ruleselectivity
- is the selectivity ruletolerances
- is the selectivity tolerance array (one for each selectivity rule,
null
for taking the default tolerance DEF_TOLERANCE
for each rule)ReactionException
- on errorsetIgnoreReactionDefinedStandardizer(boolean)
public RxnMolecule getReaction()
public void setReactionString(java.lang.String str) throws ReactionException
r:
denotes the reactivity rule
s:
denotes the selectivity rule(s) separated by ";"
t:
denotes the selectivity tolerance(s) separated by ";"
[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
str
- is the reaction configuration string described aboveReactionException
- on configuration errorpublic void setReactionString(java.lang.String str, java.lang.String rid) throws ReactionException
r:
denotes the reactivity rule
s:
denotes the selectivity rule(s) separated by ";"
t:
denotes the selectivity tolerance(s) separated by ";"
[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
str
- is the reaction configuration string described aboverid
- is the reaction IDReactionException
- on configuration errorpublic int getReactantCount()
public int getProductCount()
public Molecule getReactionReactant(int i)
i
- is the reactant indexpublic Molecule getReactionProduct(int i)
i
- is the reactant indexpublic Molecule[] getReactants()
public void restart()
react()
will return the first product set.public void setReactants(Molecule[] mols) throws ReactionException
mols
- is the reactant arrayReactionException
- if setting the reactants failspublic Molecule[] react() throws ReactionException
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[])
.
ReactionException
- on reaction processing errorpublic boolean isLicensed()
isLicensed
in interface chemaxon.license.Licensable
public java.util.Map<MolAtom,AtomIdentifier> getReactionMap()
AtomIdentifier
containing
information on the:
AtomIdentifier.getMoleculeIndex()
, meaninig
the index of the molecule in the provided reactansAtomIdentifier.getAtomIndex()
, meaninig the index
of atom in the origin moleculeAtomIdentifier.getReactionSchemaMap()
, meaninig the map identifier of atom in the reaction mapReactionPerformer.react()
method is
called.