Skip to content

Commit 8f2ff65

Browse files
bsrate.cpp: ensuring the per-read information is still calculated properly with the new format of summary statistics
1 parent 2da0f55 commit 8f2ff65

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/analysis/bsrate.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,10 @@ count_states_pos(const bool INCLUDE_CPGS, const string &chrom,
251251
if (is_cytosine(chrom[rpos]) &&
252252
(rpos >= chrom_lim || !is_guanine(chrom[rpos + 1]) ||
253253
INCLUDE_CPGS)) {
254-
const auto qc = seq_nt16_str[bam_seqi(seq, qpos)];
255-
summaries[fpos].update_pos(qc);
254+
const auto nt = seq_nt16_str[bam_seqi(seq, qpos)];
255+
summaries[fpos].update_pos(nt);
256+
n_conv += (nt == 'T');
257+
n_uconv += (nt == 'C');
256258
}
257259
}
258260
}
@@ -292,8 +294,10 @@ count_states_neg(const bool INCLUDE_CPGS, const string &chrom,
292294
if (rpos > chrom_lim) ++hanging;
293295
if (is_guanine(chrom[rpos]) &&
294296
(rpos == 0 || !is_cytosine(chrom[rpos - 1]) || INCLUDE_CPGS)) {
295-
const auto qc = seq_nt16_str[bam_seqi(seq, qpos - 1)];
296-
summaries[fpos].update_neg(qc);
297+
const auto nt = seq_nt16_str[bam_seqi(seq, qpos - 1)];
298+
summaries[fpos].update_neg(nt);
299+
n_conv += (nt == 'T');
300+
n_uconv += (nt == 'C');
297301
}
298302
}
299303
}
@@ -363,7 +367,7 @@ write_summary(const string &summary_file, vector<bsrate_summary> &summaries) {
363367

364368
template<typename T> static inline void
365369
update_per_read_stats(const pair<T, T> &x, vector<vector<T>> &tab) {
366-
if (x.second < tab.size()) ++tab[x.second][x.first];
370+
if (x.second < std::size(tab)) ++tab[x.second][x.first];
367371
}
368372

369373
static inline vector<double>

0 commit comments

Comments
 (0)