The Treeterbi and Parallel Treeterbi algorithms: efficient, optimal decoding for ordinary, generalized and pair HMMs

Bioinformatics. 2007 Mar 1;23(5):545-54. doi: 10.1093/bioinformatics/btl659. Epub 2007 Jan 18.


Motivation: Hidden Markov models (HMMs) and generalized HMMs been successfully applied to many problems, but the standard Viterbi algorithm for computing the most probable interpretation of an input sequence (known as decoding) requires memory proportional to the length of the sequence, which can be prohibitive. Existing approaches to reducing memory usage either sacrifice optimality or trade increased running time for reduced memory.

Results: We developed two novel decoding algorithms, Treeterbi and Parallel Treeterbi, and implemented them in the TWINSCAN/N-SCAN gene-prediction system. The worst case asymptotic space and time are the same as for standard Viterbi, but in practice, Treeterbi optimally decodes arbitrarily long sequences with generalized HMMs in bounded memory without increasing running time. Parallel Treeterbi uses the same ideas to split optimal decoding across processors, dividing latency to completion by approximately the number of available processors with constant average overhead per processor. Using these algorithms, we were able to optimally decode all human chromosomes with N-SCAN, which increased its accuracy relative to heuristic solutions. We also implemented Treeterbi for Pairagon, our pair HMM based cDNA-to-genome aligner.

Availability: The TWINSCAN/N-SCAN/PAIRAGON open source software package is available from

Publication types

  • Research Support, N.I.H., Extramural

MeSH terms

  • Algorithms*
  • Chromosomes, Human
  • Computational Biology
  • DNA, Complementary / chemistry
  • Genes*
  • Genomics / methods*
  • Humans
  • Markov Chains
  • Programming Languages


  • DNA, Complementary