SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
minimiser_hash.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
16
17namespace seqan3
18{
21struct seed : seqan3::detail::strong_type<uint64_t, seed>
22{
24};
25
28struct window_size : seqan3::detail::strong_type<uint32_t, window_size>
29{
31};
32} // namespace seqan3
33
34namespace seqan3::detail
35{
39{
46 constexpr auto operator()(shape const & shape, window_size const window_size) const
47 {
49 }
50
58 constexpr auto operator()(shape const & shape, window_size const window_size, seed const seed) const
59 {
61 }
62
72 template <std::ranges::range urng_t>
73 constexpr auto operator()(urng_t && urange,
74 shape const & shape,
76 seed const seed = seqan3::seed{0x8F3F73B5CF1C9ADE}) const
77 {
78 static_assert(std::ranges::viewable_range<urng_t>,
79 "The range parameter to views::minimiser_hash cannot be a temporary of a non-view range.");
80 static_assert(std::ranges::forward_range<urng_t>,
81 "The range parameter to views::minimiser_hash must model std::ranges::forward_range.");
83 "The range parameter to views::minimiser_hash must be over elements of seqan3::semialphabet.");
84
85 if (shape.size() > window_size.get())
86 throw std::invalid_argument{"The size of the shape cannot be greater than the window size."};
87
88 auto forward_strand = std::forward<urng_t>(urange) | seqan3::views::kmer_hash(shape)
89 | std::views::transform(
90 [seed](uint64_t i)
91 {
92 return i ^ seed.get();
93 });
94
95 auto reverse_strand = std::forward<urng_t>(urange) | seqan3::views::complement | std::views::reverse
97 | std::views::transform(
98 [seed](uint64_t i)
99 {
100 return i ^ seed.get();
101 })
102 | std::views::reverse;
103
104 return seqan3::detail::minimiser_view(forward_strand, reverse_strand, window_size.get() - shape.size() + 1);
105 }
106};
107
108} // namespace seqan3::detail
109
110namespace seqan3::views
111{
112
191
193
194} // namespace seqan3::views
Template for range adaptor closure objects that store arguments and wrap a proto-adaptor.
Definition adaptor_from_functor.hpp:54
The type returned by seqan3::views::minimiser.
Definition minimiser.hpp:47
CRTP base class to declare a strong typedef for a regular type to avoid ambiguous parameter settings ...
Definition strong_type.hpp:174
constexpr value_t & get() &noexcept
Returns the underlying value.
Definition strong_type.hpp:201
constexpr strong_type() noexcept=default
Defaulted.
constexpr size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Definition dynamic_bitset.hpp:1230
A class that defines which positions of a pattern to hash.
Definition shape.hpp:57
Provides seqan3::views::complement.
constexpr auto minimiser_hash
Computes minimisers for a range with a given shape, window size and seed.
Definition minimiser_hash.hpp:190
auto const complement
A view that converts a range of nucleotides to their complement.
Definition complement.hpp:64
constexpr auto kmer_hash
Computes hash values for each position of a range via a given shape.
Definition kmer_hash.hpp:766
The basis for seqan3::alphabet, but requires only rank interface (not char).
Provides seqan3::views::kmer_hash.
Provides seqan3::views::minimiser.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
The SeqAn namespace for views.
Definition char_strictly_to.hpp:19
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides basic data structure for strong types.
seqan3::views::minimiser_hash's range adaptor object type (non-closure).
Definition minimiser_hash.hpp:39
constexpr auto operator()(shape const &shape, window_size const window_size) const
Store the shape and the window size and return a range adaptor closure object.
Definition minimiser_hash.hpp:46
constexpr auto operator()(shape const &shape, window_size const window_size, seed const seed) const
Store the shape, the window size and the seed and return a range adaptor closure object.
Definition minimiser_hash.hpp:58
constexpr auto operator()(urng_t &&urange, shape const &shape, window_size const window_size, seed const seed=seqan3::seed{0x8F3F73B5CF1C9ADE}) const
Call the view's constructor with the underlying view, a seqan3::shape and a window size as argument.
Definition minimiser_hash.hpp:73
strong_type for seed.
Definition minimiser_hash.hpp:22
strong_type for the window_size.
Definition minimiser_hash.hpp:29
Hide me