SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
seqan3::masked< sequence_alphabet_t > Class Template Reference

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 >:

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

Read functions
constexpr char_type to_char () const noexcept
 Return the letter as a character of char_type. More...
 
constexpr rank_type to_rank () const noexcept
 Return the letter's numeric value (rank in the alphabet). More...
 
Write functions
constexpr masked< sequence_alphabet_t > & assign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters. More...
 
constexpr masked< sequence_alphabet_t > & assign_rank (rank_type const c) noexcept
 Assign from a numeric value. More...
 
Read functions
constexpr char_type to_char () const noexcept
 Return the letter as a character of char_type. More...
 
constexpr rank_type to_rank () const noexcept
 Return the letter's numeric value (rank in the alphabet). More...
 
Write functions
constexpr masked< sequence_alphabet_t > & assign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters. More...
 
constexpr masked< sequence_alphabet_t > & assign_rank (rank_type const c) noexcept
 Assign from a numeric value. More...
 
Constructors, destructor and assignment
constexpr masked ()=default
 Defaulted.
 
constexpr masked (masked const &)=default
 Defaulted.
 
constexpr masked (masked &&)=default
 Defaulted.
 
constexpr maskedoperator= (masked const &)=default
 Defaulted.
 
constexpr maskedoperator= (masked &&)=default
 Defaulted.
 
 ~masked ()=default
 Defaulted.
 
Write functions
constexpr maskedassign_char (char_type const c) noexcept
 Assign from a character.
 
Read functions
constexpr char_type to_char () const noexcept
 Return a character.
 
Read functions

All read operations are constant complexity.

constexpr operator type () const noexcept
 Implicit cast to a single letter. Works only if the type is unique in the type list.
 
Read functions
constexpr char_type to_char () const noexcept
 Return the letter as a character of char_type. More...
 
constexpr rank_type to_rank () const noexcept
 Return the letter's numeric value (rank in the alphabet). More...
 
Write functions
constexpr masked< sequence_alphabet_t > & assign_char (char_type const c) noexcept
 Assign from a character, implicitly converts invalid characters. More...
 
constexpr masked< sequence_alphabet_t > & assign_rank (rank_type const c) noexcept
 Assign from a numeric value. More...
 

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.
 

Protected Types

Member types
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()).
 

Static Protected Attributes

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

Related Functions

(Note that these are not member functions.)

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.
 

Detailed Description

template<writable_alphabet 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_tType 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.

int main()
{
using seqan3::operator""_dna4;
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";
}
}

Member Function Documentation

◆ assign_char()

constexpr masked< sequence_alphabet_t > & seqan3::alphabet_base< masked< sequence_alphabet_t > , size, void >::assign_char ( char_type const  c)
inlineconstexprnoexceptinherited

Assign from a character, implicitly converts invalid characters.

Parameters
cThe character to be assigned.

Provides an implementation for seqan3::assign_char_to, required to model seqan3::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ assign_rank()

constexpr masked< sequence_alphabet_t > & seqan3::alphabet_base< masked< sequence_alphabet_t > , size, void >::assign_rank ( rank_type const  c)
inlineconstexprnoexceptinherited

Assign from a numeric value.

Parameters
cThe rank to be assigned.

Provides an implementation for seqan3::assign_rank_to, required to model seqan3::semialphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ to_char()

constexpr char_type seqan3::alphabet_base< masked< sequence_alphabet_t > , size, void >::to_char
inlineconstexprnoexceptinherited

Return the letter as a character of char_type.

Provides an implementation for seqan3::to_char, required to model seqan3::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ to_rank()

constexpr rank_type seqan3::alphabet_base< masked< sequence_alphabet_t > , size, void >::to_rank
inlineconstexprnoexceptinherited

Return the letter's numeric value (rank in the alphabet).

Provides an implementation for seqan3::to_rank, required to model seqan3::semialphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

Member Data Documentation

◆ char_to_rank

template<writable_alphabet sequence_alphabet_t>
constexpr std::array<rank_type, detail::size_in_values_v<char_type> > seqan3::masked< sequence_alphabet_t >::char_to_rank
staticconstexprprotected
Initial value:
{
[] ()
{
for (size_t i = 0; i < 256; ++i)
{
char_type c = static_cast<char_type>(i);
ret[i] = is_lower(c)
}
return ret;
} ()
}

Char to rank conversion table.

◆ rank_to_char

template<writable_alphabet sequence_alphabet_t>
constexpr std::array<char_type, alphabet_size> seqan3::masked< sequence_alphabet_t >::rank_to_char
staticconstexprprotected
Initial value:

Rank to char conversion table.


The documentation for this class was generated from the following file:
debug_stream.hpp
Provides seqan3::debug_stream and related types.
seqan3::assign_rank_to
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:239
dna4.hpp
Provides seqan3::dna4, container aliases and string literals.
seqan3::masked
Implementation of a masked composite, which extends a given alphabet with a mask.
Definition: masked.hpp:44
seqan3::masked::char_type
alphabet_char_t< sequence_alphabet_type > char_type
Equals the char_type of sequence_alphabet_type.
Definition: masked.hpp:55
seqan3::alphabet_base< masked< sequence_alphabet_t >,(1 *... *alphabet_size< component_types >), void >::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.
Definition: alphabet_base.hpp:176
seqan3::masked::sequence_alphabet_type
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: masked.hpp:52
seqan3::to_char
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: concept.hpp:321
seqan3::to_rank
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:143
masked.hpp
Extends a given alphabet with the mask alphabet.
seqan3::alphabet_base::assign_char
constexpr derived_type & assign_char(char_type const c) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:142
seqan3::mask::UNMASKED
static const mask UNMASKED
Member for UNMASKED.
Definition: mask.hpp:60
std::array
seqan3::assign_char_to
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition: concept.hpp:417
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
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:81
seqan3::is_lower
constexpr auto is_lower
Checks whether c is a lower case character.
Definition: predicate.hpp:271