Raptor
A fast and space-efficient pre-filter
All Classes Namespaces Files Functions Variables Macros Pages Concepts
adjust_seed.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 <cstdint>
13
14namespace raptor
15{
16
17/*\brief Adjust the default seed such that it does not interfere with the IBF's hashing.
18 *\param kmer_size The used k-mer size. For gapped shapes, this corresponds to the number of set bits (count()).
19 *\details
20 *
21 * The hashing used with the IBF assumes that the input values are uniformly distributed.
22 * However, we use a 64 bit seed, and unless the `kmer_size` is 32, not all 64 bits of the k-mers change.
23 * Hence, we need to shift the seed to the right.
24 *
25 * For example, using 2-mers and a seed of length 8 bit, the values for the k-mers will only change for the last 4 bits:
26 *
27 * ```
28 * seed = 1111'1011
29 * kmer = 0000'XXXX
30 * ```
31 *
32 * `seed XOR kmer` will then always have 4 leading ones.
33 */
34static inline constexpr uint64_t adjust_seed(uint8_t const kmer_size) noexcept
35{
36 return 0x8F3F73B5CF1C9ADEULL >> (64u - 2u * kmer_size);
37}
38
39} // namespace raptor
Hide me