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.sequenceScores.differentiable
Class IndependentProductDiffSS

    java.lang.Object
      de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
          de.jstacs.sequenceScores.differentiable.IndependentProductDiffSS

All Implemented Interfaces:
  DifferentiableSequenceScore, SequenceScore, Storable, Cloneable

Direct Known Subclasses:
  IndependentProductDiffSM

    public class IndependentProductDiffSS

extends AbstractDifferentiableSequenceScore

This class enables the user to model parts of a sequence independent of each other. For instance, the first part of the sequence is modeled by the first `DifferentiableSequenceScore` and has the length of the first `DifferentiableSequenceScore`, the second part starts directly after the first part, is modeled by the second `DifferentiableSequenceScore` ... etc. It is also possible to use a `DifferentiableSequenceScore` for more than one sequence part and in both orientations (if possible).
It is important to set the equivalent sample size (ESS) of each instance carefully, i.e., corresponding to the ESS of the parts.

Author:
  Jens Keilwagen

Field Summary
`protected int[]` | `index` This index indicates which entry of the array `score` should be used for the specific parts.
`protected boolean[]` | `isVariable` This array specifies for each entry of `score` whether it is able to score sequences of variable length.
`protected int[]` | `partialLength` This array specifies the lengths of the specific parts.
`protected boolean[]` | `reverse` This array specifies whether the sequence or its reverse complement is used in the specific parts.
`protected DifferentiableSequenceScore[]` | `score` The internally used `DifferentiableSequenceScore`s.
`protected int[]` | `start` This array specifies the start positions of the specific parts.
`protected int[]` | `startIndexOfParams` This array contains the start indices for `DifferentiableSequenceScore.setParameters(double[], int)` on `score`.

Fields inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
`alphabets, length, r`

Fields inherited from interface de.jstacs.sequenceScores.differentiable.DifferentiableSequenceScore
`UNKNOWN`

Constructor Summary
`IndependentProductDiffSS(boolean plugIn, DifferentiableSequenceScore... functions)` This constructor creates an instance of an `IndependentProductDiffSS` from a given series of independent `DifferentiableSequenceScore`s.
`IndependentProductDiffSS(boolean plugIn, DifferentiableSequenceScore[] functions, int[] length)` This constructor creates an instance of an `IndependentProductDiffSS` from given series of independent `DifferentiableSequenceScore`s and lengths.
`IndependentProductDiffSS(boolean plugIn, DifferentiableSequenceScore[] functions, int[] index, int[] length, boolean[] reverse)` This is the main constructor.
`IndependentProductDiffSS(StringBuffer source)` This is the constructor for the interface `Storable`.

Method Summary
`IndependentProductDiffSS` | `clone()` Creates a clone (deep copy) of the current `DifferentiableSequenceScore` instance.
`protected void` | `extractFurtherInformation(StringBuffer xml)` This method is the opposite of `getFurtherInformation()`.
`int` | `extractSequenceParts(int scoringFunctionIndex, DataSet[] data, DataSet[] result)` This method extracts the corresponding `Sequence` parts for a specific `DifferentiableSequenceScore`.
`double[][]` | `extractWeights(int number, double[][] weights)` This method creates the weights for `extractSequenceParts(int, DataSet[], DataSet[])`.
`protected void` | `fromXML(StringBuffer rep)` This method is called in the constructor for the `Storable` interface to create a scoring function from a `StringBuffer`.
`double[]` | `getCurrentParameterValues()` Returns a `double` array of dimension `DifferentiableSequenceScore.getNumberOfParameters()` containing the current parameter values.
`DifferentiableSequenceScore[]` | `getFunctions()` This method returns a deep copy of the internally used `DifferentiableSequenceScore`.
`protected StringBuffer` | `getFurtherInformation()` This method is used to append further information of the instance to the XML representation.
`int[]` | `getIndices()` This method returns a deep copy of the internally used indices of the `DifferentiableSequenceScore` for the parts.
`String` | `getInstanceName()` Should return a short instance name such as iMM(0), BN(2), ...
`protected static int[]` | `getLengthArray(DifferentiableSequenceScore... function)` This method provides an array of lengths that can be used for instance as `partialLength`.
`double` | `getLogScoreAndPartialDerivation(Sequence seq, int start, IntList indices, DoubleList partialDer)` Returns the logarithmic score for a `Sequence` beginning at position `start` in the `Sequence` and fills lists with the indices and the partial derivations.
`double` | `getLogScoreFor(Sequence seq, int start)` Returns the logarithmic score for the `Sequence` `seq` beginning at position `start` in the `Sequence`.
`int` | `getNumberOfParameters()` Returns the number of parameters in this `DifferentiableSequenceScore`.
`int` | `getNumberOfRecommendedStarts()` This method returns the number of recommended optimization starts.
`int[]` | `getPartialLengths()` This method returns a deep copy of the internally used partial lengths of the parts.
`boolean[]` | `getReverseSwitches()` This method returns a deep copy of the internally used switches for the parts whether to use the corresponding `DifferentiableSequenceScore` forward or as reverse complement.
`void` | `initializeFunction(int index, boolean freeParams, DataSet[] data, double[][] weights)` This method creates the underlying structure of the `DifferentiableSequenceScore`.
`void` | `initializeFunctionRandomly(boolean freeParams)` This method initializes the `DifferentiableSequenceScore` randomly.
`boolean` | `isInitialized()` This method can be used to determine whether the instance is initialized.
`void` | `setParameters(double[] params, int start)` This method sets the internal parameters to the values of `params` between `start` and `start + `DifferentiableSequenceScore.getNumberOfParameters()` - 1`
`protected void` | `setParamsStarts()` This method set the value of the array `startIndexOfParams`.
`String` | `toString()`
`StringBuffer` | `toXML()` This method returns an XML representation as `StringBuffer` of an instance of the implementing class.

Methods inherited from class de.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
`getAlphabetContainer, getCharacteristics, getInitialClassParam, getLength, getLogScoreAndPartialDerivation, getLogScoreAndPartialDerivation, getLogScoreFor, getLogScoreFor, getLogScoreFor, getLogScoreFor, getNumberOfStarts, getNumericalCharacteristics`

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

Field Detail

### score

    protected DifferentiableSequenceScore[] score

  The internally used `DifferentiableSequenceScore`s.

### index

    protected int[] index

  This index indicates which entry of the array `score` should be used for the specific parts.

### start

    protected int[] start

  This array specifies the start positions of the specific parts.

### partialLength

    protected int[] partialLength

  This array specifies the lengths of the specific parts.

### reverse

    protected boolean[] reverse

  This array specifies whether the sequence or its reverse complement is used in the specific parts.

### isVariable

    protected boolean[] isVariable

  This array specifies for each entry of `score` whether it is able to score sequences of variable length.

### startIndexOfParams

    protected int[] startIndexOfParams

  This array contains the start indices for `DifferentiableSequenceScore.setParameters(double[], int)` on `score`.

Constructor Detail

### IndependentProductDiffSS

    public IndependentProductDiffSS(boolean plugIn,
                                    DifferentiableSequenceScore... functions)
                             throws CloneNotSupportedException,
                                    WrongAlphabetException

  This constructor creates an instance of an `IndependentProductDiffSS` from a given series of independent `DifferentiableSequenceScore`s. The length that is modeled by each component is determined by `SequenceScore.getLength()`. So the length should not be 0.

  Parameters:
    `plugIn` - whether to use plugIn parameters for the parts, otherwise the last parameters are used for parts that are instance of `HomogeneousDiffSM`
    `functions` - the components, i.e. the given series of independent `DifferentiableSequenceScore`s
  Throws:
    `CloneNotSupportedException` - if at least one element of `functions` could not be cloned
    `WrongAlphabetException` - if the user tries to use an alphabet for a reverse complement that can not be used for a reverse complement.
  See Also:
    `IndependentProductDiffSS(boolean, DifferentiableSequenceScore[], int[])`

### IndependentProductDiffSS

    public IndependentProductDiffSS(boolean plugIn,
                                    DifferentiableSequenceScore[] functions,
                                    int[] length)
                             throws CloneNotSupportedException,
                                    WrongAlphabetException

  This constructor creates an instance of an `IndependentProductDiffSS` from given series of independent `DifferentiableSequenceScore`s and lengths.

  Parameters:
    `plugIn` - whether to use plugIn parameters for the parts, otherwise the last parameters are used for parts that are instance of `HomogeneousDiffSM`
    `functions` - the components, i.e. the given series of independent `DifferentiableSequenceScore`s
    `length` - the lengths, one for each component
  Throws:
    `CloneNotSupportedException` - if at least one component could not be cloned
    `WrongAlphabetException` - if the user tries to use an alphabet for a reverse complement that can not be used for a reverse complement.
  See Also:
    `IndependentProductDiffSS(boolean, DifferentiableSequenceScore[], int[], int[], boolean[])`

### IndependentProductDiffSS

    public IndependentProductDiffSS(boolean plugIn,
                                    DifferentiableSequenceScore[] functions,
                                    int[] index,
                                    int[] length,
                                    boolean[] reverse)
                             throws CloneNotSupportedException,
                                    WrongAlphabetException

  This is the main constructor.

  Parameters:
    `plugIn` - whether to use plugIn parameters for the parts, otherwise the last parameters are used for parts that are instance of `HomogeneousDiffSM`
    `functions` - the `DifferentiableSequenceScore`
    `index` - the index of the `DifferentiableSequenceScore` at each part
    `length` - the length of each part
    `reverse` - a switch whether to use it directly or the reverse complementary strand
  Throws:
    `CloneNotSupportedException` - if at least one component could not be cloned
    `WrongAlphabetException` - if the user tries to use an alphabet for a reverse complement that can not be used for a reverse complement.

### IndependentProductDiffSS

    public IndependentProductDiffSS(StringBuffer source)
                             throws NonParsableException

  This is the constructor for the interface `Storable`. Creates a new `IndependentProductDiffSS` out of a `StringBuffer` as returned by `toXML()`.

  Parameters:
    `source` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the XML representation could not be parsed

Method Detail

### getLengthArray

    protected static final int[] getLengthArray(DifferentiableSequenceScore... function)
                                         throws IllegalArgumentException

  This method provides an array of lengths that can be used for instance as `partialLength`.

  Parameters:
    `function` - the internally used `DifferentiableSequenceScore`s
  Returns:
    an array of lengths that can be used for instance as `partialLength`
  Throws:
    `IllegalArgumentException` - if at least one `function` has length 0
  See Also:
    `SequenceScore.getLength()`, `IndependentProductDiffSS(boolean, DifferentiableSequenceScore...)`

### setParamsStarts

    protected void setParamsStarts()

  This method set the value of the array `startIndexOfParams`.

### clone

    public IndependentProductDiffSS clone()
                                   throws CloneNotSupportedException

  Description copied from interface: `DifferentiableSequenceScore`
  Creates a clone (deep copy) of the current `DifferentiableSequenceScore` instance.

  Specified by:
    `clone` in interface `DifferentiableSequenceScore`
  Specified by:
    `clone` in interface `SequenceScore`
  Overrides:
    `clone` in class `AbstractDifferentiableSequenceScore`
  Returns:
    the cloned instance of the current `DifferentiableSequenceScore`
  Throws:
    `CloneNotSupportedException` - if something went wrong while cloning the `DifferentiableSequenceScore`

### initializeFunction

    public void initializeFunction(int index,
                                   boolean freeParams,
                                   DataSet[] data,
                                   double[][] weights)
                            throws Exception

  Description copied from interface: `DifferentiableSequenceScore`
  This method creates the underlying structure of the `DifferentiableSequenceScore`.

  Parameters:
    `index` - the index of the class the `DifferentiableSequenceScore` models
    `freeParams` - indicates whether the (reduced) parameterization is used
    `data` - the samples
    `weights` - the weights of the sequences in the samples
  Throws:
    `Exception` - if something went wrong

### extractSequenceParts

    public int extractSequenceParts(int scoringFunctionIndex,
                                    DataSet[] data,
                                    DataSet[] result)
                             throws Exception

  This method extracts the corresponding `Sequence` parts for a specific `DifferentiableSequenceScore`.

  Parameters:
    `scoringFunctionIndex` - the index of the `DifferentiableSequenceScore`
    `data` - the original data
    `result` - an array for the resulting `DataSet`s of `Sequence`s; has to have same length as `data`
  Returns:
    the number how often the `DifferentiableSequenceScore` was used
  Throws:
    `Exception` - if the `DataSet` can not be created

### extractWeights

    public double[][] extractWeights(int number,
                                     double[][] weights)

  This method creates the weights for `extractSequenceParts(int, DataSet[], DataSet[])`.

  Parameters:
    `number` - the number how often the weights should be copied after each other.
    `weights` - the original weights
  Returns:
    the new weights (might be `null`)
  See Also:
    `extractSequenceParts(int, DataSet[], DataSet[])`

### fromXML

    protected void fromXML(StringBuffer rep)
                    throws NonParsableException

  Description copied from class: `AbstractDifferentiableSequenceScore`
  This method is called in the constructor for the `Storable` interface to create a scoring function from a `StringBuffer`.

  Specified by:
    `fromXML` in class `AbstractDifferentiableSequenceScore`
  Parameters:
    `rep` - the XML representation as `StringBuffer`
  Throws:
    `NonParsableException` - if the `StringBuffer` could not be parsed
  See Also:
    `AbstractDifferentiableSequenceScore.AbstractDifferentiableSequenceScore(StringBuffer)`

### getFurtherInformation

    protected StringBuffer getFurtherInformation()

  This method is used to append further information of the instance to the XML representation. This method is designed to allow subclasses to add information to the XML representation.

  Returns:
    the further information as XML code in a `StringBuffer`

### extractFurtherInformation

    protected void extractFurtherInformation(StringBuffer xml)
                                      throws NonParsableException

  This method is the opposite of `getFurtherInformation()`. It extracts further information of the instance from a XML representation.

  Parameters:
    `xml` - the `StringBuffer` containing the information to be extracted as XML code
  Throws:
    `NonParsableException` - if the `StringBuffer` could not be parsed

### getInstanceName

    public String getInstanceName()

  Description copied from interface: `SequenceScore`
  Should return a short instance name such as iMM(0), BN(2), ...

  Returns:
    a short instance name

### getFunctions

    public DifferentiableSequenceScore[] getFunctions()
                                               throws Exception

  This method returns a deep copy of the internally used `DifferentiableSequenceScore`.

  Returns:
    a deep copy of the internally used `DifferentiableSequenceScore`
  Throws:
    `Exception` - if at least one `DifferentiableSequenceScore` could not be cloned
  See Also:
    `getIndices()`, `getPartialLengths()`, `getReverseSwitches()`

### getIndices

    public int[] getIndices()

  This method returns a deep copy of the internally used indices of the `DifferentiableSequenceScore` for the parts.

  Returns:
    a deep copy of the internally used indices of the `DifferentiableSequenceScore` for the parts
  See Also:
    `getFunctions()`, `getPartialLengths()`, `getReverseSwitches()`

### getPartialLengths

    public int[] getPartialLengths()

  This method returns a deep copy of the internally used partial lengths of the parts.

  Returns:
    a deep copy of the internally used partial lengths of the parts
  See Also:
    `getFunctions()`, `getIndices()`, `getReverseSwitches()`

### getReverseSwitches

    public boolean[] getReverseSwitches()

  This method returns a deep copy of the internally used switches for the parts whether to use the corresponding `DifferentiableSequenceScore` forward or as reverse complement.

  Returns:
    a deep copy of the internally used switches for the parts whether to use the corresponding `DifferentiableSequenceScore` forward or as reverse complement
  See Also:
    `getFunctions()`, `getIndices()`, `getPartialLengths()`

### getCurrentParameterValues

    public double[] getCurrentParameterValues()
                                       throws Exception

  Description copied from interface: `DifferentiableSequenceScore`
  Returns a `double` array of dimension `DifferentiableSequenceScore.getNumberOfParameters()` containing the current parameter values. If one likes to use these parameters to start an optimization it is highly recommended to invoke `DifferentiableSequenceScore.initializeFunction(int, boolean, DataSet[], double[][])` before. After an optimization this method can be used to get the current parameter values.

  Returns:
    the current parameter values
  Throws:
    `Exception` - if no parameters exist (yet)

### getLogScoreFor

    public double getLogScoreFor(Sequence seq,
                                 int start)

  Description copied from interface: `SequenceScore`
  Returns the logarithmic score for the `Sequence` `seq` beginning at position `start` in the `Sequence`.

  Parameters:
    `seq` - the `Sequence`
    `start` - the start position in the `Sequence`
  Returns:
    the logarithmic score for the `Sequence`

### getLogScoreAndPartialDerivation

    public double getLogScoreAndPartialDerivation(Sequence seq,
                                                  int start,
                                                  IntList indices,
                                                  DoubleList partialDer)

  Description copied from interface: `DifferentiableSequenceScore`
  Returns the logarithmic score for a `Sequence` beginning at position `start` in the `Sequence` and fills lists with the indices and the partial derivations.

  Parameters:
    `seq` - the `Sequence`
    `start` - the start position in the `Sequence`
    `indices` - an `IntList` of indices, after method invocation the list should contain the indices i where is not zero
    `partialDer` - a `DoubleList` of partial derivations, after method invocation the list should contain the corresponding that are not zero
  Returns:
    the logarithmic score for the `Sequence`

### getNumberOfParameters

    public int getNumberOfParameters()

  Description copied from interface: `DifferentiableSequenceScore`
  Returns the number of parameters in this `DifferentiableSequenceScore`. If the number of parameters is not known yet, the method returns `DifferentiableSequenceScore.UNKNOWN`.

  Returns:
    the number of parameters in this `DifferentiableSequenceScore`
  See Also:
    `DifferentiableSequenceScore.UNKNOWN`

### getNumberOfRecommendedStarts

    public int getNumberOfRecommendedStarts()

  Description copied from interface: `DifferentiableSequenceScore`
  This method returns the number of recommended optimization starts. The standard implementation returns 1.

  Specified by:
    `getNumberOfRecommendedStarts` in interface `DifferentiableSequenceScore`
  Overrides:
    `getNumberOfRecommendedStarts` in class `AbstractDifferentiableSequenceScore`
  Returns:
    the number of recommended optimization starts

### setParameters

    public void setParameters(double[] params,
                              int start)

  Description copied from interface: `DifferentiableSequenceScore`
  This method sets the internal parameters to the values of `params` between `start` and `start + `DifferentiableSequenceScore.getNumberOfParameters()` - 1`

  Parameters:
    `params` - the new parameters
    `start` - the start index in `params`

### toXML

    public StringBuffer toXML()

  Description copied from interface: `Storable`
  This method returns an XML representation as `StringBuffer` of an instance of the implementing class.

  Returns:
    the XML representation

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### isInitialized

    public boolean isInitialized()

  Description copied from interface: `SequenceScore`
  This method can be used to determine whether the instance is initialized. If the instance is initialized you should be able to invoke `SequenceScore.getLogScoreFor(Sequence)`.

  Returns:
    `true` if the instance is initialized, `false` otherwise

### initializeFunctionRandomly

    public void initializeFunctionRandomly(boolean freeParams)
                                    throws Exception

  Description copied from interface: `DifferentiableSequenceScore`
  This method initializes the `DifferentiableSequenceScore` randomly. It has to create the underlying structure of the `DifferentiableSequenceScore`.

  Parameters:
    `freeParams` - indicates whether the (reduced) parameterization is used
  Throws:
    `Exception` - if something went wrong

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