File: PairedEndReadQ.h

package info (click to toggle)
rsem 1.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 37,664 kB
  • sloc: cpp: 19,230; perl: 1,326; python: 1,245; ansic: 547; makefile: 186; sh: 154
file content (67 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef PAIREDENDREADQ_H_
#define PAIREDENDREADQ_H_

#include<cassert>
#include<iostream>
#include<string>

#include "Read.h"
#include "SingleReadQ.h"

class PairedEndReadQ : public Read {
public:
	PairedEndReadQ() : mate1(), mate2() {}
	PairedEndReadQ(const SingleReadQ& mate1, const SingleReadQ& mate2) {
		this->mate1 = mate1;
		this->mate2 = mate2;
		this->name = mate1.getName();
	}

	bool read(int argc, std::istream* argv[], int flags = 7);
	void write(int argc, std::ostream* argv[]);

	const SingleReadQ& getMate1() const { return mate1; }
	const SingleReadQ& getMate2() const { return mate2; }
	const SingleReadQ& getMate(int i) const {
		if (i == 1) return mate1;
		else return mate2;
	}

	void calc_lq(bool, int); // calculate if this read is low quality. Without calling this function, isLowQuality() will always be false

private:
	SingleReadQ mate1, mate2;
};

bool PairedEndReadQ::read(int argc, std::istream* argv[], int flags) {
	bool success;
    std::istream *inpMate1[1], *inpMate2[1];

	assert(argc == 2);
	inpMate1[0] = argv[0]; inpMate2[0] = argv[1];
	success = mate1.read(1, inpMate1, flags) && mate2.read(1, inpMate2, flags);
	name = "";
	if (flags & 4) { name = mate1.getName(); } //May chop 1 char later if we want

	return success;
}

void PairedEndReadQ::write(int argc, std::ostream* argv[]) {
	std::ostream *outMate1[1], *outMate2[1];

	assert(argc == 2);
	outMate1[0] = argv[0]; outMate2[0] = argv[1];
	mate1.write(1, outMate1);
	mate2.write(1, outMate2);
}

//calculate if this read is low quality
void PairedEndReadQ::calc_lq(bool hasPolyA, int seedLen) {
	low_quality = false;
	mate1.calc_lq(hasPolyA, seedLen);
	mate2.calc_lq(hasPolyA, seedLen);
	if (mate1.getReadLength() < seedLen || mate2.getReadLength() < seedLen) low_quality = true;
	else low_quality = mate1.isLowQuality() && mate2.isLowQuality();
}

#endif /* PAIREDENDREADQ_H_ */