Package Bio :: Package HMM :: Module DynamicProgramming :: Class AbstractDPAlgorithms
[hide private]
[frames] | no frames]

Class AbstractDPAlgorithms

source code

object --+
         |
        AbstractDPAlgorithms
Known Subclasses:

An abstract class to calculate forward and backward probabilities.

This class should not be instantiated directly, but should be used
through a derived class which implements proper scaling of variables.

This class is just meant to encapsulate the basic forward and backward
algorithms, and allow derived classes to deal with the problems of
multiplying probabilities.

Derived class of this must implement:

o _forward_recursion -- Calculate the forward values in the recursion
using some kind of technique for preventing underflow errors.

o _backward_recursion -- Calculate the backward values in the recursion
step using some technique to prevent underflow errors.

Instance Methods [hide private]
 
__init__(self, markov_model, sequence)
Initialize to calculate forward and backward probabilities.
source code
 
_forward_recursion(self, cur_state, sequence_pos, forward_vars)
Calculate the forward recursion value.
source code
 
forward_algorithm(self)
Calculate sequence probability using the forward algorithm.
source code
 
_backward_recursion(self, cur_state, sequence_pos, forward_vars)
Calculate the backward recursion value.
source code
 
backward_algorithm(self)
Calculate sequence probability using the backward algorithm.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, markov_model, sequence)
(Constructor)

source code 
Initialize to calculate forward and backward probabilities.

Arguments:

o markov_model -- The current Markov model we are working with.

o sequence -- A training sequence containing a set of emissions.

Overrides: object.__init__

forward_algorithm(self)

source code 
Calculate sequence probability using the forward algorithm.

This implements the forward algorithm, as described on p57-58 of
Durbin et al.

Returns:

o A dictionary containing the forward variables. This has keys of the
form (state letter, position in the training sequence), and values
containing the calculated forward variable.

o The calculated probability of the sequence.

backward_algorithm(self)

source code 
Calculate sequence probability using the backward algorithm.

This implements the backward algorithm, as described on p58-59 of
Durbin et al.

Returns:

o A dictionary containing the backwards variables. This has keys
of the form (state letter, position in the training sequence),
and values containing the calculated backward variable.