-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIndelAllele.h
45 lines (38 loc) · 1.18 KB
/
IndelAllele.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
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
class IndelAllele {
friend ostream& operator<<(ostream&, const IndelAllele&);
friend bool operator==(const IndelAllele&, const IndelAllele&);
friend bool operator!=(const IndelAllele&, const IndelAllele&);
friend bool operator<(const IndelAllele&, const IndelAllele&);
public:
bool insertion;
int length;
int position;
string sequence;
IndelAllele(bool i, int l, int p, string s)
: insertion(i), length(l), position(p), sequence(s)
{ }
};
ostream& operator<<(ostream& out, const IndelAllele& indel) {
string t = indel.insertion ? "i" : "d";
out << t << ":" << indel.position << ":" << indel.sequence;
return out;
}
bool operator==(const IndelAllele& a, const IndelAllele& b) {
return (a.insertion == b.insertion
&& a.length == b.length
&& a.position == b.position
&& a.sequence == b.sequence);
}
bool operator!=(const IndelAllele& a, const IndelAllele& b) {
return !(a==b);
}
bool operator<(const IndelAllele& a, const IndelAllele& b) {
ostringstream as, bs;
as << a;
bs << b;
return as.str() < bs.str();
}