Logo Search packages:      
Sourcecode: python-biopython version File versions  Download package

def Bio::MarkovModel::find_states (   markov_model,
  output 
)

find_states(markov_model, output) -> list of (states, score)

Definition at line 423 of file MarkovModel.py.

00423                                      :
    """find_states(markov_model, output) -> list of (states, score)"""
    mm = markov_model
    N = len(mm.states)
    
    # _viterbi does calculations in log space.  Add a tiny bit to the
    # matrices so that the logs will not break.
    x = mm.p_initial + VERY_SMALL_NUMBER
    y = mm.p_transition + VERY_SMALL_NUMBER
    z = mm.p_emission + VERY_SMALL_NUMBER
    lp_initial, lp_transition, lp_emission = map(log, (x, y, z))
    # Change output into a list of indexes into the alphabet.
    indexes = listfns.itemindex(mm.alphabet)
    output = [indexes[x] for x in output]
    
    # Run the viterbi algorithm.
    results = _viterbi(N, lp_initial, lp_transition, lp_emission, output)

    for i in range(len(results)):
        states, score = results[i]
        results[i] = [mm.states[x] for x in states], exp(score)
    return results

def _viterbi(N, lp_initial, lp_transition, lp_emission, output):


Generated by  Doxygen 1.6.0   Back to index