-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathmain.cpp
50 lines (42 loc) · 1.33 KB
/
main.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
#include "tabix.hpp"
#include <vector>
using namespace std;
const string VERSION = "1.1.1";
int main(int argc, char** argv) {
if (argc < 2) {
cout << argv[0] << " [file] [ [region] ... ]" << endl
<< "Writes out regions from bgzf-compressed, tabix-indexed file." << endl
<< "Supply 'header' to print out the header, and no regions to" << endl
<< "print the contents of the entire file." << endl << endl
<< "Version " << VERSION << endl;
return 1;
}
string filename = string(argv[1]);
vector<string> regions;
for (int i = 2; i < argc; ++i) {
regions.push_back(string(argv[i]));
}
Tabix file(filename);
if (!regions.empty()) {
for (vector<string>::iterator r = regions.begin(); r != regions.end(); ++r) {
string& region = *r;
if (region == "header") {
string header;
file.getHeader(header);
cout << header;
} else {
string line;
file.setRegion(region);
while (file.getNextLine(line)) {
cout << line << endl;
}
}
}
} else {
string line;
while (file.getNextLine(line)) {
cout << line << endl;
}
}
return 0;
}