BitMagic-C++
|
Example: Use succinct vectors for histogram construction. More...
#include <iostream>
#include <memory>
#include <vector>
#include <random>
#include <algorithm>
#include <stdexcept>
#include "bm.h"
#include "bmtimer.h"
#include "bmsparsevec.h"
#include "bmsparsevec_compr.h"
#include "bmdbg.h"
#include "bmundef.h"
Go to the source code of this file.
Typedefs | |
typedef bm::bvector | bvector_type |
typedef bvector_type::size_type | bv_size_type |
typedef bm::sparse_vector< unsigned, bvector_type > | sparse_vector_u32 |
typedef bm::rsc_sparse_vector< unsigned, sparse_vector_u32 > | rsc_sparse_vector_u32 |
typedef std::vector< std::pair< bv_size_type, bv_size_type > > | bv_ranges_vector |
Functions | |
static void | generate_test_data (rsc_sparse_vector_u32 &csv, unsigned size) |
Generate a test RSC vector with a randomly distributed values imitating distribution density of genome variations it adds a huge area of empty in the middle to simulate chr centromere. More... | |
static void | generate_access_samples (std::vector< bvector_type::size_type > &sample_vec, unsigned size) |
generate list of random indexes (locations) to read histogram values More... | |
static void | compute_historgam (sparse_vector_u32 &hist_sv, const rsc_sparse_vector_u32 &csv, sparse_vector_u32::size_type sampling_size) |
Compute histogram as a SV vector using fixed sampling interval. More... | |
static void | compute_rsc_historgam (rsc_sparse_vector_u32 &hist_rsc, const rsc_sparse_vector_u32 &csv, sparse_vector_u32::size_type sampling_size) |
Compute histogram as a RSC vector using fixed sampling interval. More... | |
static void | compute_adaptive_rsc_histogram (rsc_sparse_vector_u32 &hist_rsc, const rsc_sparse_vector_u32 &csv, sparse_vector_u32::size_type sampling_size) |
Adaptive histogram identifies number of not NULL elements (events) and varies the size of the histogram bin trying to make sure all bins (but last) are the same weight. More... | |
static void | verify_histograms (const rsc_sparse_vector_u32 &hist_rsc, const sparse_vector_u32 &hist_sv, sparse_vector_u32::size_type sampling_size) |
Some test to confirm correctness. More... | |
static unsigned long long | access_bench1 (const sparse_vector_u32 &hist_sv, const std::vector< bvector_type::size_type > &sample_vec, unsigned sampling_size) |
Access benchmark 1. More... | |
static unsigned long long | access_bench2 (const rsc_sparse_vector_u32 &hist_rsc, const std::vector< bvector_type::size_type > &sample_vec) |
Access benchmark 2. More... | |
static void | access_bench3 (const rsc_sparse_vector_u32 &hist_rsc, const std::vector< bvector_type::size_type > &sample_vec, const rsc_sparse_vector_u32 &rsc_data) |
More... | |
int | main (void) |
More... | |
Variables | |
const unsigned | test_size = 250000000 |
More... | |
const unsigned | sampling_interval = 2500 |
More... | |
bm::chrono_taker ::duration_map_type | timing_map |
More... | |
Example: Use succinct vectors for histogram construction.
Definition in file xsample09.cpp.
|
static |
Access benchmark 1.
uses regular bit-transposed sparse vector to read histogram values in random order. It relies on fixed inetrval sampling.
Definition at line 273 of file xsample09.cpp.
Referenced by main().
|
static |
Access benchmark 2.
Uses Rank-Select bit-transposed vector to read histogram values Sampling interval can be non-fixed (variadic, adaptive sampling). Method finds the interval start and value using RSC container not NULL vector
Definition at line 294 of file xsample09.cpp.
References bm::bvector< Alloc >::find_reverse(), and bm::rsc_sparse_vector< Val, SV >::get_null_bvector().
Referenced by main().
|
static |
Definition at line 319 of file xsample09.cpp.
References bm::bvector< Alloc >::find(), bm::bvector< Alloc >::find_reverse(), and bm::rsc_sparse_vector< Val, SV >::get_null_bvector().
Referenced by main().
|
static |
Adaptive histogram identifies number of not NULL elements (events) and varies the size of the histogram bin trying to make sure all bins (but last) are the same weight.
Definition at line 220 of file xsample09.cpp.
References BM_DECLARE_TEMP_BLOCK, bm::rsc_sparse_vector< Val, SV >::get_null_bvector(), bm::rsc_sparse_vector< Val, SV >::optimize(), bm::rsc_sparse_vector< Val, SV >::push_back(), bm::rank_range_split(), and bm::rsc_sparse_vector< Val, SV >::sync().
Referenced by main().
|
static |
Compute histogram as a SV vector using fixed sampling interval.
Definition at line 143 of file xsample09.cpp.
References BM_DECLARE_TEMP_BLOCK, bm::sparse_vector< Val, BV >::get_back_inserter(), bm::rsc_sparse_vector< Val, SV >::get_null_bvector(), bm::sparse_vector< Val, BV >::optimize(), and bm::rsc_sparse_vector< Val, SV >::size().
Referenced by main().
|
static |
Compute histogram as a RSC vector using fixed sampling interval.
Histogram values are stored as "true" interval start coordinates and it is a more flexible scheme if we eventually decide to use adaptive sampling (variable step).
Definition at line 180 of file xsample09.cpp.
References BM_DECLARE_TEMP_BLOCK, bm::rsc_sparse_vector< Val, SV >::get_null_bvector(), bm::rsc_sparse_vector< Val, SV >::load_from(), bm::rsc_sparse_vector< Val, SV >::optimize(), bm::sparse_vector< Val, BV >::set(), bm::rsc_sparse_vector< Val, SV >::size(), bm::rsc_sparse_vector< Val, SV >::sync(), and bm::use_null.
Referenced by main().
|
static |
generate list of random indexes (locations) to read histogram values
Definition at line 124 of file xsample09.cpp.
Referenced by main().
|
static |
Generate a test RSC vector with a randomly distributed values imitating distribution density of genome variations it adds a huge area of empty in the middle to simulate chr centromere.
Definition at line 83 of file xsample09.cpp.
References BM_DECLARE_TEMP_BLOCK, bm::rsc_sparse_vector< Val, SV >::get_back_inserter(), bm::rsc_sparse_vector< Val, SV >::optimize(), and bm::rsc_sparse_vector< Val, SV >::sync().
Referenced by main().
int main | ( | void | ) |
Definition at line 357 of file xsample09.cpp.
References access_bench1(), access_bench2(), access_bench3(), bm::sparse_vector< Val, BV >::begin(), bm::rsc_sparse_vector< Val, SV >::calc_stat(), bm::sparse_vector< Val, BV >::calc_stat(), compute_adaptive_rsc_histogram(), compute_historgam(), compute_rsc_historgam(), bm::bvector< Alloc >::count(), bm::sparse_vector< Val, BV >::end(), generate_access_samples(), generate_test_data(), bm::rsc_sparse_vector< Val, SV >::get_null_bvector(), bm::chrono_taker< TOut >::print_duration_map(), sampling_interval, bm::sparse_vector< Val, BV >::size(), bm::rsc_sparse_vector< Val, SV >::size(), test_size, timing_map, and verify_histograms().
|
static |
Some test to confirm correctness.
Definition at line 246 of file xsample09.cpp.
References bm::rsc_sparse_vector< Val, SV >::get_null_bvector().
Referenced by main().