83 static char lut[] = {
'A',
'T',
'G',
'C',
'N',
'$' };
91template<
typename SV>
void PrintSV(
const SV& sv)
93 cout <<
"size() = " << sv.size() <<
" : ";
94 auto it = sv.begin();
auto it_end = sv.end();
95 for (; it != it_end; ++it)
107template<
typename SV,
typename VECT>
108void TestSV(
const SV& sv,
const VECT& vect)
110 auto it = sv.begin();
auto it_end = sv.end();
111 auto itv = vect.begin();
auto itv_end = vect.end();
112 for (; it != it_end && itv != itv_end; ++it, ++itv)
120 cerr <<
"Error: reference vector mismatch!" << endl;
124 if (it != it_end || itv != itv_end)
126 cerr <<
"Error: reference size mismatch!" << endl;
169 auto v1 = *it1;
auto v2 = *it2;
186 for (
unsigned i = 0; i < sz; ++i)
188 unsigned code = rand() % 4;
190 assert(bp ==
'A' || bp ==
'T' || bp ==
'G' || bp ==
'C');
228 const unsigned case_size = 200000000;
229 const unsigned centr_size = 7000000;
251 vector_char_type::size_type sz = vect.size();
252 vector_char_type::size_type delta = sz / m_count;
254 for (vector_char_type::size_type i = 0; i < sz; i += delta)
256 vector_char_type::value_type v1 = vect[i];
257 unsigned code = rand() % 4;
258 vector_char_type::value_type v2 =
int2DNA(code);
261 vect_m.push_back(vector_pairs_type::value_type(
unsigned(i), code));
266 for (vector_char_type::size_type i = 1; i < sz / 4; i += (rand()%(1024 * 10)))
268 vector_char_type::value_type v1 = vect[i];
269 unsigned code = rand() % 4;
270 vector_char_type::value_type v2 =
int2DNA(code);
273 vect_m.push_back(vector_pairs_type::value_type(
unsigned(i), code));
280const unsigned rep = 20000;
297 for (
unsigned k = 0; k < sz; ++k)
299 unsigned i = vect_m[k].first;
314 assert(cnt == vect_m.size());
325 unsigned sz = (unsigned)vect_m.size();
331 for (
unsigned k = 0; k < sz; ++k)
333 unsigned i = vect_m[k].first;
334 vector_char_type::value_type v1 = vect[i];
335 vector_char_type::value_type v2 =
int2DNA(vect_m[k].second);
342 vector_char_type::size_type pos;
343 auto it = vect.begin();
auto it_end = vect.end();
344 auto it1 = vect1.begin();
345 for (; it != it_end; ++it, ++it1)
350 pos = vector_char_type::size_type(it - vect.begin());
359 assert(cnt == vect_m.size());
370 unsigned sz = (unsigned)vect_m.size();
375 unsigned vs = unsigned(vect.size());
377 for (
unsigned k = 0; k < sz; ++k)
379 unsigned i = vect_m[k].first;
380 vector_char_type::value_type v1 = vect[i];
381 assert(vect_m[k].second < 4);
382 vector_char_type::value_type v2 =
int2DNA(vect_m[k].second);
387 const char* s1 = vect.data();
388 const char* s2 = vect1.data();
390 int res = ::strncmp(s1, s2, vs);
395 assert(cnt == vect_m.size());
405 unsigned sz = (unsigned)vect_m.size();
410 for (
unsigned k = 0; k < sz; ++k)
412 unsigned i = vect_m[k].first;
425 assert(cnt == vect_m.size());
435 unsigned sz = (unsigned)vect_m.size();
440 for (
unsigned k = 0; k < sz; ++k)
442 unsigned i = vect_m[k].first;
456 assert(cnt == vect_m.size());
470 const char* s =
"ATGTCNNNNNTATA";
474 for (
unsigned i = 0; s[i]; ++i)
491 cout <<
"Generate benchmark test data." << endl;
495 cout <<
"generated mismatches=" << vect_m.size() << endl;
497 cout <<
"SV mismatch search test" << endl;
500 cout <<
"STL interator mismatch test" << endl;
506 cout <<
"strncmp() test" << endl;
509 cout <<
"SV compare test" << endl;
515 cout <<
"SV compare iterators test" << endl;
521 std::cout << std::endl <<
"Performance:" << std::endl;
525 catch(std::exception& ex)
527 std::cerr << ex.what() << std::endl;
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
Sparse constainer sparse_vector<> for integer types using bit-transposition transform.
Algorithms for bm::sparse_vector.
Serialization for sparse_vector<>
Timing utilities for benchmarking (internal)
pre-processor un-defines to avoid global space pollution (internal)
Utility class to collect performance measurements and statistics.
std::map< std::string, statistics > duration_map_type
test name to duration map
static void print_duration_map(TOut &tout, const duration_map_type &dmap, format fmt=ct_time)
succinct sparse vector with runtime compression using bit-slicing / transposition method
bvector_type::size_type size_type
size_type size() const BMNOEXCEPT
return size of the vector
void set(size_type idx, value_type v)
set specified element with bounds checking and automatic resize
back_insert_iterator get_back_inserter()
Provide back insert iterator Back insert iterator implements buffered insertion, which is faster,...
friend back_insert_iterator
const_iterator begin() const BMNOEXCEPT
Provide const iterator access to container content
void optimize(bm::word_t *temp_block=0, typename bvector_type::optmode opt_mode=bvector_type::opt_compress, typename sparse_vector< Val, BV >::statistics *stat=0)
run memory optimization for all vector planes
bool sparse_vector_find_first_mismatch(const SV &sv1, const SV &sv2, typename SV::size_type &midx, bm::null_support null_proc=bm::use_null)
Find first mismatch (element which is different) between two sparse vectors (uses linear scan in bit-...
static void test_sv_cmp(const svector_u32 &sv, const vector_pairs_type &vect_m)
void TestSV(const SV &sv, const VECT &vect)
Test sparse vector against reference vector (for QA purposes)
bm::sparse_vector< unsigned, bm::bvector<> > svector_u32
static int compare_sv_it(const svector_u32 &sv1, const svector_u32 &sv2)
static int compare_sv(const svector_u32 &sv1, const svector_u32 &sv2)
static void test_strcmp(const vector_char_type &vect, const vector_pairs_type &vect_m)
void test_sv_cmp_it(const svector_u32 &sv, const vector_pairs_type &vect_m)
static void add_centromer_Ns(svector_u32 &sv, vector_char_type &vect, unsigned csz)
static void test_mismatch_search(const svector_u32 &sv, const vector_pairs_type &vect_m)
bm::chrono_taker ::duration_map_type timing_map
std::vector< char > vector_char_type
static void test_vect_mismatch_search(const vector_char_type &vect, const vector_pairs_type &vect_m)
char int2DNA(unsigned code)
Translate integer code to DNA letter.
void PrintSV(const SV &sv)
Print sparse vector.
static void generate_DNA_vector(svector_u32 &sv, vector_char_type &vect, unsigned sz)
std::vector< std::pair< unsigned, unsigned > > vector_pairs_type
static void generate_mismatches(vector_pairs_type &vect_m, const vector_char_type &vect, unsigned m_count)
static void generate_big_case(svector_u32 &sv, vector_char_type &vect)
unsigned DNA2int(char DNA_bp)
Translate DNA letter to integer code Please note this function uses extended alphabet ATGC plus 'N' a...