hmmer-3.3/src/p7_trace.c
/* Function: p7_trace_Reverse()
 * Synopsis: Reverse the arrays in a traceback structure.
 * 
 * Purpose:  Reverse the arrays in a traceback structure.  Tracebacks
 *           from DP algorithms are collected backwards, and they call this
 *           function when they're done.
 *           
 *           At least for now, this invalidates any domain index
 *           table, if it exists. The expectd order of invocation is
 *           to create the traceback backwards, <Reverse()> it, then
 *           <IndexDomains()> it.
 *           
 * Args:     tr - the traceback to reverse. tr->N must be set.
 *                
 * Return:   <eslOK> on success; <tr> is modified.
 */
p7_trace_Reverse()
Synopsis: Reverse the arrays in a traceback structure.

Reverse the arrays in a traceback structure.  Tracebacks
from DP algorithms are collected backwards, and they call this
function when they're done.

At least for now, this invalidates any domain index
table, if it exists. The expectd order of invocation is
to create the traceback backwards,  it, then
 it.

the traceback to reverse. tr->N must be set.

 on success;  is modified.
p7_trace_Reverse () Synopsis : Reverse the arrays in a traceback structure . Reverse the arrays in a traceback structure . Tracebacks from DP algorithms are collected backwards and they call this function when they ' re done . At least for now this invalidates any domain index table if it exists . The expectd order of invocation is to create the traceback backwards it then it . the traceback to reverse . tr - > N must be set . on success ; is modified .
int
p7_trace_Reverse(P7_TRACE *tr)
{
  int    z;
  int    tmp;
  float  tmpf;
  for (z = 0; z < tr->N; z++)
    {
      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))
	{
	  if (tr->i[z] == 0 && tr->i[z+1] > 0) 
	    { 
	      tr->i[z]   = tr->i[z+1]; 
	      tr->i[z+1] = 0; 
	      if (tr->pp != NULL) {
		tr->pp[z]   = tr->pp[z+1];
		tr->pp[z+1] = 0.0;
	      }
	    }
	}
    }
  for (z = 0; z < tr->N/2; z++)
    {
      tmp = tr->st[tr->N-z-1];  tr->st[tr->N-z-1] = tr->st[z];   tr->st[z] = tmp;
      tmp = tr->k[tr->N-z-1];   tr->k[tr->N-z-1]  = tr->k[z];    tr->k[z]  = tmp;
      tmp = tr->i[tr->N-z-1];   tr->i[tr->N-z-1]  = tr->i[z];    tr->i[z]  = tmp;
      if (tr->pp != NULL) {
	tmpf = tr->pp[tr->N-z-1];   tr->pp[tr->N-z-1]  = tr->pp[z];    tr->pp[z]  = tmpf;
      }
    }
  return eslOK;
}
int p7_trace_Reverse ( P7_TRACE * tr ) { int z ; int tmp ; float tmpf ; for ( z = 0 ; z < tr -> N ; z ++ ) { 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 ) ) { if ( tr -> i [ z ] == 0 && tr -> i [ z + 1 ] > 0 ) { tr -> i [ z ] = tr -> i [ z + 1 ] ; tr -> i [ z + 1 ] = 0 ; if ( tr -> pp != NULL ) { tr -> pp [ z ] = tr -> pp [ z + 1 ] ; tr -> pp [ z + 1 ] = 0.0 ; } } } } for ( z = 0 ; z < tr -> N / 2 ; z ++ ) { tmp = tr -> st [ tr -> N - z - 1 ] ; tr -> st [ tr -> N - z - 1 ] = tr -> st [ z ] ; tr -> st [ z ] = tmp ; tmp = tr -> k [ tr -> N - z - 1 ] ; tr -> k [ tr -> N - z - 1 ] = tr -> k [ z ] ; tr -> k [ z ] = tmp ; tmp = tr -> i [ tr -> N - z - 1 ] ; tr -> i [ tr -> N - z - 1 ] = tr -> i [ z ] ; tr -> i [ z ] = tmp ; if ( tr -> pp != NULL ) { tmpf = tr -> pp [ tr -> N - z - 1 ] ; tr -> pp [ tr -> N - z - 1 ] = tr -> pp [ z ] ; tr -> pp [ z ] = tmpf ; } } return eslOK ; }
Function: p7_trace_Reverse()
 Synopsis: Reverse the arrays in a traceback structure.
Function : p7_trace_Reverse () Synopsis : Reverse the arrays in a traceback structure .
/* For emit-on-transition states N,C,J, traces always obey the
   * C-,Cx,Cx,Cx convention even when they were constructed backwards;
   * so we make them Cx,Cx,Cx,C- by pulling residues backwards by one,
   * just before reversing them. (Other ways of doing this would be
   * fine too.
   */ /* Reverse the trace in place. */ /* don't worry about the middle residue in odd-length N, since we're in-place  */