|
|
constexpr | alphabet_variant () noexcept=default |
| Defaulted.
|
|
constexpr | alphabet_variant (alphabet_variant const &) noexcept=default |
| Defaulted.
|
|
constexpr | alphabet_variant (alphabet_variant &&) noexcept=default |
| Defaulted.
|
|
constexpr alphabet_variant & | operator= (alphabet_variant const &) noexcept=default |
| Defaulted.
|
|
constexpr alphabet_variant & | operator= (alphabet_variant &&) noexcept=default |
| Defaulted.
|
|
| ~alphabet_variant () noexcept=default |
| Defaulted.
|
|
template<typename alternative_t > |
constexpr | alphabet_variant (alternative_t const alternative) noexcept |
| Construction via the value of an alternative. More...
|
|
template<typename indirect_alternative_t > |
constexpr | alphabet_variant (indirect_alternative_t const rhs) noexcept |
| Constructor for arguments implicitly convertible to an alternative. More...
|
|
template<typename indirect_alternative_t > |
constexpr | alphabet_variant (indirect_alternative_t const rhs) noexcept |
| Constructor for arguments explicitly (but not implicitly) convertible to an alternative. More...
|
|
template<typename indirect_alternative_t > |
constexpr alphabet_variant & | operator= (indirect_alternative_t const &rhs) noexcept |
| Assignment for arguments assignable to an alternative. More...
|
|
|
template<size_t index> |
constexpr bool | holds_alternative () const noexcept |
| Whether the variant alphabet currently holds a value of the given alternative. More...
|
|
template<size_t index> |
constexpr auto | convert_to () const |
| Convert to the specified alphabet (throws if holds_alternative() would be false). More...
|
|
template<size_t index> |
constexpr auto | convert_unsafely_to () const noexcept |
| Convert to the specified alphabet (undefined behaviour if holds_alternative() would be false). More...
|
|
|
template<typename alternative_t > |
constexpr bool | holds_alternative () const noexcept |
| Whether the variant alphabet currently holds a value of the given alternative. More...
|
|
template<typename alternative_t > |
constexpr alternative_t | convert_to () const |
| Convert to the specified alphabet (throws if holds_alternative() would be false). More...
|
|
template<typename alternative_t > |
constexpr alternative_t | convert_unsafely_to () const noexcept |
| Convert to the specified alphabet (undefined behaviour if holds_alternative() would be false). More...
|
|
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. More...
|
|
constexpr rank_type | to_rank () const noexcept |
| Return the letter's numeric value (rank in the alphabet). More...
|
|
constexpr alphabet_variant< alternative_types... > & | assign_char (char_type const chr) noexcept |
| Assign from a character, implicitly converts invalid characters. More...
|
|
constexpr alphabet_variant< alternative_types... > & | assign_rank (rank_type const c) noexcept |
| Assign from a numeric value. More...
|
|
|
static constexpr rank_type | char_to_rank (char_type const chr) |
| Compile-time generated lookup table which maps the char to rank. More...
|
|
template<size_t index, typename alternative_t > |
static constexpr rank_type | rank_by_index_ (alternative_t const &alternative) noexcept |
| Converts an object of one of the given alternatives into the internal representation. More...
|
|
template<typename alternative_t > |
static constexpr rank_type | rank_by_type_ (alternative_t const &alternative) noexcept |
| Converts an object of one of the given alternatives into the internal representation. More...
|
|
static constexpr char_type | rank_to_char (rank_type const rank) |
| Compile-time generated lookup table which maps the rank to char. More...
|
|
|
|
Defines comparison against types that are not subject to implicit construction/conversion but are comparable against alternatives, e.g. alphabet_variant<seqan3::rna4, seqan3::gap> vs alphabet_variant<seqan3::dna4, seqan3::gap> . Only (in-)equality comparison is defined as reasoning about order of variants is inherently difficult.
|
template<typename alphabet_variant_t , typename indirect_alternative_type > |
constexpr auto | operator== (alphabet_variant_t const lhs, indirect_alternative_type const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, false, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
template<typename alphabet_variant_t , typename indirect_alternative_type > |
constexpr auto | operator!= (alphabet_variant_t const lhs, indirect_alternative_type const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, false, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void> |
constexpr auto | operator== (indirect_alternative_type const lhs, alphabet_variant_t const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, true, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void> |
constexpr auto | operator!= (indirect_alternative_type const lhs, alphabet_variant_t const rhs) noexcept -> std::enable_if_t< detail::variant_comparison_guard< alphabet_variant_t, indirect_alternative_type, true, alternative_types... >, bool > |
| (In-)Equality comparison against types comparable with alternatives but not convertible to the variant. More...
|
|
|
template<typename ... alternative_types>
class seqan3::alphabet_variant< alternative_types >
A combined alphabet that can hold values of either of its alternatives.
.
- Template Parameters
-
The alphabet_variant represents the union of two or more alternative alphabets (e.g. the four letter DNA alternative + the gap alternative). It behaves similar to a variant or std::variant, but it preserves the seqan3::alphabet.
Short description:
- combines multiple different alphabets in an "either-or"-fashion;
- is itself a seqan3::alphabet;
- its alphabet size is the sum of the individual sizes;
- default initialises to the the first alternative's default (no empty state like std::variant);
- constructible, assignable and (in-)equality-comparable with each alternative type and also all types that these are constructible/assignable/equality-comparable with;
- only convertible to its alternatives through the member function convert_to() (which can throw!)
Example
int main()
{
letter2.assign_char('-');
letter2.assign_char('K');
letter2 = 'U'_rna5;
}
Meta-header for the Alphabet / Nucleotide submodule .
Provides seqan3::alphabet_variant.
constexpr derived_type & assign_char(char_type const chr) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:165
A combined alphabet that can hold values of either of its alternatives..
Definition: alphabet_variant.hpp:120
The five letter DNA alphabet of A,C,G,T and the unknown character N..
Definition: dna5.hpp:51
The alphabet of a gap character '-'.
Definition: gap.hpp:39
The SeqAn namespace for literals.
Part of the seqan3::alphabet concept requires that the alphabet_variant provides a char representation in addition to the rank representation. For an object of seqan3::alphabet_variant, the to_char()
member function will always return the same character as if invoked on the respective alternative. In contrast, the assign_char()
member function might be ambiguous between the alternative alphabets in a variant.
For example, assigning a '!' to seqan3::dna15 resolves to an object of rank 8 with char representation 'N' while assigning '!' to seqan3::gap always resolves to rank 0, the gap symbol itself ('-'_gap). We tackle this ambiguousness by defaulting unknown characters to the representation of the first alternative (e.g. ‘alphabet_variant<dna15, gap>{}.assign_char(’!')resolves to rank 8, representing
N`_dna15).
On the other hand, two alternative alphabets might have the same char representation (e.g if you combine dna4 with dna5, 'A', 'C', 'G' and 'T' are ambiguous). We tackle this ambiguousness by always choosing the first valid char representation (e.g. ‘alphabet_variant<dna4, dna5>{}.assign_char('A’)resolves to rank 0, representing an
A`_dna4).
To explicitly assign via the character representation of a specific alphabet, assign to that type first and then assign to the variant, e.g.
int main()
{
var = 'A'_dna5;
}
This entity is stable. Since version 3.1.
template<typename ... alternative_types>
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void>
(In-)Equality comparison against types comparable with alternatives but not convertible to the variant.
- Template Parameters
-
alphabet_variant_t | The type of the variant; given as template parameter to prevent conversion. |
indirect_alternative_type | Must be comparable with an alternative's type. |
- Parameters
-
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
- Returns
true
or false
.
To determine (in-)equality, it is first deduced which alternative the argument is comparable with. It is then checked if the variant currently is in that alternative's state and if yes whether the values compare to true
; else false
is returned.
This entity is stable. Since version 3.1.
template<typename ... alternative_types>
template<typename alphabet_variant_t , typename indirect_alternative_type , typename = void>
(In-)Equality comparison against types comparable with alternatives but not convertible to the variant.
- Template Parameters
-
alphabet_variant_t | The type of the variant; given as template parameter to prevent conversion. |
indirect_alternative_type | Must be comparable with an alternative's type. |
- Parameters
-
lhs | Left-hand-side of comparison. |
rhs | Right-hand-side of comparison. |
- Returns
true
or false
.
To determine (in-)equality, it is first deduced which alternative the argument is comparable with. It is then checked if the variant currently is in that alternative's state and if yes whether the values compare to true
; else false
is returned.
This entity is stable. Since version 3.1.