SeqAn3  3.2.0-rc.1
The Modern C++ library for sequence analysis.
alphabet/structure/concept.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 
15 #include <concepts>
16 #include <optional>
17 #include <type_traits>
18 
21 
22 // ============================================================================
23 // is_pair_open()
24 // ============================================================================
25 
26 namespace seqan3::detail::adl_only
27 {
28 
30 template <typename... args_t>
31 void is_pair_open(args_t...) = delete;
32 
36 struct is_pair_open_cpo : public detail::customisation_point_object<is_pair_open_cpo, 2>
37 {
39  using base_t = detail::customisation_point_object<is_pair_open_cpo, 2>;
41  using base_t::base_t;
42 
47  template <typename alphabet_t>
48  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
49  /*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
50  );
51 
56  template <typename alphabet_t>
57  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
58  /*return*/ is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
59  );
60 
65  template <typename alphabet_t>
66  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
67  /*return*/ std::forward<alphabet_t>(alphabet).is_pair_open() == true /*;*/
68  );
69 };
70 
71 } // namespace seqan3::detail::adl_only
72 
73 namespace seqan3
74 {
106 inline constexpr auto is_pair_open = detail::adl_only::is_pair_open_cpo{};
107 
108 } // namespace seqan3
109 
110 // ============================================================================
111 // is_pair_close()
112 // ============================================================================
113 
114 namespace seqan3::detail::adl_only
115 {
116 
118 template <typename... args_t>
119 void is_pair_close(args_t...) = delete;
120 
124 struct is_pair_close_cpo : public detail::customisation_point_object<is_pair_close_cpo, 2>
125 {
127  using base_t = detail::customisation_point_object<is_pair_close_cpo, 2>;
129  using base_t::base_t;
130 
135  template <typename alphabet_t>
136  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
137  /*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
138  );
139 
144  template <typename alphabet_t>
145  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
146  /*return*/ is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
147  );
148 
153  template <typename alphabet_t>
154  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
155  /*return*/ std::forward<alphabet_t>(alphabet).is_pair_close() == true /*;*/
156  );
157 };
158 
159 } // namespace seqan3::detail::adl_only
160 
161 namespace seqan3
162 {
194 inline constexpr auto is_pair_close = detail::adl_only::is_pair_close_cpo{};
195 
196 } // namespace seqan3
197 
198 // ============================================================================
199 // is_unpaired()
200 // ============================================================================
201 
202 namespace seqan3::detail::adl_only
203 {
204 
206 template <typename... args_t>
207 void is_unpaired(args_t...) = delete;
208 
212 struct is_unpaired_cpo : public detail::customisation_point_object<is_unpaired_cpo, 2>
213 {
215  using base_t = detail::customisation_point_object<is_unpaired_cpo, 2>;
217  using base_t::base_t;
218 
223  template <typename alphabet_t>
224  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
225  /*return*/ seqan3::custom::alphabet<alphabet_t>::is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
226  );
227 
232  template <typename alphabet_t>
233  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
234  /*return*/ is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
235  );
236 
241  template <typename alphabet_t>
242  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
243  /*return*/ std::forward<alphabet_t>(alphabet).is_unpaired() == true /*;*/
244  );
245 };
246 
247 } // namespace seqan3::detail::adl_only
248 
249 namespace seqan3
250 {
282 inline constexpr auto is_unpaired = detail::adl_only::is_unpaired_cpo{};
283 
284 } // namespace seqan3
285 
286 // ============================================================================
287 // max_pseudoknot_depth
288 // ============================================================================
289 
290 namespace seqan3::detail::adl_only
291 {
292 
294 template <typename... args_t>
295 void max_pseudoknot_depth(args_t...) = delete;
296 
301 template <typename alphabet_t>
302 struct max_pseudoknot_depth_cpo : public detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>
303 {
305  using base_t = detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>;
307  using base_t::base_t;
308 
312  template <typename alphabet_type>
313  using alphabet_or_type_identity =
315  && seqan3::is_constexpr_default_constructible_v<std::remove_cvref_t<alphabet_type>>,
316  std::remove_cvref_t<alphabet_type>,
317  std::type_identity<alphabet_type>>;
318 
322  template <typename alphabet_type = alphabet_t>
323  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>)(
325  );
326 
336  template <typename alphabet_type = alphabet_t>
337  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>)(
338  /*return*/ max_pseudoknot_depth(alphabet_or_type_identity<alphabet_type>{}) /*;*/
339  );
340 
344  template <typename alphabet_type = alphabet_t>
345  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>)(
346  /*return*/ std::remove_cvref_t<alphabet_type>::max_pseudoknot_depth /*;*/
347  );
348 };
349 
350 } // namespace seqan3::detail::adl_only
351 
352 namespace seqan3
353 {
394 template <typename alph_t>
396  {
397  detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}()
398  };
399  }
400 inline constexpr auto max_pseudoknot_depth = detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}();
401 
402 } // namespace seqan3
403 
404 // ============================================================================
405 // pseudoknot_id()
406 // ============================================================================
407 
408 namespace seqan3::detail::adl_only
409 {
410 
412 template <typename... args_t>
413 void pseudoknot_id(args_t...) = delete;
414 
417 struct pseudoknot_id_cpo : public detail::customisation_point_object<pseudoknot_id_cpo, 2>
418 {
420  using base_t = detail::customisation_point_object<pseudoknot_id_cpo, 2>;
422  using base_t::base_t;
423 
428  template <typename alphabet_t>
429  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
430  /*return*/ seqan3::custom::alphabet<alphabet_t>::pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
431  );
432 
437  template <typename alphabet_t>
438  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
439  /*return*/ pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
440  );
441 
446  template <typename alphabet_t>
447  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
448  /*return*/ std::forward<alphabet_t>(alphabet).pseudoknot_id() /*;*/
449  );
450 };
451 
452 } // namespace seqan3::detail::adl_only
453 
454 namespace seqan3
455 {
489 inline constexpr auto pseudoknot_id = detail::adl_only::pseudoknot_id_cpo{};
490 
491 } // namespace seqan3
492 
493 // ============================================================================
494 // rna_structure_alphabet concept
495 // ============================================================================
496 
497 namespace seqan3
498 {
532 template <typename t>
534  {
536  };
537  {
539  };
540  {
542  };
543  {
545  };
546 
547  // this is delegated to a static class variable, which must not be 0
548  requires seqan3::max_pseudoknot_depth<t> > 0;
549  };
551 
552 } // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
The <concepts> header from C++20's standard library.
Helper utilities for defining customisation point objects (CPOs).
#define SEQAN3_CPO_OVERLOAD(...)
A macro that helps to define a seqan3::detail::customisation_point_object.
Definition: customisation_point.hpp:107
constexpr auto is_unpaired
Check whether the given character represents an unpaired nucleotide in an RNA structure.
Definition: alphabet/structure/concept.hpp:264
constexpr auto pseudoknot_id
Retrieve an id for the level of a pseudoknotted interaction (also known as 'page number').
Definition: alphabet/structure/concept.hpp:459
constexpr auto is_pair_close
Check whether the given character represents a leftward interaction in an RNA structure.
Definition: alphabet/structure/concept.hpp:182
constexpr auto is_pair_open
Check whether the given character represents a rightward interaction in an RNA structure.
Definition: alphabet/structure/concept.hpp:100
requires requires
The rank_type of the semi-alphabet; defined as the return type of seqan3::to_rank....
Definition: alphabet/concept.hpp:164
The generic alphabet concept that covers most data types used in ranges.
A concept that indicates whether an alphabet represents RNA structure.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition: alphabet/concept.hpp:49