Package chemaxon.marvin.calculations
Class MarkushEnumerationPlugin
java.lang.Object
chemaxon.marvin.plugin.CalculatorPlugin
chemaxon.marvin.calculations.MarkushEnumerationPlugin
- All Implemented Interfaces:
TaggedCalculator
,chemaxon.license.Licensable
Plugin class for enumerating Markush molecules.
Input: a Markush structure.
Output: the number of possible enumerations and the enumerated molecules.
Input: a Markush structure.
Output: the number of possible enumerations and the enumerated molecules.
Note: Enumeration does not consider R-Logic conditions.
API usage examples:
- Sequential enumeration:
// 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")); // ... } }
- Random enumeration:
// 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.
- Since:
- Marvin 5.0.3
-
Nested Class Summary
Nested classes/interfaces inherited from class chemaxon.marvin.plugin.CalculatorPlugin
CalculatorPlugin.HydrogenData
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Constant for setting all coloring options, currently scaffold and R-groups.static final int
Constant for no hit coloring.static final int
Constant for R-group coloring.static final int
Constant for scaffold coloring.static final MolFilter
Filter constant: valence filter.Fields inherited from class chemaxon.marvin.plugin.CalculatorPlugin
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checkMolecule
(Molecule mol) Checks the input molecule.Returns the number of all enumerated structures, no arithmetic overflow because counts inBigInteger
.int
Returns the magnitude (the number of decimal "digits") of the number of all enumerated structures.boolean
Gets the scaffold aligning modeMolecule[]
Returns the enumerated structures in aromatized form.int
Returns the hit coloring options.boolean
Tests whether unique Markush enumeration code should be generatedReturns the display string representation of the Markush library size (number of all enumerated structures).int
Returns the number of structures to be generated.Returns the next enumerated structure.Returns the next enumerated structure, ornull
if no more structures.Returns the product identifier of the plugin as given byLicenseManager
.Returns a warning message in case of arithmetical overflow (the number of enumerated structures exceedsLong.MAX_VALUE
),null
otherwise.Returns the result item for the specified key and index.Deprecated, for removal: This API element is subject to removal in a future version.Some implementations of this method modify the state of the plugin, which is a very confusing behavior, so the method is now deprecated and should no longer be used.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.Returns the result molecule for display.Returns the result as a document source object.Object[]
Returns the result types.long
Returns the number of all enumerated structures,-1
in case of arithmetical overflow (if the number would exceedLong.MAX_VALUE
).Returns the structure ID used in Markush code (enumeration ID) generation.Molecule[]
Returns the enumerated structures.getTypeString
(Object type) Returns a string representation of the given type.boolean
Returnstrue
if the plugin handles multifragment molecules,false
otherwise.boolean
Returnstrue
if there are more structures.boolean
Returnstrue
if count is approximate due to multiple position bonds with multicenters of variable size,false
otherwise.boolean
Returnstrue
if clean is needed for GUI display.boolean
Returntrue
if molecule filter is set.boolean
Indicates if homology groups are enumerated or not.boolean
Returnstrue
if the plugin is licensed.boolean
Returnstrue
if random enumeration is requested.boolean
run()
Creates enumerated structures.void
setAlignScaffold
(boolean value) Sets the scaffold aligning mode.protected void
Deprecated.For internal use only.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
Sets the molecule filter.protected void
setInputMolecule
(Molecule mol) Sets the input molecule.void
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
Sets random enumeration.void
setRandomSeed
(long seed) Sets the random seed to be used in case of random enumeration.void
setStructureID
(String id) Sets structure ID to be used in Markush code generation.Methods inherited from class chemaxon.marvin.plugin.CalculatorPlugin
addHeavyAtomLimitChecker, addInputChecker, arrangeHydrogenIncerments, canRepeat, checkLicense, checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, create, createModifiedInputMolecule, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getAtomIndexMap, getAtomIndexMapping, 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, loadPluginClass, loadPluginClass, readAttribute, removeWhitespace, restoreExplicitHydrogens, setAtomIndexMap, setChemicalTermsParameters, setDoublePrecision, setDoublePrecision, setDoublePrecision, setKeepHydrogens, setMolecule, setMolecule, setMolecule, setProgressMonitor, standardize, standardizeIonicGroups
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface chemaxon.calculator.TaggedCalculator
tags
-
Field Details
-
FILTER_VALENCE
Filter constant: valence filter. Set this filter insetFilter(chemaxon.util.MolFilter)
in order to reject molecules with valence errors.- Since:
- Marvin 5.1
- See Also:
-
COLORING_NONE
public static final int COLORING_NONEConstant for no hit coloring.- Since:
- Marvin 5.1
- See Also:
-
COLORING_SCAFFOLD
public static final int COLORING_SCAFFOLDConstant for scaffold coloring.- Since:
- Marvin 5.1
- See Also:
-
COLORING_RGROUPS
public static final int COLORING_RGROUPSConstant for R-group coloring.- Since:
- Marvin 5.1
- See Also:
-
COLORING_ALL
public static final int COLORING_ALLConstant for setting all coloring options, currently scaffold and R-groups.- Since:
- Marvin 5.1
- See Also:
-
-
Constructor Details
-
MarkushEnumerationPlugin
public MarkushEnumerationPlugin()Constructor.
-
-
Method Details
-
isLicensed
public boolean isLicensed()Description copied from class:CalculatorPlugin
Returnstrue
if the plugin is licensed. The license checking is based on the product name, returned byCalculatorPlugin.getProductName()
.- Specified by:
isLicensed
in interfacechemaxon.license.Licensable
- Overrides:
isLicensed
in classCalculatorPlugin
- Returns:
true
if the plugin is licensed
-
setLicenseEnvironment
Description copied from class:CalculatorPlugin
Sets license environment to be stored.- Specified by:
setLicenseEnvironment
in interfacechemaxon.license.Licensable
- Overrides:
setLicenseEnvironment
in classCalculatorPlugin
- Parameters:
env
- environment String to be stored and passed to the LicenseHandler in the isLicensed method
-
getProductName
Returns the product identifier of the plugin as given byLicenseManager
.- Specified by:
getProductName
in classCalculatorPlugin
- Returns:
- The identifier
LicenseManager.MARKUSH_ENUM_PLUGIN
-
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. Returnstrue
if parameter "single" is set to "false",false
otherwise (default:false
).- Overrides:
handlesMultiFragmentMolecules
in classCalculatorPlugin
- Returns:
- true if the plugin handles multifragment molecules, false otherwise
-
setParameters
Sets the input parameters for the plugin. Enumeration parameters and value ranges:- type: structure,structures,count
- calctype: enumerate,random
- mode: count mode (small, large, magnitude or string, default: small)
- max: max structure count
- atoms: 1-based atom indexes to be enumerated (','-separated list)
- code: true if Markush code should be generated (default: false)
- valencecheck: true if valence filter is on (default: false)
- alignscaffold: true if scaffold alignment is set (default: false)
- coloring: "scaffold", "rgroups", "none" or "all" (default: "none")
- Overrides:
setParameters
in classCalculatorPlugin
- Parameters:
params
- is the parameter table- Throws:
PluginException
- on error
-
setChemicalTermsArgument
Deprecated.For internal use only.Sets the argument string as specified in Chemical Terms expressions.- Overrides:
setChemicalTermsArgument
in classCalculatorPlugin
- Parameters:
arg
- is the atom string as a '-'-separated list- Throws:
PluginException
- on error
-
setRandomEnumeration
public void setRandomEnumeration()Sets random enumeration. Must be called before setting the molecule inCalculatorPlugin.setMolecule(chemaxon.struc.Molecule)
. Set also the number of requested structures insetMaxStructureCount(long)
, otherwise only one randomly enumerated structure will be generated.- Since:
- Marvin 5.1
-
setRandomSeed
public void setRandomSeed(long seed) Sets the random seed to be used in case of random enumeration. Must be called before setting the molecule inCalculatorPlugin.setMolecule(chemaxon.struc.Molecule)
.- Parameters:
seed
- the random seed. 0 means using the current time (default behavior).- See Also:
-
isRandomEnumeration
public boolean isRandomEnumeration()Returnstrue
if random enumeration is requested.- Returns:
true
if random enumeration is requested
-
setEnumerateHomology
public void setEnumerateHomology(boolean enumerate) Sets if homology groups should be enumerated or not. Must be called before setting the molecule.- Since:
- Marvin 5.2
-
isHomologyEnumerated
public boolean isHomologyEnumerated()Indicates if homology groups are enumerated or not.- Since:
- Marvin 5.2
-
setEnumCodeNeeded
public void setEnumCodeNeeded(boolean value) Indicates whether unique Markush enumeration code should be generated. Must be called before setting the molecule.- Parameters:
value
- true, if code generation is needed- Since:
- Marvin 5.1.2
-
getEnumCodeNeeded
public boolean getEnumCodeNeeded()Tests whether unique Markush enumeration code should be generated- Returns:
- true, if code generation is needed
- Since:
- Marvin 5.1.2
-
setStructureID
Sets structure ID to be used in Markush code generation. The name of the SDF / MRV tag storing the ID in the Markush structure or else the ID itself. Must be called before setting the molecule. Setnull
for no structure ID (default). Calling this method with non-null argument will automatically switch on Markush code generation.- Parameters:
id
- the tag name or the ID- Since:
- Marvin 5.1.3
- See Also:
-
getStructureID
Returns the structure ID used in Markush code (enumeration ID) generation.- Returns:
- the structure ID storing tag name or the ID itself
- Since:
- Marvin 5.1.3
- See Also:
-
setFilter
Sets the molecule filter. Must be called before setting the molecule. Default:null
(get all enumerated structures).- Parameters:
filter
- the molecule filter ornull
for no filtering- Since:
- Marvin 5.0
- See Also:
-
isFiltered
public boolean isFiltered()Returntrue
if molecule filter is set.- Returns:
true
if molecule filter is set
-
isApproximateCount
Returnstrue
if count is approximate due to multiple position bonds with multicenters of variable size,false
otherwise.- Returns:
true
if count is approximate- Throws:
PluginException
-
setMaxStructureCount
public void setMaxStructureCount(long max) Sets the maximum number of structures to be generated. Set-1
for unlimited. Default: unlimited for the sequential case,1
for the random case. Must be called before setting the molecule inCalculatorPlugin.setMolecule(chemaxon.struc.Molecule)
.- Parameters:
max
- is the maximum number of structures to be generated- See Also:
-
setAlignScaffold
public void setAlignScaffold(boolean value) Sets the scaffold aligning mode. Must be called before setting the molecule inCalculatorPlugin.setMolecule(chemaxon.struc.Molecule)
.- Parameters:
value
- if true, tries to align scaffold in enumerated structures as it was in the original Markush structure- Since:
- Marvin 5.1
-
getAlignScaffold
public boolean getAlignScaffold()Gets the scaffold aligning mode- Returns:
- true, if enumerated structures should be aligned to the scaffold
- Since:
- Marvin 5.1
-
setColoring
public void setColoring(int coloring) Sets hit coloring options. Must be called before setting the molecule inCalculatorPlugin.setMolecule(chemaxon.struc.Molecule)
.- Parameters:
coloring
-COLORING_SCAFFOLD
,COLORING_RGROUPS
,COLORING_NONE
, orCOLORING_ALL
- Since:
- Marvin 5.1
-
getColoring
public int getColoring()Returns the hit coloring options.- Returns:
- the hit coloring options
- Since:
- Marvin 5.1
- See Also:
-
isCleanNeeded
public boolean isCleanNeeded()Returnstrue
if clean is needed for GUI display.- Returns:
true
if clean is needed for GUI display
-
checkMolecule
Checks the input molecule.- Overrides:
checkMolecule
in classCalculatorPlugin
- Parameters:
mol
- is the input molecule- Throws:
PluginException
- with error message for the user if the molecule is refused
-
setMolecule
protected Molecule setMolecule(Molecule mol, boolean st, boolean om, boolean storeExplicitHydrogens) throws PluginException - Overrides:
setMolecule
in classCalculatorPlugin
- Throws:
PluginException
-
setInputMolecule
Sets the input molecule.- Specified by:
setInputMolecule
in classCalculatorPlugin
- Parameters:
mol
- is the input molecule- Throws:
PluginException
- on error
-
run
Creates enumerated structures.- Specified by:
run
in classCalculatorPlugin
- Returns:
true
- Throws:
PluginException
- on error- See Also:
-
countEnumerations
Returns the number of all enumerated structures, no arithmetic overflow because counts inBigInteger
.In case when the result does not exceed
Long.MAX_VALUE
, the number of enumerates is also returned bygetStructureCount()
(afterrun()
is called).Note:
run()
need not be called before using this function.- Returns:
- the number of enumerated structures
- Throws:
PluginException
- on expansion error- See Also:
-
countEnumerationsMagnitude
Returns the magnitude (the number of decimal "digits") of the number of all enumerated structures. No arithmetic overflow because counts inBigInteger
.Note:
run()
need not be called before using this function.- Returns:
- the magnitude of the number of enumerated structures
- Throws:
PluginException
- on expansion error- See Also:
-
getStructureCount
public long getStructureCount()Returns the number of all enumerated structures,-1
in case of arithmetical overflow (if the number would exceedLong.MAX_VALUE
). To handle the case of arithmetical overflow, callcountEnumerations()
orcountEnumerationsMagnitude()
. Returns the number of structures to be returned in case of random enumeration.Warning:
run()
must be called before using this function.- Returns:
- the number of enumerated structures
- See Also:
-
getLimitedStructureCount
public int getLimitedStructureCount()Returns the number of structures to be generated. This is the minimum of the actual structure count returned bygetStructureCount()
and the specified maximum (seesetMaxStructureCount(long)
). Returns the number of structures to be returned in case of random enumeration.- Returns:
- the number of structures to be generated
- See Also:
-
hasMoreStructures
public boolean hasMoreStructures()Returnstrue
if there are more structures.- Returns:
true
if there are more structures
-
getNextStructure
Returns the next enumerated structure, ornull
if no more structures.- Returns:
- the sructure
-
getNextAromatizedStructure
Returns the next enumerated structure. The structure is returned in aromatized form.- Returns:
- the structure
-
getStructures
Returns the enumerated structures.- Returns:
- the enumerated structures
- Throws:
PluginException
- if too many structures
-
getAromatizedStructures
Returns the enumerated structures in aromatized form.- Returns:
- the enumerated structures in aromatized form
- Throws:
PluginException
- if too many structures
-
getResultSource
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.- Overrides:
getResultSource
in classCalculatorPlugin
- Returns:
- the document source interface
- Throws:
PluginException
- on error- Since:
- Marvin 5.0
-
getResultTypes
Returns the result types.- Overrides:
getResultTypes
in classCalculatorPlugin
- Returns:
- the result types
-
getResultDomain
Returns the calculation domain.- Overrides:
getResultDomain
in classCalculatorPlugin
- Parameters:
type
- is the result type- Returns:
- the calculation domain
- See Also:
-
getResultCount
Returns the number of result items for the given result key.- Overrides:
getResultCount
in classCalculatorPlugin
- Parameters:
type
- is the result type- Returns:
- the number of result items
- See Also:
-
getTypeString
Returns a string representation of the given type.- Overrides:
getTypeString
in classCalculatorPlugin
- Parameters:
type
- is the type object- Returns:
- the type string
-
getResult
Returns the result item for the specified key and index.- Overrides:
getResult
in classCalculatorPlugin
- Parameters:
type
- is the result typeindex
- is the result index- Returns:
- the result item for the specified key and index
- Throws:
PluginException
- if the result cannot be returned- See Also:
-
getResult
@Deprecated(forRemoval=true) @SubjectToRemoval(date=JUL_01_2025) public Object getResult(Object type, String arg) throws PluginException Deprecated, for removal: This API element is subject to removal in a future version.Some implementations of this method modify the state of the plugin, which is a very confusing behavior, so the method is now deprecated and should no longer be used. If you used this method with an index argument, parse the index instead, and callgetResult(Object, int)
. Otherwise, call the appropriate setter method of the plugin to configure it with the argument, and callgetResult(Object, int)
with a 0 index.Returns the enumerated structures. For internal use only.- Overrides:
getResult
in classCalculatorPlugin
- Parameters:
type
- is the result type ("structures")arg
- is the atom string as a '-'-separated list- Returns:
- the enumerated structures
- Throws:
PluginException
- on error- See Also:
-
getResultAsString
Returns the specified result in String format.- Overrides:
getResultAsString
in 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
-
getRemark
Returns a warning message in case of arithmetical overflow (the number of enumerated structures exceedsLong.MAX_VALUE
),null
otherwise.- Overrides:
getRemark
in classCalculatorPlugin
- Returns:
- a warning message if there are no tautomers
-
getLibrarySizeString
Returns the display string representation of the Markush library size (number of all enumerated structures). It can be of two different forms: exact count with thousands separator for relative small values (e.g. 1,234,567) or"~10^x"
for large values. If the count isapproximate
, 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.- Returns:
- display string representation of the library size or
null
in case of random enumeration. - Throws:
PluginException
- on expansion error- See Also:
-
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:
getResultMolecule
in classCalculatorPlugin
- Returns:
- the result molecule
- Throws:
PluginException
- on error- Since:
- Marvin 4.0
-