Package chemaxon.marvin.calculations
Class ElementalAnalyserPlugin
java.lang.Object
chemaxon.marvin.plugin.CalculatorPlugin
chemaxon.marvin.calculations.ElementalAnalyserPlugin
- All Implemented Interfaces:
TaggedCalculator
,chemaxon.license.Licensable
Calculates molecular formula, mass, MS mass and composition.
API usage example:
// 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 ...
For concurrent plugin example applications using ChemAxon's concurrent framework, refer to the Concurrent plugin examples.
- Since:
- 1.0, 11/03/2002
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents the different result types of the elemental analyser plugin.Nested classes/interfaces inherited from class chemaxon.marvin.plugin.CalculatorPlugin
CalculatorPlugin.HydrogenData
-
Field Summary
Fields inherited from class chemaxon.marvin.plugin.CalculatorPlugin
ATOM, BLUE, CALCRGB_OFF, COVALENT_HYDRATION_ERROR_REMARK, CRITICAL_ERROR_MSG, EPSILON, explicitHydrogens, INCORRECT_AROMATIC_NITROGEN_REMARK, INSTABLE_TAUTOMERIC_FORM_REMARK, KEEP_HYDROGENS, keepHydrogens, licenseEnvironment, MOLECULE, MOLECULES, NAN, PLUGIN_CLASS_KEY, PLUGIN_DIR, RED, TRUE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkMolecule
(Molecule mol) Checks the input molecule.int
Returns the atom count (including implicit hydrogens).int
getAtomCount
(int z) Returns the number of atoms with given atomic number (including its isotopes).int
getAtomCount
(int z, int m) Returns the number of atoms with given atomic number in the molecule isotope with the specified mass number.Calculates the elemental analysis, the relative percent composition of a pure chemical substance by element (w/w%).Calculates the dot-disconnected molecular formula of a multifragment molecule with its formal charge.Calculates the dot-disconnected molecular formula of a multifragment molecule.Calculates the dot-disconnected isotope formula of a multifragment molecule with its formal charge.getDotDisconnectedIsotopeFormalChargeFormula
(boolean symbolD) Calculates the dot-disconnected isotope formula of a multifragment molecule with its formal charge.Calculates the dot-disconnected isotope formula of a multifragment molecule.getDotDisconnectedIsotopeFormula
(boolean symbolD) Calculates the dot-disconnected isotope formula of a multifragment molecule.Returns the calculation error information message ifCalculatorPlugin.run()
returnedfalse
(calculation error).double
Calculates the weight of the MS molecule ion using the mass of the most frequent natural isotope for element atoms.Calculates the molecular formula with formal charge.getFormalChargeFormula
(int digits) Calculates a fixed digit sortable molecular formula with formal charge.Calculates the molecular formula which is a string listing all atom types an their occurence in the molecule.getFormula
(int digits) Calculates a fixed digit sortable molecular formula.Calculates the grouped dot-disconnected molecular formula of a multifragment molecule.Returns the molecular composition (w/w%).getIsotopeComposition
(boolean symbolD) Returns the molecular composition (w/w%).List<chemaxon.common.util.Pair<BigDecimal,
BigDecimal>> Calculates the isotopic distributions for the molecule.Calculates the molecular formula (isotopes are separated).getIsotopeFormalChargeFormula
(boolean symbolD) Calculates the molecular formula with formal charge (isotopes are separated).Calculates the molecular formula (isotopes are separated).getIsotopeFormula
(boolean symbolD) Calculates the molecular formula (isotopes are separated).double
getMass()
Calculates the molecular weight of the molecule.int
Mass of the molecule calculated using the isotope mass of the most abundant constituent element isotope of each element rounded to the nearest integer value and multiplied by the number of atoms of each element.Returns the product identifier of the plugin as given byLicenseManager
.Returns the result item for the specified key and index.Deprecated, for removal: This API element is subject to removal in a future version.Some implementations of this method modify the state of the plugin, which is a very confusing behavior, so the method is now deprecated and should no longer be used.getResultAsString
(Object type, int index, Object result) Returns the specified result in String format.int
getResultCount
(Object type) Returns the number of result items for the given result key.int
getResultDomain
(Object type) Returns the calculation domainCalculatorPlugin.ATOM
orCalculatorPlugin.MOLECULE
.Returns the result molecule for display.Returns the result types.Object[]
Returns the string IDs of theresult types
.getTypeString
(Object type) Returns a string representation of the given type.boolean
Returnstrue
if the plugin handles multifragment molecules,false
otherwise.boolean
run()
Runs the tool.protected void
Deprecated.For internal use only.void
setFormulaRecognition
(boolean recognize) Recognizes the molecular formulas in pseudo labels.protected void
setInputMolecule
(Molecule mol) Sets the input molecule.void
setMolecule
(String formula) Specifies a molecule to calculate with.void
setParameters
(Properties params) Sets the input parameters for the plugin.void
standardize
(Molecule mol) Prevents default standardization: does nothing.Methods inherited from class chemaxon.marvin.plugin.CalculatorPlugin
addHeavyAtomLimitChecker, addInputChecker, arrangeHydrogenIncerments, canRepeat, checkLicense, checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, create, createModifiedInputMolecule, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getAtomIndexMap, getAtomIndexMapping, getCalcMolecule, getDisplayMolecule, getDocument, getDoublePrecision, getExplicitHydrogenData, getInputMolDim, getMainMolecule, getOriginalMolecule, getpH, getPluginResource, getQueryMoleculeErrorMessage, getRemark, getResult, getResult, getResultAsRGB, getResultAsRGB, getResultAsString, getResultCount, getResultDomain, getResultMessage, getResultMolecules, getResultsAsRGB, getResultsAsRGB, getResultsAsString, getResultsAsString, getResultSource, getWarningMessage, isInputMoleculeAromatized, isLicensed, isMsCalc, isMultiThreadedRunEnabled, isNegligibleResult, isOK, isRgrouped, loadClass, loadPluginClass, loadPluginClass, readAttribute, removeWhitespace, restoreExplicitHydrogens, setAtomIndexMap, setChemicalTermsParameters, setDoublePrecision, setDoublePrecision, setDoublePrecision, setKeepHydrogens, setLicenseEnvironment, setMolecule, setMolecule, setMolecule, setMolecule, setProgressMonitor, standardizeIonicGroups
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface chemaxon.calculator.TaggedCalculator
tags
-
Constructor Details
-
ElementalAnalyserPlugin
public ElementalAnalyserPlugin()
-
-
Method Details
-
setMolecule
Specifies a molecule to calculate with.- Parameters:
formula
- the molecular formula to calculate with- Throws:
IllegalArgumentException
- if the formula is invalid- Since:
- Marvin 5.3.2
-
getProductName
Description copied from class:CalculatorPlugin
Returns the product identifier of the plugin as given byLicenseManager
. The name is used by theCalculatorPlugin.isLicensed()
method.- Specified by:
getProductName
in classCalculatorPlugin
- Returns:
- product identifier or a default string
-
setParameters
Sets the input parameters for the plugin. Parameters:- single: "true" if single fragment mode (calculation is performed separately for each fragment) (default: "false")
- type: result types, separated by ','
(for possible values, see the string IDs of the constants in the
ElementalAnalyserPlugin.ResultType
enum) (default: "mass,exactmass,formula,composition")
- Overrides:
setParameters
in classCalculatorPlugin
- Parameters:
params
- is the parameter table- Throws:
PluginException
- on error
-
setChemicalTermsArgument
Deprecated.For internal use only.Sets the argument string as specified in Chemical Terms expressions.- Overrides:
setChemicalTermsArgument
in classCalculatorPlugin
- Parameters:
arg
- is the atomic number or the atomic number and the mass number separated by "." (e.g. "7.14")- Throws:
PluginException
- on error
-
setFormulaRecognition
public void setFormulaRecognition(boolean recognize) Recognizes the molecular formulas in pseudo labels.- Parameters:
recognize
- true to set recognition
-
handlesMultiFragmentMolecules
public boolean handlesMultiFragmentMolecules()Returnstrue
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. Returnstrue
if parameter "single" is set to "false",false
otherwise (default:false
).- Overrides:
handlesMultiFragmentMolecules
in classCalculatorPlugin
- Returns:
- true if the plugin handles multifragment molecules, false otherwise
-
checkMolecule
Checks the input molecule. Throws exception if the molecule isRxnMolecule
or if the molecule contains R-groups.- Overrides:
checkMolecule
in classCalculatorPlugin
- Parameters:
mol
- is the input molecule- Throws:
PluginException
- with error message for the user if the molecule is refused
-
setInputMolecule
Sets the input molecule.- Specified by:
setInputMolecule
in classCalculatorPlugin
- Parameters:
mol
- is the input molecule- Throws:
PluginException
- on error
-
getMass
public double getMass()Calculates the molecular weight of the molecule.- Returns:
- the molecular weigth of the molecule
- Since:
- Marvin 3.4.1
-
getExactMass
public double getExactMass()Calculates the weight of the MS molecule ion using the mass of the most frequent natural isotope for element atoms.- Returns:
- the weight of the molecule ion
- Since:
- Marvin 3.4.1
-
getNominalMass
public int getNominalMass()Mass of the molecule calculated using the isotope mass of the most abundant constituent element isotope of each element rounded to the nearest integer value and multiplied by the number of atoms of each element.- Returns:
- the nominal mass of the molecule
- Since:
- Marvin 21.14
-
getFormula
Calculates the molecular formula which is a string listing all atom types an their occurence in the molecule. For example the formula of benzene is C6H6.- Returns:
- the molecular formula
- Since:
- Marvin 3.4.1
-
getFormula
Calculates a fixed digit sortable molecular formula. If the digits parameter is 4, then the formula of benzene will be "C0006H0006".- Parameters:
digits
- number of minimum digits- Returns:
- molecular formula
- Since:
- Marvin 6.0
-
getFormalChargeFormula
Calculates the molecular formula with formal charge.- Returns:
- formula with formal charge
-
getFormalChargeFormula
Calculates a fixed digit sortable molecular formula with formal charge. If the digits parameter is 4, then the formula of benzene will be "C0006H0006".- Parameters:
digits
- number of minimum digits- Returns:
- molecular formula with formal charge
-
getIsotopeFormula
Calculates the molecular formula (isotopes are separated). For example, it returns C7D5NaO2 for the deuterated sodium benzoate.- Returns:
- isotope formula
- Since:
- Marvin 3.4.1
-
getIsotopeFormula
Calculates the molecular formula (isotopes are separated). For example, it returns C7[2H]5NaO2 or C7D5NaO2 for the deuterated sodium benzoate depending on symbolD parameter.- Parameters:
symbolD
- uses the D symbol for Deuterium and T for Tritium if true, otherwise [2H] and [3H]- Returns:
- isotope formula
- Since:
- Marvin 5.0
-
getIsotopeFormalChargeFormula
Calculates the molecular formula (isotopes are separated).- Returns:
- isotope formula with formal charge
-
getIsotopeFormalChargeFormula
Calculates the molecular formula with formal charge (isotopes are separated).- Parameters:
symbolD
- uses the D symbol for Deuterium and T for Tritium if true, otherwise [2H] and [3H]- Returns:
- isotope formula with formal charge
-
getDotDisconnectedFormula
Calculates the dot-disconnected molecular formula of a multifragment molecule. For example, it returns C7H5O2.Na for sodium benzoate.- Returns:
- the dot-disconnected formula of the molecule
- Since:
- Marvin 3.4.1
-
getDotDisconnectedFormalChargeFormula
Calculates the dot-disconnected molecular formula of a multifragment molecule with its formal charge.- Returns:
- the dot-disconnected formula of the molecule its with formal charge
-
getDotDisconnectedIsotopeFormula
Calculates the dot-disconnected isotope formula of a multifragment molecule. For example, it returns C7D5O2.Na for the deuterated sodium benzoate.- Returns:
- the dot-disconnected isotope formula of the molecule
- Since:
- Marvin 5.0
-
getDotDisconnectedIsotopeFormula
Calculates the dot-disconnected isotope formula of a multifragment molecule. For example, it returns C7[2H]5O2.Na or C7D5O2.Na for the deuterated sodium benzoate depending on symbolD parameter.- Parameters:
symbolD
- uses the D symbol for Deuterium and T for Tritium if true, otherwise [2H] and [3H]- Returns:
- the dot-disconnected isotope formula of the molecule
- Since:
- Marvin 5.0
-
getDotDisconnectedIsotopeFormalChargeFormula
Calculates the dot-disconnected isotope formula of a multifragment molecule with its formal charge.- Returns:
- the dot-disconnected isotope formula of the molecule with its formal charge
-
getDotDisconnectedIsotopeFormalChargeFormula
Calculates the dot-disconnected isotope formula of a multifragment molecule with its formal charge.- Parameters:
symbolD
- uses the D symbol for Deuterium and T for Tritium if true, otherwise [2H] and [3H]- Returns:
- the dot-disconnected isotope formula of the molecule with its formal charge
-
getGroupedDotDisconnectedFormula
Calculates the grouped dot-disconnected molecular formula of a multifragment molecule.- Returns:
- the grouped dot-disconnected formula of the molecule
- Since:
- Marvin 14.8.14
-
getComposition
Calculates the elemental analysis, the relative percent composition of a pure chemical substance by element (w/w%).- Returns:
- the molecular composition
- Since:
- Marvin 3.4.1
-
getIsotopeComposition
Returns the molecular composition (w/w%). Isotopes are separate atom types.- Returns:
- the molecular composition
- Since:
- Marvin 3.4.1
-
getIsotopeComposition
Returns the molecular composition (w/w%). Isotopes are separate atom types.- Parameters:
symbolD
- uses the D symbol for Deuterium and T for Tritium if true, otherwise [2H] and [3H]- Returns:
- the molecular composition
- Since:
- Marvin 5.0.3
-
getIsotopeDistribution
Calculates the isotopic distributions for the molecule. The distribution of fragments are merged. Takes charge into account.- Returns:
- the list of masses and distributions. the maximum of distribution is normalized to 100.
-
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 (including its isotopes).- 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 is0
, then non-isotope atoms with the given atomic number are counted.- Parameters:
z
- is the atomic numberm
- 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
Returns the result item for the specified key and index.- Overrides:
getResult
in classCalculatorPlugin
- Parameters:
type
- is the result type (use the constants ofElementalAnalyserPlugin.ResultType
or their string IDs)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:
-
getResult
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Object getResult(Object type, String arg) throws PluginException Deprecated, for removal: This API element is subject to removal in a future version.Some implementations of this method modify the state of the plugin, which is a very confusing behavior, so the method is now deprecated and should no longer be used. If you used this method with an index argument, parse the index instead, and callgetResult(Object, int)
. Otherwise, call the appropriate setter method of the plugin to configure it with the argument, and callgetResult(Object, int)
with a 0 index.Returns the atom count of a specific atom.- Overrides:
getResult
in classCalculatorPlugin
- 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:
-
getResultAsString
Returns the specified result in String format.- Overrides:
getResultAsString
in classCalculatorPlugin
- Parameters:
type
- is the result type (use the constants ofElementalAnalyserPlugin.ResultType
or their string IDs)index
- is the result indexresult
- is the result item- Returns:
- the specified result in String format
- Throws:
PluginException
- if an invalid result item is given
-
getResultCount
Returns the number of result items for the given result key.- Overrides:
getResultCount
in classCalculatorPlugin
- Parameters:
type
- is the result type (use the constants ofElementalAnalyserPlugin.ResultType
or their string IDs)- Returns:
- the number of result items
- See Also:
-
getResultDomain
Returns the calculation domainCalculatorPlugin.ATOM
orCalculatorPlugin.MOLECULE
.- Overrides:
getResultDomain
in classCalculatorPlugin
- Parameters:
type
- is the result key- Returns:
- the calculation domain
- See Also:
-
getResultTypes
Returns the string IDs of theresult types
.- Overrides:
getResultTypes
in classCalculatorPlugin
- Returns:
- the result types
- See Also:
-
getResultTypeList
Returns the result types.- Returns:
- the result types
-
getTypeString
Returns a string representation of the given type.- Overrides:
getTypeString
in classCalculatorPlugin
- Parameters:
type
- is the type object (use the constants ofElementalAnalyserPlugin.ResultType
or their string IDs)- Returns:
- the type string
-
run
Runs the tool.- Specified by:
run
in classCalculatorPlugin
- Returns:
- true if the calculation was successful, false on calculation problems
- Throws:
PluginException
- on error- See Also:
-
getErrorMessage
Description copied from class:CalculatorPlugin
Returns the calculation error information message ifCalculatorPlugin.run()
returnedfalse
(calculation error). The default implementation returns the empty string.- Overrides:
getErrorMessage
in classCalculatorPlugin
- Returns:
- the calculation error information message
-
getResultMolecule
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 (MPropHandler.convertToString(MPropertyContainer, String)
).- Overrides:
getResultMolecule
in classCalculatorPlugin
- Returns:
- the result molecule
- Throws:
PluginException
- on error- Since:
- Marvin 4.0
-
standardize
Prevents default standardization: does nothing. ElementalAnalyser does not need standardization.- Overrides:
standardize
in classCalculatorPlugin
- Parameters:
mol
- is the molecule to be standardized
-