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.
char | int2DNA (unsigned code)
| Translate integer code to DNA letter.
template<typename SV>
void | PrintSV (const SV &sv)
| Print sparse vector.
template<typename SV, typename VECT>
void | TestSV (const SV &sv, const VECT &vect)
| Test sparse vector against reference vector (for QA purposes).
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

const unsigned | rep = 20000
bm::chrono_taker ::duration_map_type | timing_map

## 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
  svsample08.cpp, svsample09.cpp, svsample10.cpp, and xsample06.cpp.

Definition at line 132 of file xsample06.cpp.

## vector_char_type

typedef std::vector<char> vector_char_type

Examples
  xsample06.cpp, xsample07.cpp, and xsample07a.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()

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()

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()

int compare_sv_it | ( | const svector_u32 & | sv1,
|  | const svector_u32 & | sv2 )

static

Examples
  xsample06.cpp.

Definition at line 162 of file xsample06.cpp.

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

Referenced by test_sv_cmp_it().

## 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()

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()

void generate_DNA_vector | ( | svector_u32 & | sv,
|  | vector_char_type & | vect,
|  | unsigned | sz )

static

Examples
  xsample06.cpp.

Definition at line 183 of file xsample06.cpp.

References bm::sparse_vector< Val, BV >::get_back_inserter(), and int2DNA().

Referenced by generate_big_case().

## generate_mismatches()

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, xsample07.cpp, and xsample07a.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 |  | ) |

Definition at line 461 of file xsample06.cpp.

References bm::chrono_taker< TOut >::ct_time, DNA2int(), generate_big_case(), generate_mismatches(), bm::sparse_vector< Val, BV >::get_back_inserter(), bm::sparse_vector< Val, BV >::optimize(), bm::chrono_taker< TOut >::print_duration_map(), PrintSV(), rep, test_mismatch_search(), test_strcmp(), test_sv_cmp(), test_sv_cmp_it(), test_vect_mismatch_search(), and timing_map.

## PrintSV()

template<typename SV>

void PrintSV | ( | const SV & | sv | ) |

Print sparse vector.

Examples
  rscsample02.cpp, rscsample03.cpp, rscsample04.cpp, rscsample06.cpp, svsample08.cpp, and xsample06.cpp.

Definition at line 91 of file xsample06.cpp.

References int2DNA().

Referenced by main().

## test_mismatch_search()

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()

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()

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()

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

## rep

const unsigned rep = 20000

Examples
  xsample06.cpp.

Definition at line 280 of file xsample06.cpp.

Referenced by main().

## timing_map

bm::chrono_taker ::duration_map_type timing_map

Definition at line 281 of file xsample06.cpp.