@PublicAPI public class ElementalAnalyserPlugin extends CalculatorPlugin
API usage example (as an alternative, you can also use
the ElementalAnalysisCalc
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 ...
For concurrent plugin example applications using ChemAxon's concurrent framework, refer to the Concurrent plugin examples.
CalculatorPlugin.HydrogenData
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 and Description |
---|
ElementalAnalyserPlugin() |
Modifier and Type | Method and Description |
---|---|
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
(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.
|
java.lang.String |
getComposition()
Calculates the elemental analysis, the relative percent composition of a pure
chemical substance by element (w/w%).
|
java.lang.String |
getDotDisconnectedFormula()
Calculates the dot-disconnected molecular formula of a multifragment
molecule.
|
java.lang.String |
getDotDisconnectedIsotopeFormula()
Calculates the dot-disconnected isotope formula of a multifragment
molecule.
|
java.lang.String |
getDotDisconnectedIsotopeFormula(boolean symbolD)
Calculates the dot-disconnected isotope formula of a multifragment
molecule.
|
java.lang.String |
getErrorMessage()
Returns the calculation error information message if
CalculatorPlugin.run()
returned false (calculation error). |
double |
getExactMass()
Calculates the weight of the MS molecule ion using the mass of the most
frequent natural isotope for element atoms.
|
java.lang.String |
getFormula()
Calculates the molecular formula which is a string listing all atom types
an their occurence in the molecule.
|
java.lang.String |
getFormula(int digits)
Calculates a fixed digit sortable molecular formula.
|
java.lang.String |
getGroupedDotDisconnectedFormula()
Calculates the grouped dot-disconnected molecular formula of a multifragment
molecule.
|
java.lang.String |
getIsotopeComposition()
Returns the molecular composition (w/w%).
|
java.lang.String |
getIsotopeComposition(boolean symbolD)
Returns the molecular composition (w/w%).
|
java.util.List<chemaxon.common.util.Pair<java.math.BigDecimal,java.math.BigDecimal>> |
getIsotopeDistribution()
Calculates the isotopic distributions for the molecule.
|
java.lang.String |
getIsotopeFormula()
Calculates the molecular formula (isotopes are separated).
|
java.lang.String |
getIsotopeFormula(boolean symbolD)
Calculates the molecular formula (isotopes are separated).
|
double |
getMass()
Calculates the molecular weight of the molecule.
|
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 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 . |
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 |
handlesMultiFragmentMolecules()
Returns
true if the plugin handles multifragment molecules,
false otherwise. |
boolean |
run()
Runs the tool.
|
void |
setFormulaRecognition(boolean recognize)
Recognizes the molecular formulas in pseudo labels.
|
protected void |
setInputMolecule(Molecule mol)
Sets the input molecule.
|
void |
setMolecule(java.lang.String formula)
Specifies a molecule to calculate with.
|
void |
setParameters(java.util.Properties params)
Sets the input parameters for the plugin.
|
void |
standardize(Molecule mol)
Prevents default standardization: does nothing.
|
arrangeHydrogenIncerments, canRepeat, checkLicense, checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, createModifiedInputMolecule, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getAtomIndexMap, 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, readAttribute, removeWhitespace, restoreExplicitHydrogens, setAtomIndexMap, setDoublePrecision, setDoublePrecision, setDoublePrecision, setKeepHydrogens, setLicenseEnvironment, setMolecule, setMolecule, setMolecule, setMolecule, setProgressMonitor, standardizeIonicGroups, standardizeNeutralGroups
public void setMolecule(java.lang.String formula) throws java.lang.IllegalArgumentException
formula
- the molecular formula to calculate withjava.lang.IllegalArgumentException
- if the formula is invalidpublic java.lang.String getProductName()
CalculatorPlugin
LicenseManager
.
The name is used by the CalculatorPlugin.isLicensed()
method.getProductName
in class CalculatorPlugin
public void setParameters(java.util.Properties params) throws PluginException
setParameters
in class CalculatorPlugin
params
- is the parameter tablePluginException
- on errorpublic void setFormulaRecognition(boolean recognize)
recognize
- true to set recognitionpublic boolean handlesMultiFragmentMolecules()
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
).handlesMultiFragmentMolecules
in class CalculatorPlugin
public void checkMolecule(Molecule mol) throws PluginException
RxnMolecule
or if the molecule contains R-groups.checkMolecule
in class CalculatorPlugin
mol
- is the input moleculePluginException
- with error message for the user if the molecule is refusedprotected void setInputMolecule(Molecule mol) throws PluginException
setInputMolecule
in class CalculatorPlugin
mol
- is the input moleculePluginException
- on errorpublic double getMass()
public double getExactMass()
public java.lang.String getFormula()
public java.lang.String getFormula(int digits)
digits
- number of minimum digitspublic java.lang.String getIsotopeFormula()
public java.lang.String getIsotopeFormula(boolean symbolD)
symbolD
- uses the D symbol for Deuterium and T for Tritium if
true, otherwise [2H] and [3H]public java.lang.String getDotDisconnectedFormula()
public java.lang.String getGroupedDotDisconnectedFormula()
public java.lang.String getDotDisconnectedIsotopeFormula()
public java.lang.String getDotDisconnectedIsotopeFormula(boolean symbolD)
symbolD
- uses the D symbol for Deuterium and T for Tritium if
true, otherwise [2H] and [3H]public java.lang.String getComposition()
public java.lang.String getIsotopeComposition()
public java.lang.String getIsotopeComposition(boolean symbolD)
symbolD
- uses the D symbol for Deuterium and T for Tritium if
true, otherwise [2H] and [3H]public java.util.List<chemaxon.common.util.Pair<java.math.BigDecimal,java.math.BigDecimal>> getIsotopeDistribution()
public int getAllAtomCount()
public int getAtomCount(int z)
z
- is the atomic numberpublic int getAtomCount(int z, int m)
0
, then non-isotope
atoms with the given atomic number are counted.z
- is the atomic numberm
- is the mass numberpublic java.lang.Object getResult(java.lang.Object type, int index) throws PluginException
getResult
in class CalculatorPlugin
type
- is the result typeindex
- is the result indexPluginException
- if the result cannot be returnedCalculatorPlugin.getResultTypes()
public java.lang.Object getResult(java.lang.Object type, java.lang.String arg) throws PluginException
getResult
in class CalculatorPlugin
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")PluginException
- if the result cannot be returnedCalculatorPlugin.getResultTypes()
public java.lang.String getResultAsString(java.lang.Object type, int index, java.lang.Object result) throws PluginException
getResultAsString
in class CalculatorPlugin
type
- is the result typeindex
- is the result indexresult
- is the result itemPluginException
- if an invalid result item is givenpublic int getResultCount(java.lang.Object type)
getResultCount
in class CalculatorPlugin
type
- is the result typegetResultTypes()
public int getResultDomain(java.lang.Object type)
CalculatorPlugin.ATOM
or CalculatorPlugin.MOLECULE
.getResultDomain
in class CalculatorPlugin
type
- is the result keygetResultTypes()
public java.lang.Object[] getResultTypes()
getResultTypes
in class CalculatorPlugin
public java.lang.String getTypeString(java.lang.Object type)
getTypeString
in class CalculatorPlugin
type
- is the type objectpublic boolean run() throws PluginException
run
in class CalculatorPlugin
PluginException
- on errorCalculatorPlugin.getErrorMessage()
public java.lang.String getErrorMessage()
CalculatorPlugin
CalculatorPlugin.run()
returned false
(calculation error).
The default implementation returns the empty string.getErrorMessage
in class CalculatorPlugin
public Molecule getResultMolecule() throws PluginException
MolAtom.getExtraLabel()
).
Molecular results are stored in molecule properties
with keys being the result types
(Molecule.getProperty(String)
).getResultMolecule
in class CalculatorPlugin
PluginException
- on errorpublic void standardize(Molecule mol)
standardize
in class CalculatorPlugin
mol
- is the molecule to be standardized