deps/kb_meme/meme-5.0.1/src/momo.c
/**
 * Sets the background frequencies. If protein database is provided, will count the number of 
 * occurrences of each amino acid and normalize. Otherwise will use NRDB frequencies.
 */
Sets the background frequencies. If protein database is provided, will count the number of
occurrences of each amino acid and normalize. Otherwise will use NRDB frequencies.
Sets the background frequencies . If protein database is provided will count the number of occurrences of each amino acid and normalize . Otherwise will use NRDB frequencies .
static void initialize_background_frequencies(MOMO_OPTIONS_T* options,
                                            SUMMARY_T* summary,
                                            SEQ_T** all_sequences,
                                            int num_sequences) {
  int i;
  int j;
  ARRAY_T * bg_freqs = NULL;
  const char* alph_letters = summary->alph_letters;
  if (options->protein_database_filename) {
    bg_freqs = allocate_array(strlen(alph_letters));
    init_array(0.0, bg_freqs);
    for (i = 0; i < num_sequences; ++i) {
      char* currseq = get_raw_sequence(all_sequences[i]);
      for (j = 0; j < strlen(currseq); ++j) {
        if (strchr(alph_letters, currseq[j])) {
          int idx = strchr(alph_letters, currseq[j]) - alph_letters;
          if (idx >= 0) {
            set_array_item_defcheck(idx, get_array_item_defcheck(idx, bg_freqs) + 1, bg_freqs);
          }
        }
      }
    }
    normalize(0.0, bg_freqs);
  } else {
    bg_freqs = get_nrdb_frequencies(summary->alph, bg_freqs);
  }
  summary->bg_freqs = bg_freqs;
}
static void initialize_background_frequencies ( MOMO_OPTIONS_T * options , SUMMARY_T * summary , SEQ_T * * all_sequences , int num_sequences ) { int i ; int j ; ARRAY_T * bg_freqs = NULL ; const char * alph_letters = summary -> alph_letters ; if ( options -> protein_database_filename ) { bg_freqs = allocate_array ( strlen ( alph_letters ) ) ; init_array ( 0.0 , bg_freqs ) ; for ( i = 0 ; i < num_sequences ; ++ i ) { char * currseq = get_raw_sequence ( all_sequences [ i ] ) ; for ( j = 0 ; j < strlen ( currseq ) ; ++ j ) { if ( strchr ( alph_letters , currseq [ j ] ) ) { int idx = strchr ( alph_letters , currseq [ j ] ) - alph_letters ; if ( idx >= 0 ) { set_array_item_defcheck ( idx , get_array_item_defcheck ( idx , bg_freqs ) + 1 , bg_freqs ) ; } } } } normalize ( 0.0 , bg_freqs ) ; } else { bg_freqs = get_nrdb_frequencies ( summary -> alph , bg_freqs ) ; } summary -> bg_freqs = bg_freqs ; }
Sets the background frequencies.
Sets the background frequencies .