SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
dssp9.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <vector>
16 
20 
21 // ------------------------------------------------------------------
22 // dssp9
23 // ------------------------------------------------------------------
24 
25 namespace seqan3
26 {
27 
60 class dssp9 : public alphabet_base<dssp9, 9>
61 {
62 private:
65 
67  friend base_t;
68 
69 public:
73  constexpr dssp9() noexcept = default;
74  constexpr dssp9(dssp9 const &) noexcept = default;
75  constexpr dssp9(dssp9 &&) noexcept = default;
76  constexpr dssp9 & operator=(dssp9 const &) noexcept = default;
77  constexpr dssp9 & operator=(dssp9 &&) noexcept = default;
78  ~dssp9() noexcept = default;
79 
81 protected:
83 
85  static constexpr char_type rank_to_char[alphabet_size]
86  {
87  'H', 'B', 'E', 'G', 'I', 'T', 'S', 'C', 'X'
88  };
89 
91  static constexpr std::array<rank_type, 256> char_to_rank
92  {
93  [] () constexpr
94  {
96 
97  // initialize with X (std::array::fill unfortunately not constexpr)
98  for (rank_type & rnk : ret)
99  rnk = 8u;
100 
101  // reverse mapping for characters
102  for (rank_type rnk = 0u; rnk < alphabet_size; ++rnk)
103  {
104  ret[static_cast<rank_type>(rank_to_char[rnk])] = rnk;
105  }
106 
107  return ret;
108  } ()
109  };
110 };
111 
124 inline std::vector<dssp9> operator""_dssp9(const char * str, std::size_t len)
125 {
126  std::vector<dssp9> vec;
127  vec.resize(len);
128 
129  for (size_t idx = 0u; idx < len; ++idx)
130  vec[idx].assign_char(str[idx]);
131 
132  return vec;
133 }
134 
143 constexpr dssp9 operator""_dssp9(char const ch) noexcept
144 {
145  return dssp9{}.assign_char(ch);
146 }
147 
149 
150 } // namespace seqan3
std::vector::resize
T resize(T... args)
alphabet_base.hpp
Provides seqan3::alphabet_base.
seqan3::dssp9
The protein structure alphabet of the characters "HGIEBTSCX".
Definition: dssp9.hpp:60
seqan3::alphabet_base< dssp9, 9 >::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:174
vector
seqan3::alphabet_base
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:51
seqan3::dssp9::~dssp9
~dssp9() noexcept=default
seqan3::alphabet_base::assign_char
constexpr derived_type & assign_char(char_type const c) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:140
seqan3::alphabet_base< dssp9, 9 >::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:62
std::array< rank_type, 256 >
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
seqan3::dssp9::dssp9
constexpr dssp9() noexcept=default
Defaulted.
transform.hpp
Provides utilities for modifying characters.
seqan3::dssp9::operator=
constexpr dssp9 & operator=(dssp9 const &) noexcept=default
Defaulted.
std::size_t
std::conditional_t
concept.hpp
Core alphabet concept and free function/type trait wrappers.