-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSampleSet.hpp
96 lines (69 loc) · 2.25 KB
/
SampleSet.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
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
94
95
96
#ifndef genomic_SampleSet_h
#define genomic_SampleSet_h
#include <string>
#include <stdexcept>
#include <fstream>
#include "global.hpp"
#include "Sample.hpp"
#include "Marker.hpp"
#include "Properties.hpp"
class GenericSampleSet;
//TODO use boost::spirit for parsing
//TODO allow use of input delimiter other than whitespace in all functions
class SampleSet
{
friend class GenericSampleSet;
// for accessing the private clone() function
// and the read() and write() functions
public:
SampleSet() : markers(NULL) {}
SampleSet(marker::Set* markerSet) : markers(markerSet) {}
SampleSet(const SampleSet& other)
: io(other.io), markers(other.markers), fileName(other.fileName) {
marker::manager.ref(markers);
}
virtual ~SampleSet() {
if (file.is_open()) file.close();
}
void setIO(const IOProperties& io) {
this->io = io;
}
void read(const vector<string>& fileNames, bool isSorted=false) {
read(fileNames, "", isSorted);
}
void read(const vector<string>& fileNames, const string& markersFileName, bool isSorted=false) {
string platform;
marker::manager.newSetName(platform);
read(fileNames, markersFileName, platform, isSorted);
}
void read(const vector<string>& fileNames, const string& markersFileName, const string& platform, bool isSorted);
void read(const string& fileName, bool append=false) {
string platform;
marker::manager.newSetName(platform);
read(fileName, platform, append);
}
// N.B. If platform name is specified explicitly by user, the marker file should be already sorted!
void read(const string& fileName, const string& platform, bool append=false);
void read(fstream& file, const string& platform, const string& fileName, bool append=false);
void write(const string& fileName);
void write(fstream& file, const string& fileName) {
this->fileName = fileName;
_write(file);
}
virtual void clear() = 0;
virtual void sort() = 0;
virtual data::Type type() = 0;
virtual size_t size() = 0;
protected:
IOProperties io;
CNACriteria cna;
string fileName;
marker::Set* markers;
private:
fstream file;
// file IO is the responsibiliity of the base class
virtual void _read(fstream& file) = 0;
virtual void _write(fstream& file) = 0;
virtual SampleSet* clone() const = 0;
};
#endif