void hmm_dump(hmm_t * hmm, FILE * fp) { int32 i; if (hmm_is_mpx(hmm)) { fprintf(fp, "MPX "); for (i = 0; i < hmm_n_emit_state(hmm); i++) fprintf(fp, " %11d", hmm_senid(hmm, i)); fprintf(fp, " ( "); for (i = 0; i < hmm_n_emit_state(hmm); i++) fprintf(fp, "%d ", hmm_ssid(hmm, i)); fprintf(fp, ")\n"); } else { fprintf(fp, "SSID "); for (i = 0; i < hmm_n_emit_state(hmm); i++) fprintf(fp, " %11d", hmm_senid(hmm, i)); fprintf(fp, " (%d)\n", hmm_ssid(hmm, 0)); } if (hmm->ctx->senscore) { fprintf(fp, "SENSCR"); for (i = 0; i < hmm_n_emit_state(hmm); i++) fprintf(fp, " %11d", hmm_senscr(hmm, i)); fprintf(fp, "\n"); } fprintf(fp, "SCORES %11d", hmm_in_score(hmm)); for (i = 1; i < hmm_n_emit_state(hmm); i++) fprintf(fp, " %11d", hmm_score(hmm, i)); fprintf(fp, " %11d", hmm_out_score(hmm)); fprintf(fp, "\n"); fprintf(fp, "HISTID %11d", hmm_in_history(hmm)); for (i = 1; i < hmm_n_emit_state(hmm); i++) fprintf(fp, " %11d", hmm_history(hmm, i)); fprintf(fp, " %11d", hmm_out_history(hmm)); fprintf(fp, "\n"); if (hmm_in_score(hmm) > 0) fprintf(fp, "ALERT!! The input score %d is large than 0. Probably wrap around.\n", hmm_in_score(hmm)); if (hmm_out_score(hmm) > 0) fprintf(fp, "ALERT!! The output score %d is large than 0. Probably wrap around\n.", hmm_out_score(hmm)); fflush(fp); }
static int32 hmm_vit_eval_3st_lr(hmm_t * hmm) { const int32 *senscore = hmm->ctx->senscore; const int32 *tp = hmm->ctx->tp[hmm->tmatid][0]; const s3senid_t *sseq = hmm->ctx->sseq[hmm_ssid(hmm, 0)]; int32 s3, s2, s1, s0, t2, t1, t0, bestScore; s2 = hmm_score(hmm, 2) + nonmpx_senscr(2); s1 = hmm_score(hmm, 1) + nonmpx_senscr(1); s0 = hmm_in_score(hmm) + nonmpx_senscr(0); /* It was the best of scores, it was the worst of scores. */ t0 = t1 = bestScore = WORST_SCORE; t2 = INT_MIN; /* Not used unless skipstate is true */ /* Transitions into non-emitting state 3 */ if (s2 > WORST_SCORE) { t1 = s2 + hmm_tprob_3st(2, 3); t0 = s2 + hmm_tprob_3st(2, 2); } if (s1 > WORST_SCORE && hmm_tprob_3st(1,3) > WORST_SCORE) t2 = s1 + hmm_tprob_3st(1, 3); if (t1 > t2) { s3 = t1; hmm_out_history(hmm) = hmm_history(hmm, 2); } else { s3 = t2; hmm_out_history(hmm) = hmm_history(hmm, 1); } if (s3 < WORST_SCORE) s3 = WORST_SCORE; hmm_out_score(hmm) = s3; bestScore = s3; /* All transitions into state 2 (state 0 is always active) */ t1 = t2 = WORST_SCORE; if (s1 > WORST_SCORE) t1 = s1 + hmm_tprob_3st(1, 2); if (hmm_tprob_3st(0, 2) > WORST_SCORE) t2 = s0 + hmm_tprob_3st(0, 2); if (t0 > t1) { if (t2 > t0) { s2 = t2; hmm_history(hmm, 2) = hmm_in_history(hmm); } else s2 = t0; } else { if (t2 > t1) { s2 = t2; hmm_history(hmm, 2) = hmm_in_history(hmm); } else { s2 = t1; hmm_history(hmm, 2) = hmm_history(hmm, 1); } } if (s2 < WORST_SCORE) s2 = WORST_SCORE; if (s2 > bestScore) bestScore = s2; hmm_score(hmm, 2) = s2; /* All transitions into state 1 */ t0 = t1 = WORST_SCORE; if (s1 > WORST_SCORE) t0 = s1 + hmm_tprob_3st(1, 1); if (s0 > WORST_SCORE) t1 = s0 + hmm_tprob_3st(0, 1); if (t0 > t1) { s1 = t0; } else { s1 = t1; hmm_history(hmm, 1) = hmm_in_history(hmm); } if (s1 < WORST_SCORE) s1 = WORST_SCORE; if (s1 > bestScore) bestScore = s1; hmm_score(hmm, 1) = s1; /* All transitions into state 0 */ s0 = s0 + hmm_tprob_3st(0, 0); if (s0 < WORST_SCORE) s0 = WORST_SCORE; if (s0 > bestScore) bestScore = s0; hmm_in_score(hmm) = s0; hmm_bestscore(hmm) = bestScore; return bestScore; }
static int32 hmm_vit_eval_5st_lr(hmm_t * hmm) { const int32 *senscore = hmm->ctx->senscore; const int32 *tp = hmm->ctx->tp[hmm->tmatid][0]; const s3senid_t *sseq = hmm->ctx->sseq[hmm_ssid(hmm, 0)]; int32 s5, s4, s3, s2, s1, s0, t2, t1, t0, bestScore; /* It was the best of scores, it was the worst of scores. */ bestScore = WORST_SCORE; s4 = hmm_score(hmm, 4) + nonmpx_senscr(4); s3 = hmm_score(hmm, 3) + nonmpx_senscr(3); /* Transitions into non-emitting state 5 */ if (s3 > WORST_SCORE) { t1 = s4 + hmm_tprob_5st(4, 5); t2 = s3 + hmm_tprob_5st(3, 5); if (t1 > t2) { s5 = t1; hmm_out_history(hmm) = hmm_history(hmm, 4); } else { s5 = t2; hmm_out_history(hmm) = hmm_history(hmm, 3); } if (s5 < WORST_SCORE) s5 = WORST_SCORE; hmm_out_score(hmm) = s5; bestScore = s5; } s2 = hmm_score(hmm, 2) + nonmpx_senscr(2); /* All transitions into state 4 */ if (s2 > WORST_SCORE) { t0 = s4 + hmm_tprob_5st(4, 4); t1 = s3 + hmm_tprob_5st(3, 4); t2 = s2 + hmm_tprob_5st(2, 4); if (t0 > t1) { if (t2 > t0) { s4 = t2; hmm_history(hmm, 4) = hmm_history(hmm, 2); } else s4 = t0; } else { if (t2 > t1) { s4 = t2; hmm_history(hmm, 4) = hmm_history(hmm, 2); } else { s4 = t1; hmm_history(hmm, 4) = hmm_history(hmm, 3); } } if (s4 < WORST_SCORE) s4 = WORST_SCORE; if (s4 > bestScore) bestScore = s4; hmm_score(hmm, 4) = s4; } s1 = hmm_score(hmm, 1) + nonmpx_senscr(1); /* All transitions into state 3 */ if (s1 > WORST_SCORE) { t0 = s3 + hmm_tprob_5st(3, 3); t1 = s2 + hmm_tprob_5st(2, 3); t2 = s1 + hmm_tprob_5st(1, 3); if (t0 > t1) { if (t2 > t0) { s3 = t2; hmm_history(hmm, 3) = hmm_history(hmm, 1); } else s3 = t0; } else { if (t2 > t1) { s3 = t2; hmm_history(hmm, 3) = hmm_history(hmm, 1); } else { s3 = t1; hmm_history(hmm, 3) = hmm_history(hmm, 2); } } if (s3 < WORST_SCORE) s3 = WORST_SCORE; if (s3 > bestScore) bestScore = s3; hmm_score(hmm, 3) = s3; } s0 = hmm_in_score(hmm) + nonmpx_senscr(0); /* All transitions into state 2 (state 0 is always active) */ t0 = s2 + hmm_tprob_5st(2, 2); t1 = s1 + hmm_tprob_5st(1, 2); t2 = s0 + hmm_tprob_5st(0, 2); if (t0 > t1) { if (t2 > t0) { s2 = t2; hmm_history(hmm, 2) = hmm_in_history(hmm); } else s2 = t0; } else { if (t2 > t1) { s2 = t2; hmm_history(hmm, 2) = hmm_in_history(hmm); } else { s2 = t1; hmm_history(hmm, 2) = hmm_history(hmm, 1); } } if (s2 < WORST_SCORE) s2 = WORST_SCORE; if (s2 > bestScore) bestScore = s2; hmm_score(hmm, 2) = s2; /* All transitions into state 1 */ t0 = s1 + hmm_tprob_5st(1, 1); t1 = s0 + hmm_tprob_5st(0, 1); if (t0 > t1) { s1 = t0; } else { s1 = t1; hmm_history(hmm, 1) = hmm_in_history(hmm); } if (s1 < WORST_SCORE) s1 = WORST_SCORE; if (s1 > bestScore) bestScore = s1; hmm_score(hmm, 1) = s1; /* All transitions into state 0 */ s0 = s0 + hmm_tprob_5st(0, 0); if (s0 < WORST_SCORE) s0 = WORST_SCORE; if (s0 > bestScore) bestScore = s0; hmm_in_score(hmm) = s0; hmm_bestscore(hmm) = bestScore; return bestScore; }