public class MarkushEnumerationPlugin extends CalculatorPlugin
Note: Enumeration does not consider R-Logic conditions.
API usage examples:
// Create plugin
MarkushEnumerationPlugin plugin = new MarkushEnumerationPlugin();
// Set target molecule
plugin.setMolecule(mol);
// Run the calculation
plugin.run();
// 1. Get results one by one
Molecule m = plugin.getNextStructure();
while (m != null) {
System.out.println(m.toFormat("smiles"));
// ...
// Getting next enumerated molecule
m = plugin.getNextStructure();
}
// OR
// 2. Get results in an array
long size = plugin.getStructureCount();
if (size != -1 && size <= Integer.MAX_VALUE) {
Molecule[] enumerated = plugin.getStructures();
for (int i = 0; i < enumerated.length; i++) {
System.out.println(enumerated[i].toFormat("smiles"));
// ...
}
}
// Create plugin
MarkushEnumerationPlugin plugin = new MarkushEnumerationPlugin();
// Set random enumeration
plugin.setRandomEnumeration();
// Set the number of random structures to generate
plugin.setMaxStructureCount(10);
// Set target molecule
plugin.setMolecule(mol);
// Run the calculation
plugin.run();
for (int i = 0; i < 10; i++) {
Molecule m = plugin.getNextStructure();
System.out.println(m.toFormat("smiles"));
// ...
}
For concurrent plugin example applications using ChemAxon's concurrent framework, refer to the Concurrent plugin examples.
CalculatorPlugin.HydrogenData| Modifier and Type | Field and Description |
|---|---|
static int |
COLORING_ALL
Constant for setting all coloring options, currently scaffold and R-groups.
|
static int |
COLORING_NONE
Constant for no hit coloring.
|
static int |
COLORING_RGROUPS
Constant for R-group coloring.
|
static int |
COLORING_SCAFFOLD
Constant for scaffold coloring.
|
static MolFilter |
FILTER_VALENCE
Filter constant: valence filter.
|
ATOM, BLUE, CALCRGB_OFF, COVALENT_HYDRATION_ERROR_REMARK, CRITICAL_ERROR_MSG, EPSILON, explicitHydrogens, INCORRECT_AROMATIC_NITROGEN_REMARK, INSTABLE_TAUTOMERIC_FORM_REMARK, KEEP_HYDROGENS, keepHydrogens, licenseEnvironment, MOLECULE, MOLECULES, NAN, PLUGIN_CLASS_KEY, PLUGIN_DIR, RED, TRUE| Constructor and Description |
|---|
MarkushEnumerationPlugin()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkMolecule(Molecule mol)
Checks the input molecule.
|
BigInteger |
countEnumerations()
Returns the number of all enumerated structures,
no arithmetic overflow because counts in
BigInteger. |
int |
countEnumerationsMagnitude()
Returns the magnitude (the number of decimal "digits")
of the number of all enumerated structures.
|
boolean |
getAlignScaffold()
Gets the scaffold aligning mode
|
Molecule[] |
getAromatizedStructures()
Returns the enumerated structures in aromatized form.
|
int |
getColoring()
Returns the hit coloring options.
|
boolean |
getEnumCodeNeeded()
Tests whether unique Markush enumeration code
should be generated
|
String |
getLibrarySizeString()
Returns the display string representation of the Markush library size (number of all enumerated structures).
|
int |
getLimitedStructureCount()
Returns the number of structures to be generated.
|
Molecule |
getNextAromatizedStructure()
Returns the next enumerated structure.
|
Molecule |
getNextStructure()
Returns the next enumerated structure, or
null if no more structures. |
String |
getProductName()
Returns the product identifier of the plugin as given by
LicenseManager. |
String |
getRemark()
Returns a warning message in case of arithmetical overflow
(the number of enumerated structures exceeds
Long.MAX_VALUE), null otherwise. |
Object |
getResult(Object type,
int index)
Returns the result item for the specified key and index.
|
Object |
getResult(Object type,
String arg)
Returns the enumerated structures.
|
String |
getResultAsString(Object type,
int index,
Object result)
Returns the specified result in String format.
|
int |
getResultCount(Object type)
Returns the number of result items for the given result key.
|
int |
getResultDomain(Object type)
Returns the calculation domain.
|
Molecule |
getResultMolecule()
Returns the result molecule for display.
|
chemaxon.marvin.plugin.PluginMDocSource |
getResultSource()
Returns the result as a document source object.
|
Object[] |
getResultTypes()
Returns the result types.
|
long |
getStructureCount()
Returns the number of all enumerated structures,
-1 in case of arithmetical overflow
(if the number would exceed Long.MAX_VALUE). |
String |
getStructureID()
Returns the structure ID used in Markush code (enumeration ID) generation.
|
Molecule[] |
getStructures()
Returns the enumerated structures.
|
String |
getTypeString(Object type)
Returns a string representation of the given type.
|
boolean |
handlesMultiFragmentMolecules()
Returns
true if the plugin handles multifragment molecules, false otherwise. |
boolean |
hasMoreStructures()
Returns
true if there are more structures. |
boolean |
isApproximateCount()
Returns
true if count is approximate due to multiple position bonds with
multicenters of variable size, false otherwise. |
protected boolean |
isCleanNeeded()
Returns
true if clean is needed for GUI display. |
protected boolean |
isFiltered()
Return
true if molecule filter is set. |
boolean |
isHomologyEnumerated()
Indicates if homology groups are enumerated or not.
|
boolean |
isLicensed()
Returns
true if the plugin is licensed. |
boolean |
isRandomEnumeration()
Returns
true if random enumeration is requested. |
boolean |
run()
Creates enumerated structures.
|
void |
setAlignScaffold(boolean value)
Sets the scaffold aligning mode.
|
void |
setColoring(int coloring)
Sets hit coloring options.
|
void |
setEnumCodeNeeded(boolean value)
Indicates whether unique Markush enumeration code
should be generated.
|
void |
setEnumerateHomology(boolean enumerate)
Sets if homology groups should be enumerated or not.
|
void |
setFilter(MolFilter filter)
Sets the molecule filter.
|
protected void |
setInputMolecule(Molecule mol)
Sets the input molecule.
|
void |
setLicenseEnvironment(String env)
Sets license environment to be stored.
|
void |
setMaxStructureCount(long max)
Sets the maximum number of structures to be generated.
|
protected Molecule |
setMolecule(Molecule mol,
boolean st,
boolean om,
boolean storeExplicitHydrogens) |
void |
setParameters(Properties params)
Sets the input parameters for the plugin.
|
void |
setRandomEnumeration()
Sets random enumeration.
|
void |
setStructureID(String id)
Sets structure ID to be used in Markush code generation.
|
arrangeHydrogenIncerments, canRepeat, checkLicense, checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, createModifiedInputMolecule, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getAtomIndexMap, getCalcMolecule, getDisplayMolecule, getDocument, getDoublePrecision, getErrorMessage, getExplicitHydrogenData, getInputMolDim, getMainMolecule, getOriginalMolecule, getpH, getPluginResource, getQueryMoleculeErrorMessage, getResult, getResult, getResultAsRGB, getResultAsRGB, getResultAsString, getResultCount, getResultDomain, getResultMessage, getResultMolecules, getResultsAsRGB, getResultsAsRGB, getResultsAsString, getResultsAsString, getWarningMessage, isInputMoleculeAromatized, isMsCalc, isMultiThreadedRunEnabled, isNegligibleResult, isOK, isRgrouped, loadClass, readAttribute, removeWhitespace, restoreExplicitHydrogens, setAtomIndexMap, setDoublePrecision, setDoublePrecision, setDoublePrecision, setKeepHydrogens, setMolecule, setMolecule, setMolecule, setProgressMonitor, standardize, standardizeIonicGroups, standardizeNeutralGroupspublic static final MolFilter FILTER_VALENCE
setFilter(chemaxon.util.MolFilter) in order to reject molecules with valence errors.setFilter(chemaxon.util.MolFilter)public static final int COLORING_NONE
public static final int COLORING_SCAFFOLD
public static final int COLORING_RGROUPS
public static final int COLORING_ALL
public boolean isLicensed()
CalculatorPlugintrue if the plugin is licensed. The license checking
is based on the product name, returned by CalculatorPlugin.getProductName().isLicensed in interface chemaxon.license.LicensableisLicensed in class CalculatorPlugintrue if the plugin is licensedpublic void setLicenseEnvironment(String env)
CalculatorPluginsetLicenseEnvironment in interface chemaxon.license.LicensablesetLicenseEnvironment in class CalculatorPluginenv - environment String to be stored and passed to the LicenseHandler in the isLicensed methodpublic String getProductName()
LicenseManager.getProductName in class CalculatorPluginLicenseManager.MARKUSH_ENUM_PLUGINpublic 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.
Returns true if parameter "single" is set to "false", false otherwise (default:
false).handlesMultiFragmentMolecules in class CalculatorPluginpublic void setParameters(Properties params) throws PluginException
setParameters in class CalculatorPluginparams - is the parameter tablePluginException - on errorpublic void setRandomEnumeration()
CalculatorPlugin.setMolecule(chemaxon.struc.Molecule).
Set also the number of requested structures in setMaxStructureCount(long),
otherwise only one randomly enumerated structure will be generated.public boolean isRandomEnumeration()
true if random enumeration is requested.true if random enumeration is requestedpublic void setEnumerateHomology(boolean enumerate)
public boolean isHomologyEnumerated()
public void setEnumCodeNeeded(boolean value)
value - true, if code generation is neededpublic boolean getEnumCodeNeeded()
public void setStructureID(String id)
null for no structure ID (default).
Calling this method with non-null argument will automatically switch on
Markush code generation.id - the tag name or the IDsetEnumCodeNeeded(boolean)public String getStructureID()
setStructureID(java.lang.String)public void setFilter(MolFilter filter)
null (get all enumerated structures).filter - the molecule filter or null for no filteringMolFilter,
FILTER_VALENCEprotected boolean isFiltered()
true if molecule filter is set.true if molecule filter is setpublic boolean isApproximateCount()
throws PluginException
true if count is approximate due to multiple position bonds with
multicenters of variable size, false otherwise.true if count is approximatePluginExceptionpublic void setMaxStructureCount(long max)
-1 for unlimited.
Default: unlimited for the sequential case, 1 for the random case.
Must be called before setting the molecule
in CalculatorPlugin.setMolecule(chemaxon.struc.Molecule).max - is the maximum number of structures to be generatedsetRandomEnumeration()public void setAlignScaffold(boolean value)
CalculatorPlugin.setMolecule(chemaxon.struc.Molecule).value - if true, tries to align scaffold in enumerated structures
as it was in the original Markush structurepublic boolean getAlignScaffold()
public void setColoring(int coloring)
CalculatorPlugin.setMolecule(chemaxon.struc.Molecule).coloring - COLORING_SCAFFOLD, COLORING_RGROUPS, COLORING_NONE, or
COLORING_ALLpublic int getColoring()
COLORING_NONE,
COLORING_SCAFFOLD,
COLORING_RGROUPS,
COLORING_ALLprotected boolean isCleanNeeded()
true if clean is needed for GUI display.true if clean is needed for GUI displaypublic void checkMolecule(Molecule mol) throws PluginException
checkMolecule in class CalculatorPluginmol - is the input moleculePluginException - with error message for the user if the molecule is refusedprotected Molecule setMolecule(Molecule mol, boolean st, boolean om, boolean storeExplicitHydrogens) throws PluginException
setMolecule in class CalculatorPluginPluginExceptionprotected void setInputMolecule(Molecule mol) throws PluginException
setInputMolecule in class CalculatorPluginmol - is the input moleculePluginException - on errorpublic boolean run()
throws PluginException
run in class CalculatorPlugintruePluginException - on errorCalculatorPlugin.getErrorMessage()public BigInteger countEnumerations() throws PluginException
BigInteger.
In case when the result does not exceed Long.MAX_VALUE, the number of enumerates is also
returned by getStructureCount() (after run() is called).
Note: run() need not be called before using this function.
PluginException - on expansion errorgetLimitedStructureCount(),
getStructureCount(),
countEnumerationsMagnitude()public int countEnumerationsMagnitude()
throws PluginException
BigInteger.
Note: run() need not be called before using this function.
PluginException - on expansion errorgetLimitedStructureCount(),
getStructureCount(),
countEnumerations()public long getStructureCount()
-1 in case of arithmetical overflow
(if the number would exceed Long.MAX_VALUE).
To handle the case of arithmetical overflow, call countEnumerations() or
countEnumerationsMagnitude().
Returns the number of structures to be returned in case of random enumeration.
Warning: run() must be called before using this function.
setRandomEnumeration(),
setMaxStructureCount(long),
getLimitedStructureCount(),
countEnumerations(),
countEnumerationsMagnitude()public int getLimitedStructureCount()
getStructureCount() and the specified
maximum (see setMaxStructureCount(long)).
Returns the number of structures to be returned in case of random enumeration.setRandomEnumeration(),
setMaxStructureCount(long),
getStructureCount()public boolean hasMoreStructures()
true if there are more structures.true if there are more structurespublic Molecule getNextStructure()
null if no more structures.public Molecule getNextAromatizedStructure()
public Molecule[] getStructures() throws PluginException
PluginException - if too many structurespublic Molecule[] getAromatizedStructures() throws PluginException
PluginException - if too many structurespublic chemaxon.marvin.plugin.PluginMDocSource getResultSource()
throws PluginException
getResultSource in class CalculatorPluginPluginException - on errorpublic Object[] getResultTypes()
getResultTypes in class CalculatorPluginpublic int getResultDomain(Object type)
getResultDomain in class CalculatorPlugintype - is the result typegetResultTypes()public int getResultCount(Object type)
getResultCount in class CalculatorPlugintype - is the result typegetResultTypes()public String getTypeString(Object type)
getTypeString in class CalculatorPlugintype - is the type objectpublic Object getResult(Object type, int index) throws PluginException
getResult in class CalculatorPlugintype - is the result typeindex - is the result indexPluginException - if the result cannot be returnedCalculatorPlugin.getResultTypes()public Object getResult(Object type, String arg) throws PluginException
getResult in class CalculatorPlugintype - is the result type ("structures")arg - is the atom string as a '-'-separated listPluginException - on errorCalculatorPlugin.getResultTypes()public String getResultAsString(Object type, int index, Object result) throws PluginException
getResultAsString in class CalculatorPlugintype - is the result typeindex - is the result indexresult - is the result itemPluginException - if an invalid result item is givenpublic String getRemark()
Long.MAX_VALUE), null otherwise.getRemark in class CalculatorPluginpublic String getLibrarySizeString() throws PluginException
" (~ 10^x)" for larger values;
and only "~ 10^x" for the largest values.
If the count is approximate, then the returned string always starts with
"~".
No arithmetic overflow can occur because counts in BigInteger.
Note: run() need not be called before using this function.
null in case of random enumeration.PluginException - on expansion errorcountEnumerations(),
countEnumerationsMagnitude()public Molecule getResultMolecule() throws PluginException
MolAtom.getExtraLabel()).
Molecular results are stored in molecule properties
with keys being the result types
(Molecule.getProperty(String)).getResultMolecule in class CalculatorPluginPluginException - on error