BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
bio::alphabet::masked< sequence_alphabet_t > Class Template Reference

A template for composite alphabets that differentiate between upper and lower case characters.. More...

#include <bio/alphabet/mask/masked.hpp>

+ Inheritance diagram for bio::alphabet::masked< sequence_alphabet_t >:

Public Types

using char_type = 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

Constructors, destructor and assignment
constexpr masked ()=default
 Defaulted.
 
constexpr masked (masked const &)=default
 Defaulted.
 
constexpr masked (masked &&) noexcept=default
 Defaulted.
 
constexpr maskedoperator= (masked const &)=default
 Defaulted.
 
constexpr maskedoperator= (masked &&) noexcept=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 rank_type to_rank () const noexcept
 Return the letter's numeric value (rank in the alphabet).
 
Write functions
constexpr derived_type & assign_char (char_type const c) 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 size_t alphabet_size = size
 The size of the alphabet, i.e. the number of different values it can take.
 

Protected Types

Member types
using rank_type = meta::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, meta::detail::size_in_values_v< char_type > > char_to_rank
 Char to rank conversion table.
 
static constexpr std::array< char_type, alphabet_sizerank_to_char
 Rank to char conversion table.
 

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>
requires std::regular<sequence_alphabet_t>
class bio::alphabet::masked< sequence_alphabet_t >

A template for composite alphabets that differentiate between upper and lower case characters.

.

Template Parameters
sequence_alphabet_tType of the first letter; must satisfy bio::alphabet::writable_alphabet and std::regular.

The masked composite is an alphabet tuple over the given alphabet and bio::alphabet::mask. It creates distinct states for upper and lower case letters, thus allowing to differentiate between symbols in masked regions and those outside. Otherwise, it models the behaviour of the given alphabet.

int main()
{
using namespace bio::alphabet::literals;
// 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())
fmt::print("{} is not the same as {}\n", dna4_masked.to_char(), dna4_another_masked.to_char());
}
constexpr derived_type & assign_char(char_type const c) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: base.hpp:145
static const mask UNMASKED
Member for UNMASKED.
Definition: mask.hpp:62
A template for composite alphabets that differentiate between upper and lower case characters....
Definition: masked.hpp:43
Provides bio::alphabet::dna4, container aliases and string literals.
Core alphabet concept and free function/type trait wrappers.
Extends a given alphabet with the mask alphabet.
An inline namespace for alphabet literals. It exists to safely allow using namespace.
Definition: aa10li.hpp:183

Member Function Documentation

◆ assign_char()

template<typename derived_type , size_t size, typename char_t = char>
constexpr derived_type & bio::alphabet::base< derived_type, size, char_t >::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 bio::alphabet::assign_char_to, required to model bio::alphabet::alphabet.

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ assign_rank()

template<typename derived_type , size_t size, typename char_t = char>
constexpr derived_type & bio::alphabet::base< derived_type, size, char_t >::assign_rank ( rank_type const  c)
inlineconstexprnoexceptinherited

Assign from a numeric value.

Parameters
cThe rank to be assigned.

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

Complexity

Constant.

Exceptions

Guaranteed not to throw.

◆ operator type()

constexpr bio::alphabet::tuple_base< masked< sequence_alphabet_t > , component_types >::operator type ( ) const
inlineconstexprnoexceptinherited

Implicit cast to a single letter. Works only if the type is unique in the type list.

◆ to_rank()

template<typename derived_type , size_t size, typename char_t = char>
constexpr rank_type bio::alphabet::base< derived_type, size, char_t >::to_rank ( ) const
inlineconstexprnoexceptinherited

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

Provides an implementation for bio::alphabet::to_rank, required to model bio::alphabet::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, meta::detail::size_in_values_v<char_type> > bio::alphabet::masked< sequence_alphabet_t >::char_to_rank
staticconstexprprotected
Initial value:
= []()
{
for (size_t i = 0; i < meta::detail::size_in_values_v<char_type>; ++i)
{
char_type c = static_cast<char_type>(i);
ret[i] =
detail::is_lower(c)
}
return ret;
}()
static constexpr size_t alphabet_size
The size of the alphabet, i.e. the number of different values it can take.
Definition: base.hpp:177
char_t< sequence_alphabet_type > char_type
Equals the char_type of sequence_alphabet_type.
Definition: masked.hpp:53
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: masked.hpp:50
constexpr auto assign_char_to
Assign a char to an alphabet object.
Definition: concept.hpp:260
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:70

Char to rank conversion table.

◆ rank_to_char

template<writable_alphabet sequence_alphabet_t>
constexpr std::array<char_type, alphabet_size> bio::alphabet::masked< sequence_alphabet_t >::rank_to_char
staticconstexprprotected
Initial value:
= []()
{
for (size_t i = 0; i < alphabet_size / 2; ++i)
{
ret[i + alphabet_size / 2] = detail::to_lower(ret[i]);
}
return ret;
}()
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: concept.hpp:192
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition: concept.hpp:138

Rank to char conversion table.


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