HIBF 1.0.0-rc.1
Loading...
Searching...
No Matches
minhashes.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024, Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024, Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <cstddef> // for size_t
13#include <cstdint> // for uint64_t, uint32_t
14#include <span> // for span
15#include <vector> // for vector
16
17#include <cereal/access.hpp> // for access
18#include <cereal/cereal.hpp> // for make_nvp, CEREAL_NVP
19
21#include <hibf/platform.hpp>
22
23namespace seqan::hibf::sketch
24{
25
37{
38 static constexpr uint64_t register_id_mask{15};
39 static constexpr size_t num_sketches{16};
40 static constexpr size_t sketch_size{40};
41
43 md_vector<uint64_t> table{}; // Each element (vector<uint64_t>) is a minhash.
44
48 minhashes() = default;
49 minhashes(minhashes const &) = default;
50 minhashes & operator=(minhashes const &) = default;
51 minhashes(minhashes &&) = default;
52 minhashes & operator=(minhashes &&) = default;
53 ~minhashes() = default;
55 minhashes(std::vector<uint64_t> const & smallest_values);
57
59 bool is_valid() const;
60
62 void fill_incomplete_sketches(std::span<uint64_t> const & more_smallest_values);
63
65 static void push_to_heap_if_smaller(uint64_t const value, std::vector<uint64_t> & heap);
66
67private:
68 friend class cereal::access;
69
70 template <typename archive_t>
71 void serialize(archive_t & archive)
72 {
73 uint32_t version{1};
74 archive(CEREAL_NVP(version));
75
76 // other members are const static currently
77 archive(CEREAL_NVP(table));
78 }
79};
80
81} // namespace seqan::hibf::sketch
Provides seqan::hibf::md_vector.
Provides platform and dependency checks.
Definition md_vector.hpp:21
MinHash sketches design to be used for Locality sensitive hashing.
Definition minhashes.hpp:37
minhashes(minhashes const &)=default
Defaulted.
minhashes(std::vector< uint64_t > const &smallest_values)
construct from a vector of the smallest values in a set (sorted ascending).
minhashes()=default
Defaulted.
bool is_valid() const
Checks whether the minHash table is completely filled.
static void push_to_heap_if_smaller(uint64_t const value, std::vector< uint64_t > &heap)
Pushes value to the heap if it is smaller than the current largest element.
static constexpr size_t num_sketches
...00001111
Definition minhashes.hpp:39
minhashes(minhashes &&)=default
Defaulted.
minhashes & operator=(minhashes const &)=default
Defaulted.
minhashes & operator=(minhashes &&)=default
Defaulted.
md_vector< uint64_t > table
A table of sketches. For LSH we need multiple sketches, stored in a table.
Definition minhashes.hpp:43
void fill_incomplete_sketches(std::span< uint64_t > const &more_smallest_values)
Adds more minhash values to an existing but incomplete table.