-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.h
69 lines (53 loc) · 1.3 KB
/
site.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef __SITE_H__
#define __SITE_H__
#include <vector>
#include <set>
#include "variant.h"
class Site {
public:
Site(const Variant &v, const std::size_t &idx): v_(v), idx_(idx) {}
Variant v() const { return v_; }
std::size_t idx() const { return idx_; }
bool operator==(const Site &other) const;
bool operator!=(const Site &other) const;
bool operator<(const Site &other) const;
std::string to_string() const;
private:
Variant v_;
std::size_t idx_;
};
inline
bool Site::operator==(const Site& other) const {
if (typeid(*this) != typeid(other))
return false;
return v_ == other.v() && idx_ == other.idx();
}
inline
bool Site::operator!=(const Site& other) const {
return !(*this == other);
}
inline
bool Site::operator<(const Site& other) const {
if (v_ != other.v()) {
return v_ < other.v();
} else {
return idx_ < other.idx();
}
}
inline
std::string Site::to_string() const {
return v_.to_string() + " " + std::to_string(idx_);
}
struct ZippedSite {
ZippedSite(const Site* s1_, const Site* s2_): s1(s1_), s2(s2_) {}
const Site* s1;
const Site* s2;
};
struct ZippedResult {
std::vector<ZippedSite> zipped_sites;
std::set<std::size_t> contig_boundaries;
std::size_t n_both;
std::size_t n_only1;
std::size_t n_only2;
};
#endif