Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.motifDiscovery
Class MutableMotifDiscovererToolbox

    java.lang.Object
      de.jstacs.motifDiscovery.MotifDiscovererToolBox
          de.jstacs.motifDiscovery.MutableMotifDiscovererToolbox

    public final class MutableMotifDiscovererToolbox

extends MotifDiscovererToolBox

This class contains some important methods for the initiation and optimization of `MutableMotifDiscoverer`.

Author:
  Jan Grau, Jens Keilwagen

Nested Class Summary
`static class` | `MutableMotifDiscovererToolbox.InitMethodForScoringFunction` This enum defines some constants for the method `getSortedInitialParameters(ScoringFunction[], InitMethodForScoringFunction[], SFBasedOptimizableFunction, int, OutputStream, int)`.

Constructor Summary
`MutableMotifDiscovererToolbox()`

Method Summary
`static void` | `clearHistoryArray(History[][] history)` This method clears all elements of an History-array, so that it can be used again.
`static History[][]` | `createHistoryArray(ScoringFunction[] funs, History template)` This method creates a History-array that can be used in an optimization.
`static int[][]` | `createMinimalNewLengthArray(ScoringFunction[] funs)` This method creates a minimalNewLength-array that can be used in an optimization.
`static boolean` | `doHeuristicSteps(ScoringFunction[] funs, Sample[] data, double[][] weights, SFBasedOptimizableFunction opt, DifferentiableFunction neg, byte algorithm, double linEps, StartDistanceForecaster startDistance, SafeOutputStream out, boolean breakOnChanged, History[][] hist, int[][] minimalNewLength, boolean maxPos)` This method tries to make some heuristic step if at least one `MutableMotifDiscovererToolbox.InitMethodForScoringFunction` is a `MutableMotifDiscoverer`.
`static Sequence[]` | `enumerate(ScoringFunction[] funs, int[] classIndex, int[] motifIndex, RecyclableSequenceEnumerator[] rse, double weight, SFBasedOptimizableFunction opt, OutputStream out)` This method allows to enumerate all possible seeds for a number of motifs in the `MutableMotifDiscoverer`s of a specific classes.
`static Sequence` | `enumerate(ScoringFunction[] funs, int classIndex, int motifIndex, RecyclableSequenceEnumerator rse, double weight, SFBasedOptimizableFunction opt, OutputStream out)` This method allows to enumerate all possible seeds for a motif in the `MutableMotifDiscoverer` of a specific class.
`static boolean` | `findModification(int clazz, int motif, MutableMotifDiscoverer mmd, ScoringFunction[] score, Sample[] data, SFBasedOptimizableFunction opt, DifferentiableFunction neg, byte algo, double linEps, StartDistanceForecaster startDistance, SafeOutputStream out, History hist, int minimalNewLength, boolean maxPos)` This method tries to find a modification, i.e. shifting, shrinking, or expanding a motif, that is promising.
`static ComparableElement<double[],Double>[]` | `getSortedInitialParameters(ScoringFunction[] funs, MutableMotifDiscovererToolbox.InitMethodForScoringFunction[] init, SFBasedOptimizableFunction opt, int n, OutputStream stream, int optimizationSteps)` This method allows to initialize the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction` using different `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`.
`static void` | `initMotif(int idx, int[] classIndex, int[] motifIndex, Sample[] s, double[][] seqWeights, boolean[] adjust, MutableMotifDiscoverer[] mmd, int[] len, Sample[] data, double[][] dataWeights)` This method allows to initialize a number of motifs.
`static double[][]` | `optimize(ScoringFunction[] funs, SFBasedOptimizableFunction opt, byte algorithm, double eps, double linEps, StartDistanceForecaster startDistance, SafeOutputStream out, boolean breakOnChanged, History[][] hist, int[][] minimalNewLength, OptimizableFunction.KindOfParameter plugIn, boolean maxPos)` This method tries to optimize the problem at hand as good as possible.
`static double[][]` | `optimize(ScoringFunction[] funs, SFBasedOptimizableFunction opt, byte algorithm, double eps, double linEps, StartDistanceForecaster startDistance, SafeOutputStream out, boolean breakOnChanged, History template, OptimizableFunction.KindOfParameter plugIn, boolean maxPos)` This method tries to optimize the problem at hand as good as possible.

Methods inherited from class de.jstacs.motifDiscovery.MotifDiscovererToolBox
`plot, plotAndAnnotate`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MutableMotifDiscovererToolbox

    public MutableMotifDiscovererToolbox()

Method Detail

### enumerate

    public static Sequence enumerate(ScoringFunction[] funs,
                                     int classIndex,
                                     int motifIndex,
                                     RecyclableSequenceEnumerator rse,
                                     double weight,
                                     SFBasedOptimizableFunction opt,
                                     OutputStream out)
                              throws Exception

  This method allows to enumerate all possible seeds for a motif in the `MutableMotifDiscoverer` of a specific class.

  Parameters:
    `funs` - the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`s
    `classIndex` - the index of the class
    `motifIndex` - the index of the motif in the `MutableMotifDiscoverer`
    `rse` - an `RecyclableSequenceEnumerator` that contains `Sequence` objects tested for initialization of the motif `motifIndex`
    `weight` - the weight of the seed `Sequence`
    `opt` - the objective function
    `out` - a stream that allows to write some output if necessary
  Returns:
    the best `Sequence` with respect to the `SFBasedOptimizableFunction`
  Throws:
    `Exception` - if something went wrong
  See Also:
    `enumerate(ScoringFunction[], int[], int[], RecyclableSequenceEnumerator[], double, SFBasedOptimizableFunction, OutputStream)`

### enumerate

    public static Sequence[] enumerate(ScoringFunction[] funs,
                                       int[] classIndex,
                                       int[] motifIndex,
                                       RecyclableSequenceEnumerator[] rse,
                                       double weight,
                                       SFBasedOptimizableFunction opt,
                                       OutputStream out)
                                throws Exception

  This method allows to enumerate all possible seeds for a number of motifs in the `MutableMotifDiscoverer`s of a specific classes.

  Parameters:
    `funs` - the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`s
    `classIndex` - the indices of the classes
    `motifIndex` - the indices of the motif in the `MutableMotifDiscoverer`s
    `rse` - an array of `RecyclableSequenceEnumerator` that contains `Sequence` objects tested for initialization of the corresponding motif
    `weight` - the weight of the seed `Sequence`
    `opt` - the objective function
    `out` - a stream that allows to write some output if necessary
  Returns:
    an array containing the best `Sequence`s with respect to the `SFBasedOptimizableFunction`
  Throws:
    `Exception` - if something went wrong

### initMotif

    public static void initMotif(int idx,
                                 int[] classIndex,
                                 int[] motifIndex,
                                 Sample[] s,
                                 double[][] seqWeights,
                                 boolean[] adjust,
                                 MutableMotifDiscoverer[] mmd,
                                 int[] len,
                                 Sample[] data,
                                 double[][] dataWeights)
                          throws Exception

  This method allows to initialize a number of motifs.

  Parameters:
    `idx` - the index indicates how many motifs are initialized
    `classIndex` - the indices of the classes of each motif
    `motifIndex` - the indices of each motif within the `MutableMotifDiscoverer`
    `s` - the `Sample`s to be used for the initialization
    `seqWeights` - the weights corresponding to the `Sample`s
    `adjust` - an array of switches indicating whether to adjust hidden parameters of not
    `mmd` - the array of `MutableMotifDiscoverer`s to be initialized
    `len` - the length of each motif
    `data` - the complete data sets
    `dataWeights` - the weights corresponding to the complete data sets
  Throws:
    `Exception` - if something went wrong

### getSortedInitialParameters

    public static ComparableElement<double[],Double>[] getSortedInitialParameters(ScoringFunction[] funs,
                                                                                  MutableMotifDiscovererToolbox.InitMethodForScoringFunction[] init,
                                                                                  SFBasedOptimizableFunction opt,
                                                                                  int n,
                                                                                  OutputStream stream,
                                                                                  int optimizationSteps)
                                                                           throws Exception

  This method allows to initialize the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction` using different `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`. It returns an array of `ComparableElement`s that contain the parameters and the

  Parameters:
    `funs` - the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`s
    `init` - the specific `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`, the entries correspond one to one to those of `fun`
    `opt` - the objective function
    `n` - the number of initializations
    `stream` - a stream that allows to write some output if necessary
    `optimizationSteps` - the number of initial steps that should be performed before evaluating the function
  Returns:
    a sorted array containing `ComparableElement`s of parameter arrays and corresponding values of the `SFBasedOptimizableFunction`
  Throws:
    `Exception` - if something went wrong

### createMinimalNewLengthArray

    public static int[][] createMinimalNewLengthArray(ScoringFunction[] funs)

  This method creates a minimalNewLength-array that can be used in an optimization.

  Parameters:
    `funs` - the ScoringFunctions used in an optimization
  Returns:
    an minimalNewLength-array for the given ScoringFunctions

### createHistoryArray

    public static History[][] createHistoryArray(ScoringFunction[] funs,
                                                 History template)
                                          throws CloneNotSupportedException

  This method creates a History-array that can be used in an optimization.

  Parameters:
    `funs` - the ScoringFunctions used in an optimization
    `template` - the template history instance
  Returns:
    an History-array for the given ScoringFunctions
  Throws:
    `CloneNotSupportedException` - if the t`template` could not be cloned

### clearHistoryArray

    public static void clearHistoryArray(History[][] history)

  This method clears all elements of an History-array, so that it can be used again.

  Parameters:
    `history` - the array

### optimize

    public static double[][] optimize(ScoringFunction[] funs,
                                      SFBasedOptimizableFunction opt,
                                      byte algorithm,
                                      double eps,
                                      double linEps,
                                      StartDistanceForecaster startDistance,
                                      SafeOutputStream out,
                                      boolean breakOnChanged,
                                      History template,
                                      OptimizableFunction.KindOfParameter plugIn,
                                      boolean maxPos)
                               throws Exception

  This method tries to optimize the problem at hand as good as possible. If the optimization uses `MutableMotifDiscoverer`s it tries to perform modify operations as long as they seem to be promising.

  Parameters:
    `funs` - the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`s for scoring sequences
    `opt` - the `SFBasedOptimizableFunction`
    `algorithm` - used for the optimization
    `eps` - used for the optimization
    `linEps` - used for the optimization
    `startDistance` - used for the optimization
    `out` - an stream that allows to obtain some information while optimization
    `breakOnChanged` - a switch that decides whether a new optimization should be started after one successful modify or after all motifs have been tried to modify.
    `template` - a history instance used to build an array with this instance
    `plugIn` - a switch whether to take the internal parameters or not
    `maxPos` - a switch whether to take the maximal shift position or not in the heuristic
  Returns:
    the optimized value (res[0][0]) and the array for the class parameters (res[1])
  Throws:
    `Exception` - if something went wrong while optimization
  See Also:
    `clearHistoryArray(de.jstacs.motifDiscovery.history.History[][])`, `optimize(ScoringFunction[], SFBasedOptimizableFunction, byte, double, double, StartDistanceForecaster, SafeOutputStream, boolean, History[][], int[][], de.jstacs.classifier.scoringFunctionBased.OptimizableFunction.KindOfParameter, boolean)`

### optimize

    public static double[][] optimize(ScoringFunction[] funs,
                                      SFBasedOptimizableFunction opt,
                                      byte algorithm,
                                      double eps,
                                      double linEps,
                                      StartDistanceForecaster startDistance,
                                      SafeOutputStream out,
                                      boolean breakOnChanged,
                                      History[][] hist,
                                      int[][] minimalNewLength,
                                      OptimizableFunction.KindOfParameter plugIn,
                                      boolean maxPos)
                               throws Exception

  This method tries to optimize the problem at hand as good as possible. If the optimization uses `MutableMotifDiscoverer`s it tries to perform modify operations as long as they seem to be promising.

  Parameters:
    `funs` - the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`s for scoring sequences
    `opt` - the `SFBasedOptimizableFunction`
    `algorithm` - used for the optimization
    `eps` - used for the optimization
    `linEps` - used for the optimization
    `startDistance` - used for the optimization
    `out` - an stream that allows to obtain some information while optimization
    `breakOnChanged` - a switch that decides whether a new optimization should be started after one successful modify or after all motifs have been tried to modify.
    `hist` - an array that is used to check whether a modify-operation can be performed
    `minimalNewLength` - the minimal new length for each motif in each class, that will be used in an expand if the motif was shortened before
    `plugIn` - a switch whether to take the internal parameters or not
    `maxPos` - a switch whether to take the maximal shift position or not in the heuristic
  Returns:
    the optimized value (res[0][0]) and the array for the class parameters (res[1])
  Throws:
    `Exception` - if something went wrong while optimization

### doHeuristicSteps

    public static boolean doHeuristicSteps(ScoringFunction[] funs,
                                           Sample[] data,
                                           double[][] weights,
                                           SFBasedOptimizableFunction opt,
                                           DifferentiableFunction neg,
                                           byte algorithm,
                                           double linEps,
                                           StartDistanceForecaster startDistance,
                                           SafeOutputStream out,
                                           boolean breakOnChanged,
                                           History[][] hist,
                                           int[][] minimalNewLength,
                                           boolean maxPos)
                                    throws Exception

  This method tries to make some heuristic step if at least one `MutableMotifDiscovererToolbox.InitMethodForScoringFunction` is a `MutableMotifDiscoverer`. These heuristic steps include shift, shrink, and expand as far as the user allows those operations by the `History` array.

  Parameters:
    `funs` - the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`s for scoring sequences
    `data` - array of `Sample` containing the data for each class
    `weights` - the weights corresponding to the `Sequence`s in `data`
    `opt` - the `SFBasedOptimizableFunction`
    `neg` - the `NegativeDifferentiableFunction` used in the optimization
    `algorithm` - used for the optimization
    `linEps` - used for the optimization
    `startDistance` - used for the optimization
    `out` - an stream that allows to obtain some information while optimization
    `breakOnChanged` - a switch that decides whether a new optimization should be started after one successful modify or after all motifs have been tried to modify.
    `hist` - an array that is used to check whether a modify-operation can be performed
    `minimalNewLength` - the minimal new length for each motif in each class, that will be used in an expand if the motif was shortened before
    `maxPos` - a switch whether to take the maximal shift position or not in the heuristic
  Returns:
    `true` if some heuristic steps has been performed otherwise `false`
  Throws:
    `Exception` - if something went wrong

### findModification

    public static boolean findModification(int clazz,
                                           int motif,
                                           MutableMotifDiscoverer mmd,
                                           ScoringFunction[] score,
                                           Sample[] data,
                                           SFBasedOptimizableFunction opt,
                                           DifferentiableFunction neg,
                                           byte algo,
                                           double linEps,
                                           StartDistanceForecaster startDistance,
                                           SafeOutputStream out,
                                           History hist,
                                           int minimalNewLength,
                                           boolean maxPos)
                                    throws Exception

  This method tries to find a modification, i.e. shifting, shrinking, or expanding a motif, that is promising. The method returns `true` a modification was found and could be performed.
  For finding a promising modification, the method test various shifts and computes the number of sequences predicted to be bound.

  Parameters:
    `clazz` - the class index for which the Scoring function will be tested for modification
    `motif` - the motif index for which the Scoring function will be tested for modification
    `mmd` - the `MutableMotifDiscoverer` that will be tested
    `score` - the `MutableMotifDiscovererToolbox.InitMethodForScoringFunction`s for scoring sequences
    `data` - array of `Sample` containing the data for each class
    `opt` - the `SFBasedOptimizableFunction`
    `neg` - the `NegativeDifferentiableFunction` used in the optimization
    `algo` - used for the optimization
    `linEps` - used for the optimization
    `startDistance` - used for the optimization
    `out` - an stream that allows to obtain some information
    `hist` - an instance to check whether a modify-operation can be performed
    `minimalNewLength` - the minimal new length for each motif in each class, that will be used in an expand if the motif was shortened before
    `maxPos` - a switch whether to take the maximal shift position or not in the heuristic
  Returns:
    `true` if a modification has been performed
  Throws:
    `Exception` - if something went wrong
  See Also:
    `SignificantMotifOccurrencesFinder.getNumberOfBoundSequences(Sample, int)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD