Class HBDAPlugin

  • All Implemented Interfaces:
    chemaxon.license.Licensable

    @PublicAPI
    public class HBDAPlugin
    extends MajorMicrospeciesAccessorPlugin
    Plugin class for H bond acceptor/donor calculation.

    API usage example:

     // create plugin
     HBDAPlugin plugin = new HBDAPlugin();
     
     // set plugin parameters
     plugin.setDoublePrecision(2);
     plugin.setpHLower(2.0);
     plugin.setpHUpper(12.0);
     plugin.setpHStep(2.0);
     
     // optional: take major microspecies at pH=7.4
     // skip this if you want to calculate HBDA for the input molecule as it is
     plugin.setpH(7.4);
     
     // read target molecule
     MolImporter mi = new MolImporter("target.mol");
     Molecule mol = mi.read();
     mi.close();
     
     // set target molecule
     plugin.setMolecule(mol);
     
     // run the calculation
     plugin.run();
     
     // get results
     
     // average acceptor/donor counts by microspecies distributions at given pH-s
     double[] pHs = plugin.getpHs();
     double[] msacc = plugin.getMsAcceptorCounts();
     double[] msdon = plugin.getMsDonorCounts();
     
     System.out.println("pH\tmsacc\tmsdon");
     for (int i = 0; i < pHs.length; ++i) {
         System.out.println("" + plugin.format(pHs[i]) + "\t" + plugin.format(msacc[i]) + "\t"
                + plugin.format(msdon[i]));
     }
     
     // molecular data
     // with multiplicity
     int molecularAcceptorCount = plugin.getAcceptorCount();
     int molecularDonorCount = plugin.getDonorCount();
     // without multiplicity
     int molecularAcceptorAtomCount = plugin.getAcceptorAtomCount();
     int molecularDonorAtomCount = plugin.getDonorAtomCount();
     System.out.println();
     System.out.println("Acceptor count with multiplicity: " + molecularAcceptorCount);
     System.out.println("Donor count with multiplicity: " + molecularDonorCount);
     System.out.println("Acceptor count without multiplicity: " + molecularAcceptorAtomCount);
     System.out.println("Donor count without multiplicity: " + molecularDonorAtomCount);
     
     // atomic data
     System.out.println();
     System.out.println("Atom\tAcceptor count\tDonor count");
     int count = mol.getAtomCount();
     for (int i = 0; i < count; ++i) {
     
         // atomic acceptor/donor count with multiplicity
         int atomicAcceptorCount = plugin.getAcceptorCount(i);
         int atomicDonorCount = plugin.getDonorCount(i);
     
         if (atomicAcceptorCount != -1) { // -1 means H atom
            System.out.println("" + (i + 1) + "\t" + atomicAcceptorCount + "\t" + atomicDonorCount);
         }
     }
     

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

    • Constructor Detail

      • HBDAPlugin

        public HBDAPlugin()
        Constructor. Creates the calculator object.
    • Method Detail

      • 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
      • setParameters

        public void setParameters​(Properties params)
                           throws PluginException
        Sets the input parameters for the plugin. Charge parameters and value ranges:
        • type:
          • acc: atomic acceptors
          • don: atomic donors
          • accsitecount: molecular acceptor count with multiplicity
          • donsitecount: molecular donor count with multiplicity
          • acceptorcount: molecular acceptor atom count without multiplicity
          • donorcount: molecular donor atom count without multiplicity
          • msacc: average acceptor count over microspecies by pH
          • msdon: average donor count over microspecies by pH
          • excludesulfur: exclude sulfur atoms from acceptors
        • precision: 0-8 or inf (number of displayed fractional digits, inf for unrounded value)
        • lower: pH lower limit (default: 0.0)
        • upper: pH upper limit (default: 14.0)
        • count: pH step count between lower and upper limits (default: 0.5)
        Overrides:
        setParameters in class MajorMicrospeciesAccessorPlugin
        Parameters:
        params - is the parameter table
        Throws:
        PluginException - on error
      • setpHLower

        public void setpHLower​(double lower)
        Sets pH lower limit for the calculation of microspecies distributions. Also activates the calculation of microspecies distributions. The default value is 0.0.
        Parameters:
        lower - is the pH lower limit
        Since:
        Marvin 3.5.1
      • setpHUpper

        public void setpHUpper​(double upper)
        Sets pH upper limit for the calculation of microspecies distributions. Also activates the calculation of microspecies distributions. The default value is 14.0.
        Parameters:
        upper - is the pH upper limit
        Since:
        Marvin 3.5.1
      • setpHStep

        public void setpHStep​(double step)
        Sets pH step for the calculation of microspecies distributions. Also activates the calculation of microspecies distributions. The default value is 0.5.
        Parameters:
        step - is the pH step
        Since:
        Marvin 3.5.1
      • isMsCalc

        protected boolean isMsCalc()
        Returns true if microspecies calculation.
        Overrides:
        isMsCalc in class CalculatorPlugin
        Returns:
        true if microspecies calculation
      • setExcludeSulfur

        public void setExcludeSulfur​(boolean e)
        Sets if sulfur atom should be excluded from hydrogen bond acceptors. Default: true
        Parameters:
        e - if true then sulfur atom is not considered to be hydrogen bond acceptor.
        Since:
        Marvin 5.3
      • setExcludeHalogens

        public void setExcludeHalogens​(boolean e)
        Sets if halogens should be excluded from hydrogen bond acceptors. Default: true
        Parameters:
        e - if true then halogens are not considered to be hydrogen bond acceptor.
        Since:
        Marvin 5.3.2
      • 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
      • getWarningMessage

        public String getWarningMessage()
        Returns the calculation warning information message if no H-bond donor/acceptor atoms found, returns the empty string otherwise.
        Overrides:
        getWarningMessage in class CalculatorPlugin
        Returns:
        the calculation warning information message
      • getpHs

        public double[] getpHs()
        Returns the pH array.
        Returns:
        the pH array
      • getMsAcceptorCounts

        public double[] getMsAcceptorCounts()
        Returns the average acceptor counts over the microspecies distribution for different pH-s. The pH array is returned by getpHs() and determined by the "lower", "upper" and "step" plugin parameters.
        Returns:
        the average acceptor counts over the microspecies distribution for pH-s returned by getpHs()
      • getMsDonorCounts

        public double[] getMsDonorCounts()
        Returns the average donor counts over the microspecies distribution for different pH-s. The pH array is returned by getpHs() and determined by the "lower", "upper" and "step" plugin parameters.
        Returns:
        the average donor counts over the microspecies distribution for pH-s returned by getpHs()
      • getAcceptorSiteCount

        public int getAcceptorSiteCount​(int index)
        Returns the atomic acceptor count corresponding to the specified atom index.
        Parameters:
        index - is the atom index
        Returns:
        the atomic acceptor count, -1 for H atoms
      • getDonorSiteCount

        public int getDonorSiteCount​(int index)
        Returns the atomic donor count corresponding to the specified atom index.
        Parameters:
        index - is the atom index
        Returns:
        the atomic donor count, -1 for H atoms
      • getAcceptorSiteCount

        public int getAcceptorSiteCount()
        Returns the overall acceptor count (with multiplicity) in the molecule.
        Returns:
        the overall acceptor count (with multiplicity) in the molecule
      • getDonorSiteCount

        public int getDonorSiteCount()
        Returns the overall donor count (with multiplicity) in the molecule.
        Returns:
        the overall donor count (with multiplicity) in the molecule
      • getAcceptorAtomCount

        public int getAcceptorAtomCount()
        Returns the overall acceptor atom count (without multiplicity) in the molecule.
        Returns:
        the overall acceptor atom count (without multiplicity) in the molecule
      • getDonorAtomCount

        public int getDonorAtomCount()
        Returns the overall donor atom count (without multiplicity) in the molecule.
        Returns:
        the overall donor atom count (without multiplicity) in the molecule
      • setGUIMode

        @Deprecated
        protected void setGUIMode​(boolean guimode)
        Deprecated.
        Sets GUI mode.
        Parameters:
        guimode - is true if GUI mode
      • getResultCount

        public int getResultCount​(Object type)
        Returns the number of result items for the given result type. Returns the atom count for types "acc" and "don", 1 otherwise.
        Overrides:
        getResultCount in class CalculatorPlugin
        Parameters:
        type - is the result type
        Returns:
        the number of result items
        See Also:
        getResultTypes()
      • getResult

        public Object getResult​(Object type,
                                int index)
                         throws PluginException
        Returns the result item for the specified type and index. HBDA returns the (pH, acceptor/donor count) arrays for types "msacceptor" and "msdonor" as a double[2][] with the 0-th element being the pH array and the 1-st element being the acceptor/donor count array. For types "acc" and "don" HBDA returns the acceptor/donor count corresponding to the specified atom index. For types "accsitecount" and "donsitecount" HBDA returns the sum of the atomic values. cc * @see #getResultTypes()
        Overrides:
        getResult in class CalculatorPlugin
        Parameters:
        type - is the result type ("acc", "don", "msacc", "msdon", "accsitecount", "donsitecount", "acceptorcount", "donorcount")
        index - is the atom index for types "acc", "don", N/A for "msacc", "msdon", "accsitecount", "donsitecount", "acceptorcount", "donorcount"
        Returns:
        the result item for the specified type and index
        Throws:
        PluginException - if the result cannot be returned
        See Also:
        CalculatorPlugin.getResultTypes()
      • 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
      • getResultAsRGB

        public int getResultAsRGB​(Object type,
                                  int index,
                                  Object result)
                           throws PluginException
        Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue). Returns "red" for acceptor "blue" for donor.
        Overrides:
        getResultAsRGB in class CalculatorPlugin
        Parameters:
        type - is the result type
        index - is the result index
        result - is the result item
        Returns:
        the specified result in color as int
        Throws:
        PluginException - if an invalid result item is given
      • getResultsAsRGB

        public long getResultsAsRGB​(Object type,
                                    int index,
                                    Object result)
                             throws PluginException
        Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue). Returns "red" for acceptor "blue" for donor.
        Overrides:
        getResultsAsRGB in class CalculatorPlugin
        Parameters:
        type - is the result type
        index - is the result index
        result - is the result item
        Returns:
        the specified result in color as int
        Throws:
        PluginException - if an invalid result item is given
      • getResultsAsString

        public String getResultsAsString​(Object type,
                                         int index,
                                         Object result)
                                  throws PluginException
        Returns the specified result in GUI-specific String format: A for acceptor, D for donor.
        Overrides:
        getResultsAsString 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
      • 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
      • isNegligibleResult

        public boolean isNegligibleResult​(Object type,
                                          int index,
                                          Object result)
                                   throws PluginException
        Returns whether the result can be ignored. Returns true for microspecies acceptor/donor count below EPSILON. Returns false for all other results.
        Overrides:
        isNegligibleResult in class CalculatorPlugin
        Parameters:
        type - is the result type
        index - is the result index
        result - is the result object
        Returns:
        true for microspecies acceptor/donor count below EPSILON
        Throws:
        PluginException