SeqAn3  3.2.0
The Modern C++ library for sequence analysis.
structured_rna.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2022, 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 
18 
19 namespace seqan3
20 {
21 
50 template <nucleotide_alphabet sequence_alphabet_t, rna_structure_alphabet structure_alphabet_t>
53  public alphabet_tuple_base<structured_rna<sequence_alphabet_t, structure_alphabet_t>,
54  sequence_alphabet_t,
55  structure_alphabet_t>
56 {
57 private:
59  using base_type = alphabet_tuple_base<structured_rna<sequence_alphabet_t, structure_alphabet_t>,
60  sequence_alphabet_t,
61  structure_alphabet_t>;
62 
63 public:
68  using sequence_alphabet_type = sequence_alphabet_t;
73  using structure_alphabet_type = structure_alphabet_t;
74 
79  using char_type = alphabet_char_t<sequence_alphabet_type>;
80 
84  constexpr structured_rna() noexcept = default;
85  constexpr structured_rna(structured_rna const &) noexcept = default;
86  constexpr structured_rna(structured_rna &&) noexcept = default;
87  constexpr structured_rna & operator=(structured_rna const &) noexcept = default;
88  constexpr structured_rna & operator=(structured_rna &&) noexcept = default;
89  ~structured_rna() noexcept = default;
90 
91  using base_type::base_type; // Inherit non-default constructors
92 
93 #if SEQAN3_DOXYGEN_ONLY(1) 0
100  constexpr structured_rna(component_type const alph) noexcept
101  {}
102 
109  constexpr structured_rna(indirect_component_type const alph) noexcept
110  {}
111 
118  constexpr structured_rna & operator=(component_type const alph) noexcept
119  {}
120 
127  constexpr structured_rna & operator=(indirect_component_type const alph) noexcept
128  {}
129 #endif // SEQAN3_DOXYGEN_ONLY
131 
132  // Inherit operators from base
133  using base_type::operator=;
134 
137 
142  constexpr structured_rna & assign_char(char_type const c) noexcept
143  {
144  seqan3::assign_char_to(c, get<0>(*this));
145  return *this;
146  }
148 
151 
156  constexpr char_type to_char() const noexcept
157  {
158  return seqan3::to_char(get<0>(*this));
159  }
160 
173  constexpr structured_rna complement() const noexcept
174  {
175  return structured_rna{get<0>(*this).complement(), get<1>(*this)};
176  }
178 
183  static constexpr bool char_is_valid(char_type const c) noexcept
184  {
185  return char_is_valid_for<sequence_alphabet_type>(c);
186  }
187 
190 
196  constexpr bool is_pair_open() const noexcept
197  {
198  return get<1>(*this).is_pair_open();
199  };
200 
206  constexpr bool is_pair_close() const noexcept
207  {
208  return get<1>(*this).is_pair_close();
209  };
210 
216  constexpr bool is_unpaired() const noexcept
217  {
218  return get<1>(*this).is_unpaired();
219  };
220 
222  static constexpr uint8_t max_pseudoknot_depth{structure_alphabet_t::max_pseudoknot_depth};
223 
231  constexpr std::optional<uint8_t> pseudoknot_id() const noexcept
232  {
233  return get<1>(*this).pseudoknot_id();
234  };
236 };
237 
240 template <typename sequence_alphabet_type, typename structure_alphabet_type>
243 
244 } // namespace seqan3
Provides seqan3::nucleotide_alphabet.
Provides seqan3::rna_structure_alphabet.
Provides seqan3::alphabet_tuple_base.
A seqan3::alphabet_tuple_base that joins a nucleotide alphabet with an RNA structure alphabet.
Definition: structured_rna.hpp:56
constexpr bool is_unpaired() const noexcept
Check whether the character represents an unpaired position in an RNA structure.
Definition: structured_rna.hpp:216
constexpr bool is_pair_open() const noexcept
Check whether the character represents a rightward interaction in an RNA structure.
Definition: structured_rna.hpp:196
constexpr structured_rna complement() const noexcept
Return a structured_rna where the sequence letter is converted to its complement.
Definition: structured_rna.hpp:173
constexpr structured_rna(indirect_component_type const alph) noexcept
Definition: structured_rna.hpp:109
constexpr char_type to_char() const noexcept
Return a character. This reads the internal sequence letter.
Definition: structured_rna.hpp:156
constexpr structured_rna & assign_char(char_type const c) noexcept
Assign from a nucleotide character. This modifies the internal sequence letter.
Definition: structured_rna.hpp:142
static constexpr bool char_is_valid(char_type const c) noexcept
Validate whether a character is valid in the sequence alphabet.
Definition: structured_rna.hpp:183
constexpr structured_rna() noexcept=default
Defaulted.
constexpr std::optional< uint8_t > pseudoknot_id() const noexcept
Get an identifier for a pseudoknotted interaction.
Definition: structured_rna.hpp:231
constexpr structured_rna & operator=(component_type const alph) noexcept
Definition: structured_rna.hpp:118
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: structured_rna.hpp:68
constexpr structured_rna(component_type const alph) noexcept
Definition: structured_rna.hpp:100
alphabet_char_t< sequence_alphabet_type > char_type
Equals the char_type of sequence_alphabet_type.
Definition: structured_rna.hpp:79
structured_rna(sequence_alphabet_type &&, structure_alphabet_type &&) -> structured_rna< std::decay_t< sequence_alphabet_type >, std::decay_t< structure_alphabet_type >>
Type deduction guide enables usage of structured_rna without specifying template args.
constexpr bool is_pair_close() const noexcept
Check whether the character represents a leftward interaction in an RNA structure.
Definition: structured_rna.hpp:206
constexpr structured_rna & operator=(indirect_component_type const alph) noexcept
Definition: structured_rna.hpp:127
static constexpr uint8_t max_pseudoknot_depth
The ability of this alphabet to represent pseudoknots, i.e. crossing interactions.
Definition: structured_rna.hpp:222
structure_alphabet_t structure_alphabet_type
Second template parameter as member type.
Definition: structured_rna.hpp:73
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition: alphabet/concept.hpp:524
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: alphabet/concept.hpp:386
requires requires
The rank_type of the semi-alphabet; defined as the return type of seqan3::to_rank....
Definition: alphabet/concept.hpp:164
Refines seqan3::alphabet and adds assignability.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29