X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=PairedEndQModel.h;h=64e486b66b98d19fafc98bce67ef0a5bd85131ad;hb=bf13409ebd15750dc9be1f92a622188d81ae634d;hp=e328779b6675a3579aa221c32f490b99648053e4;hpb=a95154919f950f86de9104b2b9dcf1f0c7e83387;p=rsem.git diff --git a/PairedEndQModel.h b/PairedEndQModel.h index e328779..64e486b 100644 --- a/PairedEndQModel.h +++ b/PairedEndQModel.h @@ -61,12 +61,12 @@ public: mw = NULL; if (isMaster) { - ori = new Orientation(params.probF); if (!estRSPD) rspd = new RSPD(estRSPD); qd = new QualDist(); mld = new LenDist(params.mate_minL, params.mate_maxL); } + ori = new Orientation(params.probF); gld = new LenDist(params.minL, params.maxL); if (estRSPD) rspd = new RSPD(estRSPD, params.B); qpro = new QProfile(); @@ -199,8 +199,6 @@ public: } int getModelType() const { return model_type; } - - bool simulate(int, PairedEndReadQ&, SingleReadQ&, int&); private: static const int model_type = 3; @@ -300,7 +298,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 +309,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"); @@ -335,7 +337,7 @@ void PairedEndQModel::write(const char* outF) { nqpro->write(fo); if (mw != NULL) { - fprintf(fo, "%d\n", M); + fprintf(fo, "\n%d\n", M); for (int i = 0; i < M; i++) { fprintf(fo, "%.15g ", mw[i]); } @@ -401,9 +403,8 @@ bool PairedEndQModel::simulate(int rid, PairedEndReadQ& read, int& sid) { readseq2 = qpro->simulate(sampler, mateL2, m2pos, m2dir, qual2, ref); } - std::ostringstream stdout; - stdout<