Skip to content

Commit

Permalink
In bsw2_stat(), fail to infer when no pairs are within boundaries
Browse files Browse the repository at this point in the history
Just as we set r.failed and return early if there are no high-quality
read pairs at all, also do so if there are none within the calculated
boundaries.  This avoids returning avg=NAN std=NAN, which leads to
malloc(INFINITY) and a crash; fixes lh3#108.
  • Loading branch information
jmarshall committed Jul 3, 2017
1 parent 298284d commit bcb475c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bwtsw2_pair.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ bsw2pestat_t bsw2_stat(int n, bwtsw2_t **buf, kstring_t *msg, int max_ins)
for (i = x = 0, r.avg = 0; i < k; ++i)
if (isize[i] >= r.low && isize[i] <= r.high)
r.avg += isize[i], ++x;
if (x == 0) {
ksprintf(msg, "[%s] fail to infer the insert size distribution: no pairs within boundaries.\n", __func__);
free(isize);
r.failed = 1;
return r;
}
r.avg /= x;
for (i = 0, r.std = 0; i < k; ++i)
if (isize[i] >= r.low && isize[i] <= r.high)
Expand Down

0 comments on commit bcb475c

Please sign in to comment.