-
Notifications
You must be signed in to change notification settings - Fork 1
/
extract_sequence.cpp
68 lines (56 loc) · 1.58 KB
/
extract_sequence.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
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iostream>
#include "rlcsa.h"
#include "misc/utils.h"
#ifdef MULTITHREAD_SUPPORT
#include <omp.h>
const int MAX_THREADS = 64;
#endif
using namespace CSA;
int main(int argc, char** argv)
{
std::cout << "RLCSA display test" << std::endl;
if(argc < 4)
{
std::cout << "Usage: extract_sequence base_name sequence_number output" << std::endl;
return 1;
}
std::cout << "Base name: " << argv[1] << std::endl;
usint sequence = atoi(argv[2]);
std::cout << "Sequence number: " << sequence << std::endl;
std::cout << "Output: " << argv[3] << std::endl;
std::cout << std::endl;
RLCSA rlcsa(argv[1]);
if(!rlcsa.supportsDisplay())
{
std::cerr << "Error: Display is not supported!" << std::endl;
return 2;
}
rlcsa.printInfo();
rlcsa.reportSize(true);
if(sequence >= rlcsa.getNumberOfSequences())
{
std::cerr << "Error: Invalid sequence number!" << std::endl;
return 3;
}
std::ofstream output(argv[3], std::ios_base::binary);
if(!output)
{
std::cerr << "Error: Cannot open output file!" << std::endl;
return 4;
}
double start = readTimer();
uchar* buffer = rlcsa.display(sequence);
usint bytes = length(rlcsa.getSequenceRange(sequence));
output.write((char*)buffer, bytes);
delete[] buffer;
output.close();
double time = readTimer() - start;
double megabytes = bytes / (double)MEGABYTE;
std::cout << megabytes << " megabytes in " << time << " seconds (" << (megabytes / time) << " MB/s)" << std::endl;
std::cout << std::endl;
return 0;
}