-
Notifications
You must be signed in to change notification settings - Fork 2
/
MarkerSet.cpp
74 lines (58 loc) · 1.35 KB
/
MarkerSet.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
72
73
74
// MarkerSet.cpp: a marker set
#include "MarkerSet.h"
#include <iostream>
using namespace std;
// MarkerSet(): default constructor
MarkerSet::MarkerSet()
{
markers.resize(MARKER_SET_SIZE);
}
MarkerSet::MarkerSet(const MarkerSet& copy)
{
markers = copy.markers; // copy.getMarkerBits();
}
void MarkerSet::clear()
{
markers.reset();
}
boost::dynamic_bitset<>& MarkerSet::getMarkerBits()
{
return markers;
}
// getMarker(): gets marker
bool MarkerSet::getMarker(int index) const
{
return markers.test( index );
}
void MarkerSet::set(int index , bool bit )
{
markers.set( index , bit );
}
void MarkerSet::print(ostream& out, unsigned int start, unsigned int end)
{
for(unsigned int i=start;i<end && (position_ms*MARKER_SET_SIZE)+i < ALL_SNPS.currentSize();i++)
{
out << ALL_SNPS.getSNP(position_ms*MARKER_SET_SIZE + i).getVariant( markers[i] );
}
}
void MarkerSet::print(ostream& out)
{
print( out , 0 , MARKER_SET_SIZE);
}
// equal(): compares another MarkerSet to see if it has the
bool MarkerSet::equal(MarkerSet * ms)
{
return markers == ms->markers;
}
int MarkerSet::diff(MarkerSet * ms) const
{
return (int) ( markers ^ ms->markers ).count();
}
// operator<<:overloaded insertion operator
ostream& operator<<(ostream& fout, const MarkerSet& m1)
{
for (int i = 0; i < MARKER_SET_SIZE; i++)
fout << m1.getMarker(i);
return fout;
}
// end MarkerSet.cpp