Package chemaxon.marvin.plugin
Class CalculatorPlugin
- java.lang.Object
-
- chemaxon.marvin.plugin.CalculatorPlugin
-
- All Implemented Interfaces:
chemaxon.license.Licensable
- Direct Known Subclasses:
AlignmentPlugin
,ConformerPlugin
,ElementalAnalyserPlugin
,GeometryPlugin
,IonChargePlugin
,IsoelectricPointPlugin
,IUPACNamingPlugin
,logDPlugin
,logPPlugin
,MajorMicrospeciesAccessorPlugin
,MajorMicrospeciesPlugin
,MarkushEnumerationPlugin
,MolecularDynamicsPlugin
,pKaPlugin
,RefractivityPlugin
,ResonancePlugin
,StereoisomerPlugin
,StructuralFrameworksPlugin
,TautomerizationPlugin
,TopologyAnalyserPlugin
@PublicAPI public abstract class CalculatorPlugin extends Object implements chemaxon.license.Licensable
Common base class for calculator plugins. Provides a uniform framework for plugin calculations and calculation result queries.API usage examples:
- Charge calculation for one input molecule.
This example shows the general API usage. Plugin specific API usage examples
can be found in the specific plugin class headers.
// 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.
- Since:
- Marvin 3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
CalculatorPlugin.HydrogenData
-
Field Summary
Fields Modifier and Type Field Description 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 String
COVALENT_HYDRATION_ERROR_REMARK
Covalent hydration error remark.protected static 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 List<CalculatorPlugin.HydrogenData>
explicitHydrogens
explicit hydrogens of the input molecule stored here key: index of the "parent" atom on the input molecule value: the hydrogen atomprotected static String
INCORRECT_AROMATIC_NITROGEN_REMARK
Incorrect aromatic nitrogen remark.protected static String
INSTABLE_TAUTOMERIC_FORM_REMARK
Instable tautomeric form remark.protected static String
KEEP_HYDROGENS
protected boolean
keepHydrogens
protected String
licenseEnvironment
Member storing license environment.static int
MOLECULE
Calculation domain type: calculation refers to the molecule.static int
MOLECULES
Calculation domain type: calculation refers to multiple molecule output.protected static Double
NAN
Double constant forDouble.NaN
.static String
PLUGIN_CLASS_KEY
Plugin class key in manifest.static String
PLUGIN_DIR
The plugin directory (relative to CLASSPATH).static int
RED
Constant storing the red rgb value (the acidic pKa result color).protected static String
TRUE
-
Constructor Summary
Constructors Constructor Description CalculatorPlugin()
Constructor.CalculatorPlugin(Consumer<Molecule> sgExpander)
Constructor.CalculatorPlugin(Consumer<Molecule> sgExpander, Consumer<Molecule> sgContractor)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addHeavyAtomLimitChecker(int limit)
Creates an input checker by callingCalculatorInputChecker.heavyAtomLimit(int)
and adds it to this plugin.void
addInputChecker(CalculatorInputChecker checker)
Adds the specified input checker to this plugin.protected void
arrangeHydrogenIncerments(Molecule mol, int atomIndex, String label, double hydrogenIncrement)
boolean
canRepeat()
Returnstrue
if repeatedly running the same plugin object while getting the results on the GUI is allowed,false
otherwise.protected void
checkLicense()
void
checkMolecule(Molecule mol)
Checks the input molecule.protected void
checkType(String type, 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)
Returnstrue
if molecule contains pseudo atom.protected static boolean
containsSRUSgroup(Molecule mol)
Decides whether a molecule contains SRU S-groups.static CalculatorPlugin
create(String clname, 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.protected Molecule
createStandardizedMolecule(Molecule mol)
Creates standardized molecule, the original input molecule is cloned.protected Molecule
createStandardizedMolecule(Molecule mol, boolean om)
Deprecated.UsecreateStandardizedMolecule(Molecule)
insteadprotected static void
dehydrogenize(Molecule mol)
Deprecated.MoleculeGraph.implicitizeHydrogens(int)
with parameterMolAtom.ALL_H
does the same.String
format(double x)
Converts a double into String, applying the maximum number of fractional digits specified.String
format(double[][] t, int intlen)
Converts adouble[][]
2xN
table to a 2-column tab-separated string representation of the table.String
format(double x, int intlen)
Converts a double into String, applying the maximum number of fractional digits specified.StringBuffer
format(double x, 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.protected int[]
getAtomIndexMap()
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.String
getErrorMessage()
Returns the calculation error information message ifrun()
returnedfalse
(calculation error).protected List<CalculatorPlugin.HydrogenData>
getExplicitHydrogenData(Molecule cmol, int n)
int
getInputMolDim()
Returns the input molecule dimension.protected Molecule
getMainMolecule(Molecule mol)
Deprecated.UsecreateModifiedInputMolecule(Molecule)
insteadprotected Molecule
getOriginalMolecule()
double
getpH()
Returns the pH where the major microspecies should be taken.static URL
getPluginResource(String path)
Returns the plugin JAR as resource URL, given the JAR file path relatively to the "plugins" directory.abstract String
getProductName()
Returns the product identifier of the plugin as given byLicenseManager
.protected static String
getQueryMoleculeErrorMessage(Molecule mol)
String
getRemark()
Returns the calculation remark.Object
getResult(int index)
Returns the result item for the specified type and index.Object
getResult(Object type, int index)
Returns the result item for the specified type and index.Object
getResult(Object type, String arg)
Returns the result item for the specified argument string.Object
getResult(String arg)
Returns the result item for the specified argument string.int
getResultAsRGB(int index, Object result)
Returns the specified result color as int format (alpha<<24 + red<<16 + green<<8 + blue).int
getResultAsRGB(Object type, int index, Object result)
Returns the specified result color as int format (alpha<<24 + red<<16 + green<<8 + blue).String
getResultAsString(int index, Object result)
Returns the specified result in String format for the first result type.String
getResultAsString(Object type, int index, Object result)
Returns the specified result in String format.int
getResultCount()
Returns the number of result items for the first result type.int
getResultCount(Object type)
Returns the number of result items for the given result key.int
getResultDomain()
int
getResultDomain(Object type)
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, Object result)
Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue).long
getResultsAsRGB(Object type, int index, Object result)
Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue).String
getResultsAsString(int index, Object result)
Returns the specified result with possible subresults.String
getResultsAsString(Object type, int index, Object result)
Returns the specified result with possible subresults.chemaxon.marvin.plugin.PluginMDocSource
getResultSource()
Returns the result as a document source object.Object[]
getResultTypes()
Returns the result types.String
getTypeString(Object type)
Returns a string representation of the given type.String
getWarningMessage()
Returns the calculation warning information message.boolean
handlesMultiFragmentMolecules()
Returnstrue
if the plugin handles multifragment molecules,false
otherwise.boolean
isInputMoleculeAromatized()
Returnstrue
if the input molecule has aromatic bond.boolean
isLicensed()
Returnstrue
if the plugin is licensed.protected boolean
isMsCalc()
Returnstrue
if microspecies calculation.boolean
isMultiThreadedRunEnabled()
For internal use only.boolean
isNegligibleResult(Object type, int index, Object result)
Returns whether the result can be ignored.boolean
isOK()
Returnstrue
if no calculation error,false
on error.protected static boolean
isRgrouped(Molecule mol)
Returnstrue
if molecule with R-groups.Class
loadClass(String clname)
Loads a class, first tries from original CALSSPATH, then from the class loader used to load this plugin class.static String
readAttribute(String attribute, String jar)
Reads an attribute from JAR manifest.protected static String
removeWhitespace(String str)
Removes whitespace characters from the given string.protected boolean
restoreExplicitHydrogens(Molecule molecule)
When the input molecule is set, the explicit H-s may be storedsetMolecule(Molecule, boolean, boolean, boolean)
The parameter should be topologically equal to the input molecule for a successfull restore.abstract boolean
run()
Runs the tool.protected boolean
setAtomIndexMap(int[] map)
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(String pr)
Sets the precision in the decimal format.protected abstract void
setInputMolecule(Molecule mol)
Sets the input molecule.protected void
setKeepHydrogens(Properties properties)
void
setLicenseEnvironment(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.protected Molecule
setMolecule(Molecule mol, boolean st, boolean om, boolean storeExplicitHydrogens)
void
setParameters(Properties params)
Sets the input parameters for the plugin.void
setProgressMonitor(MProgressMonitor pmon)
Sets a progress observer to be used inrun()
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]
-
-
-
Field Detail
-
KEEP_HYDROGENS
protected static final String KEEP_HYDROGENS
- See Also:
- Constant Field Values
-
TRUE
protected static final String TRUE
- See Also:
- Constant Field Values
-
keepHydrogens
protected boolean keepHydrogens
-
PLUGIN_DIR
public static final String PLUGIN_DIR
The plugin directory (relative to CLASSPATH).- See Also:
- Constant Field Values
-
PLUGIN_CLASS_KEY
public static final String PLUGIN_CLASS_KEY
Plugin class key in manifest.- See Also:
- Constant Field Values
-
CRITICAL_ERROR_MSG
protected static final String CRITICAL_ERROR_MSG
Critical error message.- See Also:
- Constant Field Values
-
INCORRECT_AROMATIC_NITROGEN_REMARK
protected static final String INCORRECT_AROMATIC_NITROGEN_REMARK
Incorrect aromatic nitrogen remark.- See Also:
- Constant Field Values
-
INSTABLE_TAUTOMERIC_FORM_REMARK
protected static final String INSTABLE_TAUTOMERIC_FORM_REMARK
Instable tautomeric form remark.- See Also:
- Constant Field Values
-
COVALENT_HYDRATION_ERROR_REMARK
protected static final String COVALENT_HYDRATION_ERROR_REMARK
Covalent hydration error remark.- See Also:
- Constant Field Values
-
licenseEnvironment
protected String licenseEnvironment
Member storing license environment.
-
RED
public static final int RED
Constant storing the red rgb value (the acidic pKa result color).- See Also:
- Constant Field Values
-
BLUE
public static final int BLUE
Constant storing the blue rgb value (the basic pKa result color).- See Also:
- Constant Field Values
-
CALCRGB_OFF
protected static final int CALCRGB_OFF
Calculator rgb offset.- See Also:
- Constant Field Values
-
ATOM
public static final int ATOM
Calculation domain type: calculation refers to atoms.- See Also:
- Constant Field Values
-
MOLECULE
public static final int MOLECULE
Calculation domain type: calculation refers to the molecule.- See Also:
- Constant Field Values
-
MOLECULES
public static final int MOLECULES
Calculation domain type: calculation refers to multiple molecule output.- Since:
- Marvin 5.2
- See Also:
- Constant Field Values
-
NAN
protected static final Double NAN
Double constant forDouble.NaN
.
-
EPSILON
public static final double EPSILON
The microspecies is ignored if its distribution is less than EPSILON for all pH values.- See Also:
- Constant Field Values
-
explicitHydrogens
protected List<CalculatorPlugin.HydrogenData> explicitHydrogens
explicit hydrogens of the input molecule stored here key: index of the "parent" atom on the input molecule value: the hydrogen atom
-
-
Constructor Detail
-
CalculatorPlugin
public CalculatorPlugin()
Constructor. Initializes decimal format.
-
CalculatorPlugin
@Beta public CalculatorPlugin(Consumer<Molecule> sgExpander)
Constructor. This constructor is intended to be used only internally. Please note that this constuctor is annotated with theBeta
annotation, so it can be subject to incompatible changes or complete removal in any of the upcoming releases without further notification.- Parameters:
sgExpander
- Method to use to expand sgroups.
-
CalculatorPlugin
@Beta public CalculatorPlugin(Consumer<Molecule> sgExpander, Consumer<Molecule> sgContractor)
Constructor. This constructor is intended to be used only internally. Please note that this constuctor is annotated with theBeta
annotation, so it can be subject to incompatible changes or complete removal in any of the upcoming releases without further notification.- Parameters:
sgExpander
- Method to use to expand sgroups.sgContractor
- Method to use to contract sgroups.
-
-
Method Detail
-
getPluginResource
public static URL getPluginResource(String path)
Returns the plugin JAR as resource URL, given the JAR file path relatively to the "plugins" directory.- Parameters:
path
- is the relative jar file path- Returns:
- the corresponding resource URL
-
readAttribute
public static String readAttribute(String attribute, String jar) throws PluginException
Reads an attribute from JAR manifest.- Parameters:
attribute
- is the attribute namejar
- is the JAR file name- Returns:
- the attribute value, or
null
if not exists - Throws:
PluginException
- Since:
- Marvin 4.0
-
create
public static CalculatorPlugin create(String clname, String jar) throws PluginException
Loads a plugin, first tries to load it from CLASSPATH, then from JAR. If the plugin class name isnull
then it is read from the manifest attributePLUGIN_CLASS_KEY
.- Parameters:
clname
- is the plugin class namejar
- is the plugin JAR file name- Returns:
- the created plugin
- Throws:
PluginException
- Since:
- Marvin 4.0
-
loadClass
public final Class loadClass(String clname) throws PluginException
Loads a class, first tries from original CALSSPATH, then from the class loader used to load this plugin class.- Parameters:
clname
- is the class name- Returns:
- the Class object, or
null
if could not be loaded - Throws:
PluginException
- Since:
- Marvin 4.0
-
isRgrouped
protected static boolean isRgrouped(Molecule mol)
Returnstrue
if molecule with R-groups.- Parameters:
mol
- is the molecule- Returns:
- true if molecule with R-groups
-
containsPseudoAtom
protected static boolean containsPseudoAtom(Molecule mol)
Returnstrue
if molecule contains pseudo atom.- Parameters:
mol
- the molecule to examine- Returns:
true
if the molecule contains pseudo atom, false otherwise
-
containsMulticenterSgroup
protected static boolean containsMulticenterSgroup(Molecule mol)
Decides whether a molecule contains Multicenter S-groups.- Parameters:
mol
- the molecule to examine- Returns:
- true if the molecule contains at least one MulticenterSgroup false otherwise.
-
containsSRUSgroup
protected static boolean containsSRUSgroup(Molecule mol)
Decides whether a molecule contains SRU S-groups.- Parameters:
mol
- the molecule to examine- Returns:
- true if the molecule contains at least one SRU S-group false otherwise.
-
containsCoordinateBond
protected static boolean containsCoordinateBond(MoleculeGraph mol)
Decides whether a molecule graph contains coordinate bonds.- Parameters:
mol
- the molecule to examine- Returns:
- true if the molecule contains at least one coordinate bond false otherwise.
-
dehydrogenize
@Deprecated protected static void dehydrogenize(Molecule mol)
Deprecated.MoleculeGraph.implicitizeHydrogens(int)
with parameterMolAtom.ALL_H
does the same.Makes all explicit H-s implicit.- Parameters:
mol
- is the molecule
-
removeWhitespace
protected static String removeWhitespace(String str)
Removes whitespace characters from the given string.- Parameters:
str
- is the string- Returns:
- the string without whitespace characters
-
getDocument
public static MDocument getDocument(Molecule structure)
Returns encapsulating document, creates it if needed.- Parameters:
structure
- the molecule- Returns:
- the encapsulating document
- Since:
- Marvin 5.0
-
isLicensed
public boolean isLicensed()
Returnstrue
if the plugin is licensed. The license checking is based on the product name, returned bygetProductName()
.- Specified by:
isLicensed
in interfacechemaxon.license.Licensable
- Returns:
true
if the plugin is licensed
-
setLicenseEnvironment
public void setLicenseEnvironment(String env)
Sets license environment to be stored.- Specified by:
setLicenseEnvironment
in interfacechemaxon.license.Licensable
- Parameters:
env
- environment String to be stored and passed to the LicenseHandler in the isLicensed method
-
checkLicense
protected final void checkLicense()
-
getProductName
public abstract String getProductName()
Returns the product identifier of the plugin as given byLicenseManager
. The name is used by theisLicensed()
method.- Returns:
- product identifier or a default string
-
checkType
protected void checkType(String type, String[] typerange) throws PluginException
Checks result types.- Parameters:
type
- is the type given by the usertyperange
- is the array containing the valid types- Throws:
PluginException
- if the user-type is not contained in the type-range
-
getDoublePrecision
public final int getDoublePrecision()
Returns the precision. This is the max. number of fractional digits.- Returns:
- the precision
-
setDoublePrecision
protected final void setDoublePrecision(String pr)
Sets the precision in the decimal format. This is done according to the user defined precision value: 0..8 means maximal number of fractional digits, ending padded with zeros (e.g. 12.56 -> 12.5600 for precision 4). 'inf' means maximal number of digits set to 10, no padding zeros (e.g. 12.56 -> 12.56)- Parameters:
pr
- is the precision string ("0"..."8" or "inf")
-
setDoublePrecision
public final 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).- Parameters:
precision
- is the precision
-
setDoublePrecision
public final void setDoublePrecision(int precision, boolean pad)
Sets the double -> string conversion precision (maximal number of fraction digits).- Parameters:
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=true
-
format
public final String format(double x)
Converts a double into String, applying the maximum number of fractional digits specified.- Parameters:
x
- is the double value to be converted- Returns:
- the result as String
- See Also:
setDoublePrecision(int precision, boolean pad)
-
format
public final String format(double x, int intlen)
Converts a double into String, applying the maximum number of fractional digits specified. Adds leading spaces to ensure the given integral part length.- Parameters:
x
- is the double value to be convertedintlen
- is the required integral part length- Returns:
- the result as String
- See Also:
setDoublePrecision(int precision, boolean pad)
-
format
public final StringBuffer format(double x, StringBuffer s)
Converts a double into String, applying the maximum number of fractional digits specified. Appends the result to the specified StringBuffer.- Parameters:
x
- is the double value to be converteds
- is the StringBuffer to be used- Returns:
- the StringBuffer with the current item appended
- See Also:
setDoublePrecision(int precision, boolean pad)
-
format
public final String format(double[][] t, int intlen)
Converts adouble[][]
2xN
table to a 2-column tab-separated string representation of the table.- Parameters:
t
- is the tableintlen
- is the required integral part length- Returns:
- the string representation
-
setProgressMonitor
public void setProgressMonitor(MProgressMonitor pmon)
Sets a progress observer to be used inrun()
to display progress status. Short calculations may ignore the observer object. The default implementation does nothing.- Parameters:
pmon
- is the progress monitor, may benull
-
setMolecule
public final Molecule setMolecule(Molecule mol) throws PluginException
Sets the input molecule after standardization. Standardization includes plugin specific standardization (e.g. dehydrogenize, aromatize) and sgroup expansion. The input molecule is left unchanged (it is cloned for standardization).- Parameters:
mol
- is the input molecule- Returns:
- the molecule to be used for atom indexing
- Throws:
PluginException
- on error
-
setMolecule
public Molecule setMolecule(Molecule mol, boolean st) throws PluginException
Sets the input molecule after an optional standardization. Standardization includes plugin specific standardization (e.g. dehydrogenize, aromatize) and sgroup expansion. The input molecule is left unchanged (it is cloned if standardization is required).- Parameters:
mol
- is the input moleculest
- is true if standardization is required- Returns:
- the molecule to be used for atom indexing
- Throws:
PluginException
- on error
-
setMolecule
public Molecule setMolecule(Molecule mol, boolean st, boolean om) throws PluginException
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).- Parameters:
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- Returns:
- the molecule to be used for atom indexing
- Throws:
PluginException
- on error- See Also:
setInputMolecule(Molecule)
,createStandardizedMolecule(Molecule)
,createModifiedInputMolecule(Molecule)
-
setMolecule
protected Molecule setMolecule(Molecule mol, boolean st, boolean om, boolean storeExplicitHydrogens) throws PluginException
- Throws:
PluginException
-
setAtomIndexMap
protected boolean setAtomIndexMap(int[] map)
-
getAtomIndexMap
protected int[] getAtomIndexMap()
-
getExplicitHydrogenData
protected List<CalculatorPlugin.HydrogenData> getExplicitHydrogenData(Molecule cmol, int n)
-
createModifiedInputMolecule
protected Molecule createModifiedInputMolecule(Molecule mol) throws PluginException
Returns the modified input molecule (e.g. microspecies, major tautomeric form). This method is used for modifying the input molecule set bysetMolecule(Molecule)
before passing the molecule to the calulation withsetInputMolecule(Molecule)
method. The default implementation returns the input molecule itself.- Parameters:
mol
- is the input molecule- Returns:
- the modified input molecule
- Throws:
PluginException
-
getInputMolDim
public int getInputMolDim()
Returns the input molecule dimension.- Returns:
- the input molecule dimension
-
getCalcMolecule
public Molecule getCalcMolecule()
Returns the molecule used in the calculation. This can be a standardized and/or modified version (e.g. microspecies, major tautomeric form) of the input molecule. Standardized if parameter 'st' is set totrue
insetMolecule(chemaxon.struc.Molecule, boolean)
orsetMolecule(chemaxon.struc.Molecule, boolean, boolean)
. Input molecule is modified, if the plugin overrides thecreateModifiedInputMolecule(Molecule)
mehod.- Returns:
- the molecule used in the calculation
- Since:
- Marvin 4.1
-
createStandardizedMolecule
@Deprecated protected Molecule createStandardizedMolecule(Molecule mol, boolean om) throws PluginException
Deprecated.UsecreateStandardizedMolecule(Molecule)
insteadCreates standardized molecule, the original input molecule is cloned. IfhandlesMultiFragmentMolecules()
returnsfalse
then takes the largest fragment (measured by atom count). The cloned molecule is standardized bystandardize(Molecule)
. Sets theatomIndexMap
: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.- Parameters:
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- Returns:
- the standardized molecule
- Throws:
PluginException
- on error
-
createStandardizedMolecule
protected Molecule createStandardizedMolecule(Molecule mol) throws PluginException
Creates standardized molecule, the original input molecule is cloned. IfhandlesMultiFragmentMolecules()
returnsfalse
then takes the largest fragment (measured by atom count). The cloned molecule is standardized bystandardize(Molecule)
. Sets theatomIndexMap
: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.- Parameters:
mol
- is the input molecule- Returns:
- the standardized molecule
- Throws:
PluginException
- on error- Since:
- Marvin 5.0
-
getMainMolecule
@Deprecated protected Molecule getMainMolecule(Molecule mol) throws PluginException
Deprecated.UsecreateModifiedInputMolecule(Molecule)
insteadReturns the molecule form with largest distribution. Returns a microspecies with largest distribution on a given pH if pH is different fromDouble.NaN
, otherwise returns the input molecule itself. The default implementation returns the input molecule itself.- Parameters:
mol
- is the input molecule- Returns:
- the molecule form with largest distribution
- Throws:
PluginException
-
getDisplayMolecule
protected Molecule getDisplayMolecule() throws PluginException
Returns the molecule object to be used for GUI display. Plugins will add atom labels and/or molecule properties to display plugin results in the molecule. The default implementation returns the original molecule.- Returns:
- the molecule object to be used for GUI display
- Throws:
PluginException
- on error
-
handlesMultiFragmentMolecules
public boolean handlesMultiFragmentMolecules()
Returnstrue
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 returnsfalse
.- Returns:
- true if the plugin handles multifragment molecules, false otherwise
-
isMsCalc
protected boolean isMsCalc()
Returnstrue
if microspecies calculation. The default implementation returnsfalse
.- Returns:
false
-
setParameters
public void setParameters(Properties params) throws PluginException
Sets the input parameters for the plugin.- Parameters:
params
- is the parameter table- Throws:
PluginException
- on error
-
getpH
public double getpH()
Returns the pH where the major microspecies should be taken. ReturnsDouble.NaN
if no microspecies calculation required.- Returns:
- the pH where the major microspecies should be taken
or
Double.NaN
if no microspecies calculation
-
checkMolecule
public void checkMolecule(Molecule mol) throws PluginException
Checks the input molecule. Throws exception if the molecule is not accepted as input molecule, otherwise does nothing (simply returns). The default implementation refuses query molecules, molecules with SRU S-groups, molecules with multicenter S-groups and molecules with coordinate bonds.- Parameters:
mol
- is the input molecule- Throws:
PluginException
- with error message for the user if the molecule is refused
-
setInputMolecule
protected abstract void setInputMolecule(Molecule mol) throws PluginException
Sets the input molecule.- Parameters:
mol
- is the input molecule- Throws:
PluginException
- on error
-
run
public abstract boolean run() throws PluginException
Runs the tool.- Returns:
- true if the calculation was successful, false on calculation problems
- Throws:
PluginException
- on error- See Also:
getErrorMessage()
-
isOK
public boolean isOK()
Returnstrue
if no calculation error,false
on error. This is the same as the return value of the last call torun()
. The default implementation returnstrue
if bothgetErrorMessage()
andgetWarningMessage()
return the empty string.- Returns:
true
if no calculation error or warning- Since:
- Marvin 4.0
-
getErrorMessage
public String getErrorMessage()
Returns the calculation error information message ifrun()
returnedfalse
(calculation error). The default implementation returns the empty string.- Returns:
- the calculation error information message
-
getWarningMessage
public String getWarningMessage()
Returns the calculation warning information message. The default implementation returns the empty string.- Returns:
- the calculation warning information message
-
getResultMessage
public final String getResultMessage()
Returns the plugin calculation error message, error or warning.- Returns:
- the plugin calculation error message
-
getRemark
public String getRemark()
Returns the calculation remark. While in case of warning or error returned ingetErrorMessage()
orgetWarningMessage()
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 returnsnull
.- Returns:
- the calculation remark
-
getResultTypes
public Object[] getResultTypes()
Returns the result types. The default implementation returnsnull
.- Returns:
- the result types
-
getTypeString
public String getTypeString(Object type)
Returns a string representation of the given type. The default implementation returnstype.toString()
.- Parameters:
type
- is the type object- Returns:
- the type string
-
getResultDomain
public int getResultDomain(Object type)
Returns the calculation domainATOM
,MOLECULE
orMOLECULES
. The default implementation returnsMOLECULE
.- Parameters:
type
- is the result type- Returns:
- the calculation domain
- See Also:
getResultTypes()
-
canRepeat
public boolean canRepeat()
Returnstrue
if repeatedly running the same plugin object while getting the results on the GUI is allowed,false
otherwise. For internal use.- Returns:
true
if allowed,false
otherwise- Since:
- Marvin 5.2
-
getResultCount
public int getResultCount(Object type)
Returns the number of result items for the given result key. The default implementation returns1
.- 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. The default implementation returnsnull
.- Parameters:
type
- is the result typeindex
- is the result index- Returns:
- the result item for the specified type and index
- Throws:
PluginException
- if the result cannot be returned- See Also:
getResultTypes()
-
getResultAsString
public String getResultAsString(Object type, int index, Object result) throws PluginException
Returns the specified result in String format. The default implementation returnsnull
.- 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
-
getResultsAsString
public String getResultsAsString(Object type, int index, Object result) throws PluginException
Returns the specified result with possible subresults. (items separated by "|" characters) (e.g. both pKa values instead of the most significant pKa) in String format.- 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
public int getResultAsRGB(Object type, int index, Object result) throws PluginException
Returns the specified result color as int format (alpha<<24 + red<<16 + green<<8 + blue).- 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
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). (e.g. both pKa colors instead of the most significant pKa color) as long (lower and upper bits).- 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
-
isNegligibleResult
public boolean isNegligibleResult(Object type, int index, Object result) throws PluginException
Returns whether the result can be ignored. Can be used to filter out out-of range values. The default implementation returnsfalse
.- Parameters:
type
- is the result typeindex
- is the result indexresult
- is the result object- Returns:
- true if the result can be ignored
- Throws:
PluginException
-
getResult
public Object getResult(Object type, String arg) throws PluginException
Returns the result item for the specified argument string. The default implementation callsgetResult(Object, int)
with the argument string converted to an integer (result index).- Parameters:
type
- is the result typearg
- is the argument string- Returns:
- the result item for the specified type and argument string
- Throws:
PluginException
- if the result cannot be returned- See Also:
getResultTypes()
-
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 (Molecule.getProperty(String)
).- Returns:
- the result molecule
- Throws:
PluginException
- on error- Since:
- Marvin 4.0
-
getResultMolecules
public Molecule[] getResultMolecules() throws PluginException
Returns the result molecule array for display. The display of the molecules in array have to be implemented in a class derived from CalculatorPluginDispaly class (example: MultipleDataDisplay class). Atomic results are stored in atom extra labels (MolAtom.getExtraLabel()
). Molecular results are stored in molecule properties with keys being the result types (Molecule.getProperty(String)
).- Returns:
- the result molecule array
- Throws:
PluginException
- on error- Since:
- Marvin 4.1
-
getResultSource
public chemaxon.marvin.plugin.PluginMDocSource getResultSource() throws PluginException
Returns the result as a document source object. This is useful for displaying the molecules in a viewer dynamically as they become available instead of collecting all results before display. The default implementation returnsnull
.- Returns:
- the document source interface
- Throws:
PluginException
- on error- Since:
- Marvin 5.0
-
getResultDomain
public int getResultDomain()
- Returns:
- the calculation domain
-
getResultCount
public int getResultCount()
Returns the number of result items for the first result type.- Returns:
- the number of result items
- See Also:
getResultTypes()
-
getResult
public Object getResult(int index) throws PluginException
Returns the result item for the specified type and index. for the first result type.- Parameters:
index
- is the result index- Returns:
- the result item for the specified type and index
- Throws:
PluginException
- if the result cannot be returned- See Also:
getResultTypes()
-
getResult
public Object getResult(String arg) throws PluginException
Returns the result item for the specified argument string. The default implementation callsgetResult(Object, int)
with the argument string converted to an integer (result index) and with the first result type.- Parameters:
arg
- is the argument string- Returns:
- the result item for the first result type and the given argument string
- Throws:
PluginException
- if the result cannot be returned- See Also:
getResultTypes()
-
getResultAsString
public String getResultAsString(int index, Object result) throws PluginException
Returns the specified result in String format for the first result type.- Parameters:
index
- is the result indexresult
- is the result item- Returns:
- the specified result in String format
- Throws:
PluginException
- if an invalid result item is given
-
getResultsAsString
public String getResultsAsString(int index, Object result) throws PluginException
Returns the specified result with possible subresults. (items separated by "|" characters) (e.g. both pKa values instead of the most significant pKa) in String format.- Parameters:
index
- 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
public int getResultAsRGB(int index, Object result) throws PluginException
Returns the specified result color as int format (alpha<<24 + red<<16 + green<<8 + blue). for the first result type.- Parameters:
index
- is the result indexresult
- is the result item- Returns:
- the specified result in color as int format
- Throws:
PluginException
- if an invalid result item is given
-
getResultsAsRGB
public long getResultsAsRGB(int index, Object result) throws PluginException
Returns the specified result color(s) as int format (alpha<<24 + red<<16 + green<<8 + blue). (e.g. both pKa colors instead of the most significant pKa color) as long (lower and upper bits).- Parameters:
index
- 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
-
getAtomCount
public final int getAtomCount()
Returns the number of atoms in the input molecule.- Returns:
- the number of atoms in the input molecule
-
getAtomIndex
public final 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.- Parameters:
index
- is the atom index in the input molecule- Returns:
- the corresponding atom index in the standardized molecule, -1 if the atom has been removed
-
isInputMoleculeAromatized
public final boolean isInputMoleculeAromatized()
Returnstrue
if the input molecule has aromatic bond.- Returns:
true
if the input molecule has aromatic bond
-
standardize
public void standardize(Molecule mol)
Standardizes the molecule by performing the transformations necessary to run the plugin (aromatize, dehydrogenize, bring nitro groups to common form, ...). This implementation performs the following transformations:- aromatization
- nitro group transformation:
[O-:1][N+:2] >> [O:1]=[N:2]
,[NH1+:1][O-:2] >> [H:3][O:2][N:1]
- sulphynil group transformation:
[#6][S+:1]([#6])[#8-:2] >> [#6][S:1]([#6])=[O:2]
- Parameters:
mol
- is the molecule to be standardized
-
standardizeIonicGroups
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]
- Parameters:
mol
- is the molecule to be standardized
- nitro groups:
-
standardizeNeutralGroups
protected static void standardizeNeutralGroups(Molecule mol)
Neutral -> ionic standardization:- sulphynil group transformation:
[#6][S:1]([#6])=[O:2] >> [#6][S+:1]([#6])[#8-:2]
[O:1]=[N:2] >> [O-:1][N+:2]
,[H:3][O:2][N:1] >> [NH1+:1][O-:2]
- Parameters:
mol
- is the molecule to be standardized
- sulphynil group transformation:
-
isMultiThreadedRunEnabled
public boolean isMultiThreadedRunEnabled()
For internal use only.- Returns:
true
if multi-threaded run is enabled
-
restoreExplicitHydrogens
protected boolean restoreExplicitHydrogens(Molecule molecule)
When the input molecule is set, the explicit H-s may be storedsetMolecule(Molecule, boolean, boolean, boolean)
The parameter should be topologically equal to the input molecule for a successfull restore.- Parameters:
molecule
- the molecule to put the H-s on- Returns:
- true if the restore was successful, false otherwise
-
setKeepHydrogens
protected void setKeepHydrogens(Properties properties)
-
arrangeHydrogenIncerments
protected void arrangeHydrogenIncerments(Molecule mol, int atomIndex, String label, double hydrogenIncrement)
-
getOriginalMolecule
protected Molecule getOriginalMolecule()
-
addInputChecker
public void addInputChecker(CalculatorInputChecker checker)
Adds the specified input checker to this plugin. The checker will be called on the input molecule when it is passed to eithercheckMolecule(chemaxon.struc.Molecule)
orsetMolecule(chemaxon.struc.Molecule)
.
-
addHeavyAtomLimitChecker
public void addHeavyAtomLimitChecker(int limit)
Creates an input checker by callingCalculatorInputChecker.heavyAtomLimit(int)
and adds it to this plugin.
-
-