SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
structured_rna.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 <iostream>
16 #include <optional>
17 #include <string>
18 #include <utility>
19 
23 
24 namespace seqan3
25 {
26 
53 template <NucleotideAlphabet sequence_alphabet_t, RnaStructureAlphabet structure_alphabet_t>
55  requires WritableAlphabet<sequence_alphabet_t> && WritableAlphabet<structure_alphabet_t>
58  public alphabet_tuple_base<structured_rna<sequence_alphabet_t, structure_alphabet_t>,
59  sequence_alphabet_t, structure_alphabet_t>
60 {
61 private:
64  sequence_alphabet_t, structure_alphabet_t>;
65 public:
67  using sequence_alphabet_type = sequence_alphabet_t;
69  using structure_alphabet_type = structure_alphabet_t;
70 
73 
77  constexpr structured_rna() noexcept = default;
78  constexpr structured_rna(structured_rna const &) noexcept = default;
79  constexpr structured_rna(structured_rna &&) noexcept = default;
80  constexpr structured_rna & operator =(structured_rna const &) noexcept = default;
81  constexpr structured_rna & operator =(structured_rna &&) noexcept = default;
82  ~structured_rna() noexcept = default;
83 
84  using base_type::base_type; // Inherit non-default constructors
85 
87  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna(component_type const alph) noexcept {} ))
89  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna(indirect_component_type const alph) noexcept {} ))
91  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna & operator=(component_type const alph) noexcept {} ))
93  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna & operator=(indirect_component_type const alph) noexcept {} ))
95 
96  // Inherit operators from base
97  using base_type::operator=;
98  using base_type::operator==;
99  using base_type::operator!=;
100  using base_type::operator>=;
101  using base_type::operator<=;
102  using base_type::operator<;
103  using base_type::operator>;
104 
108  constexpr structured_rna & assign_char(char_type const c) noexcept
109  {
110  seqan3::assign_char_to(c, get<0>(*this));
111  return *this;
112  }
113 
116  {
117  seqan3::assign_char_strictly_to(c, get<0>(*this));
118  return *this;
119  }
121 
124 
126  constexpr char_type to_char() const noexcept
127  {
128  return seqan3::to_char(get<0>(*this));
129  }
130 
141  constexpr structured_rna complement() const noexcept
142  {
143  return structured_rna{get<0>(*this).complement(), get<1>(*this)};
144  }
146 
148  static constexpr bool char_is_valid(char_type const c) noexcept
149  {
150  return char_is_valid_for<sequence_alphabet_type>(c);
151  }
152 
155 
159  constexpr bool is_pair_open() const noexcept
160  {
161  return get<1>(*this).is_pair_open();
162  };
163 
167  constexpr bool is_pair_close() const noexcept
168  {
169  return get<1>(*this).is_pair_close();
170  };
171 
175  constexpr bool is_unpaired() const noexcept
176  {
177  return get<1>(*this).is_unpaired();
178  };
179 
182 
187  constexpr std::optional<uint8_t> pseudoknot_id() const noexcept
188  {
189  return get<1>(*this).pseudoknot_id();
190  };
192 };
193 
196 template <typename sequence_alphabet_type, typename structure_alphabet_type>
197 structured_rna(sequence_alphabet_type &&, structure_alphabet_type &&)
198  -> structured_rna<std::decay_t<sequence_alphabet_type>, std::decay_t<structure_alphabet_type>>;
199 
200 } // namespace seqan3
constexpr bool is_pair_close() const noexcept
Check whether the character represents a leftward interaction in an RNA structure.
Definition: structured_rna.hpp:167
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: concept.hpp:285
constexpr auto assign_char_strictly_to
Assign a character to an alphabet object, throw if the character is not valid.
Definition: concept.hpp:577
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: structured_rna.hpp:67
constexpr bool is_unpaired() const noexcept
Check whether the character represents an unpaired position in an RNA structure.
Definition: structured_rna.hpp:175
The main SeqAn3 namespace.
constexpr char_type to_char() const noexcept
Return a character. This reads the internal sequence letter.
Definition: structured_rna.hpp:126
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:148
constexpr structured_rna complement() const noexcept
Return a structured_rna where the sequence letter is converted to its complement. ...
Definition: structured_rna.hpp:141
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the sam...
Definition: alphabet_tuple_base.hpp:188
Provides seqan3::NucleotideAlphabet.
alphabet_char_t< sequence_alphabet_type > char_type
Equals the char_type of sequence_alphabet_type.
Definition: structured_rna.hpp:72
decltype(seqan3::to_char(std::declval< alphabet_type const >())) alphabet_char_t
The char_type of the alphabet; defined as the return type of seqan3::to_char.
Definition: concept.hpp:294
constexpr bool is_pair_open() const noexcept
Check whether the character represents a rightward interaction in an RNA structure.
Definition: structured_rna.hpp:159
Provides seqan3::RnaStructureAlphabet.
structured_rna & assign_char_strictly(char_type const c)
Strict assign from a nucleotide character. This modifies the internal sequence letter.
Definition: structured_rna.hpp:115
A seqan3::alphabet_tuple_base that joins a nucleotide alphabet with an RNA structure alphabet...
Definition: structured_rna.hpp:57
static constexpr uint8_t max_pseudoknot_depth
The ability of this alphabet to represent pseudoknots, i.e. crossing interactions.
Definition: structured_rna.hpp:181
constexpr auto max_pseudoknot_depth
A type trait that holds the ability of the structure alphabet to represent pseudoknots, i.e. crossing interactions, up to a certain depth.
Definition: concept.hpp:370
constexpr structured_rna(indirect_component_type const alph) noexcept
Construction via a value of a subtype that is assignable to one of the components.
Definition: structured_rna.hpp:89
constexpr std::optional< uint8_t > pseudoknot_id() const noexcept
Get an identifier for a pseudoknotted interaction.
Definition: structured_rna.hpp:187
constexpr structured_rna() noexcept=default
Defaulted.
Provides seqan3::alphabet_tuple_base.
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition: concept.hpp:395
structure_alphabet_t structure_alphabet_type
Second template parameter as member type.
Definition: structured_rna.hpp:69