jbil.sequence
Class UniformFixedLengthSequenceModel

java.lang.Object
  extended by jbil.sequence.AbstractFixedLengthSequenceModel
      extended by jbil.sequence.UniformFixedLengthSequenceModel
All Implemented Interfaces:
FixedLengthSequenceModel, SequenceModel

public class UniformFixedLengthSequenceModel
extends AbstractFixedLengthSequenceModel

This class represents a uniform model for words of a fixed length W over a given alphabet A.

Under this model, all sequences of length W have the same probability 1/(|A|^W).

Author:
Paulo G. S. da Fonseca

Constructor Summary
UniformFixedLengthSequenceModel(Alphabet alphabet, int length)
          Creates a new fixed length uniform model.
 
Method Summary
 Alphabet getAlphabet()
          Returns the base alphabet of the modelled sequences.
 int length()
          Returns the length of the modelled sequences.
 double likelihood(Sequence word, int beginIndex)
          Returns the likelihod of the subword of the given word starting at beginIndex and with the appropriate length.
 double likelihoodThreshold(double significance)
          Computes the likelihood threshold for the given significance with a default null model.
 double likelihoodThreshold(double significance, SequenceModel nullModel)
          Given p in [0,1], we define the p-value of p as the as the probability under a null model for a sequence to have a likelihood greater or equal to p.
 double positionProbability(int position, Sequence neighbourhoodSeq, int beginIndex, int endIndex, int letterPosition)
          Computes the probability of observing a letter in a given position of the sequence.
 double prefixLikelihood(Sequence sequence, int beginIndex, int endIndex)
          Returns the likelihod of the given prefix under this model, that is, the sum of the probabilities of all words starting with the subword of sequence starting at position beginIndex and ending at position endIndex-1.
 double pvalue(Sequence word, int beginIndex)
          Returns the p-value of the subword of the given word starting at beginIndex and of the appropriate length with a default null model (typically the uniform model).
 double pvalue(Sequence word, int beginIndex, SequenceModel nullModel)
          Returns the p-value of the subword of the given word starting at beginIndex and with the appropriate length.
 Sequence sample()
          Samples a sequence with the apropriate length from this model.
 
Methods inherited from class jbil.sequence.AbstractFixedLengthSequenceModel
likelihood, likelihood, prefixLikelihood, pvalue, pvalue, pvalue, pvalue, sample, sampleN, sampleN
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniformFixedLengthSequenceModel

public UniformFixedLengthSequenceModel(Alphabet alphabet,
                                       int length)
Creates a new fixed length uniform model.

Parameters:
alphabet - The base alphabet.
length - The length of the modelled words.
Method Detail

length

public int length()
Description copied from interface: FixedLengthSequenceModel
Returns the length of the modelled sequences.


likelihood

public double likelihood(Sequence word,
                         int beginIndex)
Description copied from interface: FixedLengthSequenceModel
Returns the likelihod of the subword of the given word starting at beginIndex and with the appropriate length.


prefixLikelihood

public double prefixLikelihood(Sequence sequence,
                               int beginIndex,
                               int endIndex)
Description copied from interface: SequenceModel
Returns the likelihod of the given prefix under this model, that is, the sum of the probabilities of all words starting with the subword of sequence starting at position beginIndex and ending at position endIndex-1.


pvalue

public double pvalue(Sequence word,
                     int beginIndex)
Description copied from interface: FixedLengthSequenceModel
Returns the p-value of the subword of the given word starting at beginIndex and of the appropriate length with a default null model (typically the uniform model).

Specified by:
pvalue in interface FixedLengthSequenceModel
Overrides:
pvalue in class AbstractFixedLengthSequenceModel
See Also:
SequenceModel.pvalue(Sequence, SequenceModel)

pvalue

public double pvalue(Sequence word,
                     int beginIndex,
                     SequenceModel nullModel)
Description copied from interface: FixedLengthSequenceModel
Returns the p-value of the subword of the given word starting at beginIndex and with the appropriate length.

See Also:
SequenceModel.pvalue(Sequence, SequenceModel)

sample

public Sequence sample()
Description copied from interface: FixedLengthSequenceModel
Samples a sequence with the apropriate length from this model.


getAlphabet

public Alphabet getAlphabet()
Description copied from interface: SequenceModel
Returns the base alphabet of the modelled sequences.


likelihoodThreshold

public double likelihoodThreshold(double significance)
Description copied from interface: SequenceModel
Computes the likelihood threshold for the given significance with a default null model.

Specified by:
likelihoodThreshold in interface SequenceModel
Overrides:
likelihoodThreshold in class AbstractFixedLengthSequenceModel
See Also:
SequenceModel.likelihoodThreshold(double, SequenceModel)

likelihoodThreshold

public double likelihoodThreshold(double significance,
                                  SequenceModel nullModel)
Description copied from interface: SequenceModel
Given p in [0,1], we define the p-value of p as the as the probability under a null model for a sequence to have a likelihood greater or equal to p. The p-value is a monotonically non-increasing function of p. This method computes the value
t := max { x in [0,1] | p-value_m0(x;m) >= p }

Parameters:
significance - The p of the description above.
nullModel - The null model m0 of the description above.

positionProbability

public double positionProbability(int position,
                                  Sequence neighbourhoodSeq,
                                  int beginIndex,
                                  int endIndex,
                                  int letterPosition)
Description copied from interface: SequenceModel
Computes the probability of observing a letter in a given position of the sequence. For that, it may be necessary to indicate a sequence containig a neighbourhood of the letter.

Parameters:
position - the position at which the letter appears.
neighbourhoodSeq - A sequence containing the neighbourhood.
beginIndex - The start of the neighbourhood within neighbourhoodSeq.
endIndex - The end of the neighbourhood within neighbourhoodSeq.
letterPosition - The position of the target letter within neighbourhoodSeq.
Returns:
Pr(X[position]=neighbourhoodSeq[letterPosition] | neighbourhood of X[position] = neighbourhoodSeq[beginIndex..endIndex-1])