hmmer-3.3/src/p7_hmm.c
/* Function: p7_hmm_Renormalize()
 * Synopsis: Renormalize all parameter vectors (emissions/transitions).
 * 
 * Purpose:  Take a core HMM in counts form, and renormalize
 *           all probability vectors in the core probability model. Enforces
 *           Plan7 restrictions on nonexistent transitions.
 *
 *           Leaves other flags (stats and profile) alone, so caller
 *           needs to be wary. Renormalizing a probability model that
 *           has stats and profile scores wouldn't usually invalidate
 *           those data; and if we're renormalizing a counts model, we
 *           shouldn't have stats or profile scores yet anyway.
 *           
 * Args:     hmm - the model to renormalize.
 *                 
 * Return:   <eslOK> on success.
 */
p7_hmm_Renormalize()
Synopsis: Renormalize all parameter vectors (emissions/transitions).

Take a core HMM in counts form, and renormalize
all probability vectors in the core probability model. Enforces
Plan7 restrictions on nonexistent transitions.

Leaves other flags (stats and profile) alone, so caller
needs to be wary. Renormalizing a probability model that
has stats and profile scores wouldn't usually invalidate
those data; and if we're renormalizing a counts model, we
shouldn't have stats or profile scores yet anyway.

the model to renormalize.

 on success.
p7_hmm_Renormalize () Synopsis : Renormalize all parameter vectors ( emissions / transitions ) . Take a core HMM in counts form and renormalize all probability vectors in the core probability model . Enforces Plan7 restrictions on nonexistent transitions . Leaves other flags ( stats and profile ) alone so caller needs to be wary . Renormalizing a probability model that has stats and profile scores wouldn ' t usually invalidate those data ; and if we ' re renormalizing a counts model we shouldn ' t have stats or profile scores yet anyway . the model to renormalize . on success .
int
p7_hmm_Renormalize(P7_HMM *hmm)
{
  int   k;			
  for (k = 0; k <= hmm->M; k++) {
    esl_vec_FNorm(hmm->mat[k], hmm->abc->K);
    esl_vec_FNorm(hmm->ins[k], hmm->abc->K);
    esl_vec_FNorm(P7H_TMAT(hmm, k), p7H_NTMAT);	
    esl_vec_FNorm(P7H_TDEL(hmm, k), p7H_NTDEL);	
    esl_vec_FNorm(P7H_TINS(hmm, k), p7H_NTINS);	
  }
  hmm->t[hmm->M][p7H_DM] = 1.0;
  hmm->t[hmm->M][p7H_DD] = 0.0;
  if (hmm->t[hmm->M][p7H_MD] > 0.) {
    hmm->t[hmm->M][p7H_MD] = 0.;
    hmm->t[hmm->M][p7H_MM] = 0.5;
    hmm->t[hmm->M][p7H_MI] = 0.5;
  }
  return eslOK;
}
int p7_hmm_Renormalize ( P7_HMM * hmm ) { int k ; for ( k = 0 ; k <= hmm -> M ; k ++ ) { esl_vec_FNorm ( hmm -> mat [ k ] , hmm -> abc -> K ) ; esl_vec_FNorm ( hmm -> ins [ k ] , hmm -> abc -> K ) ; esl_vec_FNorm ( P7H_TMAT ( hmm , k ) , p7H_NTMAT ) ; esl_vec_FNorm ( P7H_TDEL ( hmm , k ) , p7H_NTDEL ) ; esl_vec_FNorm ( P7H_TINS ( hmm , k ) , p7H_NTINS ) ; } hmm -> t [ hmm -> M ] [ p7H_DM ] = 1.0 ; hmm -> t [ hmm -> M ] [ p7H_DD ] = 0.0 ; if ( hmm -> t [ hmm -> M ] [ p7H_MD ] > 0. ) { hmm -> t [ hmm -> M ] [ p7H_MD ] = 0. ; hmm -> t [ hmm -> M ] [ p7H_MM ] = 0.5 ; hmm -> t [ hmm -> M ] [ p7H_MI ] = 0.5 ; } return eslOK ; }
Function: p7_hmm_Renormalize()
 Synopsis: Renormalize all parameter vectors (emissions/transitions).
Function : p7_hmm_Renormalize () Synopsis : Renormalize all parameter vectors ( emissions / transitions ) .
/* counter for model position */ /* TMX */ /* TIX */ /* TDX */ /* If t[M][TD*] distribution was all zeros, we just made TDD nonzero. Oops.
   * Re-enforce t's on that final delete state. */ /* Rare: if t[M][TM*] distribution was all zeros (all final transitions
   * were D_M -> E) then we just made nonexistent M_M->D_M+1 transition nonzero.
   * Fix that too.
   */