X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=LenDist.h;h=90d47d74522cbc90088ff8267b387046a533a0e3;hb=dbcf1cfb8ad1086c21d64e249f012809403e7ddc;hp=d7b2ba33631dcca513f5acfe1ca6cde41f6daefc;hpb=a7af78eba4c832c3dc7ff8cbabbd7770bbd015cd;p=rsem.git diff --git a/LenDist.h b/LenDist.h index d7b2ba3..90d47d7 100644 --- a/LenDist.h +++ b/LenDist.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -189,6 +190,8 @@ void LenDist::finish() { sum += pdf[i]; } + if (sum <= EPSILON) { fprintf(stderr, "No valid read to estimate the length distribution!\n"); exit(-1); } + for (int i = 1; i <= span; i++) { pdf[i] = pdf[i] / sum; cdf[i] = cdf[i - 1] + pdf[i]; @@ -217,12 +220,12 @@ void LenDist::read(FILE *fi) { delete[] pdf; delete[] cdf; - fscanf(fi, "%d %d %d", &lb, &ub, &span); + assert(fscanf(fi, "%d %d %d", &lb, &ub, &span) == 3); pdf = new double[span + 1]; cdf = new double[span + 1]; pdf[0] = cdf[0] = 0.0; for (int i = 1; i <= span; i++) { - fscanf(fi, "%lf", &pdf[i]); + assert(fscanf(fi, "%lf", &pdf[i]) == 1); cdf[i] = cdf[i - 1] + pdf[i]; }