de.jstacs.sequenceScores.statisticalModels.trainable.discrete.inhomogeneous
Class MEM

java.lang.Object
  extended by de.jstacs.sequenceScores.statisticalModels.trainable.discrete.inhomogeneous.MEM
All Implemented Interfaces:
Storable, Cloneable

public final class MEM
extends Object
implements Storable, Cloneable

This class represents a maximum entropy model. It should not be used without the MEManager.

Author:
Jens Keilwagen

Field Summary
protected  MEMConstraint[] constraints
          The specific constraints of this MEM.
 
Constructor Summary
MEM(AbstractList<int[]> constr, int[] allAlphLen, int[] indices)
          The main constructor of a MEM.
MEM(int[] constraint, int[] allAlphLen, int[][] cond)
          The main constructor of a MEM.
MEM(StringBuffer representation)
          The constructor for the Storable interface.
 
Method Summary
 MEM clone()
           
 double getLogPriorPart(double ess)
          This method compute the prior for the current parameter ignoring some constants.
 double getLogScoreFor(Sequence seq, int start)
          Returns the logarithmic score for the sequence beginning at start.
 double getScoreFor(Sequence seq, int start)
          Returns the score for the sequence beginning at start.
 String toString(NumberFormat nf)
          This method returns some String using a given NumberFormat.
 StringBuffer toXML()
          This method returns an XML representation as StringBuffer of an instance of the implementing class.
 void train(SequenceIterator s, byte algo, TerminationCondition condition, SafeOutputStream sostream)
          This method approximates the distribution either analytically or numerically.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraints

protected MEMConstraint[] constraints
The specific constraints of this MEM.

Constructor Detail

MEM

public MEM(AbstractList<int[]> constr,
           int[] allAlphLen,
           int[] indices)
The main constructor of a MEM.

Parameters:
constr - the constraints
allAlphLen - the alphabet length of all alphabets
indices - the indices of the positions to be used

MEM

public MEM(int[] constraint,
           int[] allAlphLen,
           int[][] cond)
The main constructor of a MEM.

Parameters:
constraint - the constraint
allAlphLen - the alphabet length of all alphabets
cond - the conditional fixed positions

MEM

public MEM(StringBuffer representation)
    throws NonParsableException
The constructor for the Storable interface.

Parameters:
representation - the representation
Throws:
NonParsableException - if the the StringBuffer could not be parsed.
Method Detail

clone

public MEM clone()
          throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

getScoreFor

public double getScoreFor(Sequence seq,
                          int start)
Returns the score for the sequence beginning at start.

Parameters:
seq - the sequence
start - the start position
Returns:
the score for the sequence beginning at start

getLogScoreFor

public double getLogScoreFor(Sequence seq,
                             int start)
Returns the logarithmic score for the sequence beginning at start.

Parameters:
seq - the sequence
start - the start position
Returns:
the logarithmic score for the sequence beginning at start

getLogPriorPart

public double getLogPriorPart(double ess)
This method compute the prior for the current parameter ignoring some constants.

Parameters:
ess - the ESS to be used
Returns:
the prior for the current parameter ignoring some constants
See Also:
StatisticalModel.getLogPriorTerm()

toString

public String toString(NumberFormat nf)
This method returns some String using a given NumberFormat.

Parameters:
nf - the NumberFormat.
Returns:
some String representation

toXML

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

Specified by:
toXML in interface Storable
Returns:
the XML representation

train

public void train(SequenceIterator s,
                  byte algo,
                  TerminationCondition condition,
                  SafeOutputStream sostream)
           throws Exception
This method approximates the distribution either analytically or numerically.

Parameters:
s - the SequenceIterator used in normalization and numerical approximation
algo - the choice of numerical approximation
condition - the TerminationCondition for stopping the iterative algorithm
sostream - a possibility for writing some information
Throws:
Exception - if something went wrong inside the algorithms
See Also:
MEMTools