Skip to content

Commit

Permalink
Merge pull request #153 from smithlabcode/fixing-literal-suffix-incom…
Browse files Browse the repository at this point in the history
…pat-on-macos

Fixing problem because of macOS
  • Loading branch information
andrewdavidsmith authored Sep 30, 2023
2 parents b97b671 + 52350a2 commit 3ff4d2c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/analysis/bsrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,23 @@ struct bsrate_summary {
void set_values() {
bisulfite_conversion_rate_positive =
static_cast<double>(converted_count_positive) /
max(total_count_positive, 1ul);
max(total_count_positive, static_cast<uint64_t>(1));

bisulfite_conversion_rate_negative =
static_cast<double>(converted_count_negative) /
max(total_count_negative, 1ul);
max(total_count_negative, static_cast<uint64_t>(1));

converted_count = converted_count_positive + converted_count_negative;
total_count = total_count_positive + total_count_negative;

bisulfite_conversion_rate =
static_cast<double>(converted_count) / max(total_count, 1ul);
static_cast<double>(converted_count) /
max(total_count, static_cast<uint64_t>(1));

valid_count = total_count + error_count;

error_rate = static_cast<double>(error_count) / max(valid_count, 1ul);
error_rate = static_cast<double>(error_count) /
max(valid_count, static_cast<uint64_t>(1));
}

string tostring_as_row() const {
Expand Down
7 changes: 4 additions & 3 deletions src/analysis/hmr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ struct hmr_summary {
hmr_total_size = accumulate(cbegin(hmrs), cend(hmrs), 0,
[](const uint64_t t, const GenomicRegion &p) {
return t + p.get_width(); });
hmr_mean_size =
static_cast<double>(hmr_total_size)/std::max(1ul, hmr_count);
hmr_mean_size =
static_cast<double>(hmr_total_size)/
std::max(hmr_count, static_cast<uint64_t>(1));
}
// hmr_count is the number of identified HMRs.
uint64_t hmr_count{};
Expand Down Expand Up @@ -452,7 +453,7 @@ main_hmr(int argc, const char **argv) {
opt_parse.add_opt("params-out", 'p', "write HMM parameters to this "
"file (default: none)", false, params_out_file);
opt_parse.add_opt("seed", 's', "specify random seed", false, rng_seed);
opt_parse.add_opt("summary", 'S', "write summary output here", false,
opt_parse.add_opt("summary", 'S', "write summary output here", false,
summary_file);
opt_parse.set_show_defaults();
vector<string> leftover_args;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/pmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct pmd_summary {
[](const uint64_t t, const GenomicRegion &p) {
return t + p.get_width(); });
pmd_mean_size =
static_cast<double>(pmd_total_size)/std::max(1ul, pmd_count);
static_cast<double>(pmd_total_size)/std::max(pmd_count, static_cast<uint64_t>(1));
}
// pmd_count is the number of identified PMDs.
uint64_t pmd_count{};
Expand Down
2 changes: 1 addition & 1 deletion src/common/LevelsCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ LevelsCounter::update(const MSite &s) {
}
if (s.n_reads > 0) {
++sites_covered;
max_depth = std::max(max_depth, s.n_reads);
max_depth = std::max(max_depth, static_cast<uint64_t>(s.n_reads));
total_c += s.n_meth();
total_t += s.n_reads - s.n_meth();
total_meth += s.meth;
Expand Down
9 changes: 6 additions & 3 deletions src/common/LevelsCounter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,24 @@ struct LevelsCounter {
// is the ratio of total_c divided by coverage. This value is always
// between 0 and 1.
double mean_meth_weighted() const {
return static_cast<double>(total_c)/std::max(coverage(), 1ul);
return static_cast<double>(total_c)/
std::max(coverage(), static_cast<uint64_t>(1));
}

// fractional_meth is the fraction of "called" sites that are called
// methylated. It is the ratio of called_meth divided by
// total_called. This value is always between 0 and 1.
double fractional_meth() const {
return static_cast<double>(called_meth)/std::max(total_called(), 1ul);
return static_cast<double>(called_meth)/
std::max(total_called(), static_cast<uint64_t>(1));
}

// mean_meth is the unweighted mean methylation level. This is the
// ratio of total_meth divided by sites_covered. This value is
// always between 0 and 1.
double mean_meth() const {
return static_cast<double>(total_meth)/std::max(sites_covered, 1ul);
return static_cast<double>(total_meth)/
std::max(sites_covered, static_cast<uint64_t>(1));
}

LevelsCounter(const std::string &c) : context{c} {}
Expand Down

0 comments on commit 3ff4d2c

Please sign in to comment.