File: SingleHit.h

package info (click to toggle)
rsem 1.3.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 37,700 kB
  • sloc: cpp: 19,230; perl: 1,326; python: 1,245; ansic: 547; makefile: 186; sh: 154
file content (56 lines) | stat: -rw-r--r-- 1,017 bytes parent folder | download
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
#ifndef SINGLEHIT_H_
#define SINGLEHIT_H_

#include<cstdlib>
#include<iostream>

//char dir : 0 +, 1 - , encoding as 1 + , -1 -
class SingleHit {
public:
	SingleHit() {
		sid = 0; pos = -1; conprb = 0.0; // for noise gene
	}

	//sid encodes dir here
	SingleHit(int sid, int pos, double conprb = 0.0) {
		this->sid = sid;
		this->pos = pos;
		this->conprb = conprb;
	}

	bool isNoise() const { return sid == 0; }

	//makes no sense for noise gene
	int getDir() const { return sid < 0; }

	int getSid() const { return abs(sid); }

	int getPos() const { return pos; }

	double getConPrb() const { return conprb; }

	void setConPrb(double conprb) {
	    this->conprb = conprb;
	}

	bool read(std::istream&);
	void write(std::ostream&);

protected:
	int sid, pos; // sid encodes dir
	double conprb; // conditional probability
};

bool SingleHit::read(std::istream& in) {
	conprb = 0.0;
	return ((bool)(in>>sid>>pos));
}

void SingleHit::write(std::ostream& out) {
	out<<" "<<sid<<" "<<pos;
}

#endif /* SINGLEHIT_H_ */