13 #include "my_assert.h"
17 #include "SingleRead.h"
18 #include "SingleReadQ.h"
19 #include "PairedEndRead.h"
20 #include "PairedEndReadQ.h"
22 #include "SingleHit.h"
23 #include "PairedEndHit.h"
26 #include "SingleModel.h"
27 #include "SingleQModel.h"
28 #include "PairedEndModel.h"
29 #include "PairedEndQModel.h"
31 #include "Transcript.h"
32 #include "Transcripts.h"
35 #include "GroupInfo.h"
36 #include "HitContainer.h"
37 #include "ReadIndex.h"
38 #include "ReadReader.h"
40 #include "ModelParams.h"
42 #include "HitWrapper.h"
43 #include "BamWriter.h"
47 const double STOP_CRITERIA = 0.001;
48 const int MAX_ROUND = 10000;
49 const int MIN_ROUND = 20;
53 void *reader, *hitv, *ncpv, *mhp, *countv;
57 int m, M; // m genes, M isoforms
58 int N0, N1, N2, N_tot;
62 bool genBamF; // If user wants to generate bam file, true; otherwise, false.
63 bool bamSampling; // true if sampling from read posterior distribution when bam file is generated
64 bool updateModel, calcExpectedWeights;
65 bool genGibbsOut; // generate file for Gibbs sampler
67 char refName[STRLEN], outName[STRLEN];
68 char imdName[STRLEN], statName[STRLEN];
69 char refF[STRLEN], groupF[STRLEN], cntF[STRLEN], tiF[STRLEN];
70 char mparamsF[STRLEN], bmparamsF[STRLEN];
71 char modelF[STRLEN], thetaF[STRLEN];
74 char *pt_fn_list, *pt_chr_list;
75 char inpSamF[STRLEN], outBamF[STRLEN], fn_list[STRLEN], chr_list[STRLEN];
77 char out_for_gibbs_F[STRLEN];
79 vector<double> theta, eel; // eel : expected effective length
81 double *probv, **countvs;
85 Transcripts transcripts;
89 template<class ReadType, class HitType, class ModelType>
90 void init(ReadReader<ReadType> **&readers, HitContainer<HitType> **&hitvs, double **&ncpvs, ModelType **&mhps) {
91 int nReads, nHits, rt;
92 int nrLeft, nhT, curnr; // nrLeft : number of reads left, nhT : hit threshold per thread, curnr: current number of reads
96 char readFs[2][STRLEN];
97 ReadIndex *indices[2];
100 readers = new ReadReader<ReadType>*[nThreads];
101 genReadFileNames(imdName, 1, read_type, s, readFs);
102 for (int i = 0; i < s; i++) {
103 indices[i] = new ReadIndex(readFs[i]);
105 for (int i = 0; i < nThreads; i++) {
106 readers[i] = new ReadReader<ReadType>(s, readFs, refs.hasPolyA(), mparams.seedLen); // allow calculation of calc_lq() function
107 readers[i]->setIndices(indices);
110 hitvs = new HitContainer<HitType>*[nThreads];
111 for (int i = 0; i < nThreads; i++) {
112 hitvs[i] = new HitContainer<HitType>();
115 sprintf(datF, "%s.dat", imdName);
117 general_assert(fin.is_open(), "Cannot open " + cstrtos(datF) + "! It may not exist.");
118 fin>>nReads>>nHits>>rt;
119 general_assert(nReads == N1, "Number of alignable reads does not match!");
120 general_assert(rt == read_type, "Data file (.dat) does not have the right read type!");
123 //A just so so strategy for paralleling
124 nhT = nHits / nThreads;
128 ncpvs = new double*[nThreads];
129 for (int i = 0; i < nThreads; i++) {
130 int ntLeft = nThreads - i - 1; // # of threads left
132 general_assert(readers[i]->locate(curnr), "Read indices files do not match!");
134 while (nrLeft > ntLeft && (i == nThreads - 1 || hitvs[i]->getNHits() < nhT)) {
135 general_assert(hitvs[i]->read(fin), "Cannot read alignments from .dat file!");
138 if (verbose && nrLeft % 1000000 == 0) { printf("DAT %d reads left!\n", nrLeft); }
140 ncpvs[i] = new double[hitvs[i]->getN()];
141 memset(ncpvs[i], 0, sizeof(double) * hitvs[i]->getN());
142 curnr += hitvs[i]->getN();
144 if (verbose) { printf("Thread %d : N = %d, NHit = %d\n", i, hitvs[i]->getN(), hitvs[i]->getNHits()); }
149 mhps = new ModelType*[nThreads];
150 for (int i = 0; i < nThreads; i++) {
151 mhps[i] = new ModelType(mparams, false); // just model helper
154 probv = new double[M + 1];
155 countvs = new double*[nThreads];
156 for (int i = 0; i < nThreads; i++) {
157 countvs[i] = new double[M + 1];
161 if (verbose) { printf("EM_init finished!\n"); }
164 template<class ReadType, class HitType, class ModelType>
165 void* E_STEP(void* arg) {
166 Params *params = (Params*)arg;
167 ModelType *model = (ModelType*)(params->model);
168 ReadReader<ReadType> *reader = (ReadReader<ReadType>*)(params->reader);
169 HitContainer<HitType> *hitv = (HitContainer<HitType>*)(params->hitv);
170 double *ncpv = (double*)(params->ncpv);
171 ModelType *mhp = (ModelType*)(params->mhp);
172 double *countv = (double*)(params->countv);
174 bool needCalcConPrb = model->getNeedCalcConPrb();
178 int N = hitv->getN();
180 vector<double> fracs; //to remove this, do calculation twice
183 if (needCalcConPrb || updateModel) { reader->reset(); }
184 if (updateModel) { mhp->init(); }
186 memset(countv, 0, sizeof(double) * (M + 1));
187 for (int i = 0; i < N; i++) {
188 if (needCalcConPrb || updateModel) {
189 general_assert(reader->next(read), "Can not load a read!");
192 fr = hitv->getSAt(i);
193 to = hitv->getSAt(i + 1);
194 fracs.resize(to - fr + 1);
198 if (needCalcConPrb) { ncpv[i] = model->getNoiseConPrb(read); }
199 fracs[0] = probv[0] * ncpv[i];
200 if (fracs[0] < EPSILON) fracs[0] = 0.0;
202 for (int j = fr; j < to; j++) {
203 HitType &hit = hitv->getHitAt(j);
204 if (needCalcConPrb) { hit.setConPrb(model->getConPrb(read, hit)); }
206 fracs[id] = probv[hit.getSid()] * hit.getConPrb();
207 if (fracs[id] < EPSILON) fracs[id] = 0.0;
211 if (sum >= EPSILON) {
213 countv[0] += fracs[0];
214 if (updateModel) { mhp->updateNoise(read, fracs[0]); }
215 if (calcExpectedWeights) { ncpv[i] = fracs[0]; }
216 for (int j = fr; j < to; j++) {
217 HitType &hit = hitv->getHitAt(j);
220 countv[hit.getSid()] += fracs[id];
221 if (updateModel) { mhp->update(read, hit, fracs[id]); }
222 if (calcExpectedWeights) { hit.setConPrb(fracs[id]); }
225 else if (calcExpectedWeights) {
227 for (int j = fr; j < to; j++) {
228 HitType &hit = hitv->getHitAt(j);
237 template<class ReadType, class HitType, class ModelType>
238 void* calcConProbs(void* arg) {
239 Params *params = (Params*)arg;
240 ModelType *model = (ModelType*)(params->model);
241 ReadReader<ReadType> *reader = (ReadReader<ReadType>*)(params->reader);
242 HitContainer<HitType> *hitv = (HitContainer<HitType>*)(params->hitv);
243 double *ncpv = (double*)(params->ncpv);
246 int N = hitv->getN();
249 assert(model->getNeedCalcConPrb());
252 for (int i = 0; i < N; i++) {
253 general_assert(reader->next(read), "Can not load a read!");
255 fr = hitv->getSAt(i);
256 to = hitv->getSAt(i + 1);
258 ncpv[i] = model->getNoiseConPrb(read);
259 for (int j = fr; j < to; j++) {
260 HitType &hit = hitv->getHitAt(j);
261 hit.setConPrb(model->getConPrb(read, hit));
268 template<class ModelType>
269 void calcExpectedEffectiveLengths(ModelType& model) {
271 double *pdf = NULL, *cdf = NULL, *clen = NULL; // clen[i] = sigma_{j=1}^{i}pdf[i]*(lb+i)
273 model.getGLD().copyTo(pdf, cdf, lb, ub, span);
274 clen = new double[span + 1];
276 for (int i = 1; i <= span; i++) {
277 clen[i] = clen[i - 1] + pdf[i] * (lb + i);
281 eel.resize(M + 1, 0.0);
282 for (int i = 1; i <= M; i++) {
283 int totLen = refs.getRef(i).getTotLen();
284 int fullLen = refs.getRef(i).getFullLen();
285 int pos1 = max(min(totLen - fullLen + 1, ub) - lb, 0);
286 int pos2 = max(min(totLen, ub) - lb, 0);
288 if (pos2 == 0) { eel[i] = 0.0; continue; }
290 eel[i] = fullLen * cdf[pos1] + ((cdf[pos2] - cdf[pos1]) * (totLen + 1) - (clen[pos2] - clen[pos1]));
292 if (eel[i] < MINEEL) { eel[i] = 0.0; }
300 template<class ModelType>
301 void writeResults(ModelType& model, double* counts) {
306 sprintf(modelF, "%s.model", statName);
309 //calculate tau values
310 double *tau = new double[M + 1];
311 memset(tau, 0, sizeof(double) * (M + 1));
314 for (int i = 1; i <= M; i++)
315 if (eel[i] >= EPSILON) {
316 tau[i] = theta[i] / eel[i];
320 general_assert(denom > 0, "No alignable reads?!");
322 for (int i = 1; i <= M; i++) {
326 //isoform level results
327 sprintf(outF, "%s.iso_res", imdName);
328 fo = fopen(outF, "w");
329 for (int i = 1; i <= M; i++) {
330 const Transcript& transcript = transcripts.getTranscriptAt(i);
331 fprintf(fo, "%s%c", transcript.getTranscriptID().c_str(), (i < M ? '\t' : '\n'));
333 for (int i = 1; i <= M; i++)
334 fprintf(fo, "%.2f%c", counts[i], (i < M ? '\t' : '\n'));
335 for (int i = 1; i <= M; i++)
336 fprintf(fo, "%.15g%c", tau[i], (i < M ? '\t' : '\n'));
337 for (int i = 1; i <= M; i++) {
338 const Transcript& transcript = transcripts.getTranscriptAt(i);
339 fprintf(fo, "%s%c", transcript.getGeneID().c_str(), (i < M ? '\t' : '\n'));
344 sprintf(outF, "%s.gene_res", imdName);
345 fo = fopen(outF, "w");
346 for (int i = 0; i < m; i++) {
347 const string& gene_id = transcripts.getTranscriptAt(gi.spAt(i)).getGeneID();
348 fprintf(fo, "%s%c", gene_id.c_str(), (i < m - 1 ? '\t' : '\n'));
350 for (int i = 0; i < m; i++) {
351 double sumC = 0.0; // sum of counts
352 int b = gi.spAt(i), e = gi.spAt(i + 1);
353 for (int j = b; j < e; j++) sumC += counts[j];
354 fprintf(fo, "%.2f%c", sumC, (i < m - 1 ? '\t' : '\n'));
356 for (int i = 0; i < m; i++) {
357 double sumT = 0.0; // sum of tau values
358 int b = gi.spAt(i), e = gi.spAt(i + 1);
359 for (int j = b; j < e; j++) sumT += tau[j];
360 fprintf(fo, "%.15g%c", sumT, (i < m - 1 ? '\t' : '\n'));
362 for (int i = 0; i < m; i++) {
363 int b = gi.spAt(i), e = gi.spAt(i + 1);
364 for (int j = b; j < e; j++) {
365 fprintf(fo, "%s%c", transcripts.getTranscriptAt(j).getTranscriptID().c_str(), (j < e - 1 ? ',' : (i < m - 1 ? '\t' :'\n')));
372 if (verbose) { printf("Expression Results are written!\n"); }
375 template<class ReadType, class HitType, class ModelType>
376 void release(ReadReader<ReadType> **readers, HitContainer<HitType> **hitvs, double **ncpvs, ModelType **mhps) {
378 for (int i = 0; i < nThreads; i++) {
383 for (int i = 0; i < nThreads; i++) {
395 inline bool doesUpdateModel(int ROUND) {
396 // return ROUND <= 20 || ROUND % 100 == 0;
400 //Including initialize, algorithm and results saving
401 template<class ReadType, class HitType, class ModelType>
408 double bChange = 0.0, change = 0.0; // bChange : biggest change
411 ModelType model(mparams); //master model
412 ReadReader<ReadType> **readers;
413 HitContainer<HitType> **hitvs;
415 ModelType **mhps; //model helpers
417 Params fparams[nThreads];
418 pthread_t threads[nThreads];
424 //initialize boolean variables
425 updateModel = calcExpectedWeights = false;
428 theta.resize(M + 1, 0.0);
429 init<ReadType, HitType, ModelType>(readers, hitvs, ncpvs, mhps);
431 //set initial parameters
433 theta[0] = max(N0 * 1.0 / (N_tot - N2), 1e-8);
434 double val = (1.0 - theta[0]) / M;
435 for (int i = 1; i <= M; i++) theta[i] = val;
437 model.estimateFromReads(imdName);
439 for (int i = 0; i < nThreads; i++) {
440 fparams[i].model = (void*)(&model);
442 fparams[i].reader = (void*)readers[i];
443 fparams[i].hitv = (void*)hitvs[i];
444 fparams[i].ncpv = (void*)ncpvs[i];
445 fparams[i].mhp = (void*)mhps[i];
446 fparams[i].countv = (void*)countvs[i];
449 /* set thread attribute to be joinable */
450 pthread_attr_init(&attr);
451 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
457 updateModel = doesUpdateModel(ROUND);
459 for (int i = 0; i <= M; i++) probv[i] = theta[i];
462 for (int i = 0; i < nThreads; i++) {
463 rc = pthread_create(&threads[i], &attr, E_STEP<ReadType, HitType, ModelType>, (void*)(&fparams[i]));
464 pthread_assert(rc, "pthread_create", "Cannot create thread " + itos(i) + " (numbered from 0) at ROUND " + itos(ROUND) + "!");
467 for (int i = 0; i < nThreads; i++) {
468 rc = pthread_join(threads[i], &status);
469 pthread_assert(rc, "pthread_join", "Cannot join thread " + itos(i) + " (numbered from 0) at ROUND " + itos(ROUND) + "!");
472 model.setNeedCalcConPrb(false);
474 for (int i = 1; i < nThreads; i++) {
475 for (int j = 0; j <= M; j++) {
476 countvs[0][j] += countvs[i][j];
485 for (int i = 0; i <= M; i++) sum += countvs[0][i];
486 assert(sum >= EPSILON);
487 for (int i = 0; i <= M; i++) theta[i] = countvs[0][i] / sum;
491 for (int i = 0; i < nThreads; i++) { model.collect(*mhps[i]); }
496 bChange = 0.0; totNum = 0;
497 for (int i = 0; i <= M; i++)
498 if (probv[i] >= 1e-7) {
499 change = fabs(theta[i] - probv[i]) / probv[i];
500 if (change >= STOP_CRITERIA) ++totNum;
501 if (bChange < change) bChange = change;
504 if (verbose) printf("ROUND = %d, SUM = %.15g, bChange = %f, totNum = %d\n", ROUND, sum, bChange, totNum);
505 } while (ROUND < MIN_ROUND || (totNum > 0 && ROUND < MAX_ROUND));
506 // } while (ROUND < 1);
508 if (totNum > 0) fprintf(stderr, "Warning: RSEM reaches %d iterations before meeting the convergence criteria.\n", MAX_ROUND);
510 //generate output file used by Gibbs sampler
512 if (model.getNeedCalcConPrb()) {
513 for (int i = 0; i < nThreads; i++) {
514 rc = pthread_create(&threads[i], &attr, calcConProbs<ReadType, HitType, ModelType>, (void*)(&fparams[i]));
515 pthread_assert(rc, "pthread_create", "Cannot create thread " + itos(i) + " (numbered from 0) when generating files for Gibbs sampler!");
517 for (int i = 0; i < nThreads; i++) {
518 rc = pthread_join(threads[i], &status);
519 pthread_assert(rc, "pthread_join", "Cannot join thread " + itos(i) + " (numbered from 0) when generating files for Gibbs sampler!");
522 model.setNeedCalcConPrb(false);
524 sprintf(out_for_gibbs_F, "%s.ofg", imdName);
525 fo = fopen(out_for_gibbs_F, "w");
526 fprintf(fo, "%d %d\n", M, N0);
527 for (int i = 0; i < nThreads; i++) {
528 int numN = hitvs[i]->getN();
529 for (int j = 0; j < numN; j++) {
530 int fr = hitvs[i]->getSAt(j);
531 int to = hitvs[i]->getSAt(j + 1);
534 if (ncpvs[i][j] >= EPSILON) { ++totNum; fprintf(fo, "%d %.15g ", 0, ncpvs[i][j]); }
535 for (int k = fr; k < to; k++) {
536 HitType &hit = hitvs[i]->getHitAt(k);
537 if (hit.getConPrb() >= EPSILON) {
539 fprintf(fo, "%d %.15g ", hit.getSid(), hit.getConPrb());
543 if (totNum > 0) { fprintf(fo, "\n"); }
549 sprintf(thetaF, "%s.theta", statName);
550 fo = fopen(thetaF, "w");
551 fprintf(fo, "%d\n", M + 1);
554 for (int i = 0; i < M; i++) fprintf(fo, "%.15g ", theta[i]);
555 fprintf(fo, "%.15g\n", theta[M]);
557 //calculate expected effective lengths for each isoform
558 calcExpectedEffectiveLengths<ModelType>(model);
560 //correct theta vector
562 for (int i = 1; i <= M; i++)
563 if (eel[i] < EPSILON) { theta[i] = 0.0; }
564 else sum += theta[i];
566 general_assert(sum >= EPSILON, "No Expected Effective Length is no less than" + ftos(MINEEL, 6) + "?!");
568 for (int i = 0; i <= M; i++) theta[i] /= sum;
570 //calculate expected weights and counts using learned parameters
571 updateModel = false; calcExpectedWeights = true;
572 for (int i = 0; i <= M; i++) probv[i] = theta[i];
573 for (int i = 0; i < nThreads; i++) {
574 rc = pthread_create(&threads[i], &attr, E_STEP<ReadType, HitType, ModelType>, (void*)(&fparams[i]));
575 pthread_assert(rc, "pthread_create", "Cannot create thread " + itos(i) + " (numbered from 0) when calculating expected weights!");
577 for (int i = 0; i < nThreads; i++) {
578 rc = pthread_join(threads[i], &status);
579 pthread_assert(rc, "pthread_join", "Cannot join thread " + itos(i) + " (numbered from 0) when calculating expected weights!");
581 model.setNeedCalcConPrb(false);
582 for (int i = 1; i < nThreads; i++) {
583 for (int j = 0; j <= M; j++) {
584 countvs[0][j] += countvs[i][j];
589 /* destroy attribute */
590 pthread_attr_destroy(&attr);
592 //convert theta' to theta
593 double *mw = model.getMW();
595 for (int i = 0; i <= M; i++) {
596 theta[i] = (mw[i] < EPSILON ? 0.0 : theta[i] / mw[i]);
599 assert(sum >= EPSILON);
600 for (int i = 0; i <= M; i++) theta[i] /= sum;
603 for (int i = 0; i < M; i++) fprintf(fo, "%.15g ", theta[i]);
604 fprintf(fo, "%.15g\n", theta[M]);
608 writeResults<ModelType>(model, countvs[0]);
611 sprintf(outBamF, "%s.transcript.bam", outName);
617 uniform01 rg(engine_type(time(NULL)));
619 if (verbose) printf("Begin to sample reads from their posteriors.\n");
620 for (int i = 0; i < nThreads; i++) {
621 local_N = hitvs[i]->getN();
622 for (int j = 0; j < local_N; j++) {
623 fr = hitvs[i]->getSAt(j);
624 to = hitvs[i]->getSAt(j + 1);
627 arr[0] = ncpvs[i][j];
628 for (int k = fr; k < to; k++) arr[k - fr + 1] = arr[k - fr] + hitvs[i]->getHitAt(k).getConPrb();
629 id = (arr[len - 1] < EPSILON ? -1 : sample(rg, arr, len)); // if all entries in arr are 0, let id be -1
630 for (int k = fr; k < to; k++) hitvs[i]->getHitAt(k).setConPrb(k - fr + 1 == id ? 1.0 : 0.0);
634 if (verbose) printf("Sampling is finished.\n");
637 BamWriter writer(inpSamType, inpSamF, pt_fn_list, outBamF, transcripts);
638 HitWrapper<HitType> wrapper(nThreads, hitvs);
639 writer.work(wrapper);
642 release<ReadType, HitType, ModelType>(readers, hitvs, ncpvs, mhps);
645 int main(int argc, char* argv[]) {
650 printf("Usage : rsem-run-em refName read_type sampleName sampleToken [-p #Threads] [-b samInpType samInpF has_fn_list_? [fn_list]] [-q] [--gibbs-out] [--sampling]\n\n");
651 printf(" refName: reference name\n");
652 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");
653 printf(" sampleName: sample's name, including the path\n");
654 printf(" sampleToken: sampleName excludes the path\n");
655 printf(" -p: number of threads which user wants to use. (default: 1)\n");
656 printf(" -b: produce bam format output file. (default: off)\n");
657 printf(" -q: set it quiet\n");
658 printf(" --gibbs-out: generate output file used by Gibbs sampler. (default: off)\n");
659 printf(" --sampling: sample each read from its posterior distribution when bam file is generated. (default: off)\n");
660 printf("// model parameters should be in imdName.mparams.\n");
664 time_t a = time(NULL);
666 strcpy(refName, argv[1]);
667 read_type = atoi(argv[2]);
668 strcpy(outName, argv[3]);
669 sprintf(imdName, "%s.temp/%s", argv[3], argv[4]);
670 sprintf(statName, "%s.stat/%s", argv[3], argv[4]);
677 pt_fn_list = pt_chr_list = NULL;
679 for (int i = 5; i < argc; i++) {
680 if (!strcmp(argv[i], "-p")) { nThreads = atoi(argv[i + 1]); }
681 if (!strcmp(argv[i], "-b")) {
683 inpSamType = argv[i + 1][0];
684 strcpy(inpSamF, argv[i + 2]);
685 if (atoi(argv[i + 3]) == 1) {
686 strcpy(fn_list, argv[i + 4]);
687 pt_fn_list = (char*)(&fn_list);
690 if (!strcmp(argv[i], "-q")) { quiet = true; }
691 if (!strcmp(argv[i], "--gibbs-out")) { genGibbsOut = true; }
692 if (!strcmp(argv[i], "--sampling")) { bamSampling = true; }
695 general_assert(nThreads > 0, "Number of threads should be bigger than 0!");
700 sprintf(refF, "%s.seq", refName);
703 sprintf(groupF, "%s.grp", refName);
707 sprintf(tiF, "%s.ti", refName);
708 transcripts.readFrom(tiF);
710 sprintf(cntF, "%s.cnt", statName);
713 general_assert(fin.is_open(), "Cannot open " + cstrtos(cntF) + "! It may not exist.");
715 fin>>N0>>N1>>N2>>N_tot;
718 general_assert(N1 > 0, "There are no alignable reads!");
720 if (nThreads > N1) nThreads = N1;
722 //set model parameters
724 mparams.N[0] = N0; mparams.N[1] = N1; mparams.N[2] = N2;
725 mparams.refs = &refs;
727 sprintf(mparamsF, "%s.mparams", imdName);
730 general_assert(fin.is_open(), "Cannot open " + cstrtos(mparamsF) + "It may not exist.");
732 fin>> mparams.minL>> mparams.maxL>> mparams.probF;
733 int val; // 0 or 1 , for estRSPD
735 mparams.estRSPD = (val != 0);
736 fin>> mparams.B>> mparams.mate_minL>> mparams.mate_maxL>> mparams.mean>> mparams.sd;
737 fin>> mparams.seedLen;
742 case 0 : EM<SingleRead, SingleHit, SingleModel>(); break;
743 case 1 : EM<SingleReadQ, SingleHit, SingleQModel>(); break;
744 case 2 : EM<PairedEndRead, PairedEndHit, PairedEndModel>(); break;
745 case 3 : EM<PairedEndReadQ, PairedEndHit, PairedEndQModel>(); break;
746 default : fprintf(stderr, "Unknown Read Type!\n"); exit(-1);
749 time_t b = time(NULL);
751 printTimeUsed(a, b, "EM.cpp");