SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
dssp9.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <vector>
13
17
18// ------------------------------------------------------------------
19// dssp9
20// ------------------------------------------------------------------
21
22namespace seqan3
23{
24
58class dssp9 : public alphabet_base<dssp9, 9>
59{
60private:
63
65 friend base_t;
66
67public:
71 constexpr dssp9() noexcept = default;
72 constexpr dssp9(dssp9 const &) noexcept = default;
73 constexpr dssp9(dssp9 &&) noexcept = default;
74 constexpr dssp9 & operator=(dssp9 const &) noexcept = default;
75 constexpr dssp9 & operator=(dssp9 &&) noexcept = default;
76 ~dssp9() noexcept = default;
77
79
80private:
82 static constexpr char_type rank_to_char_table[alphabet_size]{'H', 'B', 'E', 'G', 'I', 'T', 'S', 'C', 'X'};
83
85 static constexpr char_type rank_to_char(rank_type const rank)
86 {
87 return rank_to_char_table[rank];
88 }
89
91 static constexpr rank_type char_to_rank(char_type const chr)
92 {
93 using index_t = std::make_unsigned_t<char_type>;
94 return char_to_rank_table[static_cast<index_t>(chr)];
95 }
96
98 static constexpr std::array<rank_type, 256> char_to_rank_table{
99 []() constexpr
100 {
102
103 ret.fill(8u);
104
105 // reverse mapping for characters
106 for (rank_type rnk = 0u; rnk < alphabet_size; ++rnk)
107 ret[static_cast<rank_type>(rank_to_char_table[rnk])] = rnk;
108
109 return ret;
110 }()};
111};
112
113inline namespace literals
114{
115
129constexpr dssp9 operator""_dssp9(char const ch) noexcept
130{
131 return dssp9{}.assign_char(ch);
132}
133
145SEQAN3_WORKAROUND_LITERAL std::vector<dssp9> operator""_dssp9(char const * str, std::size_t len)
146{
148 vec.resize(len);
149
150 for (size_t idx = 0u; idx < len; ++idx)
151 vec[idx].assign_char(str[idx]);
152
153 return vec;
154}
156
157} // namespace literals
158
159} // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
Provides seqan3::alphabet_base.
A CRTP-base that makes defining a custom alphabet easier.
Definition alphabet_base.hpp:54
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
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
std::conditional_t< std::same_as< char, void >, char, char > char_type
The char representation; conditional needed to make semi alphabet definitions legal.
Definition alphabet_base.hpp:69
The protein structure alphabet of the characters "HGIEBTSCX".
Definition dssp9.hpp:59
constexpr dssp9() noexcept=default
Defaulted.
T fill(T... args)
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
#define SEQAN3_WORKAROUND_LITERAL
Our char literals returning std::vector should be constexpr if constexpr std::vector is supported.
Definition platform.hpp:311
T resize(T... args)
Provides utilities for modifying characters.
Hide me