SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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 <optional>
16 
19 #include <seqan3/std/concepts>
20 #include <seqan3/std/type_traits>
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  (
50  /*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
51  );
52 
57  template <typename alphabet_t>
58  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)
59  (
60  /*return*/ is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
61  );
62 
67  template <typename alphabet_t>
68  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)
69  (
70  /*return*/ std::forward<alphabet_t>(alphabet).is_pair_open() == true /*;*/
71  );
72 };
73 
74 } // namespace seqan3::detail::adl_only
75 
76 namespace seqan3
77 {
78 
114 inline constexpr auto is_pair_open = detail::adl_only::is_pair_open_cpo{};
116 
117 } // namespace seqan3
118 
119 // ============================================================================
120 // is_pair_close()
121 // ============================================================================
122 
123 namespace seqan3::detail::adl_only
124 {
125 
127 template <typename ...args_t>
128 void is_pair_close(args_t ...) = delete;
129 
133 struct is_pair_close_cpo : public detail::customisation_point_object<is_pair_close_cpo, 2>
134 {
136  using base_t = detail::customisation_point_object<is_pair_close_cpo, 2>;
138  using base_t::base_t;
139 
144  template <typename alphabet_t>
145  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)
146  (
147  /*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
148  );
149 
154  template <typename alphabet_t>
155  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)
156  (
157  /*return*/ is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
158  );
159 
164  template <typename alphabet_t>
165  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)
166  (
167  /*return*/ std::forward<alphabet_t>(alphabet).is_pair_close() == true /*;*/
168  );
169 };
170 
171 } // namespace seqan3::detail::adl_only
172 
173 namespace seqan3
174 {
175 
211 inline constexpr auto is_pair_close = detail::adl_only::is_pair_close_cpo{};
213 
214 } // namespace seqan3
215 
216 // ============================================================================
217 // is_unpaired()
218 // ============================================================================
219 
220 namespace seqan3::detail::adl_only
221 {
222 
224 template <typename ...args_t>
225 void is_unpaired(args_t ...) = delete;
226 
230 struct is_unpaired_cpo : public detail::customisation_point_object<is_unpaired_cpo, 2>
231 {
233  using base_t = detail::customisation_point_object<is_unpaired_cpo, 2>;
235  using base_t::base_t;
236 
241  template <typename alphabet_t>
242  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)
243  (
244  /*return*/ seqan3::custom::alphabet<alphabet_t>::is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
245  );
246 
251  template <typename alphabet_t>
252  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)
253  (
254  /*return*/ is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
255  );
256 
261  template <typename alphabet_t>
262  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)
263  (
264  /*return*/ std::forward<alphabet_t>(alphabet).is_unpaired() == true /*;*/
265  );
266 };
267 
268 } // namespace seqan3::detail::adl_only
269 
270 namespace seqan3
271 {
272 
308 inline constexpr auto is_unpaired = detail::adl_only::is_unpaired_cpo{};
310 
311 } // namespace seqan3
312 
313 // ============================================================================
314 // max_pseudoknot_depth
315 // ============================================================================
316 
317 namespace seqan3::detail::adl_only
318 {
319 
321 template <typename ...args_t>
322 void max_pseudoknot_depth(args_t ...) = delete;
323 
328 template <typename alphabet_t>
329 struct max_pseudoknot_depth_cpo : public detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>
330 {
332  using base_t = detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>;
334  using base_t::base_t;
335 
339  template <typename alphabet_type>
340  using alphabet_or_type_identity
342  seqan3::is_constexpr_default_constructible_v<std::remove_cvref_t<alphabet_type>>,
345 
349  template <typename alphabet_type = alphabet_t>
350  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>)
351  (
353  );
354 
364  template <typename alphabet_type = alphabet_t>
365  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>)
366  (
367  /*return*/ max_pseudoknot_depth(alphabet_or_type_identity<alphabet_type>{}) /*;*/
368  );
369 
373  template <typename alphabet_type = alphabet_t>
374  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>)
375  (
377  );
378 };
379 
380 #if SEQAN3_WORKAROUND_GCC_89953
381 template <typename alph_t>
382  requires requires { { max_pseudoknot_depth_cpo<alph_t>{} }; }
383 inline constexpr auto max_pseudoknot_depth_obj = max_pseudoknot_depth_cpo<alph_t>{};
384 #endif // SEQAN3_WORKAROUND_GCC_89953
385 
386 } // namespace seqan3::detail::adl_only
387 
388 namespace seqan3
389 {
390 
435 #if SEQAN3_WORKAROUND_GCC_89953
436 template <typename alph_t>
438  requires requires { { detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{} }; } &&
439  requires { { detail::adl_only::max_pseudoknot_depth_obj<alph_t>() }; }
441 inline constexpr auto max_pseudoknot_depth = detail::adl_only::max_pseudoknot_depth_obj<alph_t>();
442 #else // ^^^ workaround / no workaround vvv
443 template <typename alph_t>
445  requires requires { { detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}() }; }
447 inline constexpr auto max_pseudoknot_depth = detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}();
448 #endif // SEQAN3_WORKAROUND_GCC_89953
449 
450 } // namespace seqan3
451 
452 // ============================================================================
453 // pseudoknot_id()
454 // ============================================================================
455 
456 namespace seqan3::detail::adl_only
457 {
458 
460 template <typename ...args_t>
461 void pseudoknot_id(args_t ...) = delete;
462 
465 struct pseudoknot_id_cpo : public detail::customisation_point_object<pseudoknot_id_cpo, 2>
466 {
468  using base_t = detail::customisation_point_object<pseudoknot_id_cpo, 2>;
470  using base_t::base_t;
471 
476  template <typename alphabet_t>
477  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)
478  (
479  /*return*/ seqan3::custom::alphabet<alphabet_t>::pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
480  );
481 
486  template <typename alphabet_t>
487  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)
488  (
489  /*return*/ pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
490  );
491 
496  template <typename alphabet_t>
497  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)
498  (
499  /*return*/ std::forward<alphabet_t>(alphabet).pseudoknot_id() /*;*/
500  );
501 };
502 
503 } // namespace seqan3::detail::adl_only
504 
505 namespace seqan3
506 {
507 
545 inline constexpr auto pseudoknot_id = detail::adl_only::pseudoknot_id_cpo{};
547 
548 } // namespace seqan3
549 
550 // ============================================================================
551 // rna_structure_alphabet concept
552 // ============================================================================
553 
554 namespace seqan3
555 {
589 template <typename t>
590 SEQAN3_CONCEPT rna_structure_alphabet = seqan3::alphabet<t> && requires(t val)
591 {
592  { seqan3::is_pair_open(val) };
593  { seqan3::is_pair_close(val) };
594  { seqan3::is_unpaired(val) };
595  { seqan3::pseudoknot_id(val) };
596 
597  // this is delegated to a static class variable, which must not be 0
598  requires seqan3::max_pseudoknot_depth<t> > 0;
599 };
601 
602 } // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
The Concepts 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:113
constexpr auto is_unpaired
Check whether the given character represents an unpaired nucleotide in an RNA structure.
Definition: concept.hpp:281
constexpr auto pseudoknot_id
Retrieve an id for the level of a pseudoknotted interaction (also known as 'page number').
Definition: concept.hpp:500
constexpr auto is_pair_close
Check whether the given character represents a leftward interaction in an RNA structure.
Definition: concept.hpp:193
constexpr auto max_pseudoknot_depth
A type trait that holds the ability of the structure alphabet to represent pseudoknots,...
Definition: concept.hpp:411
constexpr auto is_pair_open
Check whether the given character represents a rightward interaction in an RNA structure.
Definition: concept.hpp:105
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: concept.hpp:49
Provides C++20 additions to the type_traits header.