hmmer-3.3/src/p7_trace.c
/* Function:  p7_trace_Dump()
 * Incept:    SRE, Fri Jan  5 09:26:04 2007 [Janelia]
 *
 * Purpose:   Dumps internals of a traceback structure <tr> to <fp>.
 *            If <gm> is non-NULL, also prints transition/emission scores.
 *            If <dsq> is non-NULL, also prints residues (using alphabet
 *            in the <gm>).
 *            
 * Args:      fp   - stream to dump to (often stdout)
 *            tr   - trace to dump
 *            gm   - NULL, or score profile corresponding to trace
 *            dsq  - NULL, or digitized seq corresponding to trace        
 *
 * Returns:   <eslOK> on success.
 * 
 * Throws:    <eslEINVAL> if trace contains something corrupt or invalid;
 *            in this case, dump will be aborted, possibly after partial
 *            output.
 */


Dumps internals of a traceback structure  to .
If  is non-NULL, also prints transition/emission scores.
If  is non-NULL, also prints residues (using alphabet
in the ).

fp   - stream to dump to (often stdout)
tr   - trace to dump
gm   - NULL, or score profile corresponding to trace
dsq  - NULL, or digitized seq corresponding to trace

 on success.

 if trace contains something corrupt or invalid;
in this case, dump will be aborted, possibly after partial
output.
Dumps internals of a traceback structure to . If is non - NULL also prints transition / emission scores . If is non - NULL also prints residues ( using alphabet in the ) . fp - stream to dump to ( often stdout ) tr - trace to dump gm - NULL or score profile corresponding to trace dsq - NULL or digitized seq corresponding to trace on success . if trace contains something corrupt or invalid ; in this case dump will be aborted possibly after partial output .
int
p7_trace_Dump(FILE *fp, const P7_TRACE *tr, const P7_PROFILE *gm, const ESL_DSQ *dsq) 
{
  int z;		
  if (tr == NULL) { fprintf(fp, " [ trace is NULL ]\n"); return eslOK; }
  if (gm == NULL) 
    {		 
      fprintf(fp, "st   k      i   - traceback len %d\n", tr->N);
      fprintf(fp, "--  ----   ----\n");
      for (z = 0; z < tr->N; z++) {
	fprintf(fp, "%1s  %4d %6d\n", 
		p7_hmm_DecodeStatetype(tr->st[z]),
		tr->k[z],
		tr->i[z]);
      } 
    } 
  else 
    {
      int   status;
      float accuracy = 0.0f;
      float sc       = 0.0f;
      float tsc;
      int   xi;
      fprintf(fp, "st   k     i      transit emission postprob - traceback len %d\n", tr->N);
      fprintf(fp, "--  ---- ------  -------- -------- --------\n");
      for (z = 0; z < tr->N; z++) 
	{
	  if (z < tr->N-1) 
	    {
	      status = p7_profile_GetT(gm, tr->st[z], tr->k[z], tr->st[z+1], tr->k[z+1], &tsc);
	      if (status != eslOK) return status;
	    }
	  else tsc = 0.0f;
	  fprintf(fp, "%1s  %4d %6d  %8.4f", p7_hmm_DecodeStatetype(tr->st[z]),  tr->k[z], tr->i[z], tsc);
	  sc += tsc;
	  if (dsq != NULL) {
	    xi = dsq[tr->i[z]];
	    if (tr->st[z] == p7T_M) {
	      fprintf(fp, " %8.4f", p7P_MSC(gm, tr->k[z], xi));
	      sc += p7P_MSC(gm, tr->k[z], xi);
	      if (tr->pp != NULL) {
		fprintf(fp, " %8.4f", tr->pp[z]);
		accuracy += tr->pp[z];
	      }
	      fprintf(fp, " %c", gm->abc->sym[xi]);
	    } 
	    else if (tr->st[z] == p7T_I) {
	      fprintf(fp, " %8.4f", p7P_ISC(gm, tr->k[z], xi));
	      sc += p7P_ISC(gm, tr->k[z], xi);
	      if (tr->pp != NULL) {
		fprintf(fp, " %8.4f", tr->pp[z]);
		accuracy += tr->pp[z];
	      }
	      fprintf(fp, " %c", (char) tolower((int) gm->abc->sym[xi]));
	    }
	    else if ((tr->st[z] == p7T_N && tr->st[z-1] == p7T_N) ||
		     (tr->st[z] == p7T_C && tr->st[z-1] == p7T_C) ||
		     (tr->st[z] == p7T_J && tr->st[z-1] == p7T_J))  {
	      fprintf(fp, " %8d", 0);
	      if (tr->pp != NULL) {
		fprintf(fp, " %8.4f", tr->pp[z]);
		accuracy += tr->pp[z];
	      }
	      fprintf(fp, " %c", (char) tolower((int) gm->abc->sym[xi]));
	    }
	  } 
	  else fprintf(fp, " %8s %8s %c", "-", "-", '-');
	  fputs("\n", fp);
	}
      fprintf(fp, "                -------- -------- --------\n");
      fprintf(fp, "                  total: %8.4f %8.4f\n\n", sc, accuracy);
    }
  return eslOK;
}
int p7_trace_Dump ( FILE * fp , const P7_TRACE * tr , const P7_PROFILE * gm , const ESL_DSQ * dsq ) { int z ; if ( tr == NULL ) { fprintf ( fp , " \n " ) ; return eslOK ; } if ( gm == NULL ) { fprintf ( fp , " \n " , tr -> N ) ; fprintf ( fp , " \n " ) ; for ( z = 0 ; z < tr -> N ; z ++ ) { fprintf ( fp , " \n " , p7_hmm_DecodeStatetype ( tr -> st [ z ] ) , tr -> k [ z ] , tr -> i [ z ] ) ; } } else { int status ; float accuracy = 0.0f ; float sc = 0.0f ; float tsc ; int xi ; fprintf ( fp , " \n " , tr -> N ) ; fprintf ( fp , " \n " ) ; for ( z = 0 ; z < tr -> N ; z ++ ) { if ( z < tr -> N - 1 ) { status = p7_profile_GetT ( gm , tr -> st [ z ] , tr -> k [ z ] , tr -> st [ z + 1 ] , tr -> k [ z + 1 ] , & tsc ) ; if ( status != eslOK ) return status ; } else tsc = 0.0f ; fprintf ( fp , " " , p7_hmm_DecodeStatetype ( tr -> st [ z ] ) , tr -> k [ z ] , tr -> i [ z ] , tsc ) ; sc += tsc ; if ( dsq != NULL ) { xi = dsq [ tr -> i [ z ] ] ; if ( tr -> st [ z ] == p7T_M ) { fprintf ( fp , " " , p7P_MSC ( gm , tr -> k [ z ] , xi ) ) ; sc += p7P_MSC ( gm , tr -> k [ z ] , xi ) ; if ( tr -> pp != NULL ) { fprintf ( fp , " " , tr -> pp [ z ] ) ; accuracy += tr -> pp [ z ] ; } fprintf ( fp , " " , gm -> abc -> sym [ xi ] ) ; } else if ( tr -> st [ z ] == p7T_I ) { fprintf ( fp , " " , p7P_ISC ( gm , tr -> k [ z ] , xi ) ) ; sc += p7P_ISC ( gm , tr -> k [ z ] , xi ) ; if ( tr -> pp != NULL ) { fprintf ( fp , " " , tr -> pp [ z ] ) ; accuracy += tr -> pp [ z ] ; } fprintf ( fp , " " , ( char ) tolower ( ( int ) gm -> abc -> sym [ xi ] ) ) ; } else if ( ( tr -> st [ z ] == p7T_N && tr -> st [ z - 1 ] == p7T_N ) || ( tr -> st [ z ] == p7T_C && tr -> st [ z - 1 ] == p7T_C ) || ( tr -> st [ z ] == p7T_J && tr -> st [ z - 1 ] == p7T_J ) ) { fprintf ( fp , " " , 0 ) ; if ( tr -> pp != NULL ) { fprintf ( fp , " " , tr -> pp [ z ] ) ; accuracy += tr -> pp [ z ] ; } fprintf ( fp , " " , ( char ) tolower ( ( int ) gm -> abc -> sym [ xi ] ) ) ; } } else fprintf ( fp , " " , " " , " " , ' ' ) ; fputs ( " \n " , fp ) ; } fprintf ( fp , " \n " ) ; fprintf ( fp , " \n \n " , sc , accuracy ) ; } return eslOK ; }
Function:  p7_trace_Dump()
 Incept:    SRE, Fri Jan  5 09:26:04 2007 [Janelia]
Function : p7_trace_Dump () Incept : SRE Fri Jan 5 09 : 26 : 04 2007 [ Janelia ]
/* replace void w/ P7_PROFILE */ /* counter for trace position */ /* Yes, this does get used: during model construction. */