Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

silencing compiler warnings #170

Merged
merged 9 commits into from
Oct 19, 2023
9 changes: 5 additions & 4 deletions src/amrfinder/amrfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ convert_coordinates(const string &genome_file, vector<GenomicRegion> &amrs) {

unordered_map<string, string> chrom_lookup;
for (auto i = 0u; i < n_chroms; ++i)
chrom_lookup.emplace(move(c_name[i]), move(c_seq[i]));
chrom_lookup.emplace(std::move(c_name[i]), std::move(c_seq[i]));

vector<pair<uint32_t, uint32_t>> chrom_parts = get_chrom_partition(amrs);
std::atomic_uint32_t conv_failure = 0;
Expand Down Expand Up @@ -300,7 +300,8 @@ process_chrom(const bool verbose, const uint32_t n_threads,
const auto n_blocks = n_threads*blocks_per_thread;

const uint64_t lim = n_cpgs - window_size + 1;
const auto blocks = get_block_bounds(0ul, lim, lim/n_blocks);
const auto blocks = get_block_bounds(static_cast<uint64_t>(0),
lim, lim/n_blocks);

atomic_ulong windows_tested = 0;

Expand All @@ -324,7 +325,7 @@ process_chrom(const bool verbose, const uint32_t n_threads,
}
#pragma omp critical
{
all_amrs.push_back(move(curr_amrs));
all_amrs.push_back(std::move(curr_amrs));
}
windows_tested += windows_tested_block;
}
Expand All @@ -335,7 +336,7 @@ process_chrom(const bool verbose, const uint32_t n_threads,

amrs.reserve(total_amrs);
for (auto &v : all_amrs)
for (auto &a : v) amrs.push_back(move(a));
for (auto &a : v) amrs.push_back(std::move(a));

return windows_tested;
}
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/bsrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ main_bsrate(int argc, const char **argv) {

auto chrom_itr = chrom_lookup.find(the_tid);
if (chrom_itr == end(chrom_lookup))
throw runtime_error("could not find chrom: " + the_tid);
throw runtime_error("could not find chrom: " +
std::to_string(the_tid));

chrom_idx = chrom_itr->second;

Expand Down
5 changes: 2 additions & 3 deletions src/analysis/hmr-rep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ get_domain_scores_rep(const vector<bool> &state_ids,


static void
build_domains(const bool VERBOSE,
const vector<MSite> &cpgs,
build_domains(const vector<MSite> &cpgs,
const vector<double> &post_scores,
const vector<size_t> &reset_points,
const vector<bool> &state_ids,
Expand Down Expand Up @@ -506,7 +505,7 @@ main_hmr_rep(int argc, const char **argv) {
fdr_cutoff = get_stepup_cutoff(p_values, 0.01);

vector<GenomicRegion> domains;
build_domains(VERBOSE, cpgs, posteriors, reset_points, state_ids, domains);
build_domains(cpgs, posteriors, reset_points, state_ids, domains);

std::ofstream of;
if (!outfile.empty()) of.open(outfile);
Expand Down
5 changes: 2 additions & 3 deletions src/analysis/hmr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ get_domain_scores(const vector<bool> &state_ids,


static void
build_domains(const bool VERBOSE,
const vector<MSite> &cpgs,
build_domains(const vector<MSite> &cpgs,
const vector<double> &post_scores,
const vector<size_t> &reset_points,
const vector<bool> &state_ids,
Expand Down Expand Up @@ -557,7 +556,7 @@ main_hmr(int argc, const char **argv) {
p_fb, p_bf, domain_score_cutoff);

vector<GenomicRegion> domains;
build_domains(VERBOSE, cpgs, posteriors, reset_points, state_ids, domains);
build_domains(cpgs, posteriors, reset_points, state_ids, domains);

std::ofstream of;
if (!outfile.empty()) of.open(outfile.c_str());
Expand Down
24 changes: 15 additions & 9 deletions src/analysis/hypermr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,13 @@ separate_regions(const size_t desert_size, vector<MSite> &cpgs, vector<T> &meth,
reset_points.push_back(cpgs.size());
}


// ADS (!!!) this function seems to not be working at all right now
static void
read_params_file(const string &params_file, betabin &hypo_emission,
betabin &HYPER_emission, betabin &HYPO_emission,
read_params_file(const string &params_file,
// betabin &hypo_emission,
// betabin &HYPER_emission,
// betabin &HYPO_emission,
vector<vector<double>> &trans) {
std::ifstream in(params_file);
if (!in) throw runtime_error("failed to read param file: " + params_file);
Expand Down Expand Up @@ -142,7 +146,7 @@ write_params_file(const string &params_file, const betabin &hypo_emission,
}

static void
build_domains(const bool VERBOSE, const vector<MSite> &cpgs,
build_domains(const vector<MSite> &cpgs,
const vector<pair<double, double>> &meth,
const vector<size_t> &reset_points,
const vector<STATE_LABELS> &classes,
Expand Down Expand Up @@ -190,7 +194,7 @@ build_domains(const bool VERBOSE, const vector<MSite> &cpgs,
}

static void
filter_domains(const bool VERBOSE, const double min_cumulative_meth,
filter_domains(const double min_cumulative_meth,
vector<GenomicRegion> &domains) {
size_t j = 0;
for (size_t i = 0; i < domains.size(); ++i)
Expand Down Expand Up @@ -317,8 +321,11 @@ main_hypermr(int argc, const char **argv) {
betabin hypo_emission, HYPER_emission, HYPO_emission;

if (!params_in_file.empty())
read_params_file(params_in_file, hypo_emission, HYPER_emission,
HYPO_emission, trans);
read_params_file(params_in_file,
// hypo_emission,
// HYPER_emission,
// HYPO_emission,
trans);
else {
const double n_reads = mean_cov;
const double fg_alpha = 0.33 * n_reads;
Expand Down Expand Up @@ -349,9 +356,8 @@ main_hypermr(int argc, const char **argv) {

// identify the domains of hypermethylation
vector<GenomicRegion> domains;
build_domains(VERBOSE, cpgs, hmm.observations, reset_points, classes,
domains);
filter_domains(VERBOSE, min_cumulative_meth, domains);
build_domains(cpgs, hmm.observations, reset_points, classes, domains);
filter_domains(min_cumulative_meth, domains);

// write the results
ofstream of;
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/multimethstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ all_is_finite(const vector<double> &scores) {

static void
process_with_cpgs_loaded(const bool VERBOSE,
const bool sort_data_if_needed,
// const bool sort_data_if_needed,
const bool PRINT_NUMERIC_ONLY,
const bool report_more_information,
const char level_code,
Expand Down Expand Up @@ -625,7 +625,7 @@ main_multimethstat(int argc, const char **argv) {
std::ostream out(outfile.empty() ? cout.rdbuf() : of.rdbuf());

if (load_entire_file)
process_with_cpgs_loaded(VERBOSE, sort_data_if_needed,
process_with_cpgs_loaded(VERBOSE, // sort_data_if_needed,
PRINT_NUMERIC_ONLY,
report_more_information,
level_code[0],
Expand Down
22 changes: 6 additions & 16 deletions src/analysis/pmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,24 +533,19 @@ get_domain_scores(const vector<bool> &classes,


static void
build_domains(const bool VERBOSE,
const vector<SimpleGenomicRegion> &bins,
const vector<double> &post_scores,
build_domains(const vector<SimpleGenomicRegion> &bins,
const vector<size_t> &reset_points,
const vector<bool> &classes,
const vector<size_t> &dists_btwn_bins,
vector<GenomicRegion> &domains) {

size_t n_bins = 0, reset_idx = 1, prev_end = 0;
bool in_domain = false;
double score = 0;
for (size_t i = 0; i < classes.size(); ++i) {
if (reset_points[reset_idx] == i) {
if (in_domain) {
domains.back().set_end(prev_end);
domains.back().set_score(n_bins);
n_bins = 0;
score = 0;
in_domain = false;
}
++reset_idx;
Expand All @@ -561,13 +556,11 @@ build_domains(const bool VERBOSE,
in_domain = true;
}
++n_bins;
score += post_scores[i];
}
else if (in_domain) {
domains.back().set_end(prev_end);
domains.back().set_score(n_bins);
n_bins = 0;
score = 0;
in_domain = false;
}
prev_end = bins[i].get_end();
Expand Down Expand Up @@ -1029,10 +1022,9 @@ get_min_reads_for_confidence(const double conf_level) {
// ADS: this function will return num_lim<size_t>::max() if the
// fraction of "good" bins is zero for all attempted bin sizes.
static size_t
binsize_selection(const bool &VERBOSE, const size_t resolution,
const size_t min_bin_sz, const size_t max_bin_sz,
const double conf_level, const double min_frac_passed,
const string &cpgs_file) {
binsize_selection(const size_t resolution, const size_t min_bin_sz,
const size_t max_bin_sz, const double conf_level,
const double min_frac_passed, const string &cpgs_file) {

const size_t min_cov_to_pass = get_min_reads_for_confidence(conf_level);

Expand Down Expand Up @@ -1239,8 +1231,7 @@ main_pmd(int argc, const char **argv) {
for (size_t i = 0; i < n_replicates && !insufficient_data; ++i) {
const bool arrayData = check_if_array_data(cpgs_file[i]);
if (!arrayData) {
bin_size = binsize_selection(VERBOSE, resolution,
min_bin_size, max_bin_size,
bin_size = binsize_selection(resolution, min_bin_size, max_bin_size,
confidence_interval, prop_accept,
cpgs_file[i]);
if (bin_size == num_lim<size_t>::max())
Expand Down Expand Up @@ -1414,8 +1405,7 @@ main_pmd(int argc, const char **argv) {
}

vector<GenomicRegion> domains;
build_domains(VERBOSE, bins[0], scores, reset_points, classes,
dists_btwn_bins, domains);
build_domains(bins[0], reset_points, classes, domains);

size_t good_pmd_count = 0;
vector<GenomicRegion> good_domains;
Expand Down
4 changes: 2 additions & 2 deletions src/common/EpireadStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ compute_model_likelihoods(double &single_score, double &pair_score,
vector<double> a1(n_cpgs, low_prob), a2(n_cpgs, high_prob), indicators;
resolve_epialleles(max_itr, reads, mixing, indicators, a1, a2);

constexpr double log_mixing1 = log(mixing);
constexpr double log_mixing2 = log(1.0 - mixing);
const double log_mixing1 = log(mixing);
const double log_mixing2 = log(1.0 - mixing);

pair_score = transform_reduce(
cbegin(reads), cend(reads), 0.0, std::plus<>(),
Expand Down
5 changes: 5 additions & 0 deletions src/common/MSite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,13 @@ MSite::MSite(const string &line) {
failed = failed || (field_e == c_end);

{
#ifdef __APPLE__
const int ret = std::sscanf(field_s, "%lf", &meth);
failed = failed || (ret < 1);
#else
const auto [ptr, ec] = from_chars(field_s, field_e, meth);
failed = failed || (ptr == field_s);
#endif
}

field_s = find_if(field_e + 1, c_end, not_sep);
Expand Down
15 changes: 12 additions & 3 deletions src/common/ThreeStateHMM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ ThreeStateHMM::estimate_state_posterior(const size_t start, const size_t end) {
vector<double> hypo_evidence(end - start, 0), HYPER_evidence(end - start, 0),
HYPO_evidence(end - start, 0);

double prev_denom(0), denom(0);
#ifndef NDEBUG
double prev_denom = 0.0;
#endif
double denom = 0.0;
for (size_t i = start; i < end; ++i) {
hypo_evidence[i - start] = forward[i].hypo + backward[i].hypo;
HYPER_evidence[i - start] = forward[i].HYPER + backward[i].HYPER;
Expand All @@ -286,7 +289,9 @@ ThreeStateHMM::estimate_state_posterior(const size_t start, const size_t end) {
HYPO_evidence[i - start]);

if (i > start) assert(fabs(exp(prev_denom - denom) - 1) < 1e-6);
#ifndef NDEBUG
prev_denom = denom;
#endif
}

for (size_t i = start; i < end; ++i) {
Expand Down Expand Up @@ -407,8 +412,10 @@ ThreeStateHMM::single_iteration() {
for (size_t i = 0; i < reset_points.size() - 1; ++i) {
const double forward_score =
forward_algorithm(reset_points[i], reset_points[i + 1]);
#ifndef NDEBUG
const double backward_score =
backward_algorithm(reset_points[i], reset_points[i + 1]);
#endif
backward_algorithm(reset_points[i], reset_points[i + 1]);

assert(fabs((forward_score - backward_score) /
max(forward_score, backward_score)) < 1e-10);
Expand Down Expand Up @@ -491,8 +498,10 @@ ThreeStateHMM::PosteriorDecoding() {
for (size_t i = 0; i < reset_points.size() - 1; ++i) {
const double forward_score =
forward_algorithm(reset_points[i], reset_points[i + 1]);
#ifndef NDEBUG
const double backward_score =
backward_algorithm(reset_points[i], reset_points[i + 1]);
#endif
backward_algorithm(reset_points[i], reset_points[i + 1]);

assert(fabs((forward_score - backward_score) /
max(forward_score, backward_score)) < 1e-10);
Expand Down
Loading