Optimal spaced seeds for hidden Markov models, with applications to homologous coding regions