Skip to content

Commit 5a2ee67

Browse files
src/analysis/cpgbins.cpp: changed a variable from uint64_t to size_t because macOS gcc-14.2.0 was complaining
1 parent deaff4a commit 5a2ee67

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/analysis/cpgbins.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@
2020
#include "MSite.hpp"
2121
#include "OptionParser.hpp"
2222
#include "bsutils.hpp"
23-
#include "xcounts_utils.hpp"
2423
#include "smithlab_utils.hpp"
24+
#include "xcounts_utils.hpp"
2525

2626
#include <bamxx.hpp>
2727

2828
#include <algorithm>
2929
#include <charconv>
30+
#include <cstdint>
3031
#include <filesystem>
3132
#include <fstream>
3233
#include <iostream>
@@ -45,6 +46,8 @@ using std::ostream;
4546
using std::runtime_error;
4647
using std::size;
4748
using std::string;
49+
using std::uint32_t;
50+
using std::uint64_t;
4851
using std::unordered_map;
4952
using std::vector;
5053

@@ -75,13 +78,13 @@ format_levels_counter(const LevelsCounter &lc) {
7578
return oss.str();
7679
}
7780

78-
7981
static unordered_map<string, uint64_t>
8082
get_chrom_sizes(const string &chrom_sizes_file) {
8183
unordered_map<string, uint64_t> chrom_sizes;
8284

8385
ifstream in(chrom_sizes_file);
84-
if (!in) throw runtime_error("failed to open file: " + chrom_sizes_file);
86+
if (!in)
87+
throw runtime_error("failed to open file: " + chrom_sizes_file);
8588

8689
string line;
8790
while (getline(in, line)) {
@@ -91,7 +94,8 @@ get_chrom_sizes(const string &chrom_sizes_file) {
9194
if (!(iss >> chrom_name >> chrom_size))
9295
throw runtime_error("bad line in " + chrom_sizes_file + ":\n" + line);
9396
string dummy;
94-
if (iss >> dummy) throw runtime_error("too many columns: " + line);
97+
if (iss >> dummy)
98+
throw runtime_error("too many columns: " + line);
9599

96100
if (chrom_sizes.find(chrom_name) != cend(chrom_sizes))
97101
throw runtime_error("repeated entry " + chrom_name + " in " +
@@ -105,7 +109,8 @@ get_chrom_sizes(const string &chrom_sizes_file) {
105109
static vector<string>
106110
get_chrom_names(const string &chrom_sizes_file) {
107111
ifstream in(chrom_sizes_file);
108-
if (!in) throw runtime_error("failed to open file: " + chrom_sizes_file);
112+
if (!in)
113+
throw runtime_error("failed to open file: " + chrom_sizes_file);
109114

110115
vector<string> chrom_names;
111116

@@ -121,7 +126,6 @@ get_chrom_names(const string &chrom_sizes_file) {
121126
return chrom_names;
122127
}
123128

124-
125129
static void
126130
update(LevelsCounter &lc, const xcounts_entry &xce) {
127131
const uint64_t n_reads = xce.n_meth + xce.n_unmeth;
@@ -149,7 +153,8 @@ process_chrom(const bool report_more_info, const char level_code,
149153

150154
uint64_t j = 0;
151155
for (auto i = 0ul; i < chrom_size; i += bin_size) {
152-
while (j < size(sites) && sites[j].pos < i) ++j;
156+
while (j < size(sites) && sites[j].pos < i)
157+
++j;
153158

154159
LevelsCounter lc;
155160
while (j < size(sites) && sites[j].pos < i + bin_size)
@@ -166,7 +171,8 @@ process_chrom(const bool report_more_info, const char level_code,
166171
: (level_code == 'u' ? lc.sites_covered
167172
: lc.total_called()))));
168173
out << r;
169-
if (report_more_info) out << '\t' << format_levels_counter(lc);
174+
if (report_more_info)
175+
out << '\t' << format_levels_counter(lc);
170176
out << '\n';
171177
}
172178
}
@@ -182,7 +188,8 @@ process_chrom(const bool report_more_info, const string &chrom_name,
182188
r.set_start(i);
183189
r.set_end(std::min(i + bin_size, chrom_size));
184190
out << r;
185-
if (report_more_info) out << '\t' << lc_formatted;
191+
if (report_more_info)
192+
out << '\t' << lc_formatted;
186193
out << '\n';
187194
}
188195
}
@@ -210,7 +217,8 @@ Columns (beyond the first 6) in the BED format output:
210217
bool verbose = false;
211218
bool report_more_info = false;
212219
uint32_t n_threads = 1;
213-
uint64_t bin_size = 1000;
220+
// uint64_t bin_size = 1000;
221+
size_t bin_size = 1000; // ADS: for macOS gcc-14.2.0
214222
string level_code = "w";
215223
string outfile;
216224

@@ -266,7 +274,8 @@ Columns (beyond the first 6) in the BED format output:
266274
std::ofstream of;
267275
if (!outfile.empty()) {
268276
of.open(outfile);
269-
if (!of) throw runtime_error("failed to open outfile: " + outfile);
277+
if (!of)
278+
throw runtime_error("failed to open outfile: " + outfile);
270279
}
271280
std::ostream out(outfile.empty() ? cout.rdbuf() : of.rdbuf());
272281

0 commit comments

Comments
 (0)