biopython v1.71.0 Bio.HMM.DynamicProgramming.AbstractDPAlgorithms

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:

  • _forward_recursion — Calculate the forward values in the recursion using some kind of technique for preventing underflow errors.
  • _backward_recursion — Calculate the backward values in the recursion step using some technique to prevent underflow errors.

Link to this section Summary

Functions

Initialize to calculate forward and backward probabilities

Calculate the backward recursion value

Calculate the forward recursion value

Calculate sequence probability using the backward algorithm

Calculate sequence probability using the forward algorithm

Link to this section Functions

Initialize to calculate forward and backward probabilities.

Arguments:

  • markov_model — The current Markov model we are working with.
  • sequence — A training sequence containing a set of emissions.
Link to this function _backward_recursion()

Calculate the backward recursion value.

Link to this function _forward_recursion()

Calculate the forward recursion value.

Link to this function backward_algorithm()

Calculate sequence probability using the backward algorithm.

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

Returns:

  • 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.
Link to this function forward_algorithm()

Calculate sequence probability using the forward algorithm.

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

Returns:

  • 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.
  • The calculated probability of the sequence.