Loading...
Searching...
No Matches
dssp9.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 <vector>
#include <seqan3/alphabet/alphabet_base.hpp>
#include <seqan3/alphabet/concept.hpp>
#include <seqan3/utility/char_operations/transform.hpp>
// ------------------------------------------------------------------
// dssp9
// ------------------------------------------------------------------
namespace seqan3
{
class dssp9 : public alphabet_base<dssp9, 9>
{
private:
using base_t = alphabet_base<dssp9, 9>;
friend base_t;
public:
constexpr dssp9() noexcept = default;
constexpr dssp9(dssp9 const &) noexcept = default;
constexpr dssp9(dssp9 &&) noexcept = default;
constexpr dssp9 & operator=(dssp9 const &) noexcept = default;
constexpr dssp9 & operator=(dssp9 &&) noexcept = default;
~dssp9() noexcept = default;
private:
static constexpr char_type rank_to_char_table[alphabet_size]{'H', 'B', 'E', 'G', 'I', 'T', 'S', 'C', 'X'};
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(8u);
// reverse mapping for characters
for (rank_type rnk = 0u; rnk < alphabet_size; ++rnk)
ret[static_cast<rank_type>(rank_to_char_table[rnk])] = rnk;
return ret;
}()};
};
inline namespace literals
{
constexpr dssp9 operator""_dssp9(char const ch) noexcept
{
return dssp9{}.assign_char(ch);
}
SEQAN3_WORKAROUND_LITERAL std::vector<dssp9> operator""_dssp9(char const * str, std::size_t len)
{
std::vector<dssp9> vec;
vec.resize(len);
for (size_t idx = 0u; idx < len; ++idx)
vec[idx].assign_char(str[idx]);
return vec;
}
} // namespace literals
} // namespace seqan3
concept.hpp
Core alphabet concept and free function/type trait wrappers.
alphabet_base.hpp
Provides seqan3::alphabet_base.
seqan3::alphabet_base< dssp9, 9 >::assign_char
constexpr dssp9 & assign_char(char_type const chr) noexcept
Definition alphabet_base.hpp:160
seqan3::alphabet_base< dssp9, 9 >::alphabet_base
constexpr alphabet_base() noexcept=default
seqan3::alphabet_base< dssp9, 9 >::rank_type
detail::min_viable_uint_t< size - 1 > rank_type
Definition alphabet_base.hpp:77
seqan3::alphabet_base< dssp9, 9 >::alphabet_size
static constexpr detail::min_viable_uint_t< size > alphabet_size
Definition alphabet_base.hpp:196
seqan3::alphabet_base< dssp9, 9 >::char_type
std::conditional_t< std::same_as< char, void >, char, char > char_type
Definition alphabet_base.hpp:69
seqan3::dssp9::dssp9
constexpr dssp9() noexcept=default
Defaulted.
std::array::fill
T fill(T... args)
std::make_unsigned_t
seqan3::literals
The SeqAn namespace for literals.
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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::size_t
transform.hpp
Provides utilities for modifying characters.
vector
Hide me