deps/kb_meme/meme-5.0.1/src/momo-modl.c
/**
 * Computes the number of bits (description length) to encode the given regexmotif.
 */
Computes the number of bits (description length) to encode the given regexmotif.
Computes the number of bits ( description length ) to encode the given regexmotif .
double compute_regexmotif_numbits(REGEX_MOTIF_T* regexmotif,
                                  MOMO_OPTIONS_T* options,
                                  SUMMARY_T* summary) {
  int i;
  int j;
  const char* alph_letters = summary->alph_letters;
  int width_no_center = options->width - 1;
  double result = 0.0;
  result += width_no_center; 
  int num_conserved = 0; 
  for (i = 0; i < width_no_center; ++i) {
    if (regexmotif->conserved[i]) {
      num_conserved++;
    }
  }
  result += num_conserved;
  for (i = 0; i < width_no_center; ++i) {
    if (regexmotif->conserved[i]) {
      int residues_length = get_residues_length(regexmotif, summary, i);
      double binaryrep = (residues_length+1)*ceil(log(strlen(alph_letters))/log(2));
      double listrep = strlen(alph_letters);
      result += (binaryrep < listrep ? binaryrep : listrep);
    }
  }
  return result;
}
double compute_regexmotif_numbits ( REGEX_MOTIF_T * regexmotif , MOMO_OPTIONS_T * options , SUMMARY_T * summary ) { int i ; int j ; const char * alph_letters = summary -> alph_letters ; int width_no_center = options -> width - 1 ; double result = 0.0 ; result += width_no_center ; int num_conserved = 0 ; for ( i = 0 ; i < width_no_center ; ++ i ) { if ( regexmotif -> conserved [ i ] ) { num_conserved ++ ; } } result += num_conserved ; for ( i = 0 ; i < width_no_center ; ++ i ) { if ( regexmotif -> conserved [ i ] ) { int residues_length = get_residues_length ( regexmotif , summary , i ) ; double binaryrep = ( residues_length + 1 ) * ceil ( log ( strlen ( alph_letters ) ) / log ( 2 ) ) ; double listrep = strlen ( alph_letters ) ; result += ( binaryrep < listrep ? binaryrep : listrep ) ; } } return result ; }
Computes the number of bits (description length) to encode the given regexmotif.
Computes the number of bits ( description length ) to encode the given regexmotif .
// number of bits to store conserved // number of bits to store residue representation // figure out residue representation and number of bits to encode residues