forked from HIITMetagenomics/dsm-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Query.h
125 lines (100 loc) · 2.69 KB
/
Query.h
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
* Interface for alignment queries
*/
#ifndef _Query_H_
#define _Query_H_
#include "Pattern.h"
#include "InputReader.h"
#include "OutputWriter.h"
#include <stack>
#include <vector>
#include <string>
#include <cstdlib> // exit()
/**
* Base class for queries
*/
class Query
{
public:
void align(Pattern *p, unsigned k, unsigned &reported);
void setRecursionLimit(unsigned rlimit)
{ this->rlimit = rlimit; }
void setDebug(bool b)
{ this->debug = b; }
virtual ~Query()
{ }
static const char ALPHABET_DNA[];
static const unsigned ALPHABET_SIZE = 4; // 5
inline bool pushChar(char c) {
ulong nmin = tc->LF(c, smin.top()-1);
ulong nmax = tc->LF(c, smax.top())-1;
if (nmin > nmax) return false;
smin.push(nmin);
smax.push(nmax);
match.push_back(c);
return true;
}
inline void popChar() {
smin.pop();
smax.pop();
match.pop_back();
}
protected:
virtual void firstStep() = 0;
inline void pushDelim(char c) {
match.push_back(c);
}
inline void popDelim() {
match.pop_back();
}
inline int min(int a, int b) {
if (a < b) return a; else return b;
}
inline int min(int a, int b, int c) {
if (a < b) if (a < c) return a; else return c;
else if (b < c) return b; else return c;
}
/*inline void newMatch(void) {
ulong min = smin.top();
ulong occs = smax.top() - min + 1;
if (occs > report - sum)
occs = report - sum;
this->sum += occs;
TextCollection::position_vector posv;
tc.getPosition(posv, min, min + occs - 1);
for (TextCollection::position_vector::iterator pos = posv.begin();
pos != posv.end(); ++pos)
outputw.report(*p, *pos, "RNAME", std::string(text, l),
smax.top() - min + 1); // FIXME
}*/
Query(TextCollection *tc_, OutputWriter &ow, bool vrb,
bool incr, bool rvrs, unsigned rprt);
Pattern *p;
unsigned patlen;
const char *pat;
TextCollection *tc;
OutputWriter &outputw;
bool verbose;
bool reverse;
bool debug;
unsigned report;
unsigned klimit;
unsigned sum;
ulong textlen;
unsigned rlimit;
const char *ALPHABET;
static const char ALPHABET_SOLID[];
static const char ALPHABET_SHIFTED[];
std::stack<ulong> smin;
std::stack<ulong> smax;
std::vector<uchar> match;
ulong callcounter;
ulong counterstart;
ulong pathcounter; // FIXME
private:
Query();
// No copy constructor or assignment
Query(Query const&);
Query& operator = (Query const&);
};
#endif // _Query_H_