chemaxon.marvin.calculations
Class PredictorPlugin

java.lang.Object
  extended by chemaxon.marvin.plugin.CalculatorPlugin
      extended by chemaxon.marvin.calculations.PredictorPlugin
All Implemented Interfaces:
chemaxon.license.Licensable

public class PredictorPlugin
extends CalculatorPlugin

Plugin class for running previously trained predictions on molecules.

API usage example:

    // create plugin
    PredictorPlugin plugin = new PredictorPlugin();

    // set the prediction
    try {
        plugin.setPrediction("pampa");
    } catch (PluginException e) {
        System.err.println("Invalid prediction id, or parameter file for prediction cannot be loaded.");
        // ...
    }

    // for each input molecule run the calculation and display the results
    MolImporter importer = new MolImporter("mols.sdf");
    Molecule mol = null;
    int count = 0;
    while ((mol = importer.read()) != null) {

        // set the input molecule
        plugin.setMolecule(mol);

        // run the calculation
        plugin.run();

        // get the result
        double predictedValue = plugin.getPredictedValue(); 

        // print '[mol number]: predicted value'
        System.out.println("["+(++count)+"]: "+predictedValue);
    }  
    importer.close();
 /* 

For concurrent plugin example applications using ChemAxon's concurrent framework, refer to the Concurrent plugin examples.

Since:
Marvin 5.4
Author:
Zsolt Mohacsi

Field Summary
 
Fields inherited from class chemaxon.marvin.plugin.CalculatorPlugin
ATOM, BLUE, CALCRGB_OFF, COVALENT_HYDRATION_ERROR_REMARK, CRITICAL_ERROR_MSG, EPSILON, INCORRECT_AROMATIC_NITROGEN_REMARK, INSTABLE_TAUTOMERIC_FORM_REMARK, licenseEnvironment, MOLECULE, MOLECULES, NAN, PLUGIN_CLASS_KEY, PLUGIN_DIR, RED
 
Constructor Summary
PredictorPlugin()
           
 
Method Summary
 java.lang.String getErrorMessage()
          Returns the calculation error information message if CalculatorPlugin.run() returned false (calculation error).
 double getPredictedValue()
          Returns the predicted value.
 java.lang.String getProductName()
          Returns the product identifier of the plugin as given by LicenseManager.
 java.lang.Object getResult(java.lang.Object type, int index)
          Returns the result item for the specified type and index.
 java.lang.Object getResult(java.lang.Object type, java.lang.String arg)
          Returns the result item for the specified argument string.
 java.lang.String getResultAsString(java.lang.Object type, int index, java.lang.Object result)
          Returns the specified result in String format.
 Molecule getResultMolecule()
          Returns the result molecule for display.
 java.lang.Object[] getResultTypes()
          Returns the result types.
 double getStandardError()
           
static java.lang.String[] getTrainingIds()
          Returns the id's of available predictions.
 boolean needError()
           
 boolean run()
          Runs the tool.
protected  void setInputMolecule(Molecule mol)
          Sets the input molecule.
 void setParameters(java.util.Properties params)
          Sets the input parameters for the plugin.
 void setTraining(java.lang.String trainingId)
          Sets the prediction.
 void standardize(Molecule mol)
          Standardizes the molecule by performing the transformations necessary to run the plugin (aromatize, dehydrogenize, bring nitro groups to common form, ...).
 
Methods inherited from class chemaxon.marvin.plugin.CalculatorPlugin
canRepeat, checkLicense, checkMolecule, checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, createModifiedInputMolecule, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getCalcMolecule, getDisplayMolecule, getDocument, getDoublePrecision, getInputMolDim, getMainMolecule, getpH, getPluginResource, getQueryMoleculeErrorMessage, getRemark, getResult, getResult, getResultAsRGB, getResultAsRGB, getResultAsString, getResultCount, getResultCount, getResultDomain, getResultDomain, getResultMessage, getResultMolecules, getResultsAsRGB, getResultsAsRGB, getResultsAsString, getResultsAsString, getResultSource, getTypeString, getWarningMessage, handlesMultiFragmentMolecules, isInputMoleculeAromatized, isLicensed, isMsCalc, isMultiThreadedRunEnabled, isNegligibleResult, isOK, isRgrouped, loadClass, readAttribute, removeWhitespace, setDoublePrecision, setDoublePrecision, setDoublePrecision, setLicenseEnvironment, setMolecule, setMolecule, setMolecule, setProgressMonitor, standardizeIonicGroups, standardizeNeutralGroups
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PredictorPlugin

public PredictorPlugin()
Method Detail

getProductName

public java.lang.String getProductName()
Description copied from class: CalculatorPlugin
Returns the product identifier of the plugin as given by LicenseManager. The name is used by the CalculatorPlugin.isLicensed() method.

Specified by:
getProductName in class CalculatorPlugin
Returns:
product identifier or a default string

setInputMolecule

protected void setInputMolecule(Molecule mol)
                         throws PluginException
Description copied from class: CalculatorPlugin
Sets the input molecule.

Specified by:
setInputMolecule in class CalculatorPlugin
Parameters:
mol - is the input molecule
Throws:
PluginException - on error

setParameters

public void setParameters(java.util.Properties params)
                   throws PluginException
Description copied from class: CalculatorPlugin
Sets the input parameters for the plugin.

Overrides:
setParameters in class CalculatorPlugin
Parameters:
params - is the parameter table
Throws:
PluginException - on error

getTrainingIds

public static java.lang.String[] getTrainingIds()
Returns the id's of available predictions.

Returns:
the id's of available predictions

setTraining

public void setTraining(java.lang.String trainingId)
                 throws PluginException
Sets the prediction.

Parameters:
trainingId - the training id
Throws:
PluginException - if training id is invalid, or parameter file for training cannot be loaded

run

public boolean run()
            throws PluginException
Description copied from class: CalculatorPlugin
Runs the tool.

Specified by:
run in class CalculatorPlugin
Returns:
true if the calculation was successful, false on calculation problems
Throws:
PluginException - on error
See Also:
CalculatorPlugin.getErrorMessage()

getPredictedValue

public double getPredictedValue()
Returns the predicted value.

Returns:
the predicted value

getStandardError

public double getStandardError()

getResultTypes

public java.lang.Object[] getResultTypes()
Description copied from class: CalculatorPlugin
Returns the result types. The default implementation returns null.

Overrides:
getResultTypes in class CalculatorPlugin
Returns:
the result types

getResult

public java.lang.Object getResult(java.lang.Object type,
                                  int index)
                           throws PluginException
Description copied from class: CalculatorPlugin
Returns the result item for the specified type and index. The default implementation returns null.

Overrides:
getResult in class CalculatorPlugin
Parameters:
type - is the result type
index - is the result index
Returns:
the result item for the specified type and index
Throws:
PluginException - if the result cannot be returned
See Also:
CalculatorPlugin.getResultTypes()

getResult

public java.lang.Object getResult(java.lang.Object type,
                                  java.lang.String arg)
                           throws PluginException
Description copied from class: CalculatorPlugin
Returns the result item for the specified argument string. The default implementation calls CalculatorPlugin.getResult(Object, int) with the argument string converted to an integer (result index).

Overrides:
getResult in class CalculatorPlugin
Parameters:
type - is the result type
arg - is the argument string
Returns:
the result item for the specified type and argument string
Throws:
PluginException - if the result cannot be returned
See Also:
CalculatorPlugin.getResultTypes()

getResultAsString

public java.lang.String getResultAsString(java.lang.Object type,
                                          int index,
                                          java.lang.Object result)
                                   throws PluginException
Description copied from class: CalculatorPlugin
Returns the specified result in String format. The default implementation returns null.

Overrides:
getResultAsString in class CalculatorPlugin
Parameters:
type - is the result type
index - is the result index
result - is the result item
Returns:
the specified result in String format
Throws:
PluginException - if an invalid result item is given

getResultMolecule

public Molecule getResultMolecule()
Description copied from class: CalculatorPlugin
Returns the result molecule for display. Atomic results are stored in atom extra labels (MolAtom.getExtraLabel()). Molecular results are stored in molecule properties with keys being the result types (Molecule.getProperty(String)).

Overrides:
getResultMolecule in class CalculatorPlugin
Returns:
the result molecule

getErrorMessage

public java.lang.String getErrorMessage()
Description copied from class: CalculatorPlugin
Returns the calculation error information message if CalculatorPlugin.run() returned false (calculation error). The default implementation returns the empty string.

Overrides:
getErrorMessage in class CalculatorPlugin
Returns:
the calculation error information message

standardize

public void standardize(Molecule mol)
Description copied from class: CalculatorPlugin
Standardizes the molecule by performing the transformations necessary to run the plugin (aromatize, dehydrogenize, bring nitro groups to common form, ...). This implementation performs the following transformations: To be overridden by subclasses that require other standardization (or none at all). TODO: replace by call to chemaxon.reaction.Standardizer

Overrides:
standardize in class CalculatorPlugin
Parameters:
mol - is the molecule to be standardized

needError

public boolean needError()