BitMagic-C++
Typedefs | Functions | Variables
xsample06.cpp File Reference

Example: Use of sparse vector for compressed DNA strings. More...

#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include "bm.h"
#include "bmsparsevec.h"
#include "bmsparsevec_algo.h"
#include "bmsparsevec_serial.h"
#include "bmdbg.h"
#include "bmtimer.h"
#include "bmundef.h"
Include dependency graph for xsample06.cpp:

Go to the source code of this file.

Typedefs

typedef bm::sparse_vector< unsigned, bm::bvector<> > svector_u32
 
typedef std::vector< char > vector_char_type
 
typedef std::vector< std::pair< unsigned, unsigned > > vector_pairs_type
 

Functions

unsigned DNA2int (char DNA_bp)
 Translate DNA letter to integer code Please note this function uses extended alphabet ATGC plus 'N' and '$' Ns are used to indicate ambiguity and $ is part of Burrows-Wheeler transform. More...
 
char int2DNA (unsigned code)
 Translate integer code to DNA letter. More...
 
template<typename SV >
void PrintSV (const SV &sv)
 Print sparse vector. More...
 
template<typename SV , typename VECT >
void TestSV (const SV &sv, const VECT &vect)
 Test sparse vector against reference vector (for QA purposes) More...
 
static int compare_sv (const svector_u32 &sv1, const svector_u32 &sv2)
 
static int compare_sv_it (const svector_u32 &sv1, const svector_u32 &sv2)
 
static void generate_DNA_vector (svector_u32 &sv, vector_char_type &vect, unsigned sz)
 
static void add_centromer_Ns (svector_u32 &sv, vector_char_type &vect, unsigned csz)
 
static void generate_big_case (svector_u32 &sv, vector_char_type &vect)
 
static void generate_mismatches (vector_pairs_type &vect_m, const vector_char_type &vect, unsigned m_count)
 
static void test_mismatch_search (const svector_u32 &sv, const vector_pairs_type &vect_m)
 
static void test_vect_mismatch_search (const vector_char_type &vect, const vector_pairs_type &vect_m)
 
static void test_strcmp (const vector_char_type &vect, const vector_pairs_type &vect_m)
 
static void test_sv_cmp (const svector_u32 &sv, const vector_pairs_type &vect_m)
 
void test_sv_cmp_it (const svector_u32 &sv, const vector_pairs_type &vect_m)
 
int main (void)
 

Variables

bm::chrono_taker::duration_map_type timing_map
 
const unsigned repeats = 20000
 

Detailed Description

Example: Use of sparse vector for compressed DNA strings.

Definition in file xsample06.cpp.

Typedef Documentation

◆ svector_u32

typedef bm::sparse_vector<unsigned, bm::bvector<> > svector_u32
Examples:
xsample06.cpp.

Definition at line 132 of file xsample06.cpp.

◆ vector_char_type

typedef std::vector<char> vector_char_type
Examples:
xsample06.cpp.

Definition at line 133 of file xsample06.cpp.

◆ vector_pairs_type

typedef std::vector<std::pair<unsigned, unsigned> > vector_pairs_type
Examples:
xsample06.cpp.

Definition at line 134 of file xsample06.cpp.

Function Documentation

◆ add_centromer_Ns()

static void add_centromer_Ns ( svector_u32 sv,
vector_char_type vect,
unsigned  csz 
)
static
Examples:
xsample06.cpp.

Definition at line 201 of file xsample06.cpp.

References DNA2int(), and bm::sparse_vector< Val, BV >::size().

Referenced by generate_big_case().

◆ compare_sv()

static int compare_sv ( const svector_u32 sv1,
const svector_u32 sv2 
)
static
Examples:
xsample06.cpp.

Definition at line 141 of file xsample06.cpp.

References bm::sparse_vector_find_first_mismatch().

Referenced by test_sv_cmp().

◆ compare_sv_it()

static int compare_sv_it ( const svector_u32 sv1,
const svector_u32 sv2 
)
static

◆ DNA2int()

unsigned DNA2int ( char  DNA_bp)
inline

Translate DNA letter to integer code Please note this function uses extended alphabet ATGC plus 'N' and '$' Ns are used to indicate ambiguity and $ is part of Burrows-Wheeler transform.

Examples:
xsample06.cpp.

Definition at line 58 of file xsample06.cpp.

Referenced by add_centromer_Ns(), and main().

◆ generate_big_case()

static void generate_big_case ( svector_u32 sv,
vector_char_type vect 
)
static
Examples:
xsample06.cpp.

Definition at line 226 of file xsample06.cpp.

References add_centromer_Ns(), generate_DNA_vector(), bm::sparse_vector< Val, BV >::optimize(), and TestSV().

Referenced by main().

◆ generate_DNA_vector()

static void generate_DNA_vector ( svector_u32 sv,
vector_char_type vect,
unsigned  sz 
)
static

◆ generate_mismatches()

static void generate_mismatches ( vector_pairs_type vect_m,
const vector_char_type vect,
unsigned  m_count 
)
static
Examples:
xsample06.cpp.

Definition at line 243 of file xsample06.cpp.

References int2DNA().

Referenced by main().

◆ int2DNA()

char int2DNA ( unsigned  code)
inline

Translate integer code to DNA letter.

Examples:
xsample06.cpp.

Definition at line 81 of file xsample06.cpp.

Referenced by generate_DNA_vector(), generate_mismatches(), PrintSV(), test_strcmp(), test_vect_mismatch_search(), and TestSV().

◆ main()

int main ( void  )

◆ PrintSV()

template<typename SV >
void PrintSV ( const SV &  sv)

Print sparse vector.

Examples:
xsample06.cpp.

Definition at line 91 of file xsample06.cpp.

References int2DNA().

Referenced by main().

◆ test_mismatch_search()

static void test_mismatch_search ( const svector_u32 sv,
const vector_pairs_type vect_m 
)
static
Examples:
xsample06.cpp.

Definition at line 288 of file xsample06.cpp.

References bm::sparse_vector< Val, BV >::set(), bm::sparse_vector_find_first_mismatch(), and timing_map.

Referenced by main().

◆ test_strcmp()

static void test_strcmp ( const vector_char_type vect,
const vector_pairs_type vect_m 
)
static
Examples:
xsample06.cpp.

Definition at line 367 of file xsample06.cpp.

References int2DNA(), and timing_map.

Referenced by main().

◆ test_sv_cmp()

static void test_sv_cmp ( const svector_u32 sv,
const vector_pairs_type vect_m 
)
static
Examples:
xsample06.cpp.

Definition at line 402 of file xsample06.cpp.

References compare_sv(), bm::sparse_vector< Val, BV >::set(), and timing_map.

Referenced by main().

◆ test_sv_cmp_it()

void test_sv_cmp_it ( const svector_u32 sv,
const vector_pairs_type vect_m 
)
inline
Examples:
xsample06.cpp.

Definition at line 432 of file xsample06.cpp.

References compare_sv_it(), bm::sparse_vector< Val, BV >::set(), and timing_map.

Referenced by main().

◆ test_vect_mismatch_search()

static void test_vect_mismatch_search ( const vector_char_type vect,
const vector_pairs_type vect_m 
)
static
Examples:
xsample06.cpp.

Definition at line 321 of file xsample06.cpp.

References int2DNA(), and timing_map.

Referenced by main().

◆ TestSV()

template<typename SV , typename VECT >
void TestSV ( const SV &  sv,
const VECT &  vect 
)

Test sparse vector against reference vector (for QA purposes)

Examples:
xsample06.cpp.

Definition at line 108 of file xsample06.cpp.

References int2DNA().

Referenced by generate_big_case().

Variable Documentation

◆ repeats

const unsigned repeats = 20000
Examples:
xsample06.cpp.

Definition at line 281 of file xsample06.cpp.

Referenced by main().

◆ timing_map