]> git.donarmstrong.com Git - rsem.git/blobdiff - ReadReader.h
Added posterior standard deviation of counts as output if either '--calc-pme' or...
[rsem.git] / ReadReader.h
index f1bd1f59a8395c5938a034199e7cd48b70d6a9fb..141585aa5cfe78ff3cd1aca0899f227f092928af 100644 (file)
@@ -7,6 +7,7 @@
 #include<iostream>
 #include<cassert>
 #include<fstream>
+#include<vector>
 
 #include "utils.h"
 #include "SingleRead.h"
 template<class ReadType>
 class ReadReader {
 public:
-       ReadReader() { s = 0; indices = NULL; arr = NULL; }
-       ReadReader(int s, char readFs[][STRLEN]);
+       ReadReader() { s = 0; indices = NULL; arr = NULL; hasPolyA = false; seedLen = -1; }
+       ReadReader(int s, char readFs[][STRLEN], bool hasPolyA = false, int seedLen = -1);
        ~ReadReader();
 
        void setIndices(ReadIndex** indices) {
                this->indices = indices;
        }
 
-       bool locate(long); // You should guarantee that indices exist and rid is valid, otherwise return false; If it fails, you should reset it manually!
+       bool locate(READ_INT_TYPE); // You should guarantee that indices exist and rid is valid, otherwise return false; If it fails, you should reset it manually!
        void reset();
 
        bool next(ReadType& read, int flags = 7) {
-               return read.read(s, (std::istream**)arr, flags);
+               bool success = read.read(s, (std::istream**)arr, flags);
+               if (success && seedLen > 0) { read.calc_lq(hasPolyA, seedLen); }
+               return success;
        }
 
 private:
@@ -39,10 +42,13 @@ private:
        ReadIndex **indices;
        std::ifstream** arr;
        std::streampos *locations;
+
+       bool hasPolyA;
+       int seedLen;
 };
 
 template<class ReadType>
-ReadReader<ReadType>::ReadReader(int s, char readFs[][STRLEN]) {
+ReadReader<ReadType>::ReadReader(int s, char readFs[][STRLEN], bool hasPolyA, int seedLen) {
        assert(s > 0);
        this->s = s;
        arr = new std::ifstream*[s];
@@ -53,6 +59,8 @@ ReadReader<ReadType>::ReadReader(int s, char readFs[][STRLEN]) {
                if (!arr[i]->is_open()) { fprintf(stderr, "Cannot open %s! It may not exist.\n", readFs[i]); exit(-1); }
                locations[i] = arr[i]->tellg();
        }
+       this->hasPolyA = hasPolyA;
+       this->seedLen = seedLen;
 }
 
 template<class ReadType>
@@ -71,15 +79,15 @@ ReadReader<ReadType>::~ReadReader() {
 }
 
 template<class ReadType>
-bool ReadReader<ReadType>::locate(long rid) {
-       long crid = -1;
+bool ReadReader<ReadType>::locate(READ_INT_TYPE rid) {
+       READ_INT_TYPE crid = -1;
        ReadType read;
 
        if (indices == NULL) return false;
 
        //We should make sure that crid returned by each indices is the same
        for (int i = 0; i < s; i++) {
-               long val = indices[i]->locate(rid, *arr[i]);
+               READ_INT_TYPE val = indices[i]->locate(rid, *arr[i]);
                if (i == 0) { crid = val; } else { assert(crid == val); }
        }
        assert(crid <= rid);
@@ -87,7 +95,7 @@ bool ReadReader<ReadType>::locate(long rid) {
 
        if (crid < rid) return false;
 
-       std::streampos tmp[s];
+       std::vector<std::streampos> tmp(s);
        for (int i = 0; i < s; i++) { tmp[i] = arr[i]->tellg(); }
 
        if (!read.read(s, (std::istream**)arr, 0)) return false;