Package Bio :: Package HMM :: Module MarkovModel :: Class MarkovModelBuilder
[show private | hide private]
[frames | no frames]

Class MarkovModelBuilder


Interface to build up a Markov Model.

This class is designed to try to separate the task of specifying the Markov Model from the actual model itself. This is in hopes of making the actual Markov Model classes smaller.

So, this builder class should be used to create Markov models instead of trying to initiate a Markov Model directly.
Method Summary
  __init__(self, state_alphabet, emission_alphabet)
Initialize a builder to create Markov Models.
  allow_all_transitions(self)
A convenience function to create transitions between all states.
  allow_transition(self, from_state, to_state, probability, pseudocount)
Set a transition as being possible between the two states.
  destroy_transition(self, from_state, to_state)
Restrict transitions between the two states.
  get_markov_model(self)
Return the markov model corresponding with the current parameters.
  set_emission_pseudocount(self, seq_state, emission_state, count)
Set the default pseudocount for an emission.
  set_emission_score(self, seq_state, emission_state, probability)
Set the probability of a emission from a particular state.
  set_equal_probabilities(self)
Reset all probabilities to be an average value.
  set_random_probabilities(self)
Set all probabilities to randomly generated numbers.
  set_transition_pseudocount(self, from_state, to_state, count)
Set the default pseudocount for a transition.
  set_transition_score(self, from_state, to_state, probability)
Set the probability of a transition between two states.

Class Variable Summary
int DEFAULT_PSEUDO = 1                                                                     

Method Details

__init__(self, state_alphabet, emission_alphabet)
(Constructor)

Initialize a builder to create Markov Models.

Arguments:

o state_alphabet -- An alphabet containing all of the letters that can appear in the states

o emission_alphabet -- An alphabet containing all of the letters for states that can be emitted by the HMM.

allow_all_transitions(self)

A convenience function to create transitions between all states.

By default all transitions within the alphabet are disallowed; this is a way to change this to allow all possible transitions.

allow_transition(self, from_state, to_state, probability=None, pseudocount=None)

Set a transition as being possible between the two states.

probability and pseudocount are optional arguments specifying the probabilities and pseudo counts for the transition. If these are not supplied, then the values are set to the default values.

Raises: KeyError -- if the two states already have an allowed transition.

destroy_transition(self, from_state, to_state)

Restrict transitions between the two states.

Raises: KeyError if the transition is not currently allowed.

get_markov_model(self)

Return the markov model corresponding with the current parameters.

Each markov model returned by a call to this function is unique (ie. they don't influence each other).

set_emission_pseudocount(self, seq_state, emission_state, count)

Set the default pseudocount for an emission.

To avoid computational problems, it is helpful to be able to set a 'default' pseudocount to start with for estimating transition and emission probabilities (see p62 in Durbin et al for more discussion on this. By default, all emissions have a pseudocount of 1.

Raises: KeyError if the emission from the given state is not allowed.

set_emission_score(self, seq_state, emission_state, probability)

Set the probability of a emission from a particular state.

Raises: KeyError if the emission from the given state is not allowed.

set_equal_probabilities(self)

Reset all probabilities to be an average value.

This resets the values of all allowed transitions and all allowed emissions to be equal to 1 divided by the number of possible elements.

This is useful if you just want to initialize a Markov Model to starting values (ie. if you have no prior notions of what the probabilities should be -- or if you are just feeling too lazy to calculate them :-).

Warning 1 -- this will reset all currently set probabilities.

Warning 2 -- This just sets all probabilities for transitions and emissions to total up to 1, so it doesn't ensure that the sum of each set of transitions adds up to 1.

set_random_probabilities(self)

Set all probabilities to randomly generated numbers.

This will reset the value of all allowed transitions and emissions to random values.

Warning 1 -- This will reset any currently set probabibilities.

Warning 2 -- This does not check to ensure that the sum of all of the probabilities is less then 1. It just randomly assigns a probability to each

set_transition_pseudocount(self, from_state, to_state, count)

Set the default pseudocount for a transition.

To avoid computational problems, it is helpful to be able to set a 'default' pseudocount to start with for estimating transition and emission probabilities (see p62 in Durbin et al for more discussion on this. By default, all transitions have a pseudocount of 1.

Raises: KeyError if the transition is not allowed.

set_transition_score(self, from_state, to_state, probability)

Set the probability of a transition between two states.

Raises: KeyError if the transition is not allowed.

Class Variable Details

DEFAULT_PSEUDO

Type:
int
Value:
1                                                                     

Generated by Epydoc 2.1 on Sat Jul 16 15:49:01 2005 http://epydoc.sf.net