/* * Get a background distribution * - by reading values from a file if filename is given, or * - equal to the NRDB frequencies if filename is NULL. */ ARRAY_T* get_background(ALPH_T alph, char* bg_filename) { ARRAY_T* background; if ((bg_filename == NULL) || (strcmp(bg_filename, "nrdb") == 0)) { background = get_nrdb_frequencies(alph, NULL); } else { background = get_file_frequencies(&alph, bg_filename, NULL); } return(background); }
/* * Sets the background for the pseudo-counts * but requires the alphabet to do it. */ static void set_pseudo_bg(MREAD_T *mread) { ALPH_T alph; alph = mread->formats->get_alphabet(mread->formats->data); assert(alph != INVALID_ALPH); if (!mread->other_bg) { // no change to other_bg if (mread->other_bg_src == NULL || strcmp(mread->other_bg_src, "--nrdb--") == 0) { mread->other_bg = get_nrdb_frequencies(alph, NULL); } else if (strcmp(mread->other_bg_src, "--uniform--") == 0) { mread->other_bg = get_uniform_frequencies(alph, NULL); } else if (strcmp(mread->other_bg_src, "--motif--") == 0 || strcmp(mread->other_bg_src, "motif-file") == 0) { // motif_bg is loaded elsewhere } else { mread->other_bg = get_file_frequencies(&(alph), mread->other_bg_src, NULL); } } if (mread->other_bg) mread->pseudo_bg = mread->other_bg; else mread->pseudo_bg = mread->motif_bg; }
ARRAY_T* ramen_load_background() { ALPH_T alph = DNA_ALPH; ARRAY_T* freqs; switch (args.bg_format) { case UNIFORM_BG: freqs = get_uniform_frequencies(alph, NULL); break; case MOTIF_BG: //We've previously read in the freqs when we read the motif list freqs = motifs.bg_freqs; //so we're just copying a pointer address so that we use them. break; case FILE_BG: freqs = get_file_frequencies(&alph, args.bg_filename, NULL); break; default: die("Illegal background option"); freqs = NULL; // make compiler happy } return freqs; }