20namespace seqan3::detail
24using sam_tag_variant = std::variant<char,
28 std::vector<std::byte>,
32 std::vector<uint16_t>,
34 std::vector<uint32_t>,
39constexpr char sam_tag_type_char[12] = {
'A',
'i',
'f',
'Z',
'H',
'B',
'B',
'B',
'B',
'B',
'B',
'B'};
42constexpr char sam_tag_type_char_extra[12] = {
'\0',
'\0',
'\0',
'\0',
'\0',
'c',
'C',
's',
'S',
'i',
'I',
'f'};
70template <small_
string<2> str>
71constexpr uint16_t
operator""_tag()
73 static_assert(str.size() == 2,
"Illegal SAM tag: Exactly two characters must be given.");
75 constexpr char char0 = str[0];
76 constexpr char char1 = str[1];
78 static_assert((
is_alpha(char0) && is_alnum(char1)),
"Illegal SAM tag: a SAM tag must match /[A-Za-z][A-Za-z0-9]/.");
80 return static_cast<uint16_t
>(char0) * 256 +
static_cast<uint16_t
>(char1);
163template <u
int16_t tag_value>
167 using type = detail::sam_tag_variant;
172template <u
int16_t tag_value>
179template <>
struct sam_tag_type<
"BC"_tag> {
using type =
std::string; };
184template <>
struct sam_tag_type<
"CG"_tag> {
using type = std::vector<int32_t>; };
196template <>
struct sam_tag_type<
"FZ"_tag> {
using type = std::vector<uint16_t>; };
352 template <u
int16_t tag>
353 requires (!std::same_as<sam_tag_type_t<tag>,
variant_type>)
356 if ((*this).count(tag) == 0)
357 (*this)[tag] = sam_tag_type_t<tag>{};
359 return std::get<sam_tag_type_t<tag>>((*this)[tag]);
363 template <u
int16_t tag>
364 requires (!std::same_as<sam_tag_type_t<tag>,
variant_type>)
367 if ((*this).count(tag) == 0)
368 (*this)[tag] = sam_tag_type_t<tag>{};
370 return std::get<sam_tag_type_t<tag>>(std::move((*
this)[tag]));
375 template <u
int16_t tag>
376 requires (!std::same_as<sam_tag_type_t<tag>,
variant_type>)
377 auto const &
get()
const &
379 return std::get<sam_tag_type_t<tag>>((*this).at(tag));
384 template <u
int16_t tag>
385 requires (!std::same_as<sam_tag_type_t<tag>,
variant_type>)
386 auto const &&
get()
const &&
388 return std::get<sam_tag_type_t<tag>>(std::move((*this).at(tag)));
The SAM tag dictionary class that stores all optional SAM fields.
Definition sam_tag_dictionary.hpp:327
detail::sam_tag_variant variant_type
The variant type defining all valid SAM tag field types.
Definition sam_tag_dictionary.hpp:334
auto && get() &&
Uses std::map::operator[] for access and default initializes new keys.
Definition sam_tag_dictionary.hpp:365
auto & get() &
Uses std::map::operator[] for access and default initializes new keys.
Definition sam_tag_dictionary.hpp:354
auto const && get() const &&
Uses std::map::at() for access and throws when the key is unknown.
Definition sam_tag_dictionary.hpp:386
auto const & get() const &
Uses std::map::at() for access and throws when the key is unknown.
Definition sam_tag_dictionary.hpp:377
constexpr auto is_alpha
Checks whether c is a graphic character.
Definition predicate.hpp:211
The SeqAn namespace for literals.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides character predicates for tokenisation.
A constexpr string implementation to manipulate string literals at compile time.
The generic base class.
Definition sam_tag_dictionary.hpp:165
detail::sam_tag_variant type
The type for all unknown tags with no extra overload defaults to a std::variant.
Definition sam_tag_dictionary.hpp:167
typename sam_tag_type< tag_value >::type sam_tag_type_t
Short cut helper for seqan3::sam_tag_type::type.
Definition sam_tag_dictionary.hpp:173
Provides type traits for working with templates.