third_party_software/hmmer-3.0-linux-intel-x86_64/easel/miniapps/esl-alimanip.c
/* write_rf_gapthresh
 *                   
 * Given an MSA write/rewrite RF based on fraction
 * of gaps in each column. If fraction < gapthresh RF is an 'x',
 * otherwise it's a '.' (gap).
 */


Given an MSA write/rewrite RF based on fraction
of gaps in each column.
Given an MSA write / rewrite RF based on fraction of gaps in each column .
static int
write_rf_gapthresh(const ESL_GETOPTS *go, char *errbuf, ESL_MSA *msa, float gapthresh)
{
  int      status;
  int64_t  apos;
  int64_t  gaps;
  int      i;
  int      nrf = 0;
  if(msa->rf == NULL) { 
    ESL_ALLOC(msa->rf, sizeof(char) * (msa->alen+1));
  }
  for (apos = 1; apos <= msa->alen; apos++) msa->rf[(apos-1)] = '.';
  for (apos = 1; apos <= msa->alen; apos++) {
    for (gaps = 0, i = 0; i < msa->nseq; i++) {
      if (esl_abc_XIsGap(msa->abc, msa->ax[i][apos])) gaps++;
    }
    if((double) gaps / (double) msa->nseq < gapthresh) { 
      nrf++;
      msa->rf[(apos-1)] = 'x';
    }
    else { 
      msa->rf[(apos-1)] = '.';
    }
  }
  msa->rf[msa->alen] = '\0';
  return eslOK;
 ERROR:
  return status;
}
static int write_rf_gapthresh ( const ESL_GETOPTS * go , char * errbuf , ESL_MSA * msa , float gapthresh ) { int status ; int64_t apos ; int64_t gaps ; int i ; int nrf = 0 ; if ( msa -> rf == NULL ) { ESL_ALLOC ( msa -> rf , sizeof ( char ) * ( msa -> alen + 1 ) ) ; } for ( apos = 1 ; apos <= msa -> alen ; apos ++ ) msa -> rf [ ( apos - 1 ) ] = ' ' ; for ( apos = 1 ; apos <= msa -> alen ; apos ++ ) { for ( gaps = 0 , i = 0 ; i < msa -> nseq ; i ++ ) { if ( esl_abc_XIsGap ( msa -> abc , msa -> ax [ i ] [ apos ] ) ) gaps ++ ; } if ( ( double ) gaps / ( double ) msa -> nseq < gapthresh ) { nrf ++ ; msa -> rf [ ( apos - 1 ) ] = ' ' ; } else { msa -> rf [ ( apos - 1 ) ] = ' ' ; } } msa -> rf [ msa -> alen ] = ' \0 ' ; return eslOK ; ERROR : return status ; }
write_rf_gapthresh
write_rf_gapthresh
/* set as all gaps */ /* column passes gap threshold */ /* column fails the gap threshold */