-
Notifications
You must be signed in to change notification settings - Fork 0
/
Deletion.cpp
71 lines (62 loc) · 1.98 KB
/
Deletion.cpp
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
68
69
70
71
#include "Deletion.h"
#include "Helper.h"
#include <cassert>
#include <sstream>
using namespace std;
Deletion::Deletion(const string &referenceName,
int start1,
int end1,
int start2,
int end2,
int length,
const string& fromTag) :
referenceName(referenceName),
start1(start1),
end1(end1),
start2(start2),
end2(end2),
length(length),
fromTag(fromTag) {
assert(checkRep());
}
Deletion::~Deletion() {
}
string Deletion::toBedpe() const {
stringstream fmt;
fmt << referenceName << "\t" << start1 - 1 << "\t" << end1 << "\t"
<< referenceName << "\t" << start2 - 1 << "\t" << end2;
return fmt.str();
}
bool Deletion::overlaps(const Deletion &other) const
{
if (referenceName != other.referenceName) return false;
return ((start1-1 >= other.start1-1 && start1-1 <= other.end1) ||
(other.start1-1 >= start1-1 && other.start1-1 <= end1)) &&
((start2-1 >= other.start2-1 && start2-1 <= other.end2) ||
(other.start2-1 >= start2-1 && other.start2-1 <= end2));
}
bool Deletion::operator<(const Deletion &other) const
{
if (referenceName != other.referenceName) return referenceName < other.referenceName;
if (start1 != other.start1) return start1 < other.start1;
if (start2 != other.start2) return start2 < other.start2;
if (end1 != other.end1) return end1 < other.end1;
return end2 < other.end2;
}
bool Deletion::operator==(const Deletion &other) const
{
return referenceName == other.referenceName &&
start1 == other.start1 && start2 == other.start2 &&
end1 == other.end1 && end2 == other.end2;
}
std::ostream& operator <<(ostream &stream, const Deletion &del)
{
stream << del.toBedpe();
return stream;
}
bool Deletion::checkRep() const
{
return (start1 <= end1) &&
(start2 <= end2) &&
(length <= Helper::SVLEN_THRESHOLD);
}