-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_rephash.cpp
45 lines (33 loc) · 958 Bytes
/
test_rephash.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
#include <iostream>
#include <string>
#include <stdint.h>
#include <vector>
#include <stdlib.h>
#include <algorithm>
#include "rephash.h"
int main(int argc, char **argv) {
size_t k = atoi(argv[1]);
const char *fw = "TGATCTTTCAGATTGTAGAGTTTCATTTAGTTTACCAGTACTCGTGCGCCCGCCGAATCCAGGCGTCAAA";
const char *bw = "TTTGACGCCTGGATTCGGCGGGCGCACGAGTACTGGTAAACTAAATGAAACTCTACAATCTGAAAGATCA";
size_t l = std::string(fw).size();
std::vector<uint64_t> fh,bh;
RepHash hf(k);
hf.seed(42);
hf.init(fw);
fh.push_back(hf.hash());
for (size_t i = k; i < l; i++) {
hf.update(fw[i-k],fw[i]);
fh.push_back(hf.hash());
}
hf.init(bw);
bh.push_back(hf.hash());
for (size_t i = k; i < l; i++) {
hf.update(bw[i-k],bw[i]);
bh.push_back(hf.hash());
}
reverse(bh.begin(),bh.end());
for (size_t i = 0; i < fh.size(); i++) {
std::cout << fh[i] << std::endl << bh[i] << std::endl;
}
std::cout << (fh == bh) << std::endl;
}