Skip to content

Commit

Permalink
don't raise assertion failure
Browse files Browse the repository at this point in the history
An reoccurring issue #5 and #8
  • Loading branch information
lh3 committed Apr 23, 2021
1 parent b17412d commit b64f202
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qv.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,13 @@ int yak_qv_solve(const int64_t *hist, const int64_t *cnt, int kmer, double fpr,
// compute adjusted qv
for (c = 0, adj_sum = 0.0; c < n_cnt; ++c)
adj_sum += qs->adj_cnt[c];
assert(adj_sum <= (double)qs->tot);
qs->err = qs->tot - adj_sum;
qs->qv = -4.3429448190325175 * log(log(qs->tot / adj_sum) / kmer);
if (adj_sum <= (double)qs->tot) {
qs->err = qs->tot - adj_sum;
qs->qv = -4.3429448190325175 * log(log(qs->tot / adj_sum) / kmer);
} else {
fprintf(stderr, "WARNING: failed to estimate the calibrated QV\n");
qs->err = 0;
qs->qv = qs->qv_raw;
}
return 0;
}

0 comments on commit b64f202

Please sign in to comment.