Use of sparse vector for compressed DNA strings (2 bits per bp) Construction of comparison functions on bit-transposed compressed containers, benchmarking.
- See also
- bm::sparse_vector
-
bm::sparse_vector_find_first_mismatch
-
bm::bvector<>::find_first_mismatch()
#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
{
try
{
cout << "sparse vectors without NULL:" << endl;
{
sv2 = sv1;
if (found)
std::cout << "Mismatch found." << endl;
else
std::cout << "Mismatch not found" << endl;
sv2[2] = 0;
if (found)
{
std::cout << "Mismatch found at: " << pos << endl;
}
}
cout << endl << "sparse vectors with NULL:" << endl;
{
sv1[1] = 1;
sv1[2] = 2;
sv1[4] = 0;
sv2 = sv1;
if (found)
std::cout << "Mismatch found." << endl;
else
std::cout << "Mismatch not found" << endl;
sv2[4] = 10;
if (found)
{
std::cout << "Mismatch found at: " << pos << endl;
}
sv2[3] = 0;
if (found)
{
std::cout << "Mismatch found at: " << pos << endl;
}
}
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
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-...