X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=PairedEndQModel.h;h=cbc5475588d19996154d892cc99af336b75ddbde;hb=1bcc1302290b4ae654b0362aae770fcf5c767cb7;hp=5437eb4c0051974b501829aa6ad68c6f69072ac3;hpb=a97cc1d4f0111f7fe523227412a2147f7a763d56;p=rsem.git diff --git a/PairedEndQModel.h b/PairedEndQModel.h index 5437eb4..cbc5475 100644 --- a/PairedEndQModel.h +++ b/PairedEndQModel.h @@ -199,8 +199,6 @@ public: } int getModelType() const { return model_type; } - - bool simulate(int, PairedEndReadQ&, SingleReadQ&, int&); private: static const int model_type = 3; @@ -245,16 +243,21 @@ void PairedEndQModel::estimateFromReads(const char* readFN) { SingleReadQ mate1 = read.getMate1(); SingleReadQ mate2 = read.getMate2(); - mld->update(mate1.getReadLength(), 1.0); - mld->update(mate2.getReadLength(), 1.0); - - qd->update(mate1.getQScore()); - qd->update(mate2.getQScore()); - - if (i == 0) { - nqpro->updateC(mate1.getReadSeq(), mate1.getQScore()); - nqpro->updateC(mate2.getReadSeq(), mate2.getQScore()); - } + if (!read.isLowQuality()) { + mld->update(mate1.getReadLength(), 1.0); + mld->update(mate2.getReadLength(), 1.0); + + qd->update(mate1.getQScore()); + qd->update(mate2.getQScore()); + + if (i == 0) { + nqpro->updateC(mate1.getReadSeq(), mate1.getQScore()); + nqpro->updateC(mate2.getReadSeq(), mate2.getQScore()); + } + } + else if (verbose && (mate1.getReadLength() < OLEN || mate2.getReadLength() < OLEN)) { + printf("Warning: Read %s is ignored due to at least one of the mates' length < %d!\n", read.getName().c_str(), OLEN); + } ++cnt; if (verbose && cnt % 1000000 == 0) { printf("%d READS PROCESSED\n", cnt); } @@ -300,7 +303,7 @@ void PairedEndQModel::read(const char* inpF) { 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); @@ -311,15 +314,19 @@ void PairedEndQModel::read(const char* inpF) { qpro->read(fi); nqpro->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 master node can call. Only be called at EM.cpp void PairedEndQModel::write(const char* outF) { FILE *fo = fopen(outF, "w"); @@ -401,9 +408,8 @@ bool PairedEndQModel::simulate(int rid, PairedEndReadQ& read, int& sid) { readseq2 = qpro->simulate(sampler, mateL2, m2pos, m2dir, qual2, ref); } - std::ostringstream stdout; - stdout<