hmmer-3.3/easel/esl_sq.c
/* Function:  esl_sq_Checksum()
 * Synopsis:  Calculate a 32-bit checksum for a sequence.
 * Incept:    SRE, Tue Aug 25 14:32:17 2009 [Janelia]
 *
 * Purpose:   Calculate a 32-bit checksum for <sq>.
 * 
 *            Only the sequence data are considered, not name or other
 *            annotation. For text mode sequences, the checksum is
 *            case sensitive.  The checksum is also sensitive to
 *            whether the sequence is text or digital mode; the same
 *            sequence in will yield different checksums in digital
 *            vs. text mode.
 *            
 * Returns:   <eslOK> on success; the checksum is in <*ret_checksum>.
 */
esl_sq_Checksum()
Synopsis:  Calculate a 32-bit checksum for a sequence.

Calculate a 32-bit checksum for .

Only the sequence data are considered, not name or other
annotation. For text mode sequences, the checksum is
case sensitive.  The checksum is also sensitive to
whether the sequence is text or digital mode; the same
sequence in will yield different checksums in digital
vs. text mode.

 on success; the checksum is in <*ret_checksum>.
esl_sq_Checksum () Synopsis : Calculate a 32 - bit checksum for a sequence . Calculate a 32 - bit checksum for . Only the sequence data are considered not name or other annotation . For text mode sequences the checksum is case sensitive . The checksum is also sensitive to whether the sequence is text or digital mode ; the same sequence in will yield different checksums in digital vs . text mode . on success ; the checksum is in < * ret_checksum > .
int
esl_sq_Checksum(const ESL_SQ *sq, uint32_t *ret_checksum)
{
  uint32_t val = 0;
  uint64_t pos;
  if (sq->seq != NULL)
    {
      for (pos = 0; pos < sq->n; pos++)
	{
	  val += sq->seq[pos];
	  val += (val << 10);
	  val ^= (val >>  6);
	}
    }
  else
    {
      for (pos = 1; pos <= sq->n; pos++)
	{
	  val += sq->dsq[pos];
	  val += (val << 10);
	  val ^= (val >>  6);
	}
    }
  val += (val <<  3);
  val ^= (val >> 11);
  val += (val << 15);
  *ret_checksum = val;
  return eslOK;
}
int esl_sq_Checksum ( const ESL_SQ * sq , uint32_t * ret_checksum ) { uint32_t val = 0 ; uint64_t pos ; if ( sq -> seq != NULL ) { for ( pos = 0 ; pos < sq -> n ; pos ++ ) { val += sq -> seq [ pos ] ; val += ( val << 10 ) ; val ^= ( val >> 6 ) ; } } else { for ( pos = 1 ; pos <= sq -> n ; pos ++ ) { val += sq -> dsq [ pos ] ; val += ( val << 10 ) ; val ^= ( val >> 6 ) ; } } val += ( val << 3 ) ; val ^= ( val >> 11 ) ; val += ( val << 15 ) ; * ret_checksum = val ; return eslOK ; }
Function:  esl_sq_Checksum()
 Synopsis:  Calculate a 32-bit checksum for a sequence.
Function : esl_sq_Checksum () Synopsis : Calculate a 32 - bit checksum for a sequence .