hmmer-3.3/easel/miniapps/esl-alimanip.c
/* Function: msa_remove_seqs_above_maxlen()
 * 
 * Purpose:  Remove sequences in MSA whose dealigned length is more than a maximum length.
 */


Remove sequences in MSA whose dealigned length is more than a maximum length.
Remove sequences in MSA whose dealigned length is more than a maximum length .
static int
msa_remove_seqs_above_maxlen(ESL_MSA *msa, float maxlen, ESL_MSA **ret_new_msa)
{
  int  status;
  int *useme;
  int  i;
  ESL_MSA *new_msa;
  ESL_SQ *sq;
  sq = esl_sq_CreateDigital(msa->abc);
  ESL_ALLOC(useme, sizeof(int) * msa->nseq);
  for (i = 0; i < msa->nseq; i++) {
    esl_sq_GetFromMSA(msa, i, sq);
    useme[i] = ((float) sq->n <= maxlen) ? TRUE : FALSE;
    esl_sq_Reuse(sq);
  }
  if(esl_vec_ISum(useme, msa->nseq) == 0) esl_fatal("No sequences are less than maximum allowed length.");
  if((status = esl_msa_SequenceSubset(msa, useme, &new_msa)) != eslOK) esl_fatal("esl_msa_SequenceSubset() had a problem.");
  free(useme);
  esl_sq_Destroy(sq);
  *ret_new_msa = new_msa;
  return eslOK;
 ERROR:
  esl_fatal("msa_remove_seqs_above_maxlen() memory allocation error.");
  return eslOK; 
}
static int msa_remove_seqs_above_maxlen ( ESL_MSA * msa , float maxlen , ESL_MSA * * ret_new_msa ) { int status ; int * useme ; int i ; ESL_MSA * new_msa ; ESL_SQ * sq ; sq = esl_sq_CreateDigital ( msa -> abc ) ; ESL_ALLOC ( useme , sizeof ( int ) * msa -> nseq ) ; for ( i = 0 ; i < msa -> nseq ; i ++ ) { esl_sq_GetFromMSA ( msa , i , sq ) ; useme [ i ] = ( ( float ) sq -> n <= maxlen ) ? TRUE : FALSE ; esl_sq_Reuse ( sq ) ; } if ( esl_vec_ISum ( useme , msa -> nseq ) == 0 ) esl_fatal ( " " ) ; if ( ( status = esl_msa_SequenceSubset ( msa , useme , & new_msa ) ) != eslOK ) esl_fatal ( " " ) ; free ( useme ) ; esl_sq_Destroy ( sq ) ; * ret_new_msa = new_msa ; return eslOK ; ERROR : esl_fatal ( " " ) ; return eslOK ; }
Function: msa_remove_seqs_above_maxlen()
Function : msa_remove_seqs_above_maxlen ()
/*printf("useme[i:%d]: %d\n", i, useme[i]);*/ /* NEVERREACHED */