HIBF 1.0.0-rc.1
Loading...
Searching...
No Matches
config.hpp
1// SPDX-FileCopyrightText: 2006-2026, Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2026, Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
5#pragma once
6
7#include <cstddef> // for size_t
8#include <cstdint> // for uint32_t, uint8_t
9#include <functional> // for function
10#include <iosfwd> // for istream, ostream
11
12#include <cereal/access.hpp> // for access
13#include <cereal/cereal.hpp> // for make_nvp, CEREAL_NVP
14
15#include <hibf/misc/insert_iterator.hpp> // for insert_iterator
16#include <hibf/platform.hpp>
17
18namespace seqan::hibf
19{
20
75struct config
76{
111 std::function<void(size_t const, insert_iterator &&)> input_fn{};
112
125
137
154 double maximum_fpr{0.05};
155
182 double relaxed_fpr{0.3};
183
195 size_t threads{1u};
197
214 uint8_t sketch_bits{12};
215
233 size_t tmax{};
234
253
271 bool track_occupancy{false};
272
288 double alpha{1.2};
289
303
314
326
327 void read_from(std::istream & stream);
328 void write_to(std::ostream & stream) const;
329
359
361 constexpr bool operator==(config const & other) const
362 {
363 // clang-format off
365 maximum_fpr == other.maximum_fpr &&
366 relaxed_fpr == other.relaxed_fpr &&
367 threads == other.threads &&
368 sketch_bits == other.sketch_bits &&
369 tmax == other.tmax &&
371 alpha == other.alpha &&
375 // clang-format on
376 }
377
378private:
379 friend class cereal::access;
380
381 static constexpr uint32_t version{3u};
382
383 template <typename archive_t>
384 void serialize(archive_t & archive)
385 {
386 uint32_t parsed_version{version};
387 archive(cereal::make_nvp("version", parsed_version));
388
389 archive(CEREAL_NVP(number_of_user_bins));
390 archive(CEREAL_NVP(number_of_hash_functions));
391 archive(CEREAL_NVP(maximum_fpr));
392 archive(CEREAL_NVP(relaxed_fpr));
393 archive(CEREAL_NVP(threads));
394
395 archive(CEREAL_NVP(sketch_bits));
396 archive(CEREAL_NVP(tmax));
397
398 if (parsed_version >= 2u)
399 {
400 archive(CEREAL_NVP(empty_bin_fraction));
401
402 if (parsed_version >= 3u)
403 archive(CEREAL_NVP(track_occupancy));
404 else
406 }
407
408 archive(CEREAL_NVP(alpha));
409 archive(CEREAL_NVP(max_rearrangement_ratio));
410 archive(CEREAL_NVP(disable_estimate_union));
411 archive(CEREAL_NVP(disable_rearrangement));
412 }
413};
414
415} // namespace seqan::hibf
Definition insert_iterator.hpp:25
Provides platform and dependency checks.
The configuration used to build an (H)IBF.
Definition config.hpp:76
uint8_t sketch_bits
The number of bits for HyperLogLog sketches.
Definition config.hpp:214
void validate_and_set_defaults()
Checks several variables of seqan::hibf::config and sets default values if necessary.
size_t number_of_hash_functions
The number of hash functions for the underlying Bloom Filters.
Definition config.hpp:136
double maximum_fpr
The desired maximum false positive rate of the underlying Bloom Filters. [RECOMMENDED_TO_ADAPT].
Definition config.hpp:154
double empty_bin_fraction
The percentage of empty bins in the layout.
Definition config.hpp:252
bool track_occupancy
Track the amount of emplaced elements for each technical bin.
Definition config.hpp:271
bool disable_estimate_union
Whether to disable union estimate of user bins to improve the layout.
Definition config.hpp:313
double alpha
A scaling factor to influence the amount of merged bins produced by the layout algorithm.
Definition config.hpp:288
bool disable_rearrangement
Whether to disable rearranging user bins based on their content similarity.
Definition config.hpp:324
size_t number_of_user_bins
The number of user bins.
Definition config.hpp:124
constexpr bool operator==(config const &other) const
Two configs are equal if all options, except seqan::hibf::config::input_fn, are equal.
Definition config.hpp:361
double relaxed_fpr
Allow a higher FPR in non-accuracy-critical parts of the HIBF structure.
Definition config.hpp:182
size_t threads
The number of threads to use during construction. [RECOMMENDED_TO_ADAPT].
Definition config.hpp:195
std::function< void(size_t const, insert_iterator &&) input_fn)
A function for how to hash your input [REQUIRED].
Definition config.hpp:111
double max_rearrangement_ratio
The maximal cardinality ratio in the clustering intervals of the layout rearrangement algorithm.
Definition config.hpp:302
size_t tmax
The maximum number of technical bins of each IBF in the HIBF.
Definition config.hpp:233
A strong type that represents the empty bin fraction for the seqan::hibf::interleaved_bloom_filter.
Definition interleaved_bloom_filter.hpp:85
A strong type that represents whether to track occupancy for the seqan::hibf::interleaved_bloom_filte...
Definition interleaved_bloom_filter.hpp:94