chemaxon.reaction
Class ConcurrentReactorProcessor

java.lang.Object
  extended by chemaxon.reaction.ConcurrentReactorProcessor

public class ConcurrentReactorProcessor
extends java.lang.Object

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 command line interface and API to concurrent reaction processing.

See the documentation for details.

An example usage of the API:

 MolExporter exporter = new MolExporter(System.out, "smiles");
 Molecule rxnmol = new MolImporter("reaction.rxn").read();
 MolImporter[] importers = new MolImporter[] { new MolImporter("reactants1.smiles"), new MolImporter("reactants2.smiles") };

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

 // set reactor properties
 reactor.setIgnoreRules(Reactor.IGNORE_REACTIVITY | Reactor.IGNORE_SELECTIVITY);

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

 // create ConcurrentReactorProcessor
 ConcurrentReactorProcessor crp = new ConcurrentReactorProcessor();

 // set the reactor for ConcurrentReactorProcessor
 crp.setReactor(reactor);

 // set the reactant iterators and the processing mode for ConcurrentReactorProcessor
 crp.setReactantIterators(MoleculeIteratorFactory.getMoleculeIterators(importers), ConcurrentReactorProcessor.MODE_COMBINATORIAL);

 // react the reactants and export the output (reactions are performed in concurrent mode)
 Molecule[] products;
 while ((products = crp.react()) != null) {
     for (Molecule product : products) {
         exporter.write(product);
     }
 }
 

Since:
JChem 5.2
Version:
JChem 5.5, 03/01/2011
Author:
Zsolt Mohacsi

Field Summary
static int MODE_COMBINATORIAL
          Mode constant: combinatorial mode.
static int MODE_SEQUENTIAL
          Mode constant: sequential mode.
 
Constructor Summary
ConcurrentReactorProcessor()
           
 
Method Summary
 double getProgress()
          Estimates the progress.
 Molecule[] getReactants()
          Returns the input reactants of the last processed reaction.
 void initialize()
          For internal use only.
static void main(java.lang.String[] args)
          Command line entry point.
 Molecule[] react()
          Generates the product list(s) for all reactant sets.
 java.util.List<Molecule[]> reactNext()
          Reacts the next reactant set and returns all product sets in a list.
 void setReactantIterators(MoleculeIterator[] reactantIterators, int mode)
          Sets the reactant iterators.
 void setReactantIterators(MoleculeIterator[] reactantIterators, int mode, java.lang.String cacheFormat, double reservedMemorySize, boolean ignoreError)
          Sets the reactant iterators.
 void setReactantSetEnumerator(ReactantSetEnumeration e)
          Sets the reactant set enumerator.
 void setReactor(Reactor reactor)
          Sets the Reactor object that will be used for reaction processing.
 void setWorkerThreadCount(int workerThreadCount)
          Sets the number of worker threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_SEQUENTIAL

public static final int MODE_SEQUENTIAL
Mode constant: sequential mode.

See Also:
Constant Field Values

MODE_COMBINATORIAL

public static final int MODE_COMBINATORIAL
Mode constant: combinatorial mode.

See Also:
Constant Field Values
Constructor Detail

ConcurrentReactorProcessor

public ConcurrentReactorProcessor()
Method Detail

setReactor

public void setReactor(Reactor reactor)
Sets the Reactor object that will be used for reaction processing.

Parameters:
reactor - is the reactor object

setReactantIterators

public void setReactantIterators(MoleculeIterator[] reactantIterators,
                                 int mode)
                          throws ReactionException,
                                 java.io.IOException
Sets the reactant iterators. Input reactants are read from reactant iterators, and enumerated in sequential or combinatorial mode, as set by the mode parameter.

Parameters:
reactantIterators - is the MoleculeIterator array from which the input molecules are read
mode - is the enumeration mode: MODE_SEQUENTIAL or MODE_COMBINATORIAL
Throws:
ReactionException - if read error occurred
java.io.IOException - in case of I/O error

setReactantIterators

public void setReactantIterators(MoleculeIterator[] reactantIterators,
                                 int mode,
                                 java.lang.String cacheFormat,
                                 double reservedMemorySize,
                                 boolean ignoreError)
                          throws ReactionException,
                                 java.io.IOException
Sets the reactant iterators. Input reactants are read from reactant iterators, and enumerated in sequential or combinatorial mode, as set by the mode parameter.

Parameters:
reactantIterators - is the MoleculeIterator array from which the input molecules are read
mode - is the enumeration mode: MODE_SEQUENTIAL or MODE_COMBINATORIAL
cacheFormat - the format for storing molecules in cache
reservedMemorySize - the memory size in MB that should be reserved
ignoreError - is true if import errors should be ignored
Throws:
ReactionException - if read error occurred
java.io.IOException - in case of I/O error

setReactantSetEnumerator

public void setReactantSetEnumerator(ReactantSetEnumeration e)
Sets the reactant set enumerator. The reactant set enumerator enumerates the input reactants. The Molecule[] returned be ReactantSetEnumeration.next() will be used as input reactant array for Reactor.

Parameters:
e - is the reactant enumerator which enumerates the input reactants
See Also:
Reactor.setReactants(Molecule[])

initialize

public void initialize()
                throws ReactionException
For internal use only. Initialization is required only in very special cases.

Throws:
ReactionException - on reaction processing error
Since:
JChem 5.2.2.

react

public Molecule[] react()
                 throws ReactionException
Generates the product list(s) for all reactant sets. Calls the Reactor.react() method for all reactant sets and returns the next product list, or null if there are no more product lists.

The reactor and the reactant iterators or the reactant set enumerator should be set beforehand.

Returns:
the next product list, or null if there are no more product lists
Throws:
ReactionException - on reaction processing error
See Also:
getReactants()

reactNext

public java.util.List<Molecule[]> reactNext()
                                     throws ReactionException
Reacts the next reactant set and returns all product sets in a list. Reactant sets which does not generate products are skipped. null is returned if there are no more reactant sets to process.

Returns:
all product sets in a list for the next reactant set
Throws:
ReactionException - on reaction processing error
Since:
JChem 5.5
See Also:
getReactants()

getReactants

public Molecule[] getReactants()
Returns the input reactants of the last processed reaction. Should be called after react() or reactNext().

Returns:
the input reactants of the last processed reaction
Since:
JChem 5.5

setWorkerThreadCount

public void setWorkerThreadCount(int workerThreadCount)
Sets the number of worker threads. (default: 0)

Parameters:
workerThreadCount - number of worker threads

getProgress

public double getProgress()
Estimates the progress. Returns a number between 0 and 1, or returns -1. 0: none of the input molecules are processed, 1: all of the input molecules are processed, -1: information about progress can not be provided.

Returns:
a number that indicates the progress

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Command line entry point.

Parameters:
args - is the command line argument array
Throws:
java.lang.Exception - in case of error