-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcommon.hpp
More file actions
31 lines (24 loc) · 1.03 KB
/
common.hpp
File metadata and controls
31 lines (24 loc) · 1.03 KB
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
#pragma once
#include "external/pthash/external/cmd_line_parser/include/parser.hpp"
#include "include/dictionary_types.hpp"
#include <vector>
namespace sshash {
void print_cmd(int argc, char** argv) {
for (int i = 0; i != argc; ++i) std::cout << argv[i] << ' ';
std::cout << std::endl;
}
void random_kmer(char* kmer, uint64_t k) {
for (uint64_t i = 0; i != k; ++i) kmer[i] = "ACGT"[rand() % 4];
}
template <typename Dict>
void open_dictionary(Dict& dict, std::string const& index_filename, bool mmap, bool verbose) {
const uint64_t num_bytes_read = mmap ? essentials::mmap(dict, index_filename.c_str())
: essentials::load(dict, index_filename.c_str());
if (verbose) {
std::cout << "total index size: " << num_bytes_read << " [B] -- "
<< essentials::convert(num_bytes_read, essentials::MB) << " [MB] ("
<< (num_bytes_read * 8.0) / dict.num_kmers() << " [bits/kmer])" << std::endl;
dict.print_info();
}
}
} // namespace sshash