chemaxon.marvin.calculations
Class ElementalAnalyserPlugin

java.lang.Object
  extended bychemaxon.marvin.plugin.CalculatorPlugin
      extended bychemaxon.marvin.calculations.ElementalAnalyserPlugin

public class ElementalAnalyserPlugin
extends CalculatorPlugin

Calculates molecular formula, mass, MS mass and composition.

API usage example (as an alternative, you can also use the ElementalAnalyser class directly):

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

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

    // set plugin parameters
    Properties params = new Properties();
    params.put("precision", "3");
    plugin.setParameters(params);

    // set target molecule
    plugin.setMolecule(mol);

    // run the calculation
    plugin.run();

    // get results
    double exactMass = plugin.getExactMass();
    double mass = plugin.getMass();
    int atomCount1 = plugin.getAtomCount(8); // oxygen atom count
    int atomCount2 = plugin.getAtomCount(8, 0); // non-isotope oxygen count
    int atomCount3 = plugin.getAtomCount(8, 16); // oxygen isotope count with massno=16
    String formula = plugin.getFormula();
    String isotopeFormula = plugin.getIsotopeFormula();
    String composition = plugin.getComposition(); 
    String isotopeComposition = plugin.getIsotopeComposition(); 

    // do something with the results ...
 

Version:
1.0, 11/03/2002
Author:
Gyorgy Pirok

Field Summary
 
Fields inherited from class chemaxon.marvin.plugin.CalculatorPlugin
ATOM, BLUE, CALCRGB_OFF, CHART, HYDROGEN_VALENCE_ERROR_MSG, MOLECULE, NAN, RED, SUBRESULT
 
Constructor Summary
ElementalAnalyserPlugin()
           
 
Method Summary
 void checkMolecule(Molecule mol)
          Checks the input molecule.
 int getAllAtomCount()
          Returns the atom count (including implicit hydrogens).
 int getAtomCount(int z)
          Returns the number of atoms with given atomic number.
 int getAtomCount(int z, int m)
          Returns the number of atoms with given atomic number in the molecule isotope with the specified mass number.
 java.lang.String getComposition()
          Returns the molecule formula composition.
 double getExactMass()
          Returns the molecule exact mass.
 java.lang.String getFormula()
          Returns the molecule formula.
 java.lang.String getIsotopeComposition()
          Returns the molecule isotope composition.
 java.lang.String getIsotopeFormula()
          Returns the molecule isotope formula.
 double getMass()
          Returns the molecule mass.
 java.lang.Object getResult(java.lang.Object type, int index)
          Returns the result item for the specified key and index.
 java.lang.Object getResult(java.lang.Object type, java.lang.String arg)
          Returns the atom count of a specific atom.
 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.
 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 handlesMultiFragmentMolecules()
          Returns true if the plugin handles multifragment molecules, false otherwise.
 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.
protected  void standardize(Molecule mol)
          Prevents default standardization: does nothing.
 
Methods inherited from class chemaxon.marvin.plugin.CalculatorPlugin
check, checkLicense, checkLicenseKey, checkType, create, createImageMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getChartColor, getDoublePrecision, getErrorMessage, getGUIResultTypes, getLicenseKey, getMainMolecule, getMolText, getOutputClassName, getReferenceMolecule, getResult, getResult, getResultAsRGB, getResultAsRGB, getResultAsString, getResultCount, getResultDomain, getResultsAsRGB, getResultsAsRGB, getResultsAsString, getResultsAsString, getSuffix, getXAxisLabel, getXLabels, getYAxisLabel, isLicensed, isMajorityMsCalculation, isMajorMs, isMsCalc, isNegligibleResult, isRgrouped, removeWhitespace, saveLicense, setDoublePrecision, setDoublePrecision, setDoublePrecision, setLicense, setMolecule, setMolecule, setMolecule, standardizeGroups, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementalAnalyserPlugin

public ElementalAnalyserPlugin()
Method Detail

setParameters

public void setParameters(java.util.Properties params)
                   throws PluginException
Sets the input parameters for the plugin. Parameters:

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

handlesMultiFragmentMolecules

public boolean handlesMultiFragmentMolecules()
Returns true if the plugin handles multifragment molecules, false otherwise. In the latter case the plugin takes the fragment with more atoms if a multifragment molecule is given as input. Returns true if parameter "single" is set to "false", false otherwise (default: false).

Overrides:
handlesMultiFragmentMolecules in class CalculatorPlugin
Returns:
true if the plugin handles multifragment molecules, false otherwise

checkMolecule

public void checkMolecule(Molecule mol)
                   throws PluginException
Checks the input molecule. Throws exception if the molecule is RxnMolecule or if the molecule contains R-groups.

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 input molecule
Throws:
PluginException - on error

getMass

public double getMass()
Returns the molecule mass.

Returns:
the molecule mass
Since:
Marvin 3.4.1

getExactMass

public double getExactMass()
Returns the molecule exact mass.

Returns:
the molecule exact mass
Since:
Marvin 3.4.1

getFormula

public java.lang.String getFormula()
Returns the molecule formula.

Returns:
the molecule formula
Since:
Marvin 3.4.1

getIsotopeFormula

public java.lang.String getIsotopeFormula()
Returns the molecule isotope formula.

Returns:
the molecule isotope formula
Since:
Marvin 3.4.1

getComposition

public java.lang.String getComposition()
Returns the molecule formula composition.

Returns:
the molecule formula composition
Since:
Marvin 3.4.1

getIsotopeComposition

public java.lang.String getIsotopeComposition()
Returns the molecule isotope composition.

Returns:
the molecule isotope composition
Since:
Marvin 3.4.1

getAllAtomCount

public int getAllAtomCount()
Returns the atom count (including implicit hydrogens).

Returns:
the atom count
Since:
Marvin 3.4.1

getAtomCount

public int getAtomCount(int z)
Returns the number of atoms with given atomic number.

Parameters:
z - is the atomic number
Returns:
the number of atoms with given atomic number
Since:
Marvin 3.4.1

getAtomCount

public int getAtomCount(int z,
                        int m)
Returns the number of atoms with given atomic number in the molecule isotope with the specified mass number. If the mass number is 0, then non-isotope atoms with the given atomic number are counted.

Parameters:
z - is the atomic number
m - is the mass number
Returns:
the number of atoms with given atomic number in the molecule isotope with the specified mass number
Since:
Marvin 3.4.1

getResult

public java.lang.Object getResult(java.lang.Object type,
                                  int index)
                           throws PluginException
Returns the result item for the specified key and index.

Specified by:
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:
CalculatorPlugin.getResultTypes()

getResult

public java.lang.Object getResult(java.lang.Object type,
                                  java.lang.String arg)
                           throws PluginException
Returns the atom count of a specific atom.

Overrides:
getResult in class CalculatorPlugin
Parameters:
type - is the result type ("atomcount")
arg - is the atomic number or the atomic number and the mass number separated by "." (e.g. "7.14")
Returns:
number of atoms with the specified atomic number and mass number
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
Returns the specified result in String format.

Specified by:
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

getResultCount

public int getResultCount(java.lang.Object type)
Returns the number of result items for the given result key.

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

getResultDomain

public int getResultDomain(java.lang.Object type)
Returns the calculation domain CalculatorPlugin.ATOM or CalculatorPlugin.MOLECULE.

Specified by:
getResultDomain in class CalculatorPlugin
Parameters:
type - is the result key
Returns:
the calculation domain
See Also:
getResultTypes()

getResultTypes

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

Specified by:
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

run

public boolean run()
            throws PluginException
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()

standardize

protected void standardize(Molecule mol)
Prevents default standardization: does nothing. ElementalAnalyser does not need standardization.

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