Loading...
Searching...
No Matches
dna16sam.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <seqan3/alphabet/nucleotide/nucleotide_base.hpp>
namespace seqan3
{
class dna16sam : public nucleotide_base<dna16sam, 16>
{
private:
using base_t = nucleotide_base<dna16sam, 16>;
friend base_t;
friend base_t::base_t;
public:
constexpr dna16sam() noexcept = default;
constexpr dna16sam(dna16sam const &) noexcept = default;
constexpr dna16sam(dna16sam &&) noexcept = default;
constexpr dna16sam & operator=(dna16sam const &) noexcept = default;
constexpr dna16sam & operator=(dna16sam &&) noexcept = default;
~dna16sam() noexcept = default;
using base_t::base_t;
private:
static constexpr char_type rank_to_char_table
[alphabet_size]{'=', 'A', 'C', 'M', 'G', 'R', 'S', 'V', 'T', 'W', 'Y', 'H', 'K', 'D', 'B', 'N'};
static constexpr rank_type rank_complement_table[alphabet_size]{
15, // N is complement of '='_dna16sam 0
8, // T is complement of 'A'_dna16sam 1
4, // G is complement of 'C'_dna16sam 2
12, // K is complement of 'M'_dna16sam 3
2, // C is complement of 'G'_dna16sam 4
10, // Y is complement of 'R'_dna16sam 5
6, // S is complement of 'S'_dna16sam 6
14, // B is complement of 'V'_dna16sam 7
1, // A is complement of 'T'_dna16sam 8
9, // W is complement of 'W'_dna16sam 9
5, // R is complement of 'Y'_dna16sam 10
13, // D is complement of 'H'_dna16sam 11
3, // M is complement of 'K'_dna16sam 12
11, // H is complement of 'D'_dna16sam 13
7, // V is complement of 'B'_dna16sam 14
15 // N is complement of 'N'_dna16sam 15
};
static constexpr rank_type rank_complement(rank_type const rank)
{
return rank_complement_table[rank];
}
static constexpr char_type rank_to_char(rank_type const rank)
{
return rank_to_char_table[rank];
}
static constexpr rank_type char_to_rank(char_type const chr)
{
using index_t = std::make_unsigned_t<char_type>;
return char_to_rank_table[static_cast<index_t>(chr)];
}
static constexpr std::array<rank_type, 256> char_to_rank_table{[]() constexpr
{
std::array<rank_type, 256> ret{};
ret.fill(15u); // initialize with UNKNOWN ('N')
// reverse mapping for characters and their lowercase
for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
{
ret[rank_to_char_table[rnk]] = rnk;
ret[to_lower(rank_to_char_table[rnk])] = rnk;
}
// set U equal to T
ret['U'] = ret['T'];
ret['u'] = ret['t'];
return ret;
}()};
};
// ------------------------------------------------------------------
// containers
// ------------------------------------------------------------------
using dna16sam_vector = std::vector<dna16sam>;
// ------------------------------------------------------------------
// literals
// ------------------------------------------------------------------
inline namespace literals
{
constexpr dna16sam operator""_dna16sam(char const c) noexcept
{
return dna16sam{}.assign_char(c);
}
SEQAN3_WORKAROUND_LITERAL dna16sam_vector operator""_dna16sam(char const * s, size_t n)
{
dna16sam_vector r;
r.resize(n);
for (size_t i = 0; i < n; ++i)
r[i].assign_char(s[i]);
return r;
}
} // namespace literals
} // namespace seqan3
seqan3::alphabet_base::assign_char
constexpr derived_type & assign_char(char_type const chr) noexcept
Assign from a character, implicitly converts invalid characters.
Definition alphabet_base.hpp:160
seqan3::alphabet_base::rank_type
detail::min_viable_uint_t< size - 1 > rank_type
The type of the alphabet when represented as a number (e.g. via to_rank()).
Definition alphabet_base.hpp:77
seqan3::alphabet_base::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:196
seqan3::alphabet_base::char_type
std::conditional_t< std::same_as< char_t, void >, char, char_t > char_type
The char representation; conditional needed to make semi alphabet definitions legal.
Definition alphabet_base.hpp:69
seqan3::dna16sam::dna16sam_vector
std::vector< dna16sam > dna16sam_vector
Alias for a std::vector of seqan3::dna16sam.
Definition dna16sam.hpp:149
seqan3::dna16sam::dna16sam
constexpr dna16sam() noexcept=default
Defaulted.
seqan3::nucleotide_base< dna16sam, 16 >::alphabet_size
static constexpr detail::min_viable_uint_t< size > alphabet_size
std::array::fill
T fill(T... args)
seqan3::alphabet_size
constexpr auto alphabet_size
A type trait that holds the size of a (semi-)alphabet.
Definition alphabet/concept.hpp:834
seqan3::literals
The SeqAn namespace for literals.
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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:74
nucleotide_base.hpp
Provides seqan3::nucleotide_base.
SEQAN3_WORKAROUND_LITERAL
#define SEQAN3_WORKAROUND_LITERAL
Our char literals returning std::vector should be constexpr if constexpr std::vector is supported.
Definition platform.hpp:310
std::vector::resize
T resize(T... args)
std::vector
Hide me