SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
structured_rna.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 
18 
19 namespace seqan3
20 {
21 
48 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, structure_alphabet_t>
55 {
56 private:
59  sequence_alphabet_t, structure_alphabet_t>;
60 public:
62  using sequence_alphabet_type = sequence_alphabet_t;
64  using structure_alphabet_type = structure_alphabet_t;
65 
68 
72  constexpr structured_rna() noexcept = default;
73  constexpr structured_rna(structured_rna const &) noexcept = default;
74  constexpr structured_rna(structured_rna &&) noexcept = default;
75  constexpr structured_rna & operator =(structured_rna const &) noexcept = default;
76  constexpr structured_rna & operator =(structured_rna &&) noexcept = default;
77  ~structured_rna() noexcept = default;
78 
79  using base_type::base_type; // Inherit non-default constructors
80 
82  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna(component_type const alph) noexcept {} ))
84  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna(indirect_component_type const alph) noexcept {} ))
86  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna & operator=(component_type const alph) noexcept {} ))
88  SEQAN3_DOXYGEN_ONLY(( constexpr structured_rna & operator=(indirect_component_type const alph) noexcept {} ))
90 
91  // Inherit operators from base
92  using base_type::operator=;
93 
96 
98  constexpr structured_rna & assign_char(char_type const c) noexcept
99  {
100  seqan3::assign_char_to(c, get<0>(*this));
101  return *this;
102  }
104 
107 
109  constexpr char_type to_char() const noexcept
110  {
111  return seqan3::to_char(get<0>(*this));
112  }
113 
124  constexpr structured_rna complement() const noexcept
125  {
126  return structured_rna{get<0>(*this).complement(), get<1>(*this)};
127  }
129 
131  static constexpr bool char_is_valid(char_type const c) noexcept
132  {
133  return char_is_valid_for<sequence_alphabet_type>(c);
134  }
135 
138 
142  constexpr bool is_pair_open() const noexcept
143  {
144  return get<1>(*this).is_pair_open();
145  };
146 
150  constexpr bool is_pair_close() const noexcept
151  {
152  return get<1>(*this).is_pair_close();
153  };
154 
158  constexpr bool is_unpaired() const noexcept
159  {
160  return get<1>(*this).is_unpaired();
161  };
162 
165 
170  constexpr std::optional<uint8_t> pseudoknot_id() const noexcept
171  {
172  return get<1>(*this).pseudoknot_id();
173  };
175 };
176 
179 template <typename sequence_alphabet_type, typename structure_alphabet_type>
180 structured_rna(sequence_alphabet_type &&, structure_alphabet_type &&)
181  -> structured_rna<std::decay_t<sequence_alphabet_type>, std::decay_t<structure_alphabet_type>>;
182 
183 } // namespace seqan3
concept.hpp
Provides seqan3::rna_structure_alphabet.
seqan3::structured_rna::structured_rna
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:84
seqan3::structured_rna::structured_rna
constexpr structured_rna() noexcept=default
Defaulted.
concept.hpp
Provides seqan3::nucleotide_alphabet.
seqan3::alphabet_tuple_base
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the sam...
Definition: alphabet_tuple_base.hpp:120
seqan3::structured_rna::to_char
constexpr char_type to_char() const noexcept
Return a character. This reads the internal sequence letter.
Definition: structured_rna.hpp:109
seqan3::structured_rna::assign_char
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:98
seqan3::to_char
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: concept.hpp:320
seqan3::structured_rna::is_pair_open
constexpr bool is_pair_open() const noexcept
Check whether the character represents a rightward interaction in an RNA structure.
Definition: structured_rna.hpp:142
seqan3::structured_rna::is_pair_close
constexpr bool is_pair_close() const noexcept
Check whether the character represents a leftward interaction in an RNA structure.
Definition: structured_rna.hpp:150
seqan3::alphabet_char_t
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:329
seqan3::structured_rna::structure_alphabet_type
structure_alphabet_t structure_alphabet_type
Second template parameter as member type.
Definition: structured_rna.hpp:64
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
seqan3::structured_rna::max_pseudoknot_depth
static constexpr uint8_t max_pseudoknot_depth
The ability of this alphabet to represent pseudoknots, i.e. crossing interactions.
Definition: structured_rna.hpp:164
seqan3::structured_rna::pseudoknot_id
constexpr std::optional< uint8_t > pseudoknot_id() const noexcept
Get an identifier for a pseudoknotted interaction.
Definition: structured_rna.hpp:170
std::decay_t
seqan3::structured_rna::char_is_valid
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:131
seqan3::structured_rna
A seqan3::alphabet_tuple_base that joins a nucleotide alphabet with an RNA structure alphabet.
Definition: structured_rna.hpp:52
seqan3::structured_rna::complement
constexpr structured_rna complement() const noexcept
Return a structured_rna where the sequence letter is converted to its complement.
Definition: structured_rna.hpp:124
alphabet_tuple_base.hpp
Provides seqan3::alphabet_tuple_base.
seqan3::assign_char_to
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition: concept.hpp:416
std::optional
seqan3::max_pseudoknot_depth
constexpr auto max_pseudoknot_depth
A type trait that holds the ability of the structure alphabet to represent pseudoknots,...
Definition: concept.hpp:365
std::conditional_t
writable_alphabet
Refines seqan3::alphabet and adds assignability.
seqan3::structured_rna::sequence_alphabet_type
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: structured_rna.hpp:62
seqan3::structured_rna::is_unpaired
constexpr bool is_unpaired() const noexcept
Check whether the character represents an unpaired position in an RNA structure.
Definition: structured_rna.hpp:158