forked from tfwillems/HipSTR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
region.h
67 lines (54 loc) · 1.87 KB
/
region.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
#ifndef REGION_H_
#define REGION_H_
#include <assert.h>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <stdlib.h>
#include "error.h"
class Region{
private:
std::string chrom_, name_;
int32_t start_, stop_;
int period_;
public:
Region(std::string chrom, int32_t start, int32_t stop, int period){
assert(stop > start);
chrom_ = chrom; start_ = start; stop_ = stop; period_ = period; name_ = "";
}
Region(std::string chrom, int32_t start, int32_t stop, int period, std::string name){
assert(stop > start);
chrom_ = chrom; start_ = start; stop_ = stop; period_ = period; name_ = name;
}
const std::string& chrom() const { return chrom_; }
const std::string& name() const { return name_; }
int32_t start() const { return start_; }
int32_t stop() const { return stop_; }
int period() const { return period_; }
Region* copy() const { return new Region(chrom_, start_, stop_, period_, name_); }
void set_start(int32_t start){ start_ = start; }
void set_stop(int32_t stop) { stop_ = stop; }
std::string str(){
std::stringstream ss;
ss << chrom_ << ":" << start_ << "-" << stop_;
return ss.str();
}
bool operator<(const Region &r) const {
if (chrom_.compare(r.chrom()) != 0)
return chrom_.compare(r.chrom()) < 0;
if (start_ != r.start())
return start_ < r.start();
if (stop_ != r.stop())
return stop_ < r.stop();
return false;
}
};
void readRegions(std::string& input_file, std::vector<Region>& regions, uint32_t max_regions, std::string chrom, std::ostream& logger);
void orderRegions(std::vector<Region>& regions);
void orderRegions(std::vector<Region>& input_regions,
std::vector< std::vector<Region> >& output_regions,
std::map<std::string, int>& chrom_order);
#endif