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);
qd = new QualDist();
}
+ ori = new Orientation(params.probF);
if (estRSPD) { rspd = new RSPD(estRSPD, params.B); }
qpro = new QProfile();
nqpro = new NoiseQProfile();
void update(const SingleReadQ& read, const SingleHit& hit, double frac) {
if (read.isLowQuality() || frac < EPSILON) return;
- RefSeq& ref = refs->getRef(hit.getSid());
+ const RefSeq& ref = refs->getRef(hit.getSid());
+
int dir = hit.getDir();
int pos = hit.getPos();
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);
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 SingleQModel::write(const char* outF) {
FILE *fo = fopen(outF, "w");
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]);
}
}
}
- std::ostringstream stdout;
- stdout<<rid<<"_"<<dir<<"_"<<sid<<"_"<<pos;
- name = stdout.str();
+ strout<<rid<<"_"<<dir<<"_"<<sid<<"_"<<pos;
+ name = strout.str();
read = SingleReadQ(name, readseq, qual);
memset(mw, 0, sizeof(double) * (M + 1));
mw[0] = 1.0;
-
probF = ori->getProb(0);
probR = ori->getProb(1);