Class ChargePlugin

All Implemented Interfaces:
TaggedCalculator, chemaxon.license.Licensable

@PublicAPI public class ChargePlugin extends MajorMicrospeciesAccessorPlugin
Plugin class for partial charge calculation. Sigma, pi and total charge values can be calculated by this plugin. For formal charge calculation use the following methods: MoleculeGraph.getFormalCharge(), MolAtom.getCharge().

References:

  1. J.Gasteiger and M.Marsili: Tetrahedron Vol. 36. , pp. 3219-3288 (1980)
  2. M.Marsili and J.Gasteiger: International Symposium on Aromaticity, Dubrovnik, Yugoslavia , Sept (1979), Croat.Chim.Acta. (1979)
  3. Steven L. Dixon and Peter C. Jurs: J.Comp.Chem., Vol.13. No.4, 492-504 (1992)
  4. W.J.Mortier, K.V.Genechten and J.Gasteiger: J.Am.Chem.Soc., Vol. 107,829-835 (1985)

API usage example:

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

    // read target molecule
    MolImporter mi = new MolImporter(new ByteArrayInputStream("Clc1cc(Cl)c(Cl)cc1".getBytes()));
    Molecule mol = mi.read();
    mi.close();

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

    // run the calculation
    plugin.run();

    // get charge values for each atom
    int count = mol.getAtomCount();
    for (int i=0; i < count; ++i) {
        double charge = plugin.getTotalCharge(i);
        if (!Double.isNaN(charge)) {
            System.out.println("total charge for atom "+(i+1)+": "+charge);
        }
    }
 

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

  • Constructor Details

    • ChargePlugin

      public ChargePlugin()
      Constructor. Creates the charge calculator object.
  • Method Details

    • isLicensed

      public boolean isLicensed()
      Returns true if the plugin is licensed. The license checking is based on the product name, returned by getProductName().
      Specified by:
      isLicensed in interface chemaxon.license.Licensable
      Overrides:
      isLicensed in class MajorMicrospeciesAccessorPlugin
      Returns:
      true if the plugin is licensed
    • getProductName

      public String getProductName()
      Returns the product identifier of the plugin as given by LicenseManager.
      Specified by:
      getProductName in class CalculatorPlugin
      Returns:
      The identifier LicenseManager.CHARGE_PLUGIN_GROUP
    • setParameters

      public void setParameters(Properties params) throws PluginException
      Sets the input parameters for the plugin. Charge parameters and value ranges:
      • type: sigma,pi,total, formalcharge, "atomicformalcharge", aromaticsystem, aromaticsystemsigma,aromaticsystempi, aromaticring, aromaticringsigma, aromaticringpi
      • precision: 0-8 or inf (number of displayed fractional digits, inf for unrounded value)
      • implh: true or false - true if implicit H data should be shown
      • resonance: true or false - true if calculate with resonant structures (default: false)
      • pH: major microspecies on given pH is taken as input molecule if omitted then the input molecule is taken as it is
      Overrides:
      setParameters in class MajorMicrospeciesAccessorPlugin
      Parameters:
      params - is the parameter table
      Throws:
      PluginException - on error
    • setTakeResonantStructures

      public void setTakeResonantStructures(boolean resonance)
      Sets calculation with resonant structures. Default: false.
      Parameters:
      resonance - is true if charge should be calculated with resonant structures
      Since:
      Marvin 4.1
    • 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
    • setMolecule

      public Molecule setMolecule(Molecule mol, boolean st, boolean om) throws PluginException
      Description copied from class: CalculatorPlugin
      Sets the input molecule after an optional standardization and/or modification. Standardization includes plugin specific standardization (e.g. dehydrogenize, aromatize) and sgroup expansion, modification usually means taking a microspecies form, or the major tautomeric form of the input molecule (usually optional). The input molecule is left unchanged (it is cloned before standardization/modification if required).
      Overrides:
      setMolecule in class CalculatorPlugin
      Parameters:
      mol - is the input molecule
      st - is true if standardization is required
      om - is true if original input molecule is to be used for atom indexing false if modified molecule is to be used for atom indexing
      Returns:
      the molecule to be used for atom indexing
      Throws:
      PluginException - on error
      See Also:
    • handlesMultiFragmentMolecules

      public boolean handlesMultiFragmentMolecules()
      Description copied from class: CalculatorPlugin
      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. The default implementation returns false.
      Overrides:
      handlesMultiFragmentMolecules in class CalculatorPlugin
      Returns:
      true if the plugin handles multifragment molecules, false otherwise
    • run

      public boolean run() throws PluginException
      Runs the charge calculation.
      Specified by:
      run in class CalculatorPlugin
      Returns:
      true if the calculation was successful, false on calculation error
      Throws:
      PluginException - on error
      See Also:
    • getErrorMessage

      public String getErrorMessage()
      Returns the calculation error information message if run() returned false (calculation error): hydrogen valence error.
      Overrides:
      getErrorMessage in class MajorMicrospeciesAccessorPlugin
      Returns:
      the calculation error information message
    • getFormalCharge

      public int getFormalCharge()
      Returns the formal charge of the molecule.
      Returns:
      the formal charge of the molecule
      Since:
      Marvin 5.2
      See Also:
    • getFormalCharge

      public int getFormalCharge(int index)
      Returns the formal charge of a specified atom.
      Parameters:
      index - is the atom index
      Returns:
      the formal charge of a specified atom
      Since:
      Marvin 5.2
      See Also:
    • getTotalCharge

      public double getTotalCharge(int index)
      Returns the total charge of a specified atom. Total charge is the sum of partial charges on the atom.
      Parameters:
      index - is the atom index
      Returns:
      the total charge of a specified atom, Double.NaN for implicit H-s
      Since:
      Marvin 3.4.1
      See Also:
    • getSigmaCharge

      public double getSigmaCharge(int index)
      Returns the sigma charge of a specified atom.
      Parameters:
      index - is the atom index
      Returns:
      the sigma charge of a specified atom, Double.NaN for implicit H-s
      Since:
      Marvin 3.4.1
    • getPiCharge

      public double getPiCharge(int index)
      Returns the pi charge of a specified atom.
      Parameters:
      index - is the atom index
      Returns:
      the pi charge of a specified atom, Double.NaN for implicit H-s
      Since:
      Marvin 3.4.1
    • getResultantImplicitHCharge

      public double getResultantImplicitHCharge(int index)
      Returns the implicit H charge around a central atom
      Parameters:
      index - is the central atom index
      Returns:
      the implicit H charge around the central atom
      Since:
      Marvin 3.5
    • getAromaticSystemCharge

      public double getAromaticSystemCharge(int index)
      Returns the total partial charge of the aromatic system containing the specified atom.
      Parameters:
      index - is the atom index
      Returns:
      the total partial charge of the aromatic system containing the specified atom
      Since:
      Marvin 3.5
    • getAromaticSystemCharge

      public double getAromaticSystemCharge(int index, int chgtype)
      Returns the partial charge of the aromatic system containing the specified atom.
      Parameters:
      index - is the atom index
      chgtype - is the charge type: 0 - total, 1 - sigma, 2 - pi
      Returns:
      the total partial charge of the aromatic system containing the specified atom
      Since:
      Marvin 4.1
    • getAromaticRingCharge

      public double getAromaticRingCharge(int index)
      Returns the total partial charge of the smallest aromatic ring containing the specified atom.
      Parameters:
      index - is the atom index
      Returns:
      the total partial charge of the smallest aromatic ring containing the specified atom
      Since:
      Marvin 3.5
    • getAromaticRingCharge

      public double getAromaticRingCharge(int index, int chgtype)
      Returns the partial charge of the smallest aromatic ring containing the specified atom.
      Parameters:
      index - is the atom index
      chgtype - is the charge type: 0 - total, 1 - sigma, 2 - pi
      Returns:
      the total partial charge of the smallest aromatic ring containing the specified atom
      Since:
      Marvin 4.1
    • getResultTypes

      public Object[] getResultTypes()
      Returns the result types (possible types: "sigma", "pi", "total").
      Overrides:
      getResultTypes in class CalculatorPlugin
      Returns:
      the result types
    • getResultDomain

      public int getResultDomain(Object type)
      Returns the calculation domain CalculatorPlugin.ATOM or CalculatorPlugin.MOLECULE.
      Overrides:
      getResultDomain in class CalculatorPlugin
      Parameters:
      type - is the result type
      Returns:
      CalculatorPlugin.ATOM
      See Also:
    • getResultCount

      public int getResultCount(Object type)
      Returns the number of result items for the given result type. Charge returns the atom count.
      Overrides:
      getResultCount in class CalculatorPlugin
      Parameters:
      type - is the result type
      Returns:
      the number of result items
      See Also:
    • 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
    • getResult

      public Object getResult(Object type, int index) throws PluginException
      Returns the result item for the specified type and index. Charge returns the required charge value as a Double object.
      Overrides:
      getResult in class CalculatorPlugin
      Parameters:
      type - is the result type ("total", "pi", "sigma", "implh", ...)
      index - is the atom index
      Returns:
      the result item for the specified type and index
      Throws:
      PluginException - if the result cannot be returned
      See Also:
    • getResultAsString

      public String getResultAsString(Object type, int index, Object result) throws PluginException
      Returns the specified result in String format. Charge returns the rounded charge 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 (MPropHandler.convertToString(MPropertyContainer, String)).
      Overrides:
      getResultMolecule in class CalculatorPlugin
      Returns:
      the result molecule
      Throws:
      PluginException - on error
      Since:
      Marvin 4.0