Package chemaxon.standardizer
Class ConcurrentStandardizerProcessor
- java.lang.Object
-
- chemaxon.standardizer.ConcurrentStandardizerProcessor
-
@PublicAPI public class ConcurrentStandardizerProcessor extends Object
Performs standardization of molecules in concurrent mode. It requires aStandardizer
object, which is used for performing the standardizations, and aMoleculeIterator
, for providing input molecules.
This class can be used from command-line or from the API.
See also the Standardizer documentation:API usage example:
MolExporter exporter = new MolExporter(System.out, "sdf"); MolImporter importer = new MolImporter("mols.sdf"); // create Standardizer with XML configuration file Standardizer standardizer = new Standardizer(new File("config.xml")); // create a ConcurrentStandardizerProcessor ConcurrentStandardizerProcessor csp = new ConcurrentStandardizerProcessor(); // set the standardizer and the molecule iterator for ConcurrentStandardizerProcessor csp.setStandardizer(standardizer); csp.setMoleculeIterator(importer.getMoleculeIterator()); Molecule mol; // standardize the molecules and export the output (standardization is performed in concurrent mode) while ((mol = csp.standardize()) != null) { exporter.write(mol); } importer.close(); exporter.close();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ConcurrentStandardizerProcessor.MolTransformer
Molecule transformer.
-
Field Summary
Fields Modifier and Type Field Description static ConcurrentStandardizerProcessor.MolTransformer
TRANSFORMER_SET_DIM_0
Transformer: sets the molecule dimension to 0.
-
Constructor Summary
Constructors Constructor Description ConcurrentStandardizerProcessor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]
getAppliedTaskIDs()
Returns the IDs of tasks applied to the last input molecule.int[]
getAppliedTaskIndexes()
Returns the indexes of tasks applied to the last input molecule.Molecule
getInputMolecule()
Returns the input molecule (the molecule before standardization).double
getProgress()
Estimates the progress.static void
main(String[] args)
Command line entry point.void
setMoleculeIterator(MoleculeIterator iterator)
Sets the molecule iterator.void
setPreprocessor(ConcurrentStandardizerProcessor.MolTransformer tr)
Sets the preprocessor.void
setStandardizer(Standardizer standardizer)
Sets the standardizer that will be used for performing standardizations.void
setStoreAppliedTaskData(boolean store)
If set, then applied task data is stored and can be retrieved with methodsgetAppliedTaskIDs()
,getAppliedTaskIndexes()
,getInputMolecule()
.void
setWorkerThreadCount(int workerThreadCount)
Sets the number of worker threads.Molecule
standardize()
Performs the standardization of the next input molecule, and returns the standardized molecule.
-
-
-
Field Detail
-
TRANSFORMER_SET_DIM_0
public static final ConcurrentStandardizerProcessor.MolTransformer TRANSFORMER_SET_DIM_0
Transformer: sets the molecule dimension to 0.
-
-
Method Detail
-
setStandardizer
public void setStandardizer(Standardizer standardizer)
Sets the standardizer that will be used for performing standardizations.- Parameters:
standardizer
- the standardizer
-
setMoleculeIterator
public void setMoleculeIterator(MoleculeIterator iterator)
Sets the molecule iterator. The molecule iterator provides input molecules.- Parameters:
iterator
- the molecule iterator- See Also:
MoleculeIteratorFactory
-
setWorkerThreadCount
public void setWorkerThreadCount(int workerThreadCount)
Sets the number of worker threads.0
: worker thread count = number of available CPU cores
0
)- Parameters:
workerThreadCount
- number of worker threads
-
setPreprocessor
public void setPreprocessor(ConcurrentStandardizerProcessor.MolTransformer tr)
Sets the preprocessor. Preprocessor transforms the input molecule. Preprocessing is performed before standardization. For internal use only.- Parameters:
tr
- the preprocessor- Since:
- JChem 5.3
-
standardize
public Molecule standardize()
Performs the standardization of the next input molecule, and returns the standardized molecule. The input molecule is transformed and returned, no new molecule object is created. If the input molecule is a reaction then each reactant/product is standardized.- Returns:
- the input molecule, standardized;
null
if there are no more input molecules - Throws:
IllegalArgumentException
- if standardizer or molecule iterator is not setRuntimeException
- if an error occurred during standardization and in the case of concurrent processing errorchemaxon.license.LicenseException
- if there is no valid license
-
getProgress
public double getProgress()
Estimates the progress. Returns a number between0
and1
, or returns-1
.0
: none of the input molecules are standardized,1
: all of the input molecules are standardized,-1
: information about progress can not be provided.- Returns:
- a number that indicates the progress
-
setStoreAppliedTaskData
public void setStoreAppliedTaskData(boolean store)
If set, then applied task data is stored and can be retrieved with methodsgetAppliedTaskIDs()
,getAppliedTaskIndexes()
,getInputMolecule()
. Otherwise the listed methods throwNullPointerException
.- Parameters:
store
- iftrue
then applied task data is stored- See Also:
getAppliedTaskIndexes()
,getAppliedTaskIDs()
,getInputMolecule()
-
getInputMolecule
public Molecule getInputMolecule()
Returns the input molecule (the molecule before standardization).- Returns:
- the input molecule
- Throws:
NullPointerException
- ifsetStoreAppliedTaskData(boolean)
is not set- See Also:
setStoreAppliedTaskData(boolean)
-
getAppliedTaskIndexes
public int[] getAppliedTaskIndexes()
Returns the indexes of tasks applied to the last input molecule. Indexing is 0-based, with the largest index which equals to the number of tasks meaning the final clean action.- Returns:
- the indexes of tasks applied to the last input molecule
- Throws:
NullPointerException
- ifsetStoreAppliedTaskData(boolean)
is not set- See Also:
setStoreAppliedTaskData(boolean)
-
getAppliedTaskIDs
public String[] getAppliedTaskIDs()
Returns the IDs of tasks applied to the last input molecule. The IDStandardizer.FINAL_CLEAN_ID
corresponds to the final clean action.- Returns:
- the IDs of tasks applied to the last input molecule
- Throws:
NullPointerException
- ifsetStoreAppliedTaskData(boolean)
is not set- See Also:
setStoreAppliedTaskData(boolean)
-
-