-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChromosomeRegion.cpp
executable file
·39 lines (34 loc) · 1.2 KB
/
ChromosomeRegion.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
#include "ChromosomeRegion.h"
using namespace std;
ChromosomeRegion::ChromosomeRegion(int referenceId,
const string& referenceName,
int startPos,
int endPos)
: referenceId(referenceId),
referenceName(referenceName),
interval(startPos,endPos)
{
}
ChromosomeRegion *ChromosomeRegion::Merge(const ChromosomeRegion &other)
{
if (referenceId == other.GetReferenceId() && interval.overlaps(other.interval))
{
Interval newInterval = interval.merge(other.interval);
return new ChromosomeRegion(referenceId,
referenceName,
newInterval.GetStart(),
newInterval.GetEnd());
}
return this;
}
bool operator ==(const ChromosomeRegion &one, const ChromosomeRegion &two)
{
return one.referenceId == two.referenceId && one.interval == two.interval;
}
ostream &operator <<(ostream &stream, const ChromosomeRegion &cRegion)
{
stream << cRegion.referenceName
<< "\t" << cRegion.GetStartPosition()
<< "\t" << cRegion.GetEndPosition();
return stream;
}