hmmer-3.3/easel/esl_dsqdata.c
/* Unpack 5-bit encoded sequence, starting at <psq>.
 * Important: dsq[0] is already initialized to eslDSQ_SENTINEL,
 * as a nitpicky optimization (the sequence data in a chunk are
 * concatenated so that they share end/start sentinels).
 */
Unpack 5-bit encoded sequence, starting at .
Important: dsq[0] is already initialized to eslDSQ_SENTINEL,
as a nitpicky optimization (the sequence data in a chunk are
concatenated so that they share end/start sentinels).
Unpack 5 - bit encoded sequence starting at . Important : dsq [ 0 ] is already initialized to eslDSQ_SENTINEL as a nitpicky optimization ( the sequence data in a chunk are concatenated so that they share end / start sentinels ) .
static int
dsqdata_unpack5(uint32_t *psq, ESL_DSQ *dsq, int *ret_L, int *ret_P)
{
  int      pos = 0;          
  int      r   = 1;          
  uint32_t v   = psq[pos++];
  int      b;                
  while (! ESL_DSQDATA_EOD(v))               
    {
      ESL_DASSERT1(( ESL_DSQDATA_5BIT(v) )); 
      dsq[r++] = (v >> 25) & 31; dsq[r++] = (v >> 20) & 31; dsq[r++] = (v >> 15) & 31;
      dsq[r++] = (v >> 10) & 31; dsq[r++] = (v >>  5) & 31; dsq[r++] = (v >>  0) & 31;
      v = psq[pos++];
    }
  ESL_DASSERT1(( ESL_DSQDATA_5BIT(v) ));
  for (b = 25; b >= 0 && ((v >> b) & 31) != 31; b -= 5)
    dsq[r++] = (v >> b) & 31;
  dsq[r++] = eslDSQ_SENTINEL;
  *ret_L = r-2;
  *ret_P = pos;
  return eslOK;
}
static int dsqdata_unpack5 ( uint32_t * psq , ESL_DSQ * dsq , int * ret_L , int * ret_P ) { int pos = 0 ; int r = 1 ; uint32_t v = psq [ pos ++ ] ; int b ; while ( ! ESL_DSQDATA_EOD ( v ) ) { ESL_DASSERT1 ( ( ESL_DSQDATA_5BIT ( v ) ) ) ; dsq [ r ++ ] = ( v >> 25 ) & 31 ; dsq [ r ++ ] = ( v >> 20 ) & 31 ; dsq [ r ++ ] = ( v >> 15 ) & 31 ; dsq [ r ++ ] = ( v >> 10 ) & 31 ; dsq [ r ++ ] = ( v >> 5 ) & 31 ; dsq [ r ++ ] = ( v >> 0 ) & 31 ; v = psq [ pos ++ ] ; } ESL_DASSERT1 ( ( ESL_DSQDATA_5BIT ( v ) ) ) ; for ( b = 25 ; b >= 0 && ( ( v >> b ) & 31 ) != 31 ; b -= 5 ) dsq [ r ++ ] = ( v >> b ) & 31 ; dsq [ r ++ ] = eslDSQ_SENTINEL ; * ret_L = r - 2 ; * ret_P = pos ; return eslOK ; }
Unpack 5-bit encoded sequence, starting at <psq>.
Unpack 5 - bit encoded sequence starting at <psq > .
// position in psq[] // position in dsq[]. caller set dsq[0] to eslDSQ_SENTINEL. // bit shift counter // we trust that we'll see a sentinel at the end // All packets are 5-bit encoded /* Unpack sentinel packet, which may be partial; it can even contain
   * zero residues in the edge case of an L=0 sequence.
   */ // r is now L+2:   the raw sequence length + 2 sentinels // P = pos, because pos index advanced to next packet after sentinel