Package com.chemaxon.calculations.cli
Class CalculatorPluginOutput<P extends CalculatorPlugin>
java.lang.Object
chemaxon.marvin.plugin.CalculatorPluginService<P>
com.chemaxon.calculations.cli.CalculatorPluginOutput<P>
- All Implemented Interfaces:
com.chemaxon.calculations.cli.CalculatorResultAccess
- Direct Known Subclasses:
CalculatorPluginOutput
@PublicAPI
public class CalculatorPluginOutput<P extends CalculatorPlugin>
extends CalculatorPluginService<P>
implements com.chemaxon.calculations.cli.CalculatorResultAccess
Class providing plugin output in table form.
The default implementation provides the following output:
where
id | <type1> | <type2> | <type3> | ... |
<id1> | <result11> | <result12> | <result13> | ... |
<id2> | <result21> | <result22> | <result23> | ... |
... | ... | ... | ... | ... |
type1
, type2
, ... are the result types,
id1
, id2
, ... are the molecule ID-s fetched from the given ID tag of the
input SDF file or molecule indices if no such tag is given,
the resultij
is the result string for the i-th molecule and the j-th result type.
Other output formats can be implemented by subclassing this class and returning the class name in
the plugin-specific implementation of chemaxon.plugin.CalculatorPlugin.getOutputClassName().- Since:
- Marvin 3.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Constructor that sets plugin. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the output.void
close
(int opts) Closes the output.final com.chemaxon.calculations.cli.CalculatorPluginCachedResults
getCachedResults
(Molecule target, boolean stringResult) Returns cached results, separated from the plugin object, so that no further enqueries needed to the plugin to get the result.Returns the table header.final P
Returns the calculator plugin object.Returns the plugin parameter table (this should be set in the plugin).Returns the calculation remark.Returns the result string for the given molecule.int
Returns the domain for the first result type.final String
Returns the plugin calculation error message, error or warning.getResultMolecule
(Molecule target) Returns the decorated result molecule for the given target molecule.Molecule[]
getResultMolecules
(Molecule target) Returns the result molecules for the given target molecule.protected String
getResults
(Object type) Returns result items for the given result type.double
getSpecResult
(Molecule target, String arg) Returns a specific plugin result corresponding to the given molecule and argument string.final Throwable
Returns the throwable object.boolean
Returnstrue
if molecule output.boolean
isOK()
Returnstrue
if the calculation has run without error.boolean
Returnstrue
if stream output.void
setOutputParameters
(Object[] types) Prepares the output based on the result type string.void
Sets the output stream.void
setParameters
(Properties params) Sets the parameter table.final void
setPlugin
(CalculatorPlugin plugin) Deprecated.final void
setPluginChecked
(P plugin) Sets the calculator plugin object.void
setSeparator
(String separator) Sets the separator string.final void
setThrowable
(Throwable throwable) Sets the throwable object.
-
Field Details
-
plugin
The CalculatorPlugin object. -
params
The plugin parameter table. -
separator
The separator string separating the results for different result types.
-
-
Constructor Details
-
CalculatorPluginOutput
public CalculatorPluginOutput()Default constructor. -
CalculatorPluginOutput
Constructor that sets plugin.- Parameters:
plugin
- is the plugin
-
-
Method Details
-
setPlugin
Deprecated.usesetPluginChecked(CalculatorPlugin)
insteadSets the calculator plugin object.- Parameters:
plugin
- is the CalculatorPlugin object
-
setPluginChecked
Sets the calculator plugin object.- Parameters:
plugin
- is the CalculatorPlugin object
-
getPlugin
Description copied from class:CalculatorPluginService
Returns the calculator plugin object.- Specified by:
getPlugin
in classCalculatorPluginService<P extends CalculatorPlugin>
- Returns:
- the calculator plugin object
-
setThrowable
Sets the throwable object.- Parameters:
throwable
- is the CalculatorPlugin object
-
getThrowable
Returns the throwable object.- Specified by:
getThrowable
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Returns:
- the throwable plugin object
-
setSeparator
Sets the separator string.- Parameters:
separator
- is the separator string
-
setParameters
Sets the parameter table.- Parameters:
params
- is the parameter table- Throws:
PluginException
- on error
-
getPluginParameters
Returns the plugin parameter table (this should be set in the plugin). The default implementation returns the given parameter table itself.- Returns:
- the original parameter table if it is the same, a new table with the plugin params otherwise
- Throws:
PluginException
- on error
-
setOutputParameters
Prepares the output based on the result type string. The default implementation does nothing.- Parameters:
types
- the result types- Throws:
PluginException
- on error
-
isMolecular
public boolean isMolecular()Returnstrue
if molecule output. The default implementation returnsfalse
.- Returns:
true
if molecule output
-
isStreamOutput
public boolean isStreamOutput()Returnstrue
if stream output. The default implementation returnsfalse
.- Returns:
true
if stream output
-
setOutputStream
Sets the output stream. Used for molecule output. The default implementation does nothing.- Parameters:
os
- the output stream- Throws:
IOException
-
close
Closes the output. The default implementation callsclose(int)
withMolExporter.C_CLOSE_STREAM
parameter.- Throws:
IOException
-
close
Closes the output. The default implementation does nothing.- Parameters:
opts
- closing options,MolExporter.C_CLOSE_STREAM
orMolExporter.C_FLUSH_STREAM
- Throws:
IOException
- Since:
- Marvin 5.1.1
-
getCachedResults
public final com.chemaxon.calculations.cli.CalculatorPluginCachedResults getCachedResults(Molecule target, boolean stringResult) throws PluginException Returns cached results, separated from the plugin object, so that no further enqueries needed to the plugin to get the result.- Parameters:
target
- the target moleculestringResult
- istrue
if string result is needed,false
if decorated molecule is needed- Returns:
- the cached results
- Throws:
PluginException
- Since:
- Marvin 5.2
-
getResultMessage
Returns the plugin calculation error message, error or warning.- Specified by:
getResultMessage
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Returns:
- the plugin calculation error message
-
getRemark
Returns the calculation remark.- Specified by:
getRemark
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Returns:
- the calculation remark
-
isOK
public boolean isOK()Returnstrue
if the calculation has run without error.- Specified by:
isOK
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Returns:
true
if the calculation has run without error
-
getHeader
Returns the table header. The default implementation returns "id" and the result types.- Specified by:
getHeader
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Returns:
- the table header
-
getResult
Returns the result string for the given molecule. The default implementation returns the result strings corresponding to the result types.- Specified by:
getResult
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Parameters:
target
- is the target molecule- Returns:
- the result row
- Throws:
PluginException
- on error
-
getResults
Returns result items for the given result type.- Parameters:
type
- is the result type- Returns:
- result items separated by ';'
- Throws:
PluginException
- on error
-
getResultMolecule
Returns the decorated result molecule for the given target molecule. Used in case of MRV output (-M, --mrv-output).- Specified by:
getResultMolecule
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Parameters:
target
- is the target molecule- Returns:
- the result molecule
- Throws:
PluginException
- on error
-
getResultMolecules
Returns the result molecules for the given target molecule. The default implementation returnsnull
.- Specified by:
getResultMolecules
in interfacecom.chemaxon.calculations.cli.CalculatorResultAccess
- Parameters:
target
- is the target molecules- Returns:
- the result molecules
- Throws:
PluginException
- on error
-
getResultDomain
public int getResultDomain()Returns the domain for the first result type.- Returns:
- the domain for the first result type:
CalculatorPlugin.ATOM
,CalculatorPlugin.MOLECULE
orCalculatorPlugin.MOLECULES
-
getSpecResult
Returns a specific plugin result corresponding to the given molecule and argument string. The default implementation returns the result value returned byCalculatorPlugin.getResult(int index)
(converted todouble
) with index given in the argument string: the argument string format is<result index>
.- Parameters:
target
- is the target moleculearg
- is the argument string- Returns:
- the queried plugin result
- Throws:
PluginException
- in case of plugin calculation error
-
setPluginChecked(CalculatorPlugin)
instead