SeqAn3 3.4.0-rc.4
The Modern C++ library for sequence analysis.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
masked.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
16
17namespace seqan3
18{
39template <writable_alphabet sequence_alphabet_t>
40 requires std::regular<sequence_alphabet_t>
41class masked : public alphabet_tuple_base<masked<sequence_alphabet_t>, sequence_alphabet_t, mask>
42{
43private:
46
47public:
53
59
62
66 constexpr masked() = default;
67 constexpr masked(masked const &) = default;
68 constexpr masked(masked &&) = default;
69 constexpr masked & operator=(masked const &) = default;
70 constexpr masked & operator=(masked &&) = default;
71 ~masked() = default;
72
73 using base_t::base_t; // Inherit non-default constructors
75
76 // Inherit operators from base
77 using base_t::operator=;
78
86 constexpr masked & assign_char(char_type const c) noexcept
87 {
88 using index_t = std::make_unsigned_t<char_type>;
89 base_t::assign_rank(char_to_rank[static_cast<index_t>(c)]);
90 return *this;
91 }
93
102 {
104 }
106
107protected:
110 []() constexpr
111 {
113
114 for (size_t i = 0; i < alphabet_size; ++i)
115 {
116 ret[i] = (i < alphabet_size / 2)
119 }
120
121 return ret;
122 }()};
123
126 []() constexpr
127 {
129
130 for (size_t i = 0; i < 256; ++i)
131 {
132 char_type const c = static_cast<char_type>(i);
133
136 }
137
138 return ret;
139 }()};
140};
141
144template <typename sequence_alphabet_type>
146
147} //namespace seqan3
Provides seqan3::alphabet_tuple_base.
constexpr rank_type to_rank() const noexcept
Return the letter's numeric value (rank in the alphabet).
Definition alphabet_base.hpp:134
detail::min_viable_uint_t< size - 1 > rank_type
The type of the alphabet when represented as a number (e.g. via to_rank()).
Definition alphabet_base.hpp:77
static constexpr detail::min_viable_uint_t< size > alphabet_size
The size of the alphabet, i.e. the number of different values it can take.
Definition alphabet_base.hpp:196
constexpr derived_type & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition alphabet_base.hpp:184
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the sam...
Definition alphabet_tuple_base.hpp:113
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
Implementation of a masked alphabet to be used for tuple composites.
Definition mask.hpp:35
Implementation of a masked composite, which extends a given alphabet with a mask.
Definition masked.hpp:42
static constexpr std::array< rank_type, detail::size_in_values_v< char_type > > char_to_rank
Char to rank conversion table.
Definition masked.hpp:125
alphabet_char_t< sequence_alphabet_type > char_type
Equals the char_type of sequence_alphabet_type.
Definition masked.hpp:58
constexpr masked & operator=(masked &&)=default
Defaulted.
static constexpr std::array< char_type, alphabet_size > rank_to_char
Rank to char conversion table.
Definition masked.hpp:109
constexpr masked & operator=(masked const &)=default
Defaulted.
~masked()=default
Defaulted.
constexpr masked(masked &&)=default
Defaulted.
masked(sequence_alphabet_type &&, mask const &) -> masked< std::decay_t< sequence_alphabet_type > >
Type deduction guide enables usage of masked without specifying template args.
constexpr masked & assign_char(char_type const c) noexcept
Assign from a character.
Definition masked.hpp:86
constexpr masked()=default
Defaulted.
constexpr masked(masked const &)=default
Defaulted.
constexpr char_type to_char() const noexcept
Return a character.
Definition masked.hpp:101
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition alphabet/concept.hpp:517
constexpr auto to_char
Return the char representation of an alphabet object.
Definition alphabet/concept.hpp:381
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition alphabet/concept.hpp:288
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition alphabet/concept.hpp:152
constexpr auto is_lower
Checks whether c is a lower case character.
Definition predicate.hpp:243
Create a mask composite which can be applied with another alphabet.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
constexpr char_type to_lower(char_type const c) noexcept
Converts 'A'-'Z' to 'a'-'z' respectively; other characters are returned as is.
Definition transform.hpp:74
Provides character predicates for tokenisation.
Provides utilities for modifying characters.
Hide me