|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.sequenceScores.differentiable.AbstractDifferentiableSequenceScore
de.jstacs.sequenceScores.differentiable.IndependentProductDiffSS
public class IndependentProductDiffSS
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.
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 + |
protected void |
setParamsStarts()
This method set the value of the array startIndexOfParams . |
String |
toString(NumberFormat nf)
This method returns a String representation of the instance. |
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, toString, wait, wait, wait |
Field Detail |
---|
protected DifferentiableSequenceScore[] score
DifferentiableSequenceScore
s.
protected int[] index
score
should be used for the specific parts.
protected int[] start
protected int[] partialLength
protected boolean[] reverse
protected boolean[] isVariable
score
whether it is able to score sequences of variable length.
protected int[] startIndexOfParams
DifferentiableSequenceScore.setParameters(double[], int)
on score
.
Constructor Detail |
---|
public IndependentProductDiffSS(boolean plugIn, DifferentiableSequenceScore... functions) throws CloneNotSupportedException, WrongAlphabetException
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.
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
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.IndependentProductDiffSS(boolean, DifferentiableSequenceScore[], int[])
public IndependentProductDiffSS(boolean plugIn, DifferentiableSequenceScore[] functions, int[] length) throws CloneNotSupportedException, WrongAlphabetException
IndependentProductDiffSS
from given series of
independent DifferentiableSequenceScore
s and lengths.
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
slength
- the lengths, one for each component
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(boolean, DifferentiableSequenceScore[], int[], int[], boolean[])
public IndependentProductDiffSS(boolean plugIn, DifferentiableSequenceScore[] functions, int[] index, int[] length, boolean[] reverse) throws CloneNotSupportedException, WrongAlphabetException
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 partlength
- the length of each partreverse
- a switch whether to use it directly or the reverse complementary strand
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.public IndependentProductDiffSS(StringBuffer source) throws NonParsableException
Storable
.
Creates a new IndependentProductDiffSS
out of a
StringBuffer
as returned by toXML()
.
source
- the XML representation as StringBuffer
NonParsableException
- if the XML representation could not be parsedMethod Detail |
---|
protected static final int[] getLengthArray(DifferentiableSequenceScore... function) throws IllegalArgumentException
partialLength
.
function
- the internally used DifferentiableSequenceScore
s
partialLength
IllegalArgumentException
- if at least one function
has length 0SequenceScore.getLength()
,
IndependentProductDiffSS(boolean, DifferentiableSequenceScore...)
protected void setParamsStarts()
startIndexOfParams
.
public IndependentProductDiffSS clone() throws CloneNotSupportedException
DifferentiableSequenceScore
DifferentiableSequenceScore
instance.
clone
in interface DifferentiableSequenceScore
clone
in interface SequenceScore
clone
in class AbstractDifferentiableSequenceScore
DifferentiableSequenceScore
CloneNotSupportedException
- if something went wrong while cloning the
DifferentiableSequenceScore
public void initializeFunction(int index, boolean freeParams, DataSet[] data, double[][] weights) throws Exception
DifferentiableSequenceScore
DifferentiableSequenceScore
.
index
- the index of the class the DifferentiableSequenceScore
modelsfreeParams
- indicates whether the (reduced) parameterization is useddata
- the data setsweights
- the weights of the sequences in the data sets
Exception
- if something went wrongpublic int extractSequenceParts(int scoringFunctionIndex, DataSet[] data, DataSet[] result) throws Exception
Sequence
parts for a specific DifferentiableSequenceScore
.
scoringFunctionIndex
- the index of the DifferentiableSequenceScore
data
- the original dataresult
- an array for the resulting DataSet
s of Sequence
s; has to have same length as data
DifferentiableSequenceScore
was used
Exception
- if the DataSet
can not be createdpublic double[][] extractWeights(int number, double[][] weights)
extractSequenceParts(int, DataSet[], DataSet[])
.
number
- the number how often the weights should be copied after each other.weights
- the original weights
null
)extractSequenceParts(int, DataSet[], DataSet[])
protected void fromXML(StringBuffer rep) throws NonParsableException
AbstractDifferentiableSequenceScore
Storable
interface to create a scoring function from a StringBuffer
.
fromXML
in class AbstractDifferentiableSequenceScore
rep
- the XML representation as StringBuffer
NonParsableException
- if the StringBuffer
could not be parsedAbstractDifferentiableSequenceScore.AbstractDifferentiableSequenceScore(StringBuffer)
protected StringBuffer getFurtherInformation()
StringBuffer
protected void extractFurtherInformation(StringBuffer xml) throws NonParsableException
getFurtherInformation()
. It
extracts further information of the instance from a XML representation.
xml
- the StringBuffer
containing the information to be
extracted as XML code
NonParsableException
- if the StringBuffer
could not be parsedpublic String getInstanceName()
SequenceScore
public DifferentiableSequenceScore[] getFunctions() throws Exception
DifferentiableSequenceScore
.
DifferentiableSequenceScore
Exception
- if at least one DifferentiableSequenceScore
could not be clonedgetIndices()
,
getPartialLengths()
,
getReverseSwitches()
public int[] getIndices()
DifferentiableSequenceScore
for the parts.
DifferentiableSequenceScore
for the partsgetFunctions()
,
getPartialLengths()
,
getReverseSwitches()
public int[] getPartialLengths()
getFunctions()
,
getIndices()
,
getReverseSwitches()
public boolean[] getReverseSwitches()
DifferentiableSequenceScore
forward or as reverse complement.
DifferentiableSequenceScore
forward or as reverse complementgetFunctions()
,
getIndices()
,
getPartialLengths()
public double[] getCurrentParameterValues() throws Exception
DifferentiableSequenceScore
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.
Exception
- if no parameters exist (yet)public double getLogScoreFor(Sequence seq, int start)
SequenceScore
Sequence
seq
beginning at position start
in the Sequence
.
seq
- the Sequence
start
- the start position in the Sequence
Sequence
public double getLogScoreAndPartialDerivation(Sequence seq, int start, IntList indices, DoubleList partialDer)
DifferentiableSequenceScore
Sequence
beginning at
position start
in the Sequence
and fills lists with
the indices and the partial derivations.
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
partialDer
- a DoubleList
of partial derivations, after method
invocation the list should contain the corresponding
Sequence
public int getNumberOfParameters()
DifferentiableSequenceScore
DifferentiableSequenceScore
. If the
number of parameters is not known yet, the method returns
DifferentiableSequenceScore.UNKNOWN
.
DifferentiableSequenceScore
DifferentiableSequenceScore.UNKNOWN
public int getNumberOfRecommendedStarts()
DifferentiableSequenceScore
getNumberOfRecommendedStarts
in interface DifferentiableSequenceScore
getNumberOfRecommendedStarts
in class AbstractDifferentiableSequenceScore
public void setParameters(double[] params, int start)
DifferentiableSequenceScore
params
between start
and
start + DifferentiableSequenceScore.getNumberOfParameters()
- 1
params
- the new parametersstart
- the start index in params
public StringBuffer toXML()
Storable
StringBuffer
of an
instance of the implementing class.
public String toString(NumberFormat nf)
SequenceScore
String
representation of the instance.
nf
- the NumberFormat
for the String
representation of parameters or probabilities
String
representation of the instancepublic boolean isInitialized()
SequenceScore
SequenceScore.getLogScoreFor(Sequence)
.
true
if the instance is initialized, false
otherwisepublic void initializeFunctionRandomly(boolean freeParams) throws Exception
DifferentiableSequenceScore
DifferentiableSequenceScore
randomly. It has to
create the underlying structure of the DifferentiableSequenceScore
.
freeParams
- indicates whether the (reduced) parameterization is used
Exception
- if something went wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |