X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=SingleModel.h;h=97ffd29c8ce9b7d499d99979bf0d51546cb17ab7;hb=791b978145b0d22865ee350db9d58072bb99d816;hp=532f79cd2c126c79199b1072508642394e083445;hpb=1794b68d34625b39404d5aba9e72646805b710ce;p=rsem.git diff --git a/SingleModel.h b/SingleModel.h index 532f79c..97ffd29 100644 --- a/SingleModel.h +++ b/SingleModel.h @@ -61,7 +61,6 @@ public: mw = NULL; if (isMaster) { - ori = new Orientation(params.probF); gld = new LenDist(params.minL, params.maxL); if (mean >= EPSILON) { mld = new LenDist(params.mate_minL, params.mate_maxL); @@ -69,6 +68,7 @@ public: if (!estRSPD) { rspd = new RSPD(estRSPD); } } + ori = new Orientation(params.probF); if (estRSPD) { rspd = new RSPD(estRSPD, params.B); } pro = new Profile(params.maxL); npro = new NoiseProfile(); @@ -273,8 +273,11 @@ void SingleModel::estimateFromReads(const char* readFN) { int cnt = 0; while (reader.next(read)) { - mld != NULL ? mld->update(read.getReadLength(), 1.0) : gld->update(read.getReadLength(), 1.0); - if (i == 0) { npro->updateC(read.getReadSeq()); } + if (!read.isLowQuality()) { + mld != NULL ? mld->update(read.getReadLength(), 1.0) : gld->update(read.getReadLength(), 1.0); + if (i == 0) { npro->updateC(read.getReadSeq()); } + } + else if (verbose && read.getReadLength() < OLEN) { printf("Warning: Read %s is ignored due to read length < %d!\n", read.getName().c_str(), OLEN); } ++cnt; if (verbose && cnt % 1000000 == 0) { printf("%d READS PROCESSED\n", cnt); } @@ -315,17 +318,18 @@ void SingleModel::collect(const SingleModel& o) { npro->collect(*(o.npro)); } +//Only master node can call void SingleModel::read(const char* inpF) { int val; FILE *fi = fopen(inpF, "r"); if (fi == NULL) { fprintf(stderr, "Cannot open %s! It may not exist.\n", inpF); exit(-1); } - fscanf(fi, "%d", &val); + assert(fscanf(fi, "%d", &val) == 1); assert(val == model_type); ori->read(fi); gld->read(fi); - fscanf(fi, "%d", &val); + assert(fscanf(fi, "%d", &val) == 1); if (val > 0) { if (mld == NULL) mld = new LenDist(); mld->read(fi); @@ -334,14 +338,18 @@ void SingleModel::read(const char* inpF) { pro->read(fi); npro->read(fi); - if (fscanf(fi, "%d", &M) == 1) { - mw = new double[M + 1]; - for (int i = 0; i <= M; i++) fscanf(fi, "%lf", &mw[i]); + if (fscanf(fi, "%d", &val) == 1) { + if (M == 0) M = val; + if (M == val) { + mw = new double[M + 1]; + for (int i = 0; i <= M; i++) assert(fscanf(fi, "%lf", &mw[i]) == 1); + } } fclose(fi); } +//Only master node can call. Only be called at EM.cpp void SingleModel::write(const char* outF) { FILE *fo = fopen(outF, "w"); @@ -418,9 +426,8 @@ bool SingleModel::simulate(int rid, SingleRead& read, int& sid) { } } - std::ostringstream stdout; - stdout<= OLEN && (mld == NULL ? gld->getMinL() : mld->getMinL()) >= seedLen); memset(mw, 0, sizeof(double) * (M + 1));