]> git.donarmstrong.com Git - rsem.git/blob - PairedEndReadQ.h
install the rsem_perl_utils.pm to /usr/bin even though this is wrong
[rsem.git] / PairedEndReadQ.h
1 #ifndef PAIREDENDREADQ_H_
2 #define PAIREDENDREADQ_H_
3
4 #include<cassert>
5 #include<iostream>
6 #include<string>
7
8 #include "Read.h"
9 #include "SingleReadQ.h"
10
11 class PairedEndReadQ : public Read {
12 public:
13         PairedEndReadQ() : mate1(), mate2() {}
14         PairedEndReadQ(const SingleReadQ& mate1, const SingleReadQ& mate2) {
15                 this->mate1 = mate1;
16                 this->mate2 = mate2;
17                 this->name = mate1.getName();
18         }
19
20         bool read(int argc, std::istream* argv[], int flags = 7);
21         void write(int argc, std::ostream* argv[]);
22
23         const SingleReadQ& getMate1() const { return mate1; }
24         const SingleReadQ& getMate2() const { return mate2; }
25         const SingleReadQ& getMate(int i) const {
26                 if (i == 1) return mate1;
27                 else return mate2;
28         }
29
30         void calc_lq(bool, int); // calculate if this read is low quality. Without calling this function, isLowQuality() will always be false
31
32 private:
33         SingleReadQ mate1, mate2;
34 };
35
36 bool PairedEndReadQ::read(int argc, std::istream* argv[], int flags) {
37         bool success;
38     std::istream *inpMate1[1], *inpMate2[1];
39
40         assert(argc == 2);
41         inpMate1[0] = argv[0]; inpMate2[0] = argv[1];
42         success = mate1.read(1, inpMate1, flags) && mate2.read(1, inpMate2, flags);
43         name = "";
44         if (flags & 4) { name = mate1.getName(); } //May chop 1 char later if we want
45
46         return success;
47 }
48
49 void PairedEndReadQ::write(int argc, std::ostream* argv[]) {
50         std::ostream *outMate1[1], *outMate2[1];
51
52         assert(argc == 2);
53         outMate1[0] = argv[0]; outMate2[0] = argv[1];
54         mate1.write(1, outMate1);
55         mate2.write(1, outMate2);
56 }
57
58 //calculate if this read is low quality
59 void PairedEndReadQ::calc_lq(bool hasPolyA, int seedLen) {
60         low_quality = false;
61         mate1.calc_lq(hasPolyA, seedLen);
62         mate2.calc_lq(hasPolyA, seedLen);
63         if (mate1.getReadLength() < seedLen || mate2.getReadLength() < seedLen) low_quality = true;
64         else low_quality = mate1.isLowQuality() && mate2.isLowQuality();
65 }
66
67 #endif /* PAIREDENDREADQ_H_ */