ChemAxon's concurrent framework is based on the Java 5.0 java.util.concurrent API. Below there are three examples which show code samples using ChemAxon's concurrent framework. The common code is written using a ConcurrentPluginApplication class: it starts a ConcurrentProcessor with a specified InputProducer and WorkUnitFactory. The InputProducer is supposed to produce the plugin inputs: the input molecules and possibly the plugin objects performing the calculation. The WorkUnit objects produced by the WorkUnitFactory are run concurrently by the ConcurrentProcessor and are supposed to execute the plugin calculation (the CalculatorPlugin.run() method). Finally, the results are collected by
ConcurrentPluginApplication.consume(Object result) in the main thread. It is important to process the results in a single thread so that the order of the results will be the same as the order of the input molecules.
Our examples show different ways to provide the inputs and outputs for the concurrent processor. Input molecules are read from
System.in if the molecule file is omitted. The following API is used to do this:
In the following examples we use the test.smiles input file:
The logDPluginApplication is a simple application that shows a concurrent logD calculation. The input is the molecule; the output is the logD value at a given pH (the default pH is
java logDPluginApplication [pH] [molFile]
java pKaPluginApplication [count] [molFile]
consume(Object result)(in the main thread) gets the tautomers from the plugin and writes the tautomer with minimal logD. Finally, it returns the plugin object for reuse to the input producer.
The input is the plugin object together with the molecule, the output is the plugin object. The application writes the tautomer with minimal logD to the output. The number of plugin objects to be generated initially can be specified (
10 if omitted).
java TautomerizationPluginApplication [pluginCount] [molFile]