// Attemps to find the next significant CpG site. Returns true if one was found // and flase otherwise. static bool read_next_significant_cpg(istream &cpg_stream, GenomicRegion &cpg, double cutoff, bool &skipped_any, bool &sig_raw, size_t &test_cov, size_t &test_meth, size_t &rest_cov, size_t &rest_meth) { GenomicRegion region; skipped_any = false; sig_raw = false; string cpg_encoding; while (getline(cpg_stream, cpg_encoding)) { string record, chrom, name, sign; size_t position; double raw_pval, adjusted_pval, corrected_pval; std::istringstream iss(cpg_encoding); iss.exceptions(std::ios::failbit); iss >> chrom >> position >> sign >> name >> raw_pval >> adjusted_pval >> corrected_pval >> test_cov >> test_meth >> rest_cov >> rest_meth; if (0 <= corrected_pval && corrected_pval < cutoff) { cpg.set_chrom(chrom); cpg.set_start(position); cpg.set_end(position + 1); sig_raw = (0 <= raw_pval && raw_pval < cutoff); return true; } skipped_any = true; } return false; }
static void get_chrom(const MappedRead &mr, const chrom_file_map &chrom_files, GenomicRegion &chrom_region, string &chrom) { const chrom_file_map::const_iterator fn(chrom_files.find(mr.r.get_chrom())); if (fn == chrom_files.end()) throw SMITHLABException("could not find chrom: " + mr.r.get_chrom()); chrom.clear(); read_fasta_file(fn->second, mr.r.get_chrom(), chrom); if (chrom.empty()) throw SMITHLABException("could not find chrom: " + mr.r.get_chrom()); chrom_region.set_chrom(mr.r.get_chrom()); }
static void get_chrom(const bool VERBOSE, const GenomicRegion &r, const unordered_map<string, string>& chrom_files, GenomicRegion &chrom_region, string &chrom) { const unordered_map<string, string>::const_iterator fn(chrom_files.find(r.get_chrom())); if (fn == chrom_files.end()) throw runtime_error("could not find chrom: " + r.get_chrom()); chrom.clear(); read_fasta_file(fn->second, r.get_chrom(), chrom); if (chrom.empty()) throw runtime_error("could not find chrom: " + r.get_chrom()); else { chrom_region.set_chrom(r.get_chrom()); } }
static void get_chrom(const MappedRead &mr, const vector<string> &all_chroms, const unordered_map<string, size_t> &chrom_lookup, GenomicRegion &chrom_region, string &chrom) { const unordered_map<string, size_t>::const_iterator the_chrom(chrom_lookup.find(mr.r.get_chrom())); if (the_chrom == chrom_lookup.end()) throw runtime_error("could not find chrom: " + mr.r.get_chrom()); chrom = all_chroms[the_chrom->second]; if (chrom.empty()) throw runtime_error("could not find chrom: " + mr.r.get_chrom()); chrom_region.set_chrom(mr.r.get_chrom()); }