Skip to content

Commit 8bf3bd0

Browse files
Updating source files that use bamxx::bgzf_file
1 parent c01d621 commit 8bf3bd0

File tree

13 files changed

+28
-32
lines changed

13 files changed

+28
-32
lines changed

src/analysis/hmr-rep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ using std::to_string;
4747
using std::begin;
4848
using std::end;
4949

50-
using bgzf_file = bamxx::bam_bgzf;
50+
using bamxx::bgzf_file;
5151

5252
static GenomicRegion
5353
as_gen_rgn(const MSite &s) {

src/analysis/hmr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ using std::runtime_error;
4848
using std::to_string;
4949
using std::unordered_set;
5050

51-
using bgzf_file = bamxx::bam_bgzf;
51+
using bamxx::bgzf_file;
5252

5353
static GenomicRegion
5454
as_gen_rgn(const MSite &s) {

src/analysis/hypermr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ as_gen_rgn(const MSite &s) {
6161
static void
6262
load_cpgs(const string &cpgs_file, vector<MSite> &cpgs,
6363
vector<pair<double, double>> &meth) {
64-
bamxx::bam_bgzf in(cpgs_file, "r");
64+
bamxx::bgzf_file in(cpgs_file, "r");
6565
if (!in) throw runtime_error("failed opening file: " + cpgs_file);
6666

6767
MSite the_site;
6868
string line;
69-
while (in.getline(line)) cpgs.push_back(MSite(line));
69+
while (getline(in, line)) cpgs.push_back(MSite(line));
7070

7171
meth.resize(cpgs.size());
7272
for (size_t i = 0; i < cpgs.size(); ++i)

src/analysis/levels.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ using std::string;
5252
using std::to_string;
5353
using std::vector;
5454

55-
using bgzf_file = bamxx::bam_bgzf;
55+
using bamxx::bgzf_file;
5656

5757
enum class counts_file_format { ordinary, asym_cpg, sym_cpg };
5858

src/analysis/methcounts.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ tag_with_mut(const uint32_t tag, const bool mut) {
239239

240240

241241
static void
242-
write_output(const bamxx::bam_header &hdr, bamxx::bam_bgzf &out,
242+
write_output(const bamxx::bam_header &hdr, bamxx::bgzf_file &out,
243243
const int32_t tid, const string &chrom,
244244
const vector<CountSet> &counts, bool CPG_ONLY) {
245245

@@ -267,8 +267,7 @@ write_output(const bamxx::bam_header &hdr, bamxx::bam_bgzf &out,
267267
<< tag_values[tag_with_mut(the_tag, mut)] << '\t'
268268
<< (n_reads > 0 ? unconverted/n_reads : 0.0) << '\t'
269269
<< n_reads << '\n';
270-
const size_t expected_size = buf.tellp();
271-
if (out.write(buf.c_str(), expected_size))
270+
if (out.write(buf.c_str(), buf.tellp()))
272271
throw dnmt_error("error writing output");
273272
}
274273
}
@@ -397,7 +396,7 @@ process_reads(const bool VERBOSE,
397396

398397
// open the output file
399398
const string output_mode = compress_output ? "w" : "wu";
400-
bamxx::bam_bgzf out(outfile, output_mode);
399+
bamxx::bgzf_file out(outfile, output_mode);
401400
if (!out) throw dnmt_error("error opening output file: " + outfile);
402401

403402
/* set the threads for the input file decompression */

src/analysis/multimethstat.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ using std::ifstream;
4949
using std::isfinite;
5050
using std::is_sorted;
5151

52-
using bgzf_file = bamxx::bam_bgzf;
52+
using bamxx::bgzf_file;
5353

5454
static pair<bool, bool>
5555
meth_unmeth_calls(const size_t n_meth, const size_t n_unmeth) {
@@ -174,7 +174,7 @@ process_with_cpgs_loaded(const bool VERBOSE,
174174
if (!in) throw runtime_error("cannot open file: " + cpgs_file);
175175

176176
string header;
177-
in.getline(header);
177+
getline(in, header);
178178

179179
std::istringstream iss(header);
180180
string col_name;
@@ -197,7 +197,7 @@ process_with_cpgs_loaded(const bool VERBOSE,
197197
vector<vector<double> > values;
198198
MSite the_cpg;
199199
string line;
200-
while (in.getline(line)) {
200+
while (getline(in, line)) {
201201
values.push_back(vector<double>());
202202
get_site_and_values(line, the_cpg, values.back());
203203
cpgs.push_back(the_cpg);

src/analysis/pmd.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ using std::ostream;
5252
using std::ofstream;
5353
using std::to_string;
5454

55-
using bgzf_file = bamxx::bam_bgzf;
55+
using bamxx::bgzf_file;
5656

5757
static void
5858
get_adjacent_distances(const vector<GenomicRegion> &pmds,
@@ -739,7 +739,7 @@ check_if_array_data(const string &infile) {
739739
if (!in) throw std::runtime_error("bad file: " + infile);
740740

741741
std::string line;
742-
in.getline(line);
742+
getline(in, line);
743743
std::istringstream iss(line);
744744
std::string chrom, pos, strand, seq, meth, cov;
745745
iss >> chrom >> pos >> strand >> seq >> meth;

src/analysis/roimethstat.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ using std::isfinite;
5151
using std::is_sorted;
5252
using std::regex_match;
5353

54-
using bgzf_file = bamxx::bam_bgzf;
54+
using bamxx::bgzf_file;
5555

5656
static pair<bool, bool>
5757
meth_unmeth_calls(const size_t n_meth, const size_t n_unmeth) {
@@ -480,7 +480,7 @@ Columns (beyond the first 6) in the BED format output:
480480
throw runtime_error("format must be 3 or 6+ column bed: " + regions_file);
481481
if (is_msite_file(regions_file)) {
482482
cerr << opt_parse.help_message() << endl;
483-
throw runtime_error("The file seems to be a methylation file: " +
483+
throw runtime_error("The file seems to be a methylation file: " +
484484
regions_file + "\nCheck the order of the input arguments");
485485
}
486486
if (!is_msite_file(cpgs_file)) {
@@ -533,6 +533,3 @@ Columns (beyond the first 6) in the BED format output:
533533
}
534534
return EXIT_SUCCESS;
535535
}
536-
537-
538-

src/common/MSite.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ find_offset_for_msite(const std::string &chrom,
140140

141141
// ADS: using the functions below for now for static polymorphism
142142
// because I don't want to have insertion and extraction operators
143-
// hanging around for MSite with bamxx::bam_bgzf. The reason is that
143+
// hanging around for MSite with bamxx::bgzf_file. The reason is that
144144
// if we are going to use them, we need to be aware of which functions
145145
// we are calling, and not just do it unconsciously.
146146

147147
#include <bamxx.hpp>
148148
#include <sstream>
149149

150-
inline bamxx::bam_bgzf &
151-
write_site(bamxx::bam_bgzf &f, const MSite &s) {
150+
inline bamxx::bgzf_file &
151+
write_site(bamxx::bgzf_file &f, const MSite &s) {
152152
// ADS: to slow??
153153
std::ostringstream oss;
154154
oss << s.tostring() << '\n';
155-
f.write(oss.str().c_str(), oss.str().size());
155+
f.write(oss.str());
156156
return f;
157157
}
158158

@@ -161,10 +161,10 @@ write_site(std::ostream &out, const MSite &s) {
161161
return out << s << '\n';
162162
}
163163

164-
inline bamxx::bam_bgzf &
165-
read_site(bamxx::bam_bgzf &f, MSite &s) {
164+
inline bamxx::bgzf_file &
165+
read_site(bamxx::bgzf_file &f, MSite &s) {
166166
std::string line;
167-
if (f.getline(line))
167+
if (getline(f, line))
168168
s = MSite(line);
169169
return f;
170170
}

src/radmeth/methdiff.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ using std::vector;
4242
using std::ofstream;
4343
using std::ostream_iterator;
4444

45-
using bgzf_file = bamxx::bam_bgzf;
45+
using bamxx::bgzf_file;
4646

4747
static inline double
4848
log_sum_log(const double p, const double q) {
@@ -113,7 +113,7 @@ write_methdiff_site(bgzf_file &out, const MSite &a, const MSite &b,
113113
<< b.n_meth() << '\t'
114114
<< b.n_unmeth() << '\n';
115115
// clang-format on
116-
out.write(oss.str().c_str(), oss.str().size());
116+
out.write(oss.str());
117117
return out;
118118
}
119119

0 commit comments

Comments
 (0)