-
Notifications
You must be signed in to change notification settings - Fork 118
/
SingleHit.h
56 lines (39 loc) · 1009 Bytes
/
SingleHit.h
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
#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 (in>>sid>>pos);
}
void SingleHit::write(std::ostream& out) {
out<<" "<<sid<<" "<<pos;
}
#endif /* SINGLEHIT_H_ */