15 #include "my_assert.h"
19 #include "SingleRead.h"
20 #include "SingleReadQ.h"
21 #include "PairedEndRead.h"
22 #include "PairedEndReadQ.h"
24 #include "SingleHit.h"
25 #include "PairedEndHit.h"
28 #include "SingleModel.h"
29 #include "SingleQModel.h"
30 #include "PairedEndModel.h"
31 #include "PairedEndQModel.h"
33 #include "Transcript.h"
34 #include "Transcripts.h"
37 #include "GroupInfo.h"
38 #include "HitContainer.h"
39 #include "ReadIndex.h"
40 #include "ReadReader.h"
42 #include "ModelParams.h"
44 #include "HitWrapper.h"
45 #include "BamWriter.h"
49 const double STOP_CRITERIA = 0.001;
50 const int MAX_ROUND = 10000;
51 const int MIN_ROUND = 20;
55 void *reader, *hitv, *ncpv, *mhp, *countv;
59 int m, M; // m genes, M isoforms
60 READ_INT_TYPE N0, N1, N2, N_tot;
64 bool genBamF; // If user wants to generate bam file, true; otherwise, false.
65 bool bamSampling; // true if sampling from read posterior distribution when bam file is generated
66 bool updateModel, calcExpectedWeights;
67 bool genGibbsOut; // generate file for Gibbs sampler
69 char refName[STRLEN], outName[STRLEN];
70 char imdName[STRLEN], statName[STRLEN];
71 char refF[STRLEN], groupF[STRLEN], cntF[STRLEN], tiF[STRLEN];
72 char mparamsF[STRLEN];
73 char modelF[STRLEN], thetaF[STRLEN];
76 char *pt_fn_list, *pt_chr_list;
77 char inpSamF[STRLEN], outBamF[STRLEN], fn_list[STRLEN], chr_list[STRLEN];
79 char out_for_gibbs_F[STRLEN];
81 vector<double> theta, eel; // eel : expected effective length
83 double *probv, **countvs;
87 Transcripts transcripts;
91 template<class ReadType, class HitType, class ModelType>
92 void init(ReadReader<ReadType> **&readers, HitContainer<HitType> **&hitvs, double **&ncpvs, ModelType **&mhps) {
97 READ_INT_TYPE nrLeft, curnr; // nrLeft : number of reads left, curnr: current number of reads
98 HIT_INT_TYPE nhT; // nhT : hit threshold per thread
102 char readFs[2][STRLEN];
103 ReadIndex *indices[2];
106 readers = new ReadReader<ReadType>*[nThreads];
107 genReadFileNames(imdName, 1, read_type, s, readFs);
108 for (int i = 0; i < s; i++) {
109 indices[i] = new ReadIndex(readFs[i]);
111 for (int i = 0; i < nThreads; i++) {
112 readers[i] = new ReadReader<ReadType>(s, readFs, refs.hasPolyA(), mparams.seedLen); // allow calculation of calc_lq() function
113 readers[i]->setIndices(indices);
116 hitvs = new HitContainer<HitType>*[nThreads];
117 for (int i = 0; i < nThreads; i++) {
118 hitvs[i] = new HitContainer<HitType>();
121 sprintf(datF, "%s.dat", imdName);
123 general_assert(fin.is_open(), "Cannot open " + cstrtos(datF) + "! It may not exist.");
124 fin>>nReads>>nHits>>rt;
125 general_assert(nReads == N1, "Number of alignable reads does not match!");
126 general_assert(rt == read_type, "Data file (.dat) does not have the right read type!");
129 //A just so so strategy for paralleling
130 nhT = nHits / nThreads;
134 ncpvs = new double*[nThreads];
135 for (int i = 0; i < nThreads; i++) {
136 HIT_INT_TYPE ntLeft = nThreads - i - 1; // # of threads left
138 general_assert(readers[i]->locate(curnr), "Read indices files do not match!");
140 while (nrLeft > ntLeft && (i == nThreads - 1 || hitvs[i]->getNHits() < nhT)) {
141 general_assert(hitvs[i]->read(fin), "Cannot read alignments from .dat file!");
144 if (verbose && nrLeft % 1000000 == 0) { cout<< "DAT "<< nrLeft << " reads left"<< endl; }
146 ncpvs[i] = new double[hitvs[i]->getN()];
147 memset(ncpvs[i], 0, sizeof(double) * hitvs[i]->getN());
148 curnr += hitvs[i]->getN();
150 if (verbose) { cout<<"Thread "<< i<< " : N = "<< hitvs[i]->getN()<< ", NHit = "<< hitvs[i]->getNHits()<< endl; }
155 mhps = new ModelType*[nThreads];
156 for (int i = 0; i < nThreads; i++) {
157 mhps[i] = new ModelType(mparams, false); // just model helper
160 probv = new double[M + 1];
161 countvs = new double*[nThreads];
162 for (int i = 0; i < nThreads; i++) {
163 countvs[i] = new double[M + 1];
167 if (verbose) { printf("EM_init finished!\n"); }
170 template<class ReadType, class HitType, class ModelType>
171 void* E_STEP(void* arg) {
172 Params *params = (Params*)arg;
173 ModelType *model = (ModelType*)(params->model);
174 ReadReader<ReadType> *reader = (ReadReader<ReadType>*)(params->reader);
175 HitContainer<HitType> *hitv = (HitContainer<HitType>*)(params->hitv);
176 double *ncpv = (double*)(params->ncpv);
177 ModelType *mhp = (ModelType*)(params->mhp);
178 double *countv = (double*)(params->countv);
180 bool needCalcConPrb = model->getNeedCalcConPrb();
184 READ_INT_TYPE N = hitv->getN();
186 vector<double> fracs; //to remove this, do calculation twice
187 HIT_INT_TYPE fr, to, id;
189 if (needCalcConPrb || updateModel) { reader->reset(); }
190 if (updateModel) { mhp->init(); }
192 memset(countv, 0, sizeof(double) * (M + 1));
193 for (READ_INT_TYPE i = 0; i < N; i++) {
194 if (needCalcConPrb || updateModel) {
195 general_assert(reader->next(read), "Can not load a read!");
198 fr = hitv->getSAt(i);
199 to = hitv->getSAt(i + 1);
200 fracs.resize(to - fr + 1);
204 if (needCalcConPrb) { ncpv[i] = model->getNoiseConPrb(read); }
205 fracs[0] = probv[0] * ncpv[i];
206 if (fracs[0] < EPSILON) fracs[0] = 0.0;
208 for (HIT_INT_TYPE j = fr; j < to; j++) {
209 HitType &hit = hitv->getHitAt(j);
210 if (needCalcConPrb) { hit.setConPrb(model->getConPrb(read, hit)); }
212 fracs[id] = probv[hit.getSid()] * hit.getConPrb();
213 if (fracs[id] < EPSILON) fracs[id] = 0.0;
217 if (sum >= EPSILON) {
219 countv[0] += fracs[0];
220 if (updateModel) { mhp->updateNoise(read, fracs[0]); }
221 if (calcExpectedWeights) { ncpv[i] = fracs[0]; }
222 for (HIT_INT_TYPE j = fr; j < to; j++) {
223 HitType &hit = hitv->getHitAt(j);
226 countv[hit.getSid()] += fracs[id];
227 if (updateModel) { mhp->update(read, hit, fracs[id]); }
228 if (calcExpectedWeights) { hit.setConPrb(fracs[id]); }
231 else if (calcExpectedWeights) {
233 for (HIT_INT_TYPE j = fr; j < to; j++) {
234 HitType &hit = hitv->getHitAt(j);
243 template<class ReadType, class HitType, class ModelType>
244 void* calcConProbs(void* arg) {
245 Params *params = (Params*)arg;
246 ModelType *model = (ModelType*)(params->model);
247 ReadReader<ReadType> *reader = (ReadReader<ReadType>*)(params->reader);
248 HitContainer<HitType> *hitv = (HitContainer<HitType>*)(params->hitv);
249 double *ncpv = (double*)(params->ncpv);
252 READ_INT_TYPE N = hitv->getN();
255 assert(model->getNeedCalcConPrb());
258 for (READ_INT_TYPE i = 0; i < N; i++) {
259 general_assert(reader->next(read), "Can not load a read!");
261 fr = hitv->getSAt(i);
262 to = hitv->getSAt(i + 1);
264 ncpv[i] = model->getNoiseConPrb(read);
265 for (HIT_INT_TYPE j = fr; j < to; j++) {
266 HitType &hit = hitv->getHitAt(j);
267 hit.setConPrb(model->getConPrb(read, hit));
274 template<class ModelType>
275 void calcExpectedEffectiveLengths(ModelType& model) {
277 double *pdf = NULL, *cdf = NULL, *clen = NULL; // clen[i] = sigma_{j=1}^{i}pdf[i]*(lb+i)
279 model.getGLD().copyTo(pdf, cdf, lb, ub, span);
280 clen = new double[span + 1];
282 for (int i = 1; i <= span; i++) {
283 clen[i] = clen[i - 1] + pdf[i] * (lb + i);
287 eel.resize(M + 1, 0.0);
288 for (int i = 1; i <= M; i++) {
289 int totLen = refs.getRef(i).getTotLen();
290 int fullLen = refs.getRef(i).getFullLen();
291 int pos1 = max(min(totLen - fullLen + 1, ub) - lb, 0);
292 int pos2 = max(min(totLen, ub) - lb, 0);
294 if (pos2 == 0) { eel[i] = 0.0; continue; }
296 eel[i] = fullLen * cdf[pos1] + ((cdf[pos2] - cdf[pos1]) * (totLen + 1) - (clen[pos2] - clen[pos1]));
298 if (eel[i] < MINEEL) { eel[i] = 0.0; }
306 template<class ModelType>
307 void writeResults(ModelType& model, double* counts) {
312 sprintf(modelF, "%s.model", statName);
315 //calculate tau values
316 double *tau = new double[M + 1];
317 memset(tau, 0, sizeof(double) * (M + 1));
320 for (int i = 1; i <= M; i++)
321 if (eel[i] >= EPSILON) {
322 tau[i] = theta[i] / eel[i];
326 general_assert(denom > 0, "No alignable reads?!");
328 for (int i = 1; i <= M; i++) {
332 //isoform level results
333 sprintf(outF, "%s.iso_res", imdName);
334 fo = fopen(outF, "w");
335 for (int i = 1; i <= M; i++) {
336 const Transcript& transcript = transcripts.getTranscriptAt(i);
337 fprintf(fo, "%s%c", transcript.getTranscriptID().c_str(), (i < M ? '\t' : '\n'));
339 for (int i = 1; i <= M; i++)
340 fprintf(fo, "%.2f%c", counts[i], (i < M ? '\t' : '\n'));
341 for (int i = 1; i <= M; i++)
342 fprintf(fo, "%.15g%c", tau[i], (i < M ? '\t' : '\n'));
343 for (int i = 1; i <= M; i++) {
344 const Transcript& transcript = transcripts.getTranscriptAt(i);
345 fprintf(fo, "%s%c", transcript.getGeneID().c_str(), (i < M ? '\t' : '\n'));
350 sprintf(outF, "%s.gene_res", imdName);
351 fo = fopen(outF, "w");
352 for (int i = 0; i < m; i++) {
353 const string& gene_id = transcripts.getTranscriptAt(gi.spAt(i)).getGeneID();
354 fprintf(fo, "%s%c", gene_id.c_str(), (i < m - 1 ? '\t' : '\n'));
356 for (int i = 0; i < m; i++) {
357 double sumC = 0.0; // sum of counts
358 int b = gi.spAt(i), e = gi.spAt(i + 1);
359 for (int j = b; j < e; j++) sumC += counts[j];
360 fprintf(fo, "%.2f%c", sumC, (i < m - 1 ? '\t' : '\n'));
362 for (int i = 0; i < m; i++) {
363 double sumT = 0.0; // sum of tau values
364 int b = gi.spAt(i), e = gi.spAt(i + 1);
365 for (int j = b; j < e; j++) sumT += tau[j];
366 fprintf(fo, "%.15g%c", sumT, (i < m - 1 ? '\t' : '\n'));
368 for (int i = 0; i < m; i++) {
369 int b = gi.spAt(i), e = gi.spAt(i + 1);
370 for (int j = b; j < e; j++) {
371 fprintf(fo, "%s%c", transcripts.getTranscriptAt(j).getTranscriptID().c_str(), (j < e - 1 ? ',' : (i < m - 1 ? '\t' :'\n')));
378 if (verbose) { printf("Expression Results are written!\n"); }
381 template<class ReadType, class HitType, class ModelType>
382 void release(ReadReader<ReadType> **readers, HitContainer<HitType> **hitvs, double **ncpvs, ModelType **mhps) {
384 for (int i = 0; i < nThreads; i++) {
389 for (int i = 0; i < nThreads; i++) {
401 inline bool doesUpdateModel(int ROUND) {
402 // return ROUND <= 20 || ROUND % 100 == 0;
406 //Including initialize, algorithm and results saving
407 template<class ReadType, class HitType, class ModelType>
414 double bChange = 0.0, change = 0.0; // bChange : biggest change
417 ModelType model(mparams); //master model
418 ReadReader<ReadType> **readers;
419 HitContainer<HitType> **hitvs;
421 ModelType **mhps; //model helpers
423 Params fparams[nThreads];
424 pthread_t threads[nThreads];
430 //initialize boolean variables
431 updateModel = calcExpectedWeights = false;
434 theta.resize(M + 1, 0.0);
435 init<ReadType, HitType, ModelType>(readers, hitvs, ncpvs, mhps);
437 //set initial parameters
439 theta[0] = max(N0 * 1.0 / (N_tot - N2), 1e-8);
440 double val = (1.0 - theta[0]) / M;
441 for (int i = 1; i <= M; i++) theta[i] = val;
443 model.estimateFromReads(imdName);
445 for (int i = 0; i < nThreads; i++) {
446 fparams[i].model = (void*)(&model);
448 fparams[i].reader = (void*)readers[i];
449 fparams[i].hitv = (void*)hitvs[i];
450 fparams[i].ncpv = (void*)ncpvs[i];
451 fparams[i].mhp = (void*)mhps[i];
452 fparams[i].countv = (void*)countvs[i];
455 /* set thread attribute to be joinable */
456 pthread_attr_init(&attr);
457 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
463 updateModel = doesUpdateModel(ROUND);
465 for (int i = 0; i <= M; i++) probv[i] = theta[i];
468 for (int i = 0; i < nThreads; i++) {
469 rc = pthread_create(&threads[i], &attr, E_STEP<ReadType, HitType, ModelType>, (void*)(&fparams[i]));
470 pthread_assert(rc, "pthread_create", "Cannot create thread " + itos(i) + " (numbered from 0) at ROUND " + itos(ROUND) + "!");
473 for (int i = 0; i < nThreads; i++) {
474 rc = pthread_join(threads[i], &status);
475 pthread_assert(rc, "pthread_join", "Cannot join thread " + itos(i) + " (numbered from 0) at ROUND " + itos(ROUND) + "!");
478 model.setNeedCalcConPrb(false);
480 for (int i = 1; i < nThreads; i++) {
481 for (int j = 0; j <= M; j++) {
482 countvs[0][j] += countvs[i][j];
491 for (int i = 0; i <= M; i++) sum += countvs[0][i];
492 assert(sum >= EPSILON);
493 for (int i = 0; i <= M; i++) theta[i] = countvs[0][i] / sum;
497 for (int i = 0; i < nThreads; i++) { model.collect(*mhps[i]); }
502 bChange = 0.0; totNum = 0;
503 for (int i = 0; i <= M; i++)
504 if (probv[i] >= 1e-7) {
505 change = fabs(theta[i] - probv[i]) / probv[i];
506 if (change >= STOP_CRITERIA) ++totNum;
507 if (bChange < change) bChange = change;
510 if (verbose) { cout<< "ROUND = "<< ROUND<< ", SUM = "<< setprecision(15)<< sum<< ", bChange = " << setprecision(6)<< bChange<< ", totNum = " << totNum<< endl; }
511 } while (ROUND < MIN_ROUND || (totNum > 0 && ROUND < MAX_ROUND));
512 // } while (ROUND < 1);
514 if (totNum > 0) { cout<< "Warning: RSEM reaches "<< MAX_ROUND<< " iterations before meeting the convergence criteria."<< endl; }
516 //generate output file used by Gibbs sampler
518 if (model.getNeedCalcConPrb()) {
519 for (int i = 0; i < nThreads; i++) {
520 rc = pthread_create(&threads[i], &attr, calcConProbs<ReadType, HitType, ModelType>, (void*)(&fparams[i]));
521 pthread_assert(rc, "pthread_create", "Cannot create thread " + itos(i) + " (numbered from 0) when generating files for Gibbs sampler!");
523 for (int i = 0; i < nThreads; i++) {
524 rc = pthread_join(threads[i], &status);
525 pthread_assert(rc, "pthread_join", "Cannot join thread " + itos(i) + " (numbered from 0) when generating files for Gibbs sampler!");
528 model.setNeedCalcConPrb(false);
530 sprintf(out_for_gibbs_F, "%s.ofg", imdName);
531 ofstream fout(out_for_gibbs_F);
532 fout<< M<< " "<< N0<< endl;
533 for (int i = 0; i < nThreads; i++) {
534 READ_INT_TYPE numN = hitvs[i]->getN();
535 for (READ_INT_TYPE j = 0; j < numN; j++) {
536 HIT_INT_TYPE fr = hitvs[i]->getSAt(j);
537 HIT_INT_TYPE to = hitvs[i]->getSAt(j + 1);
538 HIT_INT_TYPE totNum = 0;
540 if (ncpvs[i][j] >= EPSILON) { ++totNum; fout<< "0 "<< setprecision(15)<< ncpvs[i][j]<< " "; }
541 for (HIT_INT_TYPE k = fr; k < to; k++) {
542 HitType &hit = hitvs[i]->getHitAt(k);
543 if (hit.getConPrb() >= EPSILON) {
545 fout<< hit.getSid()<< " "<< setprecision(15)<< hit.getConPrb()<< " ";
549 if (totNum > 0) { fout<< endl; }
555 sprintf(thetaF, "%s.theta", statName);
556 fo = fopen(thetaF, "w");
557 fprintf(fo, "%d\n", M + 1);
560 for (int i = 0; i < M; i++) fprintf(fo, "%.15g ", theta[i]);
561 fprintf(fo, "%.15g\n", theta[M]);
563 //calculate expected effective lengths for each isoform
564 calcExpectedEffectiveLengths<ModelType>(model);
566 //correct theta vector
568 for (int i = 1; i <= M; i++)
569 if (eel[i] < EPSILON) { theta[i] = 0.0; }
570 else sum += theta[i];
572 general_assert(sum >= EPSILON, "No Expected Effective Length is no less than" + ftos(MINEEL, 6) + "?!");
574 for (int i = 0; i <= M; i++) theta[i] /= sum;
576 //calculate expected weights and counts using learned parameters
577 updateModel = false; calcExpectedWeights = true;
578 for (int i = 0; i <= M; i++) probv[i] = theta[i];
579 for (int i = 0; i < nThreads; i++) {
580 rc = pthread_create(&threads[i], &attr, E_STEP<ReadType, HitType, ModelType>, (void*)(&fparams[i]));
581 pthread_assert(rc, "pthread_create", "Cannot create thread " + itos(i) + " (numbered from 0) when calculating expected weights!");
583 for (int i = 0; i < nThreads; i++) {
584 rc = pthread_join(threads[i], &status);
585 pthread_assert(rc, "pthread_join", "Cannot join thread " + itos(i) + " (numbered from 0) when calculating expected weights!");
587 model.setNeedCalcConPrb(false);
588 for (int i = 1; i < nThreads; i++) {
589 for (int j = 0; j <= M; j++) {
590 countvs[0][j] += countvs[i][j];
595 /* destroy attribute */
596 pthread_attr_destroy(&attr);
598 //convert theta' to theta
599 double *mw = model.getMW();
601 for (int i = 0; i <= M; i++) {
602 theta[i] = (mw[i] < EPSILON ? 0.0 : theta[i] / mw[i]);
605 assert(sum >= EPSILON);
606 for (int i = 0; i <= M; i++) theta[i] /= sum;
609 for (int i = 0; i < M; i++) fprintf(fo, "%.15g ", theta[i]);
610 fprintf(fo, "%.15g\n", theta[M]);
614 writeResults<ModelType>(model, countvs[0]);
617 sprintf(outBamF, "%s.transcript.bam", outName);
620 READ_INT_TYPE local_N;
621 HIT_INT_TYPE fr, to, len, id;
623 uniform01 rg(engine_type(time(NULL)));
625 if (verbose) cout<< "Begin to sample reads from their posteriors."<< endl;
626 for (int i = 0; i < nThreads; i++) {
627 local_N = hitvs[i]->getN();
628 for (READ_INT_TYPE j = 0; j < local_N; j++) {
629 fr = hitvs[i]->getSAt(j);
630 to = hitvs[i]->getSAt(j + 1);
633 arr[0] = ncpvs[i][j];
634 for (HIT_INT_TYPE k = fr; k < to; k++) arr[k - fr + 1] = arr[k - fr] + hitvs[i]->getHitAt(k).getConPrb();
635 id = (arr[len - 1] < EPSILON ? -1 : sample(rg, arr, len)); // if all entries in arr are 0, let id be -1
636 for (HIT_INT_TYPE k = fr; k < to; k++) hitvs[i]->getHitAt(k).setConPrb(k - fr + 1 == id ? 1.0 : 0.0);
640 if (verbose) cout<< "Sampling is finished."<< endl;
643 BamWriter writer(inpSamType, inpSamF, pt_fn_list, outBamF, transcripts);
644 HitWrapper<HitType> wrapper(nThreads, hitvs);
645 writer.work(wrapper);
648 release<ReadType, HitType, ModelType>(readers, hitvs, ncpvs, mhps);
651 int main(int argc, char* argv[]) {
656 printf("Usage : rsem-run-em refName read_type sampleName imdName statName [-p #Threads] [-b samInpType samInpF has_fn_list_? [fn_list]] [-q] [--gibbs-out] [--sampling]\n\n");
657 printf(" refName: reference name\n");
658 printf(" read_type: 0 single read without quality score; 1 single read with quality score; 2 paired-end read without quality score; 3 paired-end read with quality score.\n");
659 printf(" sampleName: sample's name, including the path\n");
660 printf(" sampleToken: sampleName excludes the path\n");
661 printf(" -p: number of threads which user wants to use. (default: 1)\n");
662 printf(" -b: produce bam format output file. (default: off)\n");
663 printf(" -q: set it quiet\n");
664 printf(" --gibbs-out: generate output file used by Gibbs sampler. (default: off)\n");
665 printf(" --sampling: sample each read from its posterior distribution when bam file is generated. (default: off)\n");
666 printf("// model parameters should be in imdName.mparams.\n");
670 time_t a = time(NULL);
672 strcpy(refName, argv[1]);
673 read_type = atoi(argv[2]);
674 strcpy(outName, argv[3]);
675 strcpy(imdName, argv[4]);
676 strcpy(statName, argv[5]);
683 pt_fn_list = pt_chr_list = NULL;
685 for (int i = 6; i < argc; i++) {
686 if (!strcmp(argv[i], "-p")) { nThreads = atoi(argv[i + 1]); }
687 if (!strcmp(argv[i], "-b")) {
689 inpSamType = argv[i + 1][0];
690 strcpy(inpSamF, argv[i + 2]);
691 if (atoi(argv[i + 3]) == 1) {
692 strcpy(fn_list, argv[i + 4]);
693 pt_fn_list = (char*)(&fn_list);
696 if (!strcmp(argv[i], "-q")) { quiet = true; }
697 if (!strcmp(argv[i], "--gibbs-out")) { genGibbsOut = true; }
698 if (!strcmp(argv[i], "--sampling")) { bamSampling = true; }
701 general_assert(nThreads > 0, "Number of threads should be bigger than 0!");
706 sprintf(refF, "%s.seq", refName);
709 sprintf(groupF, "%s.grp", refName);
713 sprintf(tiF, "%s.ti", refName);
714 transcripts.readFrom(tiF);
716 sprintf(cntF, "%s.cnt", statName);
719 general_assert(fin.is_open(), "Cannot open " + cstrtos(cntF) + "! It may not exist.");
721 fin>>N0>>N1>>N2>>N_tot;
724 general_assert(N1 > 0, "There are no alignable reads!");
726 if ((READ_INT_TYPE)nThreads > N1) nThreads = N1;
728 //set model parameters
730 mparams.N[0] = N0; mparams.N[1] = N1; mparams.N[2] = N2;
731 mparams.refs = &refs;
733 sprintf(mparamsF, "%s.mparams", imdName);
736 general_assert(fin.is_open(), "Cannot open " + cstrtos(mparamsF) + "It may not exist.");
738 fin>> mparams.minL>> mparams.maxL>> mparams.probF;
739 int val; // 0 or 1 , for estRSPD
741 mparams.estRSPD = (val != 0);
742 fin>> mparams.B>> mparams.mate_minL>> mparams.mate_maxL>> mparams.mean>> mparams.sd;
743 fin>> mparams.seedLen;
748 case 0 : EM<SingleRead, SingleHit, SingleModel>(); break;
749 case 1 : EM<SingleReadQ, SingleHit, SingleQModel>(); break;
750 case 2 : EM<PairedEndRead, PairedEndHit, PairedEndModel>(); break;
751 case 3 : EM<PairedEndReadQ, PairedEndHit, PairedEndQModel>(); break;
752 default : fprintf(stderr, "Unknown Read Type!\n"); exit(-1);
755 time_t b = time(NULL);
757 printTimeUsed(a, b, "EM.cpp");