-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
58 lines (45 loc) · 1.19 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
/*
** Description:beam search are revised based on fast_ctc_decode(https://github.com/nanoporetech/fast-ctc-decode) following MIT license.
** Author:linlian
** Date:
** Modify Record:
*/
#include "beam_search.hpp"
#include <random>
using namespace std;
int main()
{
string alphabet = "NACGT";
size_t beam_size = 5;
float beam_cut_threshold = 0.1f;
bool collapse_repeats = true;
pair<string, vector<int>> r;
constexpr int n_steps_in = 1200;
constexpr int alphabet_size = 5;
float posteriors[n_steps_in][alphabet_size];
//std::random_device rd;
std::mt19937 gen(0);
std::uniform_real_distribution<float> dis(0.0, 1.0);
// Generate random posteriors
for (int i = 0; i < n_steps_in; ++i) {
for (int j = 0; j < alphabet_size; ++j) {
posteriors[i][j] = dis(gen);
}
}
clock_t start, end;
start = clock();
beam_search(posteriors[0], n_steps_in, alphabet, beam_size, beam_cut_threshold, collapse_repeats, r);
end = clock();
auto endtime = (double)(end - start) / CLOCKS_PER_SEC;
cout << "Time:" << endtime * 1000000 << " us" << endl;
if(r.first.size() != 0);
{
cout << r.first << endl;
for (auto& d : r.second)
{
printf("%d,", d);
}
cout << endl;
}
return 0;
}