Skip to content

Commit ca11a12

Browse files
src/common.cpp: requiring an output file in writing ptredicted complexity curve
1 parent 7bcf82e commit ca11a12

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

src/common.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,9 @@ write_predicted_complexity_curve(
293293
const std::vector<double> &yield_estimates,
294294
const std::vector<double> &yield_lower_ci_lognorm,
295295
const std::vector<double> &yield_upper_ci_lognorm) {
296-
std::ofstream of;
297-
if (!outfile.empty())
298-
of.open(outfile);
299-
std::ostream out(outfile.empty() ? std::cout.rdbuf() : of.rdbuf());
296+
std::ofstream out(outfile);
297+
if (!out)
298+
throw std::runtime_error("failed to open output file: " + outfile);
300299

301300
// clang-format off
302301
out << "TOTAL_READS" << '\t'
@@ -306,13 +305,11 @@ write_predicted_complexity_curve(
306305
// clang-format on
307306

308307
out.setf(std::ios_base::fixed, std::ios_base::floatfield);
309-
out.precision(1);
310-
311308
out << 0 << '\t' << 0 << '\t' << 0 << '\t' << 0 << '\n';
312-
for (std::size_t i = 0; i < std::size(yield_estimates); ++i)
313-
out << (i + 1) * step_size << '\t' << yield_estimates[i] << '\t'
314-
<< yield_lower_ci_lognorm[i] << '\t' << yield_upper_ci_lognorm[i]
315-
<< '\n';
309+
for (auto i = 0ul; i < std::size(yield_estimates); ++i)
310+
out << static_cast<std::uint64_t>((i + 1) * step_size) << '\t'
311+
<< yield_estimates[i] << '\t' << yield_lower_ci_lognorm[i] << '\t'
312+
<< yield_upper_ci_lognorm[i] << '\n';
316313
}
317314

318315
// vals_hist[j] = n_{j} = # (counts = j)

0 commit comments

Comments
 (0)