Loading...
Searching...
No Matches
seqan3::masked< sequence_alphabet_t > Class Template Reference
Alphabet » Mask

Implementation of a masked composite, which extends a given alphabet with a mask. More...

`#include <seqan3/alphabet/mask/masked.hpp>`

Inheritance diagram for seqan3::masked< sequence_alphabet_t >:
[legend]

## Public Types

using | char_type = alphabet_char_t<sequence_alphabet_type>
| Equals the char_type of sequence_alphabet_type.
using | sequence_alphabet_type = sequence_alphabet_t
| First template parameter as member type.

## Public Member Functions

constexpr masked< sequence_alphabet_t > & | operator= (component_type const alph) noexcept
| Assignment via a value of one of the components.
constexpr masked< sequence_alphabet_t > & | operator= (indirect_component_type const alph) noexcept
| Assignment via a value of a subtype that is assignable to one of the components.
Constructors, destructor and assignment
constexpr | masked ()=default
| Defaulted.
constexpr | masked (masked const &)=default
| Defaulted.
constexpr | masked (masked &&)=default
| Defaulted.
constexpr masked & | operator= (masked const &)=default
| Defaulted.
constexpr masked & | operator= (masked &&)=default
| Defaulted.
| ~masked ()=default
| Defaulted.
Write functions
constexpr masked & | assign_char (char_type const c) noexcept
| Assign from a character.
Read functions
constexpr char_type | to_char () const noexcept
| Return a character.
Public Member Functions inherited from seqan3::alphabet_tuple_base< masked< sequence_alphabet_t >, sequence_alphabet_t, mask >
constexpr masked< sequence_alphabet_t > & | assign_rank (rank_type const c) noexcept
| Assign from a numeric value.
constexpr rank_type | to_rank () const noexcept
| Return the letter's numeric value (rank in the alphabet).
constexpr | alphabet_tuple_base (component_types... components) noexcept
| Construction from initialiser-list.
constexpr | alphabet_tuple_base (component_type const alph) noexcept
| Construction via a value of one of the components.
constexpr | alphabet_tuple_base (indirect_component_type const alph) noexcept
| Construction via a value of a subtype that is assignable to one of the components.
constexpr masked< sequence_alphabet_t > & | operator= (component_type const alph) noexcept
| Assignment via a value of one of the components.
constexpr masked< sequence_alphabet_t > & | operator= (indirect_component_type const alph) noexcept
| Assignment via a value of a subtype that is assignable to one of the components.
constexpr | operator type () const noexcept
| Implicit cast to a single letter. Works only if the type is unique in the type list.
Public Member Functions inherited from seqan3::alphabet_base< derived_type, size, char_t >
constexpr | alphabet_base () noexcept=default
| Defaulted.
constexpr | alphabet_base (alphabet_base const &) noexcept=default
| Defaulted.
constexpr | alphabet_base (alphabet_base &&) noexcept=default
| Defaulted.
constexpr alphabet_base & | operator= (alphabet_base const &) noexcept=default
| Defaulted.
constexpr alphabet_base & | operator= (alphabet_base &&) noexcept=default
| Defaulted.
| ~alphabet_base () noexcept=default
| Defaulted.
constexpr char_type | to_char () const noexcept
| Return the letter as a character of char_type.
constexpr rank_type | to_rank () const noexcept
| Return the letter's numeric value (rank in the alphabet).
constexpr derived_type & | assign_char (char_type const chr) noexcept
| Assign from a character, implicitly converts invalid characters.
constexpr derived_type & | assign_rank (rank_type const c) noexcept
| Assign from a numeric value.

## Static Public Attributes

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.
Static Public Attributes inherited from seqan3::alphabet_tuple_base< masked< sequence_alphabet_t >, sequence_alphabet_t, mask >
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.
Static Public Attributes inherited from seqan3::alphabet_base< derived_type, size, char_t >
static constexpr detail::min_viable_uint_t< size > | alphabet_size = size
| The size of the alphabet, i.e. the number of different values it can take.

## Static Protected Attributes

static constexpr std::array< rank_type, detail::size_in_values_v< char_type > > | char_to_rank
| Char to rank conversion table.
static constexpr std::array< char_type, alphabet_size > | rank_to_char
| Rank to char conversion table.

## Related Symbols

(Note that these are not member symbols.)
template<typename sequence_alphabet_type>
| masked (sequence_alphabet_type &&, mask const &) -> masked< std::decay_t< sequence_alphabet_type > >
| Type deduction guide enables usage of masked without specifying template args.

## Additional Inherited Members

Protected Types inherited from seqan3::alphabet_base< derived_type, size, char_t >
using | char_type = std::conditional_t<std::same_as<char_t, void>, char, char_t>
| The char representation; conditional needed to make semi alphabet definitions legal.
using | rank_type = detail::min_viable_uint_t<size - 1>
| The type of the alphabet when represented as a number (e.g. via to_rank()).

## Detailed Description

template<writable_alphabet sequence_alphabet_t>
requires std::regular<sequence_alphabet_t>
class seqan3::masked< sequence_alphabet_t >

Implementation of a masked composite, which extends a given alphabet with a mask.

Template Parameters

  sequence_alphabet_t | Type of the first letter; must satisfy seqan3::writable_alphabet and std::regular.

The masked composite represents a seqan3::alphabet_tuple_base of any given alphabet with the masked alphabet. It allows one to specify which portions of a sequence should be masked, without losing additional information by replacing the sequence directly.

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/mask/masked.hpp>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::masked<seqan3::dna4> dna4_masked{};
seqan3::masked<seqan3::dna4> dna4_another_masked{'A'_dna4, seqan3::mask::unmasked};
// create a dna4 masked alphabet with an unmasked A
dna4_masked.assign_char('a'); // assigns a masked 'A'_dna4
if (dna4_masked.to_char() != dna4_another_masked.to_char())
{
seqan3::debug_stream << dna4_masked.to_char() << " is not the same as " << dna4_another_masked.to_char()
<< "\n";
}
}
seqan3::mask::unmasked
static mask const unmasked
Member for unmasked.
Definition mask.hpp:65
seqan3::masked
Implementation of a masked composite, which extends a given alphabet with a mask.
Definition masked.hpp:42
seqan3::masked::assign_char
constexpr masked & assign_char(char_type const c) noexcept
Assign from a character.
Definition masked.hpp:86
seqan3::masked::to_char
constexpr char_type to_char() const noexcept
Return a character.
Definition masked.hpp:101
debug_stream.hpp
Provides seqan3::debug_stream and related types.
dna4.hpp
Provides seqan3::dna4, container aliases and string literals.
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:38
masked.hpp
Extends a given alphabet with the mask alphabet.
seqan3::literals
The SeqAn namespace for literals.

See also
  Mask submodule , it contains an explanation of hard-masking (UNKNOWN character) and soft-masking (lower/upper case letters).

This entity is stable. Since version 3.1.

## Member Typedef Documentation

## char_type

template<writable_alphabet sequence_alphabet_t>

using seqan3::masked< sequence_alphabet_t >::char_type = alphabet_char_t<sequence_alphabet_type>

Equals the char_type of sequence_alphabet_type.

This entity is stable. Since version 3.1.

## sequence_alphabet_type

template<writable_alphabet sequence_alphabet_t>

using seqan3::masked< sequence_alphabet_t >::sequence_alphabet_type = sequence_alphabet_t

First template parameter as member type.

This entity is stable. Since version 3.1.

## Member Function Documentation

## assign_char()

template<writable_alphabet sequence_alphabet_t>

masked & seqan3::masked< sequence_alphabet_t >::assign_char | ( | char_type const | c | ) |

inline constexpr noexcept

Assign from a character.

This entity is stable. Since version 3.1.

## operator=() [1/2]

template<writable_alphabet sequence_alphabet_t>

masked< sequence_alphabet_t > & seqan3::alphabet_tuple_base< masked< sequence_alphabet_t >, component_types >::operator= | ( | component_type const | alph | ) |

inline constexpr noexcept

Assignment via a value of one of the components.

Template Parameters

  component_type | One of the component types. Must be uniquely contained in the type list of the composite.

Parameters

  alph | The value of a component that should be assigned.

Note: Since the alphabet_tuple_base is a CRTP base class, we show the working examples with one of its derived classes (seqan3::qualified).

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/quality/qualified.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::qualified<seqan3::dna4, seqan3::phred42> letter1{'T'_dna4, '"'_phred42};
letter1 = 'C'_dna4; // yields {'C'_dna4, '"'_phred42}
letter1 = '#'_phred42; // yields {'C'_dna4, '#'_phred42}
}
seqan3::qualified
Joins an arbitrary alphabet with a quality alphabet.
Definition qualified.hpp:59
phred42.hpp
Provides seqan3::phred42 quality scores.
qualified.hpp
Provides quality alphabet composites.

This entity is stable. Since version 3.1.

## operator=() [2/2]

template<writable_alphabet sequence_alphabet_t>

masked< sequence_alphabet_t > & seqan3::alphabet_tuple_base< masked< sequence_alphabet_t >, component_types >::operator= | ( | indirect_component_type const | alph | ) |

inline constexpr noexcept

Assignment via a value of a subtype that is assignable to one of the components.

Template Parameters

  indirect_component_type | Type that models seqan3::weakly_assignable_from for one of the component types.

Parameters

  alph | The value of a component that should be assigned.

Note: Since the alphabet_tuple_base is a CRTP base class, we show the working examples with one of its derived classes (seqan3::qualified).

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/all.hpp>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/quality/qualified.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::qualified<seqan3::dna4, seqan3::phred42> letter1{'T'_dna4, '"'_phred42};
letter1 = 'C'_rna4; // yields {'C'_dna4, '"'_phred42}
}
all.hpp
Meta-header for the Alphabet / Nucleotide submodule .

This entity is experimental and subject to change in the future. Experimental since version 3.1.

## to_char()

template<writable_alphabet sequence_alphabet_t>

char_type seqan3::masked< sequence_alphabet_t >::to_char | ( |  | ) | const

inline constexpr noexcept

Return a character.

This entity is stable. Since version 3.1.

## Member Data Documentation

## alphabet_size

template<writable_alphabet sequence_alphabet_t>

static

The size of the alphabet, i.e. the number of different values it can take.

This entity is stable. Since version 3.1.

## char_to_rank

template<writable_alphabet sequence_alphabet_t>

std::array<rank_type, detail::size_in_values_v<char_type> > seqan3::masked< sequence_alphabet_t >::char_to_rank

static constexpr protected

Initial value:
{
[]() constexpr
{
std::array<rank_type, detail::size_in_values_v<char_type>> ret{};
for (size_t i = 0; i < 256; ++i)
{
char_type const c = static_cast<char_type>(i);
ret[i] = is_lower(c) ? seqan3::to_rank(seqan3::assign_char_to(c, sequence_alphabet_type{})) * 2
: seqan3::to_rank(seqan3::assign_char_to(c, sequence_alphabet_type{}));
}
return ret;
}()}
std::array
seqan3::masked::char_type
alphabet_char_t< sequence_alphabet_type > char_type
Equals the char_type of sequence_alphabet_type.
Definition masked.hpp:58
seqan3::masked::sequence_alphabet_type
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition masked.hpp:52
seqan3::assign_char_to
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition alphabet/concept.hpp:517
seqan3::to_rank
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition alphabet/concept.hpp:152
seqan3::is_lower
constexpr auto is_lower
Checks whether c is a lower case character.
Definition predicate.hpp:243
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26

Char to rank conversion table.

## rank_to_char

template<writable_alphabet sequence_alphabet_t>

std::array<char_type, alphabet_size> seqan3::masked< sequence_alphabet_t >::rank_to_char

static constexpr protected

Initial value:
{
[]() constexpr
{
std::array<char_type, alphabet_size> ret{};
for (size_t i = 0; i < alphabet_size; ++i)
{
ret[i] = (i < alphabet_size / 2)
? seqan3::to_char(seqan3::assign_rank_to(i, sequence_alphabet_type{}))
: to_lower(seqan3::to_char(seqan3::assign_rank_to(i / 2, sequence_alphabet_type{})));
}
return ret;
}()}
seqan3::masked::alphabet_size
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.
seqan3::to_char
constexpr auto to_char
Return the char representation of an alphabet object.
Definition alphabet/concept.hpp:381
seqan3::assign_rank_to
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition alphabet/concept.hpp:288
seqan3::to_lower
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

Rank to char conversion table.

The documentation for this class was generated from the following file:

- masked.hpp

Hide me