18
|
1 #ifndef GENOMIC_INTERVAL_HPP
|
|
2 #define GENOMIC_INTERVAL_HPP
|
|
3
|
|
4 #include "interval.hpp"
|
|
5 #include <stdio.h>
|
|
6 #include <stdlib.h>
|
|
7 #include <string>
|
|
8 #include <sstream>
|
|
9
|
|
10 class GenomicInterval: public Interval {
|
|
11
|
|
12 public:
|
|
13 string chromosome;
|
|
14
|
|
15 GenomicInterval(string chromosome = "", unsigned int start = 0, unsigned int end = 0): Interval(start, end), chromosome(chromosome) { }
|
|
16
|
|
17 bool onSameChromosome(const GenomicInterval &i) const {
|
|
18 return (chromosome == i.chromosome);
|
|
19 }
|
|
20
|
|
21 // friend bool operator==(const GenomicInterval &i1, const GenomicInterval &i2) {
|
|
22 // return ((i1.onSameChromosome(i2)) && (Interval::i1 == Interval::i2));
|
|
23 // }
|
|
24
|
|
25 // friend bool operator<(const GenomicInterval &i1, const GenomicInterval &i2) {
|
|
26 // return ((i1.onSameChromosome(i2)) && (Interval::i1 < Interval::i2));
|
|
27 // }
|
|
28
|
|
29 friend ofstream& operator<<(ofstream &stream, const GenomicInterval &i) {
|
|
30 stream << i.chromosome << '\t' << i.start << '\t' << i.end << '\n';
|
|
31 return stream;
|
|
32 }
|
|
33
|
|
34 void parseFromLine(string &line) {
|
|
35 string strStart, strEnd;
|
|
36 istringstream iss(line);
|
|
37 getline(iss, chromosome, '\t');
|
|
38 getline(iss, strStart, '\t');
|
|
39 getline(iss, strEnd, '\t');
|
|
40 start = atoi(strStart.c_str());
|
|
41 end = atoi(strEnd.c_str());
|
|
42 //cout << "read " << chromosome << ":" << start << ".." << end << endl;
|
|
43 }
|
|
44
|
|
45 };
|
|
46
|
|
47 #endif
|