-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGenomicRange.cpp
93 lines (62 loc) · 1.76 KB
/
GenomicRange.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* GenomicRange
* Date: Aug-17-2012
* Author : Gabriel Renaud gabriel.reno [at sign here ] gmail.com
*
*/
#include "GenomicRange.h"
GenomicRange::GenomicRange(string chrName,unsigned int startCoord,unsigned int endCoord){
if(startCoord>endCoord){
cerr<<"GenomicRange: Error, the start coordinate "<<startCoord<<" is greater than the end"<<endl;
exit(1);
}
this->chrName = chrName;
this->startCoord = startCoord;
this->endCoord = endCoord;
}
GenomicRange::GenomicRange(string chrName,unsigned int startCoord){
if(startCoord>endCoord){
cerr<<"GenomicRange: Error, the start coordinate "<<startCoord<<" is greater than the end"<<endl;
exit(1);
}
this->chrName = chrName;
this->startCoord = startCoord;
this->endCoord = startCoord;
}
GenomicRange::GenomicRange(){
this->chrName = "";
this->startCoord = 0;
this->endCoord = 0;
}
GenomicRange::~GenomicRange(){
}
string GenomicRange::getChrName() const {
return chrName;
}
void GenomicRange::setChrName(string chrName){
this->chrName=chrName;
}
unsigned int GenomicRange::getStartCoord() const {
return startCoord;
}
void GenomicRange::setStartCoord(unsigned int startCoord){
this->startCoord=startCoord;
}
unsigned int GenomicRange::getEndCoord() const {
return endCoord;
}
void GenomicRange::setEndCoord(unsigned int endCoord){
this->endCoord=endCoord;
}
unsigned int GenomicRange::getLength() const {
return endCoord-startCoord+1;
}
string GenomicRange::asBed() const {
return ""+chrName+"\t"+stringify(startCoord-1)+"\t"+stringify(endCoord);
}
std::ostream & operator << (std::ostream & os, const GenomicRange & ct){
os<<ct.chrName<<":"
<<ct.startCoord<<"-"
<<ct.endCoord;
return os;
}