fastq_to_fasta
A template for creation of SeqAn3 apps, with a FASTQ to FASTA example app.
adjust_seed.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/raptor/blob/main/LICENSE.md
6// --------------------------------------------------------------------------------------------------
7
8#pragma once
9
10#include <cstdint>
11
12namespace raptor
13{
14
15/*\brief Adjust the default seed such that it does not interfere with the IBF's hashing.
16 *\param kmer_size The used k-mer size. For gapped shapes, this corresponds to the number of set bits (count()).
17 *\param seed The seed.
18 *\details
19 *
20 * The hashing used with the IBF assumes that the input values are uniformly distributed.
21 * However, we use a 64 bit seed, and unless the `kmer_size` is 32, not all 64 bits of the k-mers change.
22 * Hence, we need to shift the seed to the right.
23 *
24 * 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:
25 *
26 * ```
27 * seed = 1111'1011
28 * kmer = 0000'XXXX
29 * ```
30 *
31 * `seed XOR kmer` will then always have 4 leading ones.
32 */
33static inline constexpr uint64_t adjust_seed(uint8_t const kmer_size,
34 uint64_t const seed = 0x8F3F73B5CF1C9ADEULL) noexcept
35{
36 return seed >> (64u - 2u * kmer_size);
37}
38
39} // namespace raptor
Definition: adjust_seed.hpp:13