third_party_software/hmmer-3.0-linux-intel-x86_64/easel/miniapps/esl-alimanip.c
/* Function: msa_median_length()
 * 
 * Purpose:  Returns the median (unaligned) length of 
 *           the sequences in an alignment.
 */


Returns the median (unaligned) length of
the sequences in an alignment.
Returns the median ( unaligned ) length of the sequences in an alignment .
static int
msa_median_length(ESL_MSA *msa)
{
  int  status;
  int *len;
  int  i;
  int  median;
  ESL_SQ *sq;
  sq = esl_sq_CreateDigital(msa->abc);
  ESL_ALLOC(len, sizeof(int) * msa->nseq);
  for (i = 0; i < msa->nseq; i++) {
    esl_sq_GetFromMSA(msa, i, sq);
    len[i] = sq->n;
    esl_sq_Reuse(sq);
  }
  qsort(len, msa->nseq, sizeof(int), compare_ints);
  median = len[msa->nseq / 2];
  free(len);
  esl_sq_Destroy(sq);
  return median;
 ERROR:
  esl_fatal("msa_median_length() memory allocation error.");
  return 0.; 
}
static int msa_median_length ( ESL_MSA * msa ) { int status ; int * len ; int i ; int median ; ESL_SQ * sq ; sq = esl_sq_CreateDigital ( msa -> abc ) ; ESL_ALLOC ( len , sizeof ( int ) * msa -> nseq ) ; for ( i = 0 ; i < msa -> nseq ; i ++ ) { esl_sq_GetFromMSA ( msa , i , sq ) ; len [ i ] = sq -> n ; esl_sq_Reuse ( sq ) ; } qsort ( len , msa -> nseq , sizeof ( int ) , compare_ints ) ; median = len [ msa -> nseq / 2 ] ; free ( len ) ; esl_sq_Destroy ( sq ) ; return median ; ERROR : esl_fatal ( " " ) ; return 0. ; }
Function: msa_median_length()
Function : msa_median_length ()
/* printf("i: %d len: %d\n", i, len[i]);*/ /* for (i = 0; i < msa->nseq; i++) {
    printf("i: %d len: %d\n", i, len[i]);
  }
  */ /* NEVERREACHED */