Class ElementalAnalyserPlugin

  • All Implemented Interfaces:
    chemaxon.license.Licensable

    @PublicAPI
    public class ElementalAnalyserPlugin
    extends CalculatorPlugin
    Calculates molecular formula, mass, MS mass and composition.

    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.

    Since:
    1.0, 11/03/2002
    • Constructor Detail

      • ElementalAnalyserPlugin

        public ElementalAnalyserPlugin()
    • Method Detail

      • setMolecule

        public void setMolecule​(String formula)
                         throws IllegalArgumentException
        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
      • setParameters

        public void setParameters​(Properties params)
                           throws PluginException
        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 ',', possible values:
          • "mass"
          • "exactmass"
          • "formula"
          • "isotopeformula"
          • "dotdisconnectedformula"
          • "dotdisconnectedisotopeformula"
          • "composition"
          • "isotopecomposition"
          • "atomcount"
          (default: all of these)
        Overrides:
        setParameters in class CalculatorPlugin
        Parameters:
        params - is the parameter table
        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()
        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
      • 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

        public String 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

        public String getFormula​(int digits)
        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
      • getIsotopeFormula

        public String 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

        public String getIsotopeFormula​(boolean symbolD)
        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
      • getDotDisconnectedFormula

        public String getDotDisconnectedFormula()
        Calculates the dot-disconnected molecular formula of a multifragment molecule. For example, it returns C7H5O2.Na for sodium benzoate.
        Returns:
        the dot diconnected formula of the molecule
        Since:
        Marvin 3.4.1
      • getGroupedDotDisconnectedFormula

        public String getGroupedDotDisconnectedFormula()
        Calculates the grouped dot-disconnected molecular formula of a multifragment molecule.
        Returns:
        the grouped dot diconnected formula of the molecule
        Since:
        Marvin 14.8.14
      • getDotDisconnectedIsotopeFormula

        public String 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 diconnected isotope formula of the molecule
        Since:
        Marvin 5.0
      • getDotDisconnectedIsotopeFormula

        public String getDotDisconnectedIsotopeFormula​(boolean symbolD)
        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 diconnected isotope formula of the molecule
        Since:
        Marvin 5.0
      • getComposition

        public String 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

        public String getIsotopeComposition()
        Returns the molecular composition (w/w%). Isotopes are separate atom types.
        Returns:
        the molecular composition
        Since:
        Marvin 3.4.1
      • getIsotopeComposition

        public String getIsotopeComposition​(boolean symbolD)
        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

        public List<chemaxon.common.util.Pair<BigDecimal,​BigDecimal>> 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 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
      • getResultAsString

        public String getResultAsString​(Object type,
                                        int index,
                                        Object result)
                                 throws PluginException
        Returns the specified result in String format.
        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
      • getResultCount

        public int getResultCount​(Object type)
        Returns the number of result items for the given result key.
        Overrides:
        getResultCount in class CalculatorPlugin
        Parameters:
        type - is the result type
        Returns:
        the number of result items
        See Also:
        getResultTypes()
      • getResultTypes

        public Object[] getResultTypes()
        Returns the result types. Possible result types:
        • "mass"
        • "exactmass"
        • "formula"
        • "isotopeformula"
        • "dotdisconnectedformula"
        • "groupeddotdisconnectedformula"
        • "dotdisconnectedisotopeformula"
        • "composition"
        • "isotopecomposition"
        • "atomcount"
        Overrides:
        getResultTypes in class CalculatorPlugin
        Returns:
        the result types
      • getTypeString

        public String getTypeString​(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
      • standardize

        public 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