chemaxon.marvin.calculations
Class RefractivityPlugin

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

public class RefractivityPlugin
extends CalculatorPlugin

Plugin class for refractivity calculation. Both the incremental values for atoms and the overal refractivity value for the molecule can be calculated by this plugin.

API usage example:

    // read input molecule
    MolImporter mi = new MolImporter("test.mol");
    Molecule mol = mi.read();
    mi.close();

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

    // set double precision for string conversion (optional)
    plugin.setDoublePrecision(3);

    // set target molecule
    plugin.setMolecule(mol);
        
    // run the calculation
    plugin.run();
        
    // get molecular refractivity
    double refractivity = plugin.getRefractivity();
    System.out.println("molecular refractivity: "+plugin.format(refractivity));

    // get refractivity increments values for each atom
    String str = "";
    int count = mol.getAtomCount();
    for (int i=0; i < count; ++i) {
          double increment = plugin.getRefractivityIncrement(i);
          str += plugin.format(increment);
          str += ";";
    }
    System.out.println("refractivity increments for atoms: "+str);
 

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

Author:
Nora Mate

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, NAN, PLUGIN_CLASS_KEY, PLUGIN_DIR, RED
 
Constructor Summary
RefractivityPlugin()
          Constructor.
 
Method Summary
 void checkMolecule(Molecule mol)
          Checks the input molecule.
 java.lang.String getErrorMessage()
          Returns the calculation error information message if run() returned false (calculation error): hydrogen valence error.
 double getRefractivity()
          Returns the refractivity value.
 double getRefractivityHIncrement(int index)
          Returns the refractivity increment on the H atoms attached to a given atom.
 double getRefractivityIncrement(int index)
          Returns the refractivity increment for a given atom.
 java.lang.Object getResult(java.lang.Object type, int index)
          Returns the result item for the specified key and index.
 java.lang.String getResultAsString(java.lang.Object type, int index, java.lang.Object result)
          Returns the specified result in String format.
 int getResultCount(java.lang.Object type)
          Returns the number of result items for the given result key.
 int getResultDomain(java.lang.Object type)
          Returns the calculation domain CalculatorPlugin.ATOM or CalculatorPlugin.MOLECULE.
 Molecule getResultMolecule()
          Returns the result molecule for display.
 java.lang.Object[] getResultTypes()
          Returns the result types.
 java.lang.String getTypeString(java.lang.Object type)
          Returns a string representation of the given type.
 boolean isLicensed()
          Returns true if the plugin is licensed.
 boolean run()
          Runs the refractivity calculation.
protected  void setInputMolecule(Molecule mol)
          Sets the input molecule.
 void setParameters(java.util.Properties params)
          Sets the input parameters for the plugin.
 void standardize(Molecule mol)
          Standardizes the molecule.
 
Methods inherited from class chemaxon.marvin.plugin.CalculatorPlugin
checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, createModifiedInputMolecule, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getCalcMolecule, getDisplayMolecule, getDocument, getDoublePrecision, getInputMolDim, getMainMolecule, getpH, getPluginResource, getRemark, getResult, getResult, getResult, getResultAsRGB, getResultAsRGB, getResultAsString, getResultCount, getResultDomain, getResultMessage, getResultMolecules, getResultsAsRGB, getResultsAsRGB, getResultsAsString, getResultsAsString, getResultSource, getWarningMessage, handlesMultiFragmentMolecules, isInputMoleculeAromatized, 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

RefractivityPlugin

public RefractivityPlugin()
Constructor. Creates the refractivity calculator object.

Method Detail

isLicensed

public boolean isLicensed()
Description copied from class: CalculatorPlugin
Returns true if the plugin is licensed. Implement this only if you want to sell your plugin and protect it with a license key. The default implementation always returns true which means that the plugin is free: no license key is required. This method returns only information about the licensing, license checking has to be implemented separately.

Specified by:
isLicensed in interface chemaxon.license.Licensable
Overrides:
isLicensed in class CalculatorPlugin
Returns:
true if the plugin is licensed

setParameters

public void setParameters(java.util.Properties params)
                   throws PluginException
Sets the input parameters for the plugin. Refractivity parameters and value ranges:

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

checkMolecule

public void checkMolecule(Molecule mol)
                   throws PluginException
Checks the input molecule. Throws exception if the molecule is RxnMolecule, if the molecule contains R-groups or if the molecule consists of more than one fragments.

Overrides:
checkMolecule in class CalculatorPlugin
Parameters:
mol - is the input molecule
Throws:
PluginException - with error message for the user if the molecule is refused

setInputMolecule

protected void setInputMolecule(Molecule mol)
                         throws PluginException
Sets the input molecule.

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

run

public boolean run()
            throws PluginException
Runs the refractivity calculation.

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()

getErrorMessage

public java.lang.String getErrorMessage()
Returns the calculation error information message if run() returned false (calculation error): hydrogen valence error.

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

getRefractivity

public double getRefractivity()
Returns the refractivity value. The refractivity calculation should be run beforehand by run().

Returns:
the refractivity value

getRefractivityIncrement

public double getRefractivityIncrement(int index)
Returns the refractivity increment for a given atom. The refractivity calculation should be run beforehand by run().

Parameters:
index - is the atom index
Returns:
the refractivity increment for a given atom

getRefractivityHIncrement

public double getRefractivityHIncrement(int index)
Returns the refractivity increment on the H atoms attached to a given atom. The refractivity calculation should be run beforehand by run().

Parameters:
index - is the atom index
Returns:
the refractivity increment on the H atoms attached to a given atom

getResultTypes

public java.lang.Object[] getResultTypes()
Returns the result types. Possible result types: refractivity,increments,inch

Overrides:
getResultTypes in class CalculatorPlugin
Returns:
the result types

getTypeString

public java.lang.String getTypeString(java.lang.Object type)
Returns a string representation of the given type.

Overrides:
getTypeString in class CalculatorPlugin
Parameters:
type - is the type object
Returns:
the type string

getResultDomain

public int getResultDomain(java.lang.Object type)
Returns the calculation domain CalculatorPlugin.ATOM or CalculatorPlugin.MOLECULE. Returns CalculatorPlugin.ATOM for type "increments" or "inch" and CalculatorPlugin.MOLECULE otherwise.

Overrides:
getResultDomain in class CalculatorPlugin
Parameters:
type - is the result type
Returns:
CalculatorPlugin.MOLECULE or CalculatorPlugin.ATOM
See Also:
getResultTypes()

getResultCount

public int getResultCount(java.lang.Object type)
Returns the number of result items for the given result key. Refractivity returns the atom count for types "increments" and "inch" 1 otherwise.

Overrides:
getResultCount in class CalculatorPlugin
Parameters:
type - is the result type
Returns:
the number of result items
See Also:
getResultTypes()

getResult

public java.lang.Object getResult(java.lang.Object type,
                                  int index)
                           throws PluginException
Returns the result item for the specified key and index. Refractivity returns the required refractivity value or atomic increment as a Double object.

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

getResultAsString

public java.lang.String getResultAsString(java.lang.Object type,
                                          int index,
                                          java.lang.Object result)
                                   throws PluginException
Returns the specified result in String format. Refractivity returns the rounded refractivity value in string format: the value is rounded using the 'precision' input parameter that determines the number of fractional digits displayed.

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()
                           throws PluginException
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
Throws:
PluginException - on error
Since:
Marvin 4.0

standardize

public void standardize(Molecule mol)
Standardizes the molecule. This is done by performing the transformations necessary to run the plugin (e.g. aromatize, dehydrogenize, bring nitro groups to common form). Apart from the default standardization (aromatize and nitro) removes explicit hydrogens. TODO: replace by call to chemaxon.reaction.Standardizer

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