hmmer-3.3/easel/esl_sq.c
/* Function:  esl_sq_Textize()
 * Synopsis:  Convert an <ESL_SQ> to text mode.
 * Incept:    EPN, Mon Feb 12 11:15:06 2007
 *
 * Purpose:   Given a sequence <sq> in digital mode, convert it
 *            to text mode.
 *            
 *            Internally, the <seq> text alignment field is filled, the
 *            <dsq> digital alignment field is destroyed and free'd, the
 *            sq's <abc> digital alphabet reference is nullified.
 *            
 * Args:      sq   - sequence object to convert to text
 *
 * Returns:   <eslOK> on success.
 *
 * Throws:    <eslEMEM> on allocation failure.
 *            Throws <eslECORRUPT> if the digital sequence contains 
 *            invalid codes.
 */
esl_sq_Textize()
Synopsis:  Convert an  to text mode.

Given a sequence  in digital mode, convert it
to text mode.

Internally, the  text alignment field is filled, the
 digital alignment field is destroyed and free'd, the
sq's  digital alphabet reference is nullified.

sq   - sequence object to convert to text

 on success.

 on allocation failure.
Throws  if the digital sequence contains
invalid codes.
esl_sq_Textize () Synopsis : Convert an to text mode . Given a sequence in digital mode convert it to text mode . Internally the text alignment field is filled the digital alignment field is destroyed and free ' d the sq ' s digital alphabet reference is nullified . sq - sequence object to convert to text on success . on allocation failure . Throws if the digital sequence contains invalid codes .
int
esl_sq_Textize(ESL_SQ *sq)
{
  int   x;        
  int status;
  if (sq->seq  != NULL) return eslOK;
  if (sq->dsq  == NULL) ESL_EXCEPTION(eslEINVAL, "sq has no digital sequence");
  if (sq->abc  == NULL) ESL_EXCEPTION(eslEINVAL, "sq has no digital alphabet");
  ESL_ALLOC(sq->seq, sq->salloc * sizeof(char));
  if ((status = esl_abc_Textize(sq->abc, sq->dsq, sq->n, sq->seq)) != eslOK) goto ERROR;
  if (sq->ss != NULL) 
    memmove(sq->ss, sq->ss+1, sq->n+1);	
  for (x = 0; x < sq->nxr; x++) 
    if (sq->xr[x] != NULL) 
      memmove(sq->xr[x], sq->xr[x]+1, sq->n+1);	
  free(sq->dsq);
  sq->dsq = NULL;
  sq->abc = NULL;           
  return eslOK;
 ERROR:
  if (sq->seq != NULL) free(sq->seq);
  return status;
}
int esl_sq_Textize ( ESL_SQ * sq ) { int x ; int status ; if ( sq -> seq != NULL ) return eslOK ; if ( sq -> dsq == NULL ) ESL_EXCEPTION ( eslEINVAL , " " ) ; if ( sq -> abc == NULL ) ESL_EXCEPTION ( eslEINVAL , " " ) ; ESL_ALLOC ( sq -> seq , sq -> salloc * sizeof ( char ) ) ; if ( ( status = esl_abc_Textize ( sq -> abc , sq -> dsq , sq -> n , sq -> seq ) ) != eslOK ) goto ERROR ; if ( sq -> ss != NULL ) memmove ( sq -> ss , sq -> ss + 1 , sq -> n + 1 ) ; for ( x = 0 ; x < sq -> nxr ; x ++ ) if ( sq -> xr [ x ] != NULL ) memmove ( sq -> xr [ x ] , sq -> xr [ x ] + 1 , sq -> n + 1 ) ; free ( sq -> dsq ) ; sq -> dsq = NULL ; sq -> abc = NULL ; return eslOK ; ERROR : if ( sq -> seq != NULL ) free ( sq -> seq ) ; return status ; }
Function:  esl_sq_Textize()
 Synopsis:  Convert an <ESL_SQ> to text mode.
Function : esl_sq_Textize () Synopsis : Convert an <ESL_SQ > to text mode .
/* index for optional extra residue markups */ /* Contract checks */ /* Allocate. salloc is guaranteed big enough, if it was big enough for digital. */ /* Convert. */ /* slide back to 0..n-1; +1 includes terminal \0 */ /* slide back to 0..n-1; +1 includes terminal \0 */ /* nullify reference (caller still owns real abc) */