Composition¶
Meta-header for the composition submodule; includes all headers from alphabet/composition/. composition.
- Author
- Marcel Ehrhardt <marcel.ehrhardt AT fu-berlin.de>
Contains cartesian_composition.
- Author
- Hannes Hauswedell <hannes.hauswedell AT fu-berlin.de>
-
namespace
seqan3¶ The main SeqAn3 namespace.
Helpers for seqan3::semi_alphabet_concept
These functions and metafunctions expose member variables and types so that they satisfy seqan3::semi_alphabet_concept.
Helpers for seqan3::alphabet_concept
These functions and metafunctions expose member variables and types so that they satisfy seqan3::alphabet_concept.
Helpers for seqan3::nucleotide_concept
These functions and metafunctions expose member variables and types so that they satisfy seqan3::nucleotide_concept.
Alphabet aliases
Other names (typedefs) for seqan3::nucl16
Range concepts
Adapted from the Ranges TS.
Container concepts
Container concepts as defined by the standard library (or very close).
Container-of-container concepts
Shortcuts for multi-dimensional container concepts.
- template <typename derived_type, typename first_alphabet_type, typename... alphabet_types>
-
struct
cartesian_composition¶ - #include <alphabet/composition/cartesian_composition.hpp>
The CRTP base of alphabets that contain multiple (different) letters at one position.
This data structure is CRTP base class for combined alphabets, where the different alphabet letters exist independently, similar to a tuple. In fact this class provides a tuple-like interface with
get<0>(t)and objects can be brace-initialized with the individual members.- Template Parameters
first_alphabet_type: Type of the first letter; must satisfy alphabet_concept.alphabet_types: Types of further letters (up to 4); must satisfy alphabet_concept.
- Attention
- This is a “pure base class”, you cannot instantiate it, you can only inherit from it. Most likely you are interested in using one of it’s descendents like quality_composition.
- See
- quality_composition
- See
- mask_composition
Inherits from seqan3::pod_tuple< first_alphabet_type, alphabet_types... >
Read functions
-
constexpr rank_type
to_rank() const¶ Return the letter combination’s numeric value (or “rank”) in the alphabet composition.
- Complexity
- Linear in the number of alphabets.
- template <typename type>
-
constexpr
operator type() const¶ Explicit cast to a single letter. Works only if the type is unique in the type list.
- Complexity
- Linear in the number of alphabets.
Write functions
-
constexpr derived_type &
assign_rank(rank_type const i)¶ Assign from a numeric value.
- Complexity
- Linear in the number of alpahabets.
- Exceptions
- Asserts that the parameter is smaller than value_size [only in debug mode].
Comparison operators
Lexicographically compares the values in the tuple.
Public Types
-
template<>
usingrank_type= detail::min_viable_uint_t<(alphabet_size_v<first_alphabet_type> * ... * alphabet_size_v<alphabet_types>)>¶ The type of value_size and
alphabet_size_v<cartesian_composition<...>>
Public Static Attributes
-
constexpr rank_type
value_size= {(alphabet_size_v<first_alphabet_type> * ... * alphabet_size_v<alphabet_types>)}¶ The product of the sizes of the individual alphabets.
Private Functions
-
cartesian_composition()¶ declared private to prevent direct use of the CRTP base
-
constexpr
cartesian_composition(cartesian_composition const&)¶ declared private to prevent direct use of the CRTP base
-
constexpr
cartesian_composition(cartesian_composition&&)¶ declared private to prevent direct use of the CRTP base
-
constexpr cartesian_composition &
operator=(cartesian_composition const&)¶ declared private to prevent direct use of the CRTP base
-
constexpr cartesian_composition &
operator=(cartesian_composition&&)¶ declared private to prevent direct use of the CRTP base
-
~cartesian_composition()¶ declared private to prevent direct use of the CRTP base
- template <std::size_t... idx>
-
constexpr rank_type
to_rank_impl(std::index_sequence<idx...> const&) const¶ Implementation of to_rank().
- template <std::size_t j>
-
constexpr void
assign_rank_impl(rank_type const i)¶ Implementation of assign_rank().
Private Members
-
friend seqan3::cartesian_composition::derived_type befriend the derived type so that it can instantiate
Private Static Attributes
-
constexpr std::array<rank_type, sizeof...(alphabet_types) + 1>
cummulative_alph_sizes= { [] () constexpr { std::array<rank_type, sizeof...(alphabet_types) + 1> ret{}; size_t count = 0; meta::for_each(meta::list<first_alphabet_type, alphabet_types...>{}, [&] (auto && alph) constexpr { ret[count] = static_cast<rank_type>( alphabet_size_v<std::decay_t<decltype(alph)>> * (count > 0 ? ret[count - 1] : 1)); ++count; }); return std::move(ret); }() }¶ the cummulative alphabet size products (first, first*second, first*second*third...) are cached
-
constexpr auto
positions= std::make_index_sequence<sizeof...(alphabet_types)>{}¶ An index sequence up to the number of contained letters.
Contains seqan3::union_composition.
- Author
- Marcel Ehrhardt <marcel.ehrhardt AT fu-berlin.de>
- Author
- David Heller <david.heller AT fu-berlin.de>
-
namespace
seqan3¶ The main SeqAn3 namespace.
Helpers for seqan3::semi_alphabet_concept
These functions and metafunctions expose member variables and types so that they satisfy seqan3::semi_alphabet_concept.
Helpers for seqan3::alphabet_concept
These functions and metafunctions expose member variables and types so that they satisfy seqan3::alphabet_concept.
Helpers for seqan3::nucleotide_concept
These functions and metafunctions expose member variables and types so that they satisfy seqan3::nucleotide_concept.
Alphabet aliases
Other names (typedefs) for seqan3::nucl16
Range concepts
Adapted from the Ranges TS.
Container concepts
Container concepts as defined by the standard library (or very close).
Container-of-container concepts
Shortcuts for multi-dimensional container concepts.
- template <typename first_alphabet_type, typename... alphabet_types>
-
class
union_composition¶ - #include <alphabet/composition/union_composition.hpp>
A composition that merges different regular alphabets as a single alphabet.
The union alphabet represents the union of two or more alphabets (e.g. the four letter DNA alphabet + the gap alphabet). Note that you cannot assign regular characters, but additional functions for this are available.
- Template Parameters
first_alphabet_type: Type of the first letter, e.g. dna4; must satisfy seqan3::alphabet_concept.alphabet_types: Types of further letters; must satisfy seqan3::alphabet_concept.
This class has a similar behavior as std::variant.
union_composition<dna4, gap> my_letter{}; union_composition<dna4, gap> converted_letter{dna4::C}; // doesn't work: // union_composition<dna4, gap> my_letter{'A'}; union_composition<dna4, gap>{}.assign_char('C'); // <- this does! union_composition<dna4, gap>{}.assign_char('-'); // gap character union_composition<dna4, gap>{}.assign_char('K'); // unknown characters map to the default/unknown // character of the first alphabet type (i.e. A of dna4) if (my_letter.to_char() == 'A') std::cout << "yeah\n"; // "yeah";The union alphabet can also be constructed directly from one of the base alphabets.
using alphabet_t = union_composition<dna4, dna5, gap>; constexpr alphabet_t letter0{dna4::A}; constexpr alphabet_t letter1 = dna4::C; constexpr alphabet_t letter2 = {dna4::G}; constexpr alphabet_t letter3 = static_cast<alphabet_t>(dna4::T); assert(letter0.to_rank() == 0); assert(letter1.to_rank() == 1); assert(letter2.to_rank() == 2); assert(letter3.to_rank() == 3);
Or can be assigned by one of the base alphabets.
using alphabet_t = union_composition<dna4, dna5, gap>; alphabet_t letter; letter = dna5::A; assert(letter.to_rank() == 4); letter = {dna5::C}; assert(letter.to_rank() == 5); letter = static_cast<alphabet_t>(dna5::G); assert(letter.to_rank() == 6);
Default constructors
-
constexpr
union_composition()¶
-
constexpr
union_composition(union_composition const&)¶
-
constexpr
union_composition(union_composition&&)¶
Default assignment operators
-
constexpr union_composition &
operator=(union_composition const&)¶
-
constexpr union_composition &
operator=(union_composition&&)¶
Conversion constructors
- template <typename alphabet_t>
-
constexpr
union_composition(alphabet_t const &alphabet)¶ Construction via a value of the base alphabets.
union_composition<dna4, gap> letter1{dna4::C}; // or union_composition<dna4, gap> letter2 = gap::GAP;
- Template Parameters
alphabet_t: One of the base alphabet types
- template <size_t I, typename alphabet_t>
-
constexpr
union_composition(std::in_place_index_t<I>, alphabet_t const &alphabet)¶ Construction via a value of reoccurring alphabets.
using alphabet_t = union_composition<dna4, dna4>; constexpr alphabet_t letter0{std::in_place_index_t<0>{}, dna4::A}; constexpr alphabet_t letter4{std::in_place_index_t<1>{}, dna4::A}; EXPECT_EQ(letter0.to_rank(), 0); EXPECT_EQ(letter4.to_rank(), 4);
- Template Parameters
I: The index of the i-th base alphabetalphabet_t: The i-th given base alphabet type
Conversion assignment operators
- template <typename alphabet_t>
-
constexpr union_composition &
operator=(alphabet_t const &alphabet)¶ Assignment via a value of the base alphabets.
union_composition<dna4, gap> letter1{}; letter1 = gap::GAP;
- Template Parameters
alphabet_t: One of the base alphabet types
Read functions
-
constexpr char_type
to_char() const¶ Return the letter as a character of char_type.
-
constexpr rank_type
to_rank() const¶ Return the letter’s numeric value or rank in the alphabet.
Write functions
-
constexpr union_composition &
assign_char(char_type const c)¶ Assign from a character.
-
constexpr union_composition &
assign_rank(rank_type const i)¶ Assign from a numeric value.
Comparison operators
-
constexpr bool
operator==(union_composition const &rhs) const¶
-
constexpr bool
operator!=(union_composition const &rhs) const¶
-
constexpr bool
operator<(union_composition const &rhs) const¶
-
constexpr bool
operator>(union_composition const &rhs) const¶
-
constexpr bool
operator<=(union_composition const &rhs) const¶
-
constexpr bool
operator>=(union_composition const &rhs) const¶
Public Types
Public Static Functions
- template <typename alphabet_t>
-
static constexpr bool
has_type()¶ Returns true if alphabet_t is one of the given alphabet types.
- Template Parameters
alphabet_t: The type to check
Public Static Attributes
-
constexpr size_t
value_size= (alphabet_types::value_size + ... + first_alphabet_type::value_size)¶ The size of the alphabet, i.e. the number of different values it can take.
Private Functions
- template <typename... alphabet_types>
-
constexpr auto
alphabet_prefix_sum_sizes()¶ Returns an array which contains the prefix sum over all alphabet_types::value_size’s.
using namespace seqan3::detail; constexpr auto prefix_sum = alphabet_prefix_sum_sizes<dna4, gap, dna5>(); assert(prefix_sum.size() == 4); assert(prefix_sum[0] == 0); assert(prefix_sum[1] == 4); assert(prefix_sum[2] == 5); assert(prefix_sum[3] == 10);
- template <typename char_t, typename... alphabet_types>
-
constexpr auto
value_to_char_table()¶ Returns an map at compile time where the key is the rank of the union of all alphabets and the value is the corresponding char of that rank and alphabet.
using namespace seqan3::detail::union_composition; constexpr auto value_to_char = value_to_char_table<char, dna4, gap, dna5>(); assert(value_to_char.size() == 10); assert(value_to_char[0] == 'A'); assert(value_to_char[1] == 'C'); assert(value_to_char[2] == 'G'); assert(value_to_char[3] == 'T'); assert(value_to_char[4] == '-'); assert(value_to_char[5] == 'A'); assert(value_to_char[6] == 'C'); // and so on
- template <typename char_t, typename... alphabet_types>
-
constexpr auto
char_to_value_table()¶ Returns an map at compile time where the key is the char of one of the alphabets and the value is the corresponding rank over all alphabets (by conflict will default to the first).
using namespace seqan3::detail::union_composition; constexpr auto char_to_value = char_to_value_table<char, dna4, gap, dna5>(); assert(char_to_value.size() == 256); assert(char_to_value['A'] == 0); assert(char_to_value['C'] == 1); assert(char_to_value['G'] == 2); assert(char_to_value['T'] == 3); assert(char_to_value['-'] == 4); assert(char_to_value['A'] == 0); assert(char_to_value['C'] == 1); assert(char_to_value['G'] == 2); assert(char_to_value['T'] == 3); assert(char_to_value['N'] == 9); assert(char_to_value['*'] == 0); // every other character defaults to 0
Private Members
-
rank_type
_value¶ The data member.
Private Static Functions
- template <size_t index, typename alphabet_t>
-
static constexpr rank_type
rank_by_index_(alphabet_t const &alphabet)¶ Converts an object of one of the given alphabets into the internal representation.
- template <typename alphabet_t>
-
static constexpr rank_type
rank_by_type_(alphabet_t const &alphabet)¶ Converts an object of one of the given alphabets into the internal representation.
Finds the index of alphabet_t in the given types.
Private Static Attributes
-
constexpr auto
prefix_sum_sizes¶ Compile-time generated lookup table which contains the prefix sum up to the position of each alphabet.
- See
- alphabet_prefix_sum_sizes
-
constexpr auto
value_to_char¶ Compile-time generated lookup table which maps the rank to char.
- See
- value_to_char_table
-
constexpr auto
char_to_value¶ Compile-time generated lookup table which maps the char to rank.
- See
- char_to_value_table