-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbed_utils.hpp
59 lines (47 loc) · 1.18 KB
/
bed_utils.hpp
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
#ifndef BED_HPP
#define BED_HPP
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <iterator>
#include <stdlib.h>
#include <assert.h>
#include <algorithm>
#include <unordered_map>
#include "lprint.hpp"
using namespace std ;
struct Locus {
std::string chrom ;
int position ;
int count ;
} ;
struct Track {
std::string chrom ;
uint64_t begin ;
uint64_t end ;
std::string svtype ;
int svlen ;
bool operator==(const Track &o) const {
return chrom == o.chrom && begin == o.begin && end == o.end && svtype == o.svtype ;
}
bool operator!=(const Track &o) const {
return !(*this == o) ;
}
std::string get_name() const ;
};
namespace std {
template <> struct hash<Track> {
std::size_t operator()(const Track& t) const {
uint64_t hash = 0 ;
hash += t.begin ;
hash += t.end << 32 ;
return std::hash<uint64_t>()(hash) ;
}
};
}
bool track_comparator(Track a, Track b) ;
std::vector<Track> load_tracks_from_file(std::string path) ;
std::unordered_map<Track, int> load_tracks_from_file_as_dict(std::string path) ;
#endif