Skip to content

Commit e5ee19a

Browse files
src/utils/selectsites.cpp: using Interval instead of Interval6
1 parent cfa9ae9 commit e5ee19a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/utils/selectsites.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ selectsites: Select sites, specified in a methcounts format file, that are
1616
contained in given (bed format) intervals.
1717
)";
1818

19-
#include "Interval6.hpp"
19+
#include "Interval.hpp"
2020
#include "MSite.hpp"
2121
#include "OptionParser.hpp"
2222

@@ -111,7 +111,7 @@ write_stats_output(const selectsites_summary &summary,
111111
}
112112

113113
static void
114-
collapsebed(std::vector<Interval6> &regions) {
114+
collapsebed(std::vector<Interval> &regions) {
115115
std::ptrdiff_t j = 0;
116116
for (const auto &r : regions) {
117117
if (regions[j].chrom == r.chrom && r.start <= regions[j].stop)
@@ -123,19 +123,19 @@ collapsebed(std::vector<Interval6> &regions) {
123123
}
124124

125125
static inline bool
126-
precedes(const Interval6 &r, const MSite &s) {
126+
precedes(const Interval &r, const MSite &s) {
127127
return (r.chrom < s.chrom || (r.chrom == s.chrom && r.stop <= s.pos));
128128
}
129129

130130
static inline bool
131-
contains(const Interval6 &r, const MSite &s) {
131+
contains(const Interval &r, const MSite &s) {
132132
return (r.chrom == s.chrom && (r.start <= s.pos && s.pos < r.stop));
133133
}
134134

135135
static auto
136136
process_all_sites(
137137
const bool verbose, const std::string &sites_file,
138-
const std::unordered_map<std::string, std::vector<Interval6>> &regions,
138+
const std::unordered_map<std::string, std::vector<Interval>> &regions,
139139
bamxx::bgzf_file &out) -> std::tuple<std::uint64_t, std::uint64_t> {
140140
bamxx::bgzf_file in(sites_file, "r");
141141
if (!in)
@@ -145,7 +145,7 @@ process_all_sites(
145145
std::uint64_t n_sites_selected = 0u;
146146

147147
MSite the_site, prev_site;
148-
std::vector<Interval6>::const_iterator i, i_lim;
148+
std::vector<Interval>::const_iterator i, i_lim;
149149
bool chrom_is_relevant = false;
150150
while (read_site(in, the_site)) {
151151
++n_sites_total;
@@ -173,7 +173,7 @@ process_all_sites(
173173
}
174174

175175
[[nodiscard]] static auto
176-
get_sites_in_region(std::ifstream &site_in, const Interval6 &region,
176+
get_sites_in_region(std::ifstream &site_in, const Interval &region,
177177
bamxx::bgzf_file &out) -> std::uint64_t {
178178
const std::string chrom{region.chrom};
179179
const std::size_t start_pos = region.start;
@@ -200,7 +200,7 @@ get_sites_in_region(std::ifstream &site_in, const Interval6 &region,
200200

201201
static auto
202202
process_with_sites_on_disk(const std::string &sites_file,
203-
const std::vector<Interval6> &regions,
203+
const std::vector<Interval> &regions,
204204
bamxx::bgzf_file &out) -> std::uint64_t {
205205
std::ifstream in(sites_file);
206206
if (!in)
@@ -213,8 +213,8 @@ process_with_sites_on_disk(const std::string &sites_file,
213213

214214
static void
215215
regions_by_chrom(
216-
std::vector<Interval6> &regions,
217-
std::unordered_map<std::string, std::vector<Interval6>> &lookup) {
216+
std::vector<Interval> &regions,
217+
std::unordered_map<std::string, std::vector<Interval>> &lookup) {
218218
for (auto &&r : regions)
219219
lookup[r.chrom].push_back(r);
220220
regions.clear();
@@ -313,7 +313,7 @@ main_selectsites(int argc, char *argv[]) { // NOLINT(*-avoid-c-arrays)
313313
std::cerr << "input file is so must be loaded\n";
314314
}
315315

316-
auto regions = read_intervals6(regions_file);
316+
auto regions = read_intervals(regions_file);
317317
if (!std::is_sorted(std::cbegin(regions), std::cend(regions)))
318318
throw std::runtime_error("regions not sorted in file: " + regions_file);
319319
std::tie(summary.n_target_regions, summary.target_region_size) =
@@ -329,7 +329,7 @@ main_selectsites(int argc, char *argv[]) { // NOLINT(*-avoid-c-arrays)
329329
summary.target_region_collapsed_size) =
330330
selectsites_summary::measure_target_regions(regions);
331331

332-
std::unordered_map<std::string, std::vector<Interval6>> regions_lookup;
332+
std::unordered_map<std::string, std::vector<Interval>> regions_lookup;
333333
if (!keep_file_on_disk)
334334
regions_by_chrom(regions, regions_lookup);
335335

0 commit comments

Comments
 (0)