|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.marvin.plugin.CalculatorPlugin
public abstract class CalculatorPlugin
Common base class for calculator plugins. Provides a uniform framework for plugin calculations and calculation result queries.
API usage examples:
// fill parameters
Properties params = new Properties();
params.put("precision", "3");
params.put("type", "total,sigma");
// create plugin
ChargePlugin plugin = new ChargePlugin();
// set plugin parameters
plugin.setParameters(params);
// set target molecule
Molecule mol = MolImporter.importMol("Clc1cc(Cl)c(Cl)cc1");
plugin.setMolecule(mol);
// run the calculation
plugin.run();
// get the calculation results
Object[] types = plugin.getResultTypes(); // now this is {"total", "sigma"}
for (int i=0; i < types.length; ++i) {
Object type = types[i];
System.out.println();
System.out.println(type + " charge: ");
System.out.println("atom\tcharge");
int count = plugin.getResultCount(type); // now this is the atom count
for (int j=0; j < count; ++j) {
Object result = plugin.getResult(type, j); // now this is the charge value on atom j
String rtext = plugin.getResultAsString(type, j, result); // string representation
System.out.println((j+1)+"\t"+rtext);
}
}
For concurrent plugin example applications using ChemAxon's concurrent framework, refer to the Concurrent plugin examples.
| Field Summary | |
|---|---|
static int |
ATOM
Calculation domain type: calculation refers to atoms. |
static int |
BLUE
Constant storing the blue rgb value (the basic pKa result color). |
protected static int |
CALCRGB_OFF
Calculator rgb offset. |
protected static java.lang.String |
COVALENT_HYDRATION_ERROR_REMARK
Covalent hydration error remark. |
protected static java.lang.String |
CRITICAL_ERROR_MSG
Critical error message. |
static double |
EPSILON
The microspecies is ignored if its distribution is less than EPSILON for all pH values. |
protected static java.lang.String |
INCORRECT_AROMATIC_NITROGEN_REMARK
Incorrect aromatic nitrogen remark. |
protected static java.lang.String |
INSTABLE_TAUTOMERIC_FORM_REMARK
Instable tautomeric form remark. |
protected java.lang.String |
licenseEnvironment
Member storing license environment. |
static int |
MOLECULE
Calculation domain type: calculation refers to the molecule. |
protected static java.lang.Double |
NAN
Double constant for Double.NaN. |
static java.lang.String |
PLUGIN_CLASS_KEY
Plugin class key in manifest. |
static java.lang.String |
PLUGIN_DIR
The plugin directory (relative to CLASSPATH). |
static int |
RED
Constant storing the red rgb value (the acidic pKa result color). |
| Constructor Summary | |
|---|---|
CalculatorPlugin()
Constructor. |
|
| Method Summary | |
|---|---|
void |
checkMolecule(Molecule mol)
Checks the input molecule. |
protected void |
checkType(java.lang.String type,
java.lang.String[] typerange)
Checks result types. |
protected static boolean |
containsCoordinateBond(MoleculeGraph mol)
Decides whether a molecule graph contains coordinate bonds. |
protected static boolean |
containsMulticenterSgroup(Molecule mol)
Decides whether a molecule contains Multicenter S-groups. |
protected static boolean |
containsPseudoAtom(Molecule mol)
Returns true if molecule contains pseudo atom. |
protected static boolean |
containsSRUSgroup(Molecule mol)
Decides whether a molecule contains SRU S-groups. |
static CalculatorPlugin |
create(java.lang.String clname,
java.lang.String jar)
Loads a plugin, first tries to load it from CLASSPATH, then from JAR. |
protected Molecule |
createModifiedInputMolecule(Molecule mol)
Returns the modified input molecule (e.g. microspecies, major tautomeric form). |
protected Molecule |
createStandardizedMolecule(Molecule mol)
Creates standardized molecule, the original input molecule is cloned. |
protected Molecule |
createStandardizedMolecule(Molecule mol,
boolean om)
Deprecated. Use createStandardizedMolecule(Molecule) instead |
protected static void |
dehydrogenize(Molecule mol)
Makes all explicit H-s implicit. |
java.lang.String |
format(double x)
Converts a double into String, applying the maximum number of fractional digits specified. |
java.lang.String |
format(double[][] t,
int intlen)
Converts a double[][] 2xN table
to a 2-column tab-separated string representation of the table. |
java.lang.String |
format(double x,
int intlen)
Converts a double into String, applying the maximum number of fractional digits specified. |
java.lang.StringBuffer |
format(double x,
java.lang.StringBuffer s)
Converts a double into String, applying the maximum number of fractional digits specified. |
int |
getAtomCount()
Returns the number of atoms in the input molecule. |
int |
getAtomIndex(int index)
Returns the atom index in the standardized molecule, or the atom index itself if the input molecule has not been standardized. |
Molecule |
getCalcMolecule()
Returns the molecule used in the calculation. |
protected Molecule |
getDisplayMolecule()
Returns the molecule object to be used for GUI display. |
static MDocument |
getDocument(Molecule structure)
Returns encapsulating document, creates it if needed. |
int |
getDoublePrecision()
Returns the precision. |
java.lang.String |
getErrorMessage()
Returns the calculation error information message if run()
returned false (calculation error). |
int |
getInputMolDim()
Returns the input molecule dimension. |
protected Molecule |
getMainMolecule(Molecule mol)
Deprecated. Use createModifiedInputMolecule(Molecule) instead |
double |
getpH()
Returns the pH where the major microspecies should be taken. |
static java.net.URL |
getPluginResource(java.lang.String path)
Returns the plugin JAR as resource URL, given the JAR file path relatively to the "plugins" directory. |
java.lang.String |
getRemark()
Returns the calculation remark. |
java.lang.Object |
getResult(int index)
Returns the result item for the specified type and index. |
java.lang.Object |
getResult(java.lang.Object type,
int index)
Returns the result item for the specified type and index. |
java.lang.Object |
getResult(java.lang.Object type,
java.lang.String arg)
Returns the result item for the specified argument string. |
java.lang.Object |
getResult(java.lang.String arg)
Returns the result item for the specified argument string. |
int |
getResultAsRGB(int index,
java.lang.Object result)
Returns the specified result color as int format (alpha<<24 + red<<16 + green<<8 + blue). |
int |
getResultAsRGB(java.lang.Object type,
int index,
java.lang.Object result)
Returns the specified result color as int format (alpha<<24 + red<<16 + green<<8 + blue). |
java.lang.String |
getResultAsString(int index,
java.lang.Object result)
Returns the specified result in String format for the first result type. |
java.lang.String |
getResultAsString(java.lang.Object type,
int index,
java.lang.Object result)
Returns the specified result in String format. |
int |
getResultCount()
Returns the number of result items for the first result type. |
int |
getResultCount(java.lang.Object type)
Returns the number of result items for the given result key. |
int |
getResultDomain()
Returns the calculation domain ATOM or MOLECULE. |
int |
getResultDomain(java.lang.Object type)
Returns the calculation domain ATOM or MOLECULE. |
java.lang.String |
getResultMessage()
Returns the plugin calculation error message, error or warning. |
Molecule |
getResultMolecule()
Returns the result molecule for display. |
Molecule[] |
getResultMolecules()
Returns the result molecule array for display. |
long |
getResultsAsRGB(int index,
java.lang.Object result)
Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue). |
long |
getResultsAsRGB(java.lang.Object type,
int index,
java.lang.Object result)
Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue). |
java.lang.String |
getResultsAsString(int index,
java.lang.Object result)
Returns the specified result with possible subresults. |
java.lang.String |
getResultsAsString(java.lang.Object type,
int index,
java.lang.Object result)
Returns the specified result with possible subresults. |
chemaxon.marvin.plugin.PluginMDocSource |
getResultSource()
Returns the result as a document source object. |
java.lang.Object[] |
getResultTypes()
Returns the result types. |
java.lang.String |
getTypeString(java.lang.Object type)
Returns a string representation of the given type. |
java.lang.String |
getWarningMessage()
Returns the calculation warning information message. |
boolean |
handlesMultiFragmentMolecules()
Returns true if the plugin handles multifragment molecules,
false otherwise. |
boolean |
isInputMoleculeAromatized()
Returns true if the input molecule has aromatic bond. |
boolean |
isLicensed()
Returns true if the plugin is licensed. |
protected boolean |
isMsCalc()
Returns true if microspecies calculation. |
boolean |
isMultiThreadedRunEnabled()
For internal use only. |
boolean |
isNegligibleResult(java.lang.Object type,
int index,
java.lang.Object result)
Returns whether the result can be ignored. |
boolean |
isOK()
Returns true if no calculation error,
false on error. |
protected static boolean |
isRgrouped(Molecule mol)
Returns true if molecule with R-groups. |
java.lang.Class |
loadClass(java.lang.String clname)
Loads a class, first tries from original CALSSPATH, then from the class loader used to load this plugin class. |
static java.lang.String |
readAttribute(java.lang.String attribute,
java.lang.String jar)
Reads an attribute from JAR manifest. |
protected static java.lang.String |
removeWhitespace(java.lang.String str)
Removes whitespace characters from the given string. |
abstract boolean |
run()
Runs the tool. |
void |
setDoublePrecision(int precision)
Sets the double -> string conversion precision (maximal number of fraction digits) with zero-padding (12.56 -> 12.5600 if precision=4). |
void |
setDoublePrecision(int precision,
boolean pad)
Sets the double -> string conversion precision (maximal number of fraction digits). |
protected void |
setDoublePrecision(java.lang.String pr)
Sets the precision in the decimal format. |
protected abstract void |
setInputMolecule(Molecule mol)
Sets the input molecule. |
void |
setLicenseEnvironment(java.lang.String env)
Sets license environment to be stored. |
Molecule |
setMolecule(Molecule mol)
Sets the input molecule after standardization. |
Molecule |
setMolecule(Molecule mol,
boolean st)
Sets the input molecule after an optional standardization. |
Molecule |
setMolecule(Molecule mol,
boolean st,
boolean om)
Sets the input molecule after an optional standardization and/or modification. |
void |
setParameters(java.util.Properties params)
Sets the input parameters for the plugin. |
void |
setProgressMonitor(MProgressMonitor pmon)
Sets a progress observer to be used in run() to display progress status. |
void |
standardize(Molecule mol)
Standardizes the molecule by performing the transformations necessary to run the plugin (aromatize, dehydrogenize, bring nitro groups to common form, ...). |
protected static void |
standardizeIonicGroups(Molecule mol)
Default standardization: nitro groups: [O-:1][N+:2] >> [O:1]=[N:2], [NH1+:1][O-:2] >> [H:3][O:2][N:1]
sulphynil groups: [#6][S+:1]([#6])[#8-:2]>>[#6][S:1]([#6])=[O:2]
|
protected static void |
standardizeNeutralGroups(Molecule mol)
Neutral -> ionic standardization: [O:1]=[N:2] >> [O-:1][N+:2], [H:3][O:2][N:1] >> [NH1+:1][O-:2]
sulphynil group transformation: [#6][S:1]([#6])=[O:2] >> [#6][S+:1]([#6])[#8-:2]
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PLUGIN_DIR
public static final java.lang.String PLUGIN_CLASS_KEY
protected static final java.lang.String CRITICAL_ERROR_MSG
protected static final java.lang.String INCORRECT_AROMATIC_NITROGEN_REMARK
protected static final java.lang.String INSTABLE_TAUTOMERIC_FORM_REMARK
protected static final java.lang.String COVALENT_HYDRATION_ERROR_REMARK
protected java.lang.String licenseEnvironment
public static final int RED
public static final int BLUE
protected static final int CALCRGB_OFF
public static final int ATOM
public static final int MOLECULE
protected static final java.lang.Double NAN
Double.NaN.
public static final double EPSILON
| Constructor Detail |
|---|
public CalculatorPlugin()
| Method Detail |
|---|
public static java.net.URL getPluginResource(java.lang.String path)
path - is the relative jar file path
public static java.lang.String readAttribute(java.lang.String attribute,
java.lang.String jar)
throws PluginException
attribute - is the attribute namejar - is the JAR file name
null if not exists
PluginExceptionpublic static CalculatorPlugin create(java.lang.String clname, java.lang.String jar) throws PluginException
null then it is read from
the manifest attribute PLUGIN_CLASS_KEY.
clname - is the plugin class namejar - is the plugin JAR file name
PluginException
public final java.lang.Class loadClass(java.lang.String clname)
throws PluginException
clname - is the class name
null if could not be loaded
PluginExceptionprotected static boolean isRgrouped(Molecule mol)
true if molecule with R-groups.
mol - is the molecule
protected static boolean containsPseudoAtom(Molecule mol)
true if molecule contains pseudo atom.
mol - the molecule to examine
true if the molecule contains pseudo atom, false otherwiseprotected static boolean containsMulticenterSgroup(Molecule mol)
mol - the molecule to examine
protected static boolean containsSRUSgroup(Molecule mol)
mol - the molecule to examine
protected static boolean containsCoordinateBond(MoleculeGraph mol)
mol - the molecule to examine
protected static void dehydrogenize(Molecule mol)
mol - is the moleculeprotected static java.lang.String removeWhitespace(java.lang.String str)
str - is the string
public static MDocument getDocument(Molecule structure)
structure - the molecule
public boolean isLicensed()
true if the plugin is licensed. Implement this only if you want to sell your plugin and
protect it with a license key. The default implementation always returns true which means that
the plugin is free: no license key is required. This method returns only information about the licensing,
license checking has to be implemented separately.
isLicensed in interface chemaxon.license.Licensabletrue if the plugin is licensedpublic void setLicenseEnvironment(java.lang.String env)
setLicenseEnvironment in interface chemaxon.license.Licensableenv - environment String to be stored and passed to the LicenseHandler in the isLicensed method
protected void checkType(java.lang.String type,
java.lang.String[] typerange)
throws PluginException
type - is the type given by the usertyperange - is the array containing the valid types
PluginException - if the user-type is not contained in the type-rangepublic final int getDoublePrecision()
protected final void setDoublePrecision(java.lang.String pr)
pr - is the precision string ("0"..."8" or "inf")public final void setDoublePrecision(int precision)
precision - is the precision
public final void setDoublePrecision(int precision,
boolean pad)
precision - is the precisionpad - is true if fractional ending zeros should be printed
e.g. 12.56 -> 12.56 if precision=4, pad=false
12.56 -> 12.5600 if precision=4, pad=truepublic final java.lang.String format(double x)
x - is the double value to be converted
setDoublePrecision(int precision, boolean pad)
public final java.lang.String format(double x,
int intlen)
x - is the double value to be convertedintlen - is the required integral part length
setDoublePrecision(int precision, boolean pad)
public final java.lang.StringBuffer format(double x,
java.lang.StringBuffer s)
x - is the double value to be converteds - is the StringBuffer to be used
setDoublePrecision(int precision, boolean pad)
public final java.lang.String format(double[][] t,
int intlen)
double[][] 2xN table
to a 2-column tab-separated string representation of the table.
t - is the tableintlen - is the required integral part length
public void setProgressMonitor(MProgressMonitor pmon)
run() to display progress status.
Short calculations may ignore the observer object.
The default implementation does nothing.
pmon - is the progress monitor, may be nullpublic final Molecule setMolecule(Molecule mol) throws PluginException
mol - is the input molecule
PluginException - on errorpublic Molecule setMolecule(Molecule mol, boolean st) throws PluginException
mol - is the input moleculest - is true if standardization is required
PluginException - on errorpublic Molecule setMolecule(Molecule mol, boolean st, boolean om) throws PluginException
mol - is the input moleculest - is true if standardization is requiredom - is true if original input molecule is to be used for atom indexing
false if modified molecule is to be used for atom indexing
PluginException - on errorsetInputMolecule(Molecule),
createStandardizedMolecule(Molecule),
createModifiedInputMolecule(Molecule)protected Molecule createModifiedInputMolecule(Molecule mol) throws PluginException
setMolecule(Molecule)
before passing the molecule to the calulation with setInputMolecule(Molecule)
method.
The default implementation returns the input molecule itself.
mol - is the input molecule
PluginExceptionpublic int getInputMolDim()
public Molecule getCalcMolecule()
true in
setMolecule(chemaxon.struc.Molecule, boolean) or
setMolecule(chemaxon.struc.Molecule, boolean, boolean).
Input molecule is modified, if the plugin overrides the
createModifiedInputMolecule(Molecule) mehod.
protected Molecule createStandardizedMolecule(Molecule mol, boolean om) throws PluginException
createStandardizedMolecule(Molecule) instead
handlesMultiFragmentMolecules() returns false
then takes the largest fragment (measured by atom count).
The cloned molecule is standardized by standardize(Molecule).
Sets the atomIndexMap:
atomIndexMap[i] is the index in the standardized molecule
of the i-th atom in the original molecule or -1 if this atom has been removed.
mol - is the input moleculeom - is true if original input molecule is to be used for atom indexing
false if modified molecule is to be used for atom indexing
PluginException - on errorprotected Molecule createStandardizedMolecule(Molecule mol) throws PluginException
handlesMultiFragmentMolecules() returns false
then takes the largest fragment (measured by atom count).
The cloned molecule is standardized by standardize(Molecule).
Sets the atomIndexMap:
atomIndexMap[i] is the index in the standardized molecule
of the i-th atom in the original molecule or -1 if this atom has been removed.
mol - is the input molecule
PluginException - on errorprotected Molecule getMainMolecule(Molecule mol) throws PluginException
createModifiedInputMolecule(Molecule) instead
Double.NaN,
otherwise returns the input molecule itself.
The default implementation returns the input molecule itself.
mol - is the input molecule
PluginExceptionprotected Molecule getDisplayMolecule() throws PluginException
PluginException - on errorpublic 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.
The default implementation returns false.
protected boolean isMsCalc()
true if microspecies calculation.
The default implementation returns false.
false
public void setParameters(java.util.Properties params)
throws PluginException
params - is the parameter table
PluginException - on errorpublic double getpH()
Double.NaN if no microspecies calculation required.
Double.NaN if no microspecies calculationpublic void checkMolecule(Molecule mol) throws PluginException
mol - is the input molecule
PluginException - with error message for the user if the molecule is refusedprotected abstract void setInputMolecule(Molecule mol) throws PluginException
mol - is the input molecule
PluginException - on error
public abstract boolean run()
throws PluginException
PluginException - on errorgetErrorMessage()public boolean isOK()
true if no calculation error,
false on error. This is the same as
the return value of the last call to run().
The default implementation returns true
if both getErrorMessage() and getWarningMessage()
return the empty string.
true if no calculation error or warningpublic java.lang.String getErrorMessage()
run()
returned false (calculation error).
The default implementation returns the empty string.
public java.lang.String getWarningMessage()
public final java.lang.String getResultMessage()
public java.lang.String getRemark()
getErrorMessage()
or getWarningMessage() there is no calculation result,
in case of a remark the calculation can be performed although the
result may not be correct or precise - depending on the remark.
The default implementation returns null.
public java.lang.Object[] getResultTypes()
null.
public java.lang.String getTypeString(java.lang.Object type)
type.toString().
type - is the type object
public int getResultDomain(java.lang.Object type)
ATOM or MOLECULE.
The default implementation returns MOLECULE.
type - is the result type
getResultTypes()public int getResultCount(java.lang.Object type)
1.
type - is the result type
getResultTypes()
public java.lang.Object getResult(java.lang.Object type,
int index)
throws PluginException
null.
type - is the result typeindex - is the result index
PluginException - if the result cannot be returnedgetResultTypes()
public java.lang.String getResultAsString(java.lang.Object type,
int index,
java.lang.Object result)
throws PluginException
null.
type - is the result typeindex - is the result indexresult - is the result item
PluginException - if an invalid result item is given
public java.lang.String getResultsAsString(java.lang.Object type,
int index,
java.lang.Object result)
throws PluginException
type - is the result typeindex - is the result indexresult - is the result item
PluginException - if an invalid result item is given
public int getResultAsRGB(java.lang.Object type,
int index,
java.lang.Object result)
throws PluginException
type - is the result typeindex - is the result indexresult - is the result item
PluginException - if an invalid result item is given
public long getResultsAsRGB(java.lang.Object type,
int index,
java.lang.Object result)
throws PluginException
type - is the result typeindex - is the result indexresult - is the result item
PluginException - if an invalid result item is given
public boolean isNegligibleResult(java.lang.Object type,
int index,
java.lang.Object result)
throws PluginException
false.
type - is the result typeindex - is the result indexresult - is the result object
PluginException
public java.lang.Object getResult(java.lang.Object type,
java.lang.String arg)
throws PluginException
getResult(Object, int)
with the argument string converted to an integer (result index).
type - is the result typearg - is the argument string
PluginException - if the result cannot be returnedgetResultTypes()public Molecule getResultMolecule() throws PluginException
MolAtom.getExtraLabel()).
Molecular results are stored in molecule properties
with keys being the result types
(Molecule.getProperty(String)).
PluginException - on errorpublic Molecule[] getResultMolecules() throws PluginException
MolAtom.getExtraLabel()).
Molecular results are stored in molecule properties with keys being the
result types (Molecule.getProperty(String)).
PluginException - on error
public chemaxon.marvin.plugin.PluginMDocSource getResultSource()
throws PluginException
null.
PluginException - on errorpublic int getResultDomain()
ATOM or MOLECULE.
for the first result type.
public int getResultCount()
getResultTypes()
public java.lang.Object getResult(int index)
throws PluginException
index - is the result index
PluginException - if the result cannot be returnedgetResultTypes()
public java.lang.Object getResult(java.lang.String arg)
throws PluginException
getResult(Object, int)
with the argument string converted to an integer (result index)
and with the first result type.
arg - is the argument string
PluginException - if the result cannot be returnedgetResultTypes()
public java.lang.String getResultAsString(int index,
java.lang.Object result)
throws PluginException
index - is the result indexresult - is the result item
PluginException - if an invalid result item is given
public java.lang.String getResultsAsString(int index,
java.lang.Object result)
throws PluginException
index - is the result indexresult - is the result item
PluginException - if an invalid result item is given
public int getResultAsRGB(int index,
java.lang.Object result)
throws PluginException
index - is the result indexresult - is the result item
PluginException - if an invalid result item is given
public long getResultsAsRGB(int index,
java.lang.Object result)
throws PluginException
index - is the result indexresult - is the result item
PluginException - if an invalid result item is givenpublic final int getAtomCount()
public final int getAtomIndex(int index)
index - is the atom index in the input molecule
public final boolean isInputMoleculeAromatized()
true if the input molecule has aromatic bond.
true if the input molecule has aromatic bondpublic void standardize(Molecule mol)
[O-:1][N+:2] >> [O:1]=[N:2], [NH1+:1][O-:2] >> [H:3][O:2][N:1]
[#6][S+:1]([#6])[#8-:2] >> [#6][S:1]([#6])=[O:2]
mol - is the molecule to be standardizedprotected static void standardizeIonicGroups(Molecule mol)
[O-:1][N+:2] >> [O:1]=[N:2], [NH1+:1][O-:2] >> [H:3][O:2][N:1]
[#6][S+:1]([#6])[#8-:2]>>[#6][S:1]([#6])=[O:2]
mol - is the molecule to be standardizedprotected static void standardizeNeutralGroups(Molecule mol)
[O:1]=[N:2] >> [O-:1][N+:2], [H:3][O:2][N:1] >> [NH1+:1][O-:2]
[#6][S:1]([#6])=[O:2] >> [#6][S+:1]([#6])[#8-:2]
mol - is the molecule to be standardizedpublic boolean isMultiThreadedRunEnabled()
true if multi-threaded run is enabled
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||