File: main.cpp

package info (click to toggle)
libtabixpp 1.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 376 kB
  • sloc: cpp: 194; makefile: 45; sh: 16
file content (47 lines) | stat: -rw-r--r-- 1,278 bytes parent folder | download | duplicates (6)
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
#include "tabix.hpp"
#include <vector>

using namespace std;

int main(int argc, char** argv) {

    if (argc < 2) {
        cerr << 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;
        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;
}