hmmer-3.3/easel/miniapps/esl-alimanip.c
/* Function: msa_remove_seqs_with_ambiguities()
 * 
 * Purpose:  Remove sequences in MSA that have more than <max_nambig> ambiguous residues.
 */


Remove sequences in MSA that have more than  ambiguous residues.
Remove sequences in MSA that have more than ambiguous residues .
static int
msa_remove_seqs_with_ambiguities(ESL_MSA *msa, int max_nambig, ESL_MSA **ret_new_msa)
{
  int  status;
  int *useme;
  int  i, j;
  int  nambig;
  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);
    nambig = 0;
    for (j = 1; sq->dsq[j] != eslDSQ_SENTINEL; j++) {
      if (esl_abc_XIsDegenerate(sq->abc, sq->dsq[j])) nambig++;
    }
    useme[i] = (nambig > max_nambig) ? FALSE : TRUE;
    esl_sq_Reuse(sq);
  }    
  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_with_ambiguities ( ESL_MSA * msa , int max_nambig , ESL_MSA * * ret_new_msa ) { int status ; int * useme ; int i , j ; int nambig ; 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 ) ; nambig = 0 ; for ( j = 1 ; sq -> dsq [ j ] != eslDSQ_SENTINEL ; j ++ ) { if ( esl_abc_XIsDegenerate ( sq -> abc , sq -> dsq [ j ] ) ) nambig ++ ; } useme [ i ] = ( nambig > max_nambig ) ? FALSE : TRUE ; esl_sq_Reuse ( sq ) ; } 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_with_ambiguities()
Function : msa_remove_seqs_with_ambiguities ()
/* NEVERREACHED */