]> git.donarmstrong.com Git - rsem.git/blobdiff - PairedEndModel.h
--bowtie-chunkmbs
[rsem.git] / PairedEndModel.h
index bd046becb3fcd9cacbbc271863491800a6e67ee1..c011ceea16d53757384e320ae7196251eea7b956 100644 (file)
@@ -236,14 +236,19 @@ void PairedEndModel::estimateFromReads(const char* readFN) {
                while (reader.next(read)) {
                        SingleRead mate1 = read.getMate1();
                        SingleRead mate2 = read.getMate2();
-
-                       mld->update(mate1.getReadLength(), 1.0);
-                       mld->update(mate2.getReadLength(), 1.0);
-
-                       if (i == 0) {
-                               npro->updateC(mate1.getReadSeq());
-                               npro->updateC(mate2.getReadSeq());
-                       }
+                       
+                       if (!read.isLowQuality()) {
+                         mld->update(mate1.getReadLength(), 1.0);
+                         mld->update(mate2.getReadLength(), 1.0);
+                         
+                         if (i == 0) {
+                           npro->updateC(mate1.getReadSeq());
+                           npro->updateC(mate2.getReadSeq());
+                         }
+                       }
+                       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); }
@@ -288,7 +293,7 @@ void PairedEndModel::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);
@@ -298,15 +303,18 @@ void PairedEndModel::read(const char* inpF) {
        pro->read(fi);
        npro->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 PairedEndModel::write(const char* outF) {
        FILE *fo = fopen(outF, "w");
 
@@ -382,9 +390,8 @@ bool PairedEndModel::simulate(int rid, PairedEndRead& read, int& sid) {
                readseq2 = pro->simulate(sampler, mateL2, m2pos, m2dir, ref);
        }
 
-       std::ostringstream stdout;
-       stdout<<rid<<"_"<<dir<<"_"<<sid<<"_"<<pos<<"_"<<insertL;
-       name = stdout.str();
+       strout<<rid<<"_"<<dir<<"_"<<sid<<"_"<<pos<<"_"<<insertL;
+       name = strout.str();
 
        read = PairedEndRead(SingleRead(name + "/1", readseq1), SingleRead(name + "/2", readseq2));