chemaxon.marvin.calculations
Class MarkushEnumerationPlugin

java.lang.Object
  extended by chemaxon.marvin.plugin.CalculatorPlugin
      extended by chemaxon.marvin.calculations.MarkushEnumerationPlugin
All Implemented Interfaces:
chemaxon.license.Licensable
Direct Known Subclasses:
EnumerationPlugin

public class MarkushEnumerationPlugin
extends CalculatorPlugin

Plugin class for enumerating Markush molecules.
Input: a Markush structure.
Output: the number of possible enumerations; the enumerated molecules.

API usage examples:

    // read input molecule
    MolImporter mi = new MolImporter("testMarkush.mrv");
    Molecule mol = mi.read();
    mi.close();

    // 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"));
        // using molecule ...
        // ...
        // 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"));
         // using molecules ...
       }
    }

    // OR
    // 3. Print out some random enumerated structures
    for (int i = 0; i < 10; i++) {
      Molecule m = plugin.getRandomStructure();
      System.out.println(m.toFormat("smiles"));
      // using molecule ...
    }

 

For concurrent plugin example applications using ChemAxon's concurrent framework, refer to the Concurrent plugin examples.

Since:
Marvin 5.0.3
Version:
Marvin 5.0.3, 03/18/2008
Author:
Nora Mate

Field Summary
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 (default).
 
Fields inherited from class chemaxon.marvin.plugin.CalculatorPlugin
ATOM, BLUE, CALCRGB_OFF, COVALENT_HYDRATION_ERROR_REMARK, CRITICAL_ERROR_MSG, EPSILON, INCORRECT_AROMATIC_NITROGEN_REMARK, INSTABLE_TAUTOMERIC_FORM_REMARK, licenseEnvironment, MOLECULE, NAN, PLUGIN_CLASS_KEY, PLUGIN_DIR, RED
 
Constructor Summary
MarkushEnumerationPlugin()
          Constructor.
 
Method Summary
 void checkMolecule(Molecule mol)
          Checks the input molecule.
 java.math.BigInteger countEnumerations()
          Returns the number of all enumerated structures, no arithmetic overflow because counts in BigInteger.
 int countEnumerationsMagnitude()
          Returns the magnitude of the number of all enumerated structures, no arithmetic overflow because counts in BigInteger.
 boolean getAlignScaffold()
          Gets the scaffold aligning mode
 Molecule[] getAromatizedStructures()
          Returns the enumerated structures in aromatized form.
 int getColoring()
          Returns the hit coloring options.
 boolean getEnumIDNeeded()
          Tests whether unique Markush enumeration ID should be generated
protected  java.lang.String getLibrarySizeString()
          Returns the string representation of the Markush library size.
 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.
 Molecule getRandomStructure()
          Returns a randomly selected enumerated structure
 Molecule[] getRandomStructures(int n)
          Returns the given number of randomly selected enumerated structures.
 java.lang.String getRemark()
          Returns a warning message in case of arithmetical overflow (the number of enumerated structures exceeds Long.MAX_VALUE), null otherwise.
 java.lang.Object getResult(java.lang.Object type, int index)
          Returns the result item for the specified key and index.
 java.lang.Object getResult(java.lang.Object type, java.lang.String arg)
          Returns the enumerated structures.
 java.lang.String getResultAsString(java.lang.Object type, int index, java.lang.Object result)
          Returns the specified result in String format.
 int getResultCount(java.lang.Object type)
          Returns the number of result items for the given result key.
 int getResultDomain(java.lang.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.
 java.lang.Object[] getResultTypes()
          Returns the result types.
 long getStructureCount()
          Returns the number of all enumerated structures, -1 if arithmetical overflow (exceeds Long.MAX_VALUE).
 Molecule[] getStructures()
          Returns the enumerated structures.
 java.lang.String getTypeString(java.lang.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 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 setEnumIDNeeded(boolean value)
          Indicates whether unique Markush enumeration ID should be generated
 void setFilter(MolFilter filter)
          Sets the molecule filter.
protected  void setInputMolecule(Molecule mol)
          Sets the input molecule.
 void setLicenseEnvironment(java.lang.String env)
          Sets license environment to be stored.
 void setMaxStructureCount(long max)
          Sets the maximum number of structures to be generated.
 void setParameters(java.util.Properties params)
          Sets the input parameters for the plugin.
 void setRandomEnumeration()
          Sets random enumeration.
 void standardize(Molecule mol)
          Prevents default standardization: does nothing.
 
Methods inherited from class chemaxon.marvin.plugin.CalculatorPlugin
checkType, containsCoordinateBond, containsMulticenterSgroup, containsPseudoAtom, containsSRUSgroup, create, createModifiedInputMolecule, createStandardizedMolecule, createStandardizedMolecule, dehydrogenize, format, format, format, format, getAtomCount, getAtomIndex, getCalcMolecule, getDisplayMolecule, getDocument, getDoublePrecision, getErrorMessage, getInputMolDim, getMainMolecule, getpH, getPluginResource, getResult, getResult, getResultAsRGB, getResultAsRGB, getResultAsString, getResultCount, getResultDomain, getResultMessage, getResultMolecules, getResultsAsRGB, getResultsAsRGB, getResultsAsString, getResultsAsString, getWarningMessage, isInputMoleculeAromatized, isMsCalc, isMultiThreadedRunEnabled, isNegligibleResult, isOK, isRgrouped, loadClass, readAttribute, removeWhitespace, setDoublePrecision, setDoublePrecision, setDoublePrecision, setMolecule, setMolecule, setMolecule, setProgressMonitor, standardizeIonicGroups, standardizeNeutralGroups
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILTER_VALENCE

public static final MolFilter FILTER_VALENCE
Filter constant: valence filter (default).

Since:
Marvin 5.1

COLORING_NONE

public static final int COLORING_NONE
Constant for no hit coloring.

Since:
Marvin 5.1
See Also:
Constant Field Values

COLORING_SCAFFOLD

public static final int COLORING_SCAFFOLD
Constant for scaffold coloring.

Since:
Marvin 5.1
See Also:
Constant Field Values

COLORING_RGROUPS

public static final int COLORING_RGROUPS
Constant for R-group coloring.

Since:
Marvin 5.1
See Also:
Constant Field Values

COLORING_ALL

public static final int COLORING_ALL
Constant for setting all coloring options, currently scaffold and R-groups.

Since:
Marvin 5.1
See Also:
Constant Field Values
Constructor Detail

MarkushEnumerationPlugin

public MarkushEnumerationPlugin()
Constructor.

Method Detail

isLicensed

public boolean isLicensed()
Description copied from class: CalculatorPlugin
Returns 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.

Specified by:
isLicensed in interface chemaxon.license.Licensable
Overrides:
isLicensed in class CalculatorPlugin
Returns:
true if the plugin is licensed

setLicenseEnvironment

public void setLicenseEnvironment(java.lang.String env)
Description copied from class: CalculatorPlugin
Sets license environment to be stored.

Specified by:
setLicenseEnvironment in interface chemaxon.license.Licensable
Overrides:
setLicenseEnvironment in class CalculatorPlugin
Parameters:
env - environment String to be stored and passed to the LicenseHandler in the isLicensed method

handlesMultiFragmentMolecules

public boolean handlesMultiFragmentMolecules()
Returns 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).

Overrides:
handlesMultiFragmentMolecules in class CalculatorPlugin
Returns:
true if the plugin handles multifragment molecules, false otherwise

setParameters

public void setParameters(java.util.Properties params)
                   throws PluginException
Sets the input parameters for the plugin. Enumeration parameters and value ranges:

Overrides:
setParameters in class CalculatorPlugin
Parameters:
params - is the parameter table
Throws:
PluginException - on error

setRandomEnumeration

public void setRandomEnumeration()
Sets random enumeration.

Since:
Marvin 5.1

isRandomEnumeration

public boolean isRandomEnumeration()
Returns true if random enumeration is requested.

Returns:
true if random enumeration is requested

setEnumIDNeeded

public void setEnumIDNeeded(boolean value)
Indicates whether unique Markush enumeration ID should be generated

Parameters:
value - true, if ID generation is needed
Since:
Marvin 5.1.2

getEnumIDNeeded

public boolean getEnumIDNeeded()
Tests whether unique Markush enumeration ID should be generated

Returns:
true, if ID generation is needed
Since:
Marvin 5.1.2

setFilter

public void setFilter(MolFilter filter)
Sets the molecule filter. Default: FILTER_VALENCE (accepts the molecules with no valence error). Set this to null to get all enumerated structures.

Parameters:
filter - the molecule filter or null for no filtering
Since:
Marvin 5.0
See Also:
MolFilter

isFiltered

protected boolean isFiltered()
Return true if molecule filter is set.

Returns:
true if molecule filter is set

isApproximateCount

public boolean isApproximateCount()
Returns true if count is approximate due to multiple position bonds with multicenters of variable size, false otherwise.

Returns:
true if count is approximate

setMaxStructureCount

public void setMaxStructureCount(long max)
Sets the maximum number of structures to be generated. Set -1 for unlimited. Default: unlimited.

Parameters:
max - is the maximum number of structures to be generated

setAlignScaffold

public void setAlignScaffold(boolean value)
Sets the scaffold aligning mode

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.

Parameters:
coloring - COLORING_SCAFFOLD, COLORING_RGROUPS, COLORING_NONE, or COLORING_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:
COLORING_NONE, COLORING_SCAFFOLD, COLORING_RGROUPS, COLORING_ALL

isCleanNeeded

protected boolean isCleanNeeded()
Returns true if clean is needed for GUI display.

Returns:
true if clean is needed for GUI display

checkMolecule

public void checkMolecule(Molecule mol)
                   throws PluginException
Checks the input molecule.

Overrides:
checkMolecule in class CalculatorPlugin
Parameters:
mol - is the input molecule
Throws:
PluginException - with error message for the user if the molecule is refused

setInputMolecule

protected void setInputMolecule(Molecule mol)
                         throws PluginException
Sets the input molecule.

Specified by:
setInputMolecule in class CalculatorPlugin
Parameters:
mol - is the input molecule
Throws:
PluginException - on error

run

public boolean run()
            throws PluginException
Creates enumerated structures.

Specified by:
run in class CalculatorPlugin
Returns:
true
Throws:
PluginException - on error
See Also:
CalculatorPlugin.getErrorMessage()

countEnumerations

public java.math.BigInteger countEnumerations()
                                       throws PluginException
Returns the number of all enumerated structures, no arithmetic overflow because counts in BigInteger.

Returns:
the number of enumerated structures
Throws:
PluginException - on expansion error

countEnumerationsMagnitude

public int countEnumerationsMagnitude()
                               throws PluginException
Returns the magnitude of the number of all enumerated structures, no arithmetic overflow because counts in BigInteger.

Returns:
the magnitude of the number of enumerated structures
Throws:
PluginException - on expansion error

getStructureCount

public long getStructureCount()
Returns the number of all enumerated structures, -1 if arithmetical overflow (exceeds Long.MAX_VALUE). Returns the number of structures to be returned in case of random enumeration.

Returns:
the number of enumerated structures
See Also:
#setRandomMode(), setMaxStructureCount(long), ExpansionCounter.countExpansionsLarge(), ExpansionCounter.countExpansionsMagnitude()

getLimitedStructureCount

public int getLimitedStructureCount()
Returns the number of structures to be generated. This is the minimum of the actual structure count returned by getStructureCount() and the specified maximum (see setMaxStructureCount(long)).

Returns:
the number of structures to be generated

hasMoreStructures

public boolean hasMoreStructures()
Returns true if there are more structures.

Returns:
true if there are more structures

getNextStructure

public Molecule getNextStructure()
Returns the next enumerated structure, or null if no more structures.

Returns:
the sructure

getNextAromatizedStructure

public Molecule getNextAromatizedStructure()
Returns the next enumerated structure. The structure is returned in aromatized form.

Returns:
the structure

getRandomStructure

public Molecule getRandomStructure()
Returns a randomly selected enumerated structure

Returns:
the random structure

getRandomStructures

public Molecule[] getRandomStructures(int n)
Returns the given number of randomly selected enumerated structures.

Parameters:
n - the number of random molecules to return
Returns:
the random structures

getStructures

public Molecule[] getStructures()
                         throws PluginException
Returns the enumerated structures.

Returns:
the enumerated structures
Throws:
PluginException - if too many structures

getAromatizedStructures

public Molecule[] getAromatizedStructures()
                                   throws PluginException
Returns the enumerated structures in aromatized form.

Returns:
the enumerated structures in aromatized form
Throws:
PluginException - if too many structures

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.

Overrides:
getResultSource in class CalculatorPlugin
Returns:
the document source interface
Throws:
PluginException - on error
Since:
Marvin 5.0

getResultTypes

public java.lang.Object[] getResultTypes()
Returns the result types.

Overrides:
getResultTypes in class CalculatorPlugin
Returns:
the result types

getResultDomain

public int getResultDomain(java.lang.Object type)
Returns the calculation domain.

Overrides:
getResultDomain in class CalculatorPlugin
Parameters:
type - is the result type
Returns:
the calculation domain
See Also:
getResultTypes()

getResultCount

public int getResultCount(java.lang.Object type)
Returns the number of result items for the given result key.

Overrides:
getResultCount in class CalculatorPlugin
Parameters:
type - is the result type
Returns:
the number of result items
See Also:
getResultTypes()

getTypeString

public java.lang.String getTypeString(java.lang.Object type)
Returns a string representation of the given type.

Overrides:
getTypeString in class CalculatorPlugin
Parameters:
type - is the type object
Returns:
the type string

getResult

public java.lang.Object getResult(java.lang.Object type,
                                  int index)
                           throws PluginException
Returns the result item for the specified key and index.

Overrides:
getResult in class CalculatorPlugin
Parameters:
type - is the result type
index - is the result index
Returns:
the result item for the specified key and index
Throws:
PluginException - if the result cannot be returned
See Also:
CalculatorPlugin.getResultTypes()

getResult

public java.lang.Object getResult(java.lang.Object type,
                                  java.lang.String arg)
                           throws PluginException
Returns the enumerated structures. For internal use only.

Overrides:
getResult in class CalculatorPlugin
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:
CalculatorPlugin.getResultTypes()

getResultAsString

public java.lang.String getResultAsString(java.lang.Object type,
                                          int index,
                                          java.lang.Object result)
                                   throws PluginException
Returns the specified result in String format.

Overrides:
getResultAsString in class CalculatorPlugin
Parameters:
type - is the result type
index - is the result index
result - is the result item
Returns:
the specified result in String format
Throws:
PluginException - if an invalid result item is given

getRemark

public java.lang.String getRemark()
Returns a warning message in case of arithmetical overflow (the number of enumerated structures exceeds Long.MAX_VALUE), null otherwise.

Overrides:
getRemark in class CalculatorPlugin
Returns:
a warning message if there are no tautomers

getLibrarySizeString

protected java.lang.String getLibrarySizeString()
                                         throws PluginException
Returns the string representation of the Markush library size. If the library is too big then returns an approximate form (e.g. "~ 10^45"). Returns null in case of random enumeration.

Returns:
the library size string
Throws:
PluginException

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)).

Overrides:
getResultMolecule in class CalculatorPlugin
Returns:
the result molecule
Throws:
PluginException - on error
Since:
Marvin 4.0

standardize

public void standardize(Molecule mol)
Prevents default standardization: does nothing.

Overrides:
standardize in class CalculatorPlugin
Parameters:
mol - is the molecule to be standardized