hmmer-3.3/src/p7_domaindef.c
/* Function:  reparameterize_model()
 *
 * Synopsis:  Establish new background priors based on a sequence window,
 *            and change match state emission log-odds scores accordingly.
 *
 * Purpose:    Compute new background priors based on a sequence window,
 *             and set match search model's match state emission log-odds
 *             scores accordingly. Used narrowly within the post-fwd
 *             portion of the longtarget pipeline
 *
 *             If sq != NULL: Given a sequence <sq> and <start> and length
 *             <L>, compute the residue frequency, and modify <bg> in place
 *             to store a mixture of that frequency with the default (passed
 *             in <bg>). Then update the match emission scores in place in
 *             <om> to account for new <bg> values. Prior bg values are
 *             stored for return in <bgf_arr>. This is called by
 *             rescore_isolated_domain(), which is required to call it again
 *             once complete to return <bg> and <om> to original state.
 *
 *
 *             If sq == NULL: return <bg> and <om> to original state.
 *
 *             Only used in the longtarget (nhmmer) case. In-place
 *             modification is done to avoid rampant memory allocation.
 *             Doing this requires that (a) each thread has its own
 *             independent copy of <bg> and <om>, and (b) those are
 *             returned to their original state before being used
 *             outside the function using the modified structures.
 *
 *             The pre-allocated array <sc_tmp> must be passed, for use
 *             in p7_oprofile_UpdateFwdEmissionScores().
 *
 */
reparameterize_model()
Synopsis:  Establish new background priors based on a sequence window,
and change match state emission log-odds scores accordingly.

Compute new background priors based on a sequence window,
and set match search model's match state emission log-odds
scores accordingly. Used narrowly within the post-fwd
portion of the longtarget pipeline

If sq != NULL: Given a sequence  and  and length
, compute the residue frequency, and modify  in place
to store a mixture of that frequency with the default (passed
in ). Then update the match emission scores in place in
 to account for new  values. Prior bg values are
stored for return in . This is called by
rescore_isolated_domain(), which is required to call it again
once complete to return  and  to original state.

If sq == NULL: return  and  to original state.

Only used in the longtarget (nhmmer) case. In-place
modification is done to avoid rampant memory allocation.
Doing this requires that (a) each thread has its own
independent copy of  and , and (b) those are
returned to their original state before being used
outside the function using the modified structures.

The pre-allocated array  must be passed, for use
in p7_oprofile_UpdateFwdEmissionScores().
reparameterize_model () Synopsis : Establish new background priors based on a sequence window and change match state emission log - odds scores accordingly . Compute new background priors based on a sequence window and set match search model ' s match state emission log - odds scores accordingly . Used narrowly within the post - fwd portion of the longtarget pipeline If sq ! = NULL : Given a sequence and and length compute the residue frequency and modify in place to store a mixture of that frequency with the default ( passed in ) . Then update the match emission scores in place in to account for new values . Prior bg values are stored for return in . This is called by rescore_isolated_domain () which is required to call it again once complete to return and to original state . If sq == NULL : return and to original state . Only used in the longtarget ( nhmmer ) case . In - place modification is done to avoid rampant memory allocation . Doing this requires that ( a ) each thread has its own independent copy of and and ( b ) those are returned to their original state before being used outside the function using the modified structures . The pre - allocated array must be passed for use in p7_oprofile_UpdateFwdEmissionScores () .
static int
reparameterize_model (P7_BG *bg, P7_OPROFILE *om, const ESL_SQ *sq, int start, int L, float *fwd_emissions, float *bgf_arr, float *sc_arr) {
  int     K   = om->abc->K;
  int i;
  float tmp;
  int status;
  float   bg_smooth = 1.; 
  if (sq != NULL) {
    bg_smooth = 25.0 / (ESL_MIN(100,ESL_MAX(50,sq->n)));
    esl_vec_FSet (bgf_arr, om->abc->K, 0);
    status = esl_sq_CountResidues(sq, start, L, bgf_arr);
    if (status != eslOK) p7_Fail("Invalid sequence range in reparameterize_model()\n");
    esl_vec_FNorm(bgf_arr, om->abc->K);
    for (i=0; i<K; i++) {
       tmp = bg->f[i];
       bg->f[i] = (bg_smooth*bg->f[i]) + ( (1.0-bg_smooth) * bgf_arr[i])  ;
       bgf_arr[i] = tmp;
    }
  } else {
    esl_vec_FCopy(bgf_arr, K, bg->f);
  }
  p7_oprofile_UpdateFwdEmissionScores(om, bg, fwd_emissions, sc_arr);
  return eslOK;
}
static int reparameterize_model ( P7_BG * bg , P7_OPROFILE * om , const ESL_SQ * sq , int start , int L , float * fwd_emissions , float * bgf_arr , float * sc_arr ) { int K = om -> abc -> K ; int i ; float tmp ; int status ; float bg_smooth = 1. ; if ( sq != NULL ) { bg_smooth = 25.0 / ( ESL_MIN ( 100 , ESL_MAX ( 50 , sq -> n ) ) ) ; esl_vec_FSet ( bgf_arr , om -> abc -> K , 0 ) ; status = esl_sq_CountResidues ( sq , start , L , bgf_arr ) ; if ( status != eslOK ) p7_Fail ( " \n " ) ; esl_vec_FNorm ( bgf_arr , om -> abc -> K ) ; for ( i = 0 ; i < K ; i ++ ) { tmp = bg -> f [ i ] ; bg -> f [ i ] = ( bg_smooth * bg -> f [ i ] ) + ( ( 1.0 - bg_smooth ) * bgf_arr [ i ] ) ; bgf_arr [ i ] = tmp ; } } else { esl_vec_FCopy ( bgf_arr , K , bg -> f ) ; } p7_oprofile_UpdateFwdEmissionScores ( om , bg , fwd_emissions , sc_arr ) ; return eslOK ; }
Function:  reparameterize_model()
 Synopsis:  Establish new background priors based on a sequence window,
            and change match state emission log-odds scores accordingly.
Function : reparameterize_model () Synopsis : Establish new background priors based on a sequence window and change match state emission log - odds scores accordingly .
/* Fraction of new bg frequencies that comes from a prior determined by the sequence block.
   * This is 25% for long sequences, more for shorter sequences (e.g. 50% for sequences of length 50)
   */ // will be modified immediately below, if it's used /* compute new bg->f, capturing original values into a preallocated array */ /* revert bg->f to the passed in orig_bgf   */