forked from Malfoy/OLDMPHFREP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
77 lines (63 loc) · 1.61 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
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
#include "utils.h"
#include "xor.h"
#include <fstream>
using namespace std;
int main(int argc, char ** argv){
srand (time(NULL));
uint Nelement(1000*1000);
double gamma(1.1);
uint Ncase(gamma*Nelement);
uint k(31);
cout<<"gamma :"<<gamma<<endl;
vector<uint64_t> originalkmers(Nelement);
for(uint i(0);i<Nelement;++i){
originalkmers[i]=(getRepresent(seq2intStranded(randomSeq(k)),k));
// cout<<randomSeq(k)<<endl;
// cout<<kmer[i]<<endl;
}
for(uint H(2);H<257;H*=2){
vector<uint64_t> kmers=originalkmers;
vector<vector<uint64_t>> map(Ncase);
for(uint n(0);n<H-1;++n){
for(uint i(0);i<kmers.size();++i){
uint64_t h(iterHash64(kmers[i],n)%Ncase);
// cout<<h<<endl;
map[h].push_back(kmers[i]);
}
kmers={};
for(uint i(0);i<Ncase;++i){
if(map[i].size()>1){
for(uint j(0);j<map[i].size();++j){
kmers.push_back(map[i][j]);
}
map[i]={};
}
}
// cout<<"Phase "<<n<<endl;
// cout<<kmers.size()<<endl;
// cout<<100*kmers.size()/Nelement<<" %"<<endl;
}
cout<<"Number of hash function: "<<H-1<<endl;
cout<<"Percent Unplaced element: "<<(double)100*kmers.size()/Nelement<<" %"<<endl<<endl;
}
//
// for(uint i(0);i<Nelement;++i){
// uint64_t h(hash64(kmers[i])%Nelement);
// // cout<<h<<endl;
// map[h].push_back(kmers[i]);
// }
// kmers={};
//
// for(uint i(0);i<kmers.size();++i){
// if(map[i].size()>1){
// for(uint j(0);j<map[i].size();++j){
// kmers.push_back(map[i][j]);
// }
// map[i]={};
// }
// }
// cout<<"Phase "<<n<<endl;
// cout<<kmers.size()<<endl;
// cout<<100*kmers.size()/Nelement<<" %"<<endl;
return 0;
}