Package chemaxon.marvin.calculations
Class HBDAPlugin
java.lang.Object
chemaxon.marvin.plugin.CalculatorPlugin
chemaxon.marvin.calculations.MajorMicrospeciesAccessorPlugin
chemaxon.marvin.calculations.HBDAPlugin
- All Implemented Interfaces:
TaggedCalculator,chemaxon.license.Licensable
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
Molecule mol = null;
try (MolImporter mi = new MolImporter("target.mol")) {
mol = mi.read();
}
// 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.getAcceptorSiteCount();
int molecularDonorCount = plugin.getDonorSiteCount();
// 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.getAcceptorSiteCount(i);
int atomicDonorCount = plugin.getDonorSiteCount(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.
-
Nested Class Summary
Nested classes/interfaces inherited from class chemaxon.marvin.plugin.CalculatorPlugin
CalculatorPlugin.HydrogenData -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAcceptor sign displayed in GUI.static final StringDonor sign displayed in GUI.static final doubleFields inherited from class chemaxon.marvin.calculations.MajorMicrospeciesAccessorPlugin
ionizerFields inherited from class chemaxon.marvin.plugin.CalculatorPlugin
ATOM, BLUE, CALCRGB_OFF, COVALENT_HYDRATION_ERROR_REMARK, CRITICAL_ERROR_MSG, 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckMolecule(Molecule mol) Checks the input molecule.intReturns the overall acceptor atom count (without multiplicity) in the molecule.intDeprecated, for removal: This API element is subject to removal in a future version.intgetAcceptorCount(int index) Deprecated, for removal: This API element is subject to removal in a future version.UsegetAcceptorSiteCount()instead!intReturns the overall acceptor count (with multiplicity) in the molecule.intgetAcceptorSiteCount(int index) Returns the atomic acceptor count corresponding to the specified atom index.intReturns the overall donor atom count (without multiplicity) in the molecule.intDeprecated, for removal: This API element is subject to removal in a future version.UsegetDonorSiteCount()instead!intgetDonorCount(int index) Deprecated, for removal: This API element is subject to removal in a future version.UsegetDonorSiteCount(int)instead!intReturns the overall donor count (with multiplicity) in the molecule.intgetDonorSiteCount(int index) Returns the atomic donor count corresponding to the specified atom index.Returns the calculation error information message ifrun()returned false (calculation error): hydrogen valence error.double[]Returns the average acceptor counts over the microspecies distribution for different pH-s.double[]Returns the average donor counts over the microspecies distribution for different pH-s.double[]getpHs()Returns the pH array.Returns the product identifier of the plugin as given byLicenseManager.Returns the result item for the specified type and index.intgetResultAsRGB(Object type, int index, Object result) Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue).getResultAsString(Object type, int index, Object result) Returns the specified result in String format.intgetResultCount(Object type) Returns the number of result items for the given result type.intgetResultDomain(Object type) Returns the calculation domainCalculatorPlugin.ATOMorCalculatorPlugin.MOLECULE.Returns the result molecule for display.longgetResultsAsRGB(Object type, int index, Object result) Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue).getResultsAsString(Object type, int index, Object result) Returns the specified result in GUI-specific String format:Afor acceptor,Dfor donor.Object[]Returns the result types.getTypeString(Object type) Returns a string representation of the given type.Returns the calculation warning information message if no H-bond donor/acceptor atoms found, returns the empty string otherwise.booleanReturnstrueif the plugin is licensed.booleanisMsCalc()Returnstrueif microspecies calculation.booleanisNegligibleResult(Object type, int index, Object result) Returns whether the result can be ignored.booleanrun()Runs the charge calculation.voidsetExcludeHalogens(boolean e) Sets if halogens should be excluded from hydrogen bond acceptors.voidsetExcludeSulfur(boolean e) Sets if sulfur atom should be excluded from hydrogen bond acceptors.protected voidsetGUIMode(boolean guimode) Deprecated, for removal: This API element is subject to removal in a future version.No longer used.protected voidsetInputMolecule(Molecule mol) Sets the input molecule.voidsetMsCalc(boolean mscalc) Sets microspecies calculation.voidsetParameters(Properties params) Sets the input parameters for the plugin.voidsetpHLower(double lower) Sets pH lower limit for the calculation of microspecies distributions.voidsetpHStep(double step) Sets pH step for the calculation of microspecies distributions.voidsetpHUpper(double upper) Sets pH upper limit for the calculation of microspecies distributions.tags()Returns the set of tags reported by this calculator.Methods inherited from class chemaxon.marvin.calculations.MajorMicrospeciesAccessorPlugin
createModifiedInputMolecule, getIonizerErrorMessage, getpH, setChemicalTermsArgument, setpH, standardizeMethods inherited from class chemaxon.marvin.plugin.CalculatorPlugin
addHeavyAtomLimitChecker, addInputChecker, arrangeHydrogenIncerments, canRepeat, checkLicense, checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, create, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getAtomIndexMap, getAtomIndexMapping, getCalcMolecule, getDisplayMolecule, getDocument, getDoublePrecision, getExplicitHydrogenData, getInputMolDim, getMainMolecule, getOriginalMolecule, getPluginResource, getQueryMoleculeErrorMessage, getRemark, getResult, getResult, getResult, getResultAsRGB, getResultAsString, getResultCount, getResultDomain, getResultMessage, getResultMolecules, getResultsAsRGB, getResultsAsString, getResultSource, handlesMultiFragmentMolecules, isInputMoleculeAromatized, isMultiThreadedRunEnabled, isOK, isRgrouped, loadClass, loadPluginClass, loadPluginClass, readAttribute, removeWhitespace, restoreExplicitHydrogens, setAtomIndexMap, setChemicalTermsParameters, setDoublePrecision, setDoublePrecision, setDoublePrecision, setKeepHydrogens, setLicenseEnvironment, setMolecule, setMolecule, setMolecule, setMolecule, setProgressMonitor, standardizeIonicGroups
-
Field Details
-
EPSILON
public static final double EPSILON- See Also:
-
ACCEPTOR_SIGN
Acceptor sign displayed in GUI.- See Also:
-
DONOR_SIGN
Donor sign displayed in GUI.- See Also:
-
-
Constructor Details
-
HBDAPlugin
public HBDAPlugin()Constructor. Creates the calculator object.
-
-
Method Details
-
isLicensed
public boolean isLicensed()Returnstrueif the plugin is licensed. The license checking is based on the product name, returned bygetProductName().- Specified by:
isLicensedin interfacechemaxon.license.Licensable- Overrides:
isLicensedin classMajorMicrospeciesAccessorPlugin- Returns:
trueif the plugin is licensed
-
getProductName
Returns the product identifier of the plugin as given byLicenseManager.- Specified by:
getProductNamein classCalculatorPlugin- Returns:
- The identifier
LicenseManager.HBDA_PLUGIN
-
setParameters
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:
setParametersin classMajorMicrospeciesAccessorPlugin- Parameters:
params- is the parameter table- Throws:
PluginException- on error
- type:
-
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 is0.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 is14.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 is0.5.- Parameters:
step- is the pH step- Since:
- Marvin 3.5.1
-
setMsCalc
public void setMsCalc(boolean mscalc) Sets microspecies calculation.- Parameters:
mscalc- istrueif microspecies calculation required- Since:
- Marvin 3.5.1
- See Also:
-
isMsCalc
public boolean isMsCalc()Returnstrueif microspecies calculation.- Overrides:
isMsCalcin classCalculatorPlugin- Returns:
trueif microspecies calculation
-
checkMolecule
Checks the input molecule. Throws exception if the molecule molecule contains R-groups.- Overrides:
checkMoleculein classMajorMicrospeciesAccessorPlugin- 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:
setInputMoleculein classCalculatorPlugin- Parameters:
mol- is the input molecule- Throws:
PluginException- on error
-
setExcludeSulfur
public void setExcludeSulfur(boolean e) Sets if sulfur atom should be excluded from hydrogen bond acceptors. Default:true- Parameters:
e- iftruethen 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- iftruethen halogens are not considered to be hydrogen bond acceptor.- Since:
- Marvin 5.3.2
-
run
Runs the charge calculation.- Specified by:
runin classCalculatorPlugin- Returns:
- true if the calculation was successful, false on calculation error
- Throws:
PluginException- on error- See Also:
-
getErrorMessage
Returns the calculation error information message ifrun()returned false (calculation error): hydrogen valence error.- Overrides:
getErrorMessagein classMajorMicrospeciesAccessorPlugin- Returns:
- the calculation error information message
-
getWarningMessage
Returns the calculation warning information message if no H-bond donor/acceptor atoms found, returns the empty string otherwise.- Overrides:
getWarningMessagein classCalculatorPlugin- 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 bygetpHs()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 bygetpHs()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()
-
getAcceptorCount
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public int getAcceptorCount(int index) Deprecated, for removal: This API element is subject to removal in a future version.UsegetAcceptorSiteCount()instead! -
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,
-1for H atoms
-
getDonorCount
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public int getDonorCount(int index) Deprecated, for removal: This API element is subject to removal in a future version.UsegetDonorSiteCount(int)instead! -
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,
-1for H atoms
-
getAcceptorCount
Deprecated, for removal: This API element is subject to removal in a future version.UsegetAcceptorSiteCount()instead. -
getAcceptorSiteCount
public int getAcceptorSiteCount()Returns the overall acceptor count (with multiplicity) in the molecule.- Returns:
- the overall acceptor count (with multiplicity) in the molecule
-
getDonorCount
Deprecated, for removal: This API element is subject to removal in a future version.UsegetDonorSiteCount()instead! -
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
-
getResultTypes
Returns the result types. The possible types are described insetParameters(Properties params).- Overrides:
getResultTypesin classCalculatorPlugin- Returns:
- the result types
-
setGUIMode
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) protected void setGUIMode(boolean guimode) Deprecated, for removal: This API element is subject to removal in a future version.No longer used.Sets GUI mode.- Parameters:
guimode- is true if GUI mode
-
getResultDomain
Returns the calculation domainCalculatorPlugin.ATOMorCalculatorPlugin.MOLECULE. HBDA returnsCalculatorPlugin.ATOMfor types "acc" and "don",CalculatorPlugin.MOLECULEfor types "accsitecount", "donsitecount", "acceptorcount", "donorcount", and returnsCalculatorPlugin.MOLECULEfor type "msacc" and "msdon".- Overrides:
getResultDomainin classCalculatorPlugin- Parameters:
type- is the result type- Returns:
- the domain as described above
- See Also:
-
getResultCount
Returns the number of result items for the given result type. Returns the atom count for types "acc" and "don",1otherwise.- Overrides:
getResultCountin classCalculatorPlugin- Parameters:
type- is the result type- Returns:
- the number of result items
- See Also:
-
getResult
Returns the result item for the specified type and index. HBDA returns the(pH, acceptor/donor count)arrays for types "msacceptor" and "msdonor" as adouble[2][]with the 0-th element being thepHarray and the 1-st element being theacceptor/donor countarray. For types "acc" and "don" HBDA returns theacceptor/donor countcorresponding to the specified atom index. For types "accsitecount" and "donsitecount" HBDA returns the sum of the atomic values. cc * @see #getResultTypes()- Overrides:
getResultin classCalculatorPlugin- 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:
-
getResultAsString
Returns the specified result in String format.- Overrides:
getResultAsStringin classCalculatorPlugin- Parameters:
type- is the result typeindex- is the result indexresult- is the result item- Returns:
- the specified result in String format
- Throws:
PluginException- if an invalid result item is given
-
getResultAsRGB
Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue). Returns "red" for acceptor "blue" for donor.- Overrides:
getResultAsRGBin classCalculatorPlugin- Parameters:
type- is the result typeindex- is the result indexresult- is the result item- Returns:
- the specified result in color as int
- Throws:
PluginException- if an invalid result item is given
-
getResultsAsRGB
Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue). Returns "red" for acceptor "blue" for donor.- Overrides:
getResultsAsRGBin classCalculatorPlugin- Parameters:
type- is the result typeindex- is the result indexresult- is the result item- Returns:
- the specified result in color as int
- Throws:
PluginException- if an invalid result item is given
-
getResultsAsString
Returns the specified result in GUI-specific String format:Afor acceptor,Dfor donor.- Overrides:
getResultsAsStringin classCalculatorPlugin- Parameters:
type- is the result typeindex- is the result indexresult- is the result item- Returns:
- the specified result in String format
- Throws:
PluginException- if an invalid result item is given
-
getTypeString
Returns a string representation of the given type.- Overrides:
getTypeStringin classCalculatorPlugin- Parameters:
type- is the type object- Returns:
- the type string
-
isNegligibleResult
Returns whether the result can be ignored. Returnstruefor microspecies acceptor/donor count belowEPSILON. Returnsfalsefor all other results.- Overrides:
isNegligibleResultin classCalculatorPlugin- Parameters:
type- is the result typeindex- is the result indexresult- is the result object- Returns:
- true for microspecies acceptor/donor count below
EPSILON - Throws:
PluginException
-
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:
getResultMoleculein classCalculatorPlugin- Returns:
- the result molecule
- Throws:
PluginException- on error- Since:
- Marvin 4.0
-
tags
Description copied from interface:TaggedCalculatorReturns the set of tags reported by this calculator. The same tags should be returned unless the calculator is modified using a mutator method, e.g. if some settings are changed.New tags can be introduced and reported in the future by existing calculators, so do not depend on the exact set of reported tags, only check for the presence of certain tags.
- Returns:
- the tags
-
getAcceptorSiteCount()instead.