|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.jstacs.models.AbstractModel
de.jstacs.models.mixture.AbstractMixtureModel
de.jstacs.models.mixture.motif.HiddenMotifMixture
public abstract class HiddenMotifMixture
This is the main class that every generative motif discoverer should implement. It implements the mixture of containing 0 or 1 motif in a sequence.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class de.jstacs.models.mixture.AbstractMixtureModel |
|---|
AbstractMixtureModel.Algorithm, AbstractMixtureModel.Parameterization |
| Nested classes/interfaces inherited from interface de.jstacs.motifDiscovery.MotifDiscoverer |
|---|
MotifDiscoverer.KindOfProfile |
| Field Summary | |
|---|---|
protected byte |
bgMaxMarkovOrder
The order of the background model. |
protected PositionPrior |
posPrior
The prior for the positions. |
protected boolean |
trainOnlyMotifModel
A switch that enables to train only the motif model. |
| Fields inherited from class de.jstacs.models.mixture.AbstractMixtureModel |
|---|
algorithm, algorithmHasBeenRun, alternativeModel, burnInTest, componentHyperParams, compProb, counter, dimension, estimateComponentProbs, file, filereader, filewriter, initialIteration, logWeights, model, optimizeModel, sample, samplingIndex, sostream, starts, stationaryIteration, weights |
| Fields inherited from class de.jstacs.models.AbstractModel |
|---|
alphabets, length |
| Constructor Summary | |
|---|---|
protected |
HiddenMotifMixture(Model[] models,
int starts,
boolean estimateComponentProbs,
double[] componentHyperParams,
double[] weights,
PositionPrior posPrior,
boolean trainOnlyMotifModel,
AbstractMixtureModel.Algorithm algorithm,
double alpha,
double eps,
AbstractMixtureModel.Parameterization parametrization,
int initialIteration,
int stationaryIteration,
BurnInTest burnInTest)
Creates a new AbstractMixtureModel. |
protected |
HiddenMotifMixture(StringBuffer xml)
The standard constructor for the interface Storable. |
| Method Summary | |
|---|---|
protected void |
checkLength(int index,
int l)
This method checks if the length l of the model with index index is
capable for the current instance. |
HiddenMotifMixture |
clone()
Follows the conventions of Object's clone-method. |
protected Sequence[] |
emitSampleUsingCurrentParameterSet(int n,
int... lengths)
Standard implementation throwing an OperationNotSupportedException. |
protected void |
extractFurtherInformation(StringBuffer xml)
This method is used in the subclasses to extract further information from the xml representation and to set these as values of the instance. |
protected StringBuffer |
getFurtherInformation()
This method is used in the subclasses to append further information at the xml representation. |
String |
getInstanceName()
Should return a short instance name such as iMM(0), BN(2), ... |
double |
getLogPriorTerm()
Returns a value that is proportional to the log of the prior. |
abstract int |
getMinimalSequenceLength()
Returns the minimal length a sequence respectively a sample has to have. |
protected void |
getNewParameters(int iteration,
double[][] seqWeights,
double[] w)
This method trains the internal models on the internal sample and the given weights. |
String |
toString()
Should give a simple representation (text) of the model as String. |
void |
train(Sample data,
double[] weights)
Trains the Model object given the data as Sample using the specified weights. |
void |
trainBgModel(Sample data,
double[] weights)
This method trains the bg-model. |
| Methods inherited from class de.jstacs.models.AbstractModel |
|---|
getAlphabetContainer, getLength, getLogProbFor, getLogProbFor, getLogProbFor, getMaximalMarkovOrder, getPriorTerm, getProbFor, getProbFor, setNewAlphabetContainerInstance, train |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface de.jstacs.motifDiscovery.MotifDiscoverer |
|---|
getGlobalIndexOfMotifInComponent, getIndexOfMaximalComponentFor, getMotifLength, getNumberOfComponents, getNumberOfMotifs, getNumberOfMotifsInComponent, getProfileOfScoresFor, getStrandFor |
| Methods inherited from interface de.jstacs.Storable |
|---|
toXML |
| Field Detail |
|---|
protected PositionPrior posPrior
protected boolean trainOnlyMotifModel
protected byte bgMaxMarkovOrder
| Constructor Detail |
|---|
protected HiddenMotifMixture(Model[] models,
int starts,
boolean estimateComponentProbs,
double[] componentHyperParams,
double[] weights,
PositionPrior posPrior,
boolean trainOnlyMotifModel,
AbstractMixtureModel.Algorithm algorithm,
double alpha,
double eps,
AbstractMixtureModel.Parameterization parametrization,
int initialIteration,
int stationaryIteration,
BurnInTest burnInTest)
throws CloneNotSupportedException,
IllegalArgumentException,
WrongAlphabetException
models - the single models building the AbstractMixtureModel, if the model is trained using
AbstractMixtureModel.Algorithm.GIBBS_SAMPLING the models that will be adjusted have to implement
GibbsSamplingComponent.
The models that are used for the flanking sequences have to be able to score sequences of arbitrary length.starts - the number of times the algorithm will be started in the train method, at least 1estimateComponentProbs - the switch for estimating the component probabilities in the algorithm or to hold them fixed;
if the component parameters are fixed, the values of weights will be used, otherwise
the componentHyperParams will be incorporated in the adjustmentcomponentHyperParams - the hyperparameters for the component assignment prior,
estimateComponentProbs == true
null or has to have length dimension
null or an array with all values zero (0) than ML
parameterization
weights - null or the weights for the components (than weights.length == dimension)posPrior - this object determine the positional distribution that shall be usedtrainOnlyMotifModel - a switch whether to train only the motif modelalgorithm - either AbstractMixtureModel.Algorithm.EM
or AbstractMixtureModel.Algorithm.GIBBS_SAMPLINGalpha - only for AbstractMixtureModel.Algorithm.EMtrain to initialize
the gammas. It is recommended to use alpha = 1 (uniform distribution on a simplex).eps - only for AbstractMixtureModel.Algorithm.EMparametrization - only for AbstractMixtureModel.Algorithm.EMAbstractMixtureModel.Parameterization.THETA
or AbstractMixtureModel.Parameterization.LAMBDA
LAMBDA
initialIteration - only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLINGstationaryIteration/starts)stationaryIteration - only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLINGburnInTest - only for AbstractMixtureModel.Algorithm.GIBBS_SAMPLINGIllegalArgumentException - if
weights != null && weights.length != 2
weights != null and it exists an i where weights[i] < 0
starts < 1
WrongAlphabetException - if not all models work on the same simple alphabet
CloneNotSupportedException - if the models can not be cloned
protected HiddenMotifMixture(StringBuffer xml)
throws NonParsableException
Storable.
xml - the StringBuffer containing the model
NonParsableException - if the StringBuffer can not be parsed| Method Detail |
|---|
public HiddenMotifMixture clone()
throws CloneNotSupportedException
AbstractModelObject's clone-method.
clone in interface Modelclone in class AbstractMixtureModelAbstractModel (the member-AlphabetContainer
isn't deeply cloned since it is assumed to be immutable). The type of the returned object is defined by
the class X directly inherited from AbstractModel. Hence X's
clone-method should work as:Object o = (X)super.clone(); 2. all additional member variables of o
defined by X that are not of simple data-types like int, double, ... , have to be deeply
copied 3. return o
CloneNotSupportedExceptionprotected StringBuffer getFurtherInformation()
AbstractMixtureModel
getFurtherInformation in class AbstractMixtureModelAbstractMixtureModel.extractFurtherInformation(StringBuffer)
protected void extractFurtherInformation(StringBuffer xml)
throws NonParsableException
AbstractMixtureModel
extractFurtherInformation in class AbstractMixtureModelxml - the xml representation
NonParsableException - if the xml representation is not parsableAbstractMixtureModel.getFurtherInformation()
public void train(Sample data,
double[] weights)
throws Exception
ModelSample using the specified weights. The weight
at position i belongs to the element at position i. So the array weight should have the number of
sequences in the sample as dimension. (Optionally it is possible to use weight == null if all
weights have the value one.)
train in interface Modeltrain in class AbstractMixtureModeldata - the given sequencesweights - the weights of the elements, each weight should be non-negative
Exception - an Exception should be thrown if the training did not succeed (e.g. the weights dimension of weights
and number of samples does not match).Sample.getElementAt(int),
Sample.ElementEnumerator
public final void trainBgModel(Sample data,
double[] weights)
throws Exception
data - the sampleweights - the weights
Exception - if something went wrong
protected void getNewParameters(int iteration,
double[][] seqWeights,
double[] w)
throws Exception
AbstractMixtureModel
getNewParameters in class AbstractMixtureModeliteration - the number this method has been invokedseqWeights - the weights for each model and sequencew - the weights for the components
Exception - if the training of the internal models went wrong
protected void checkLength(int index,
int l)
AbstractMixtureModell of the model with index index is
capable for the current instance. Otherwise an IllegalArgumentException is thrown.
checkLength in class AbstractMixtureModelindex - the index of the modell - the length of the modelpublic abstract int getMinimalSequenceLength()
public String getInstanceName()
Model
getInstanceName in interface ModelgetInstanceName in class AbstractMixtureModel
public double getLogPriorTerm()
throws Exception
Model
getLogPriorTerm in interface ModelgetLogPriorTerm in class AbstractMixtureModelException - if something went wrongModel.getPriorTerm()public String toString()
Model
toString in interface ModeltoString in class Object
protected Sequence[] emitSampleUsingCurrentParameterSet(int n,
int... lengths)
throws Exception
emitSampleUsingCurrentParameterSet in class AbstractMixtureModeln - the number of sequences to be sampledlengths - the corresponding lengths
Exception - if it was impossible to sampleAbstractModel.emitSample(int, int...)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||