SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
alphabet/structure/concept.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <concepts>
13#include <optional>
14#include <type_traits>
15
18
19// ============================================================================
20// is_pair_open()
21// ============================================================================
22
23namespace seqan3::detail::adl_only
24{
25
27template <typename... args_t>
28void is_pair_open(args_t...) = delete;
29
33struct is_pair_open_cpo : public detail::customisation_point_object<is_pair_open_cpo, 2>
34{
36 using base_t = detail::customisation_point_object<is_pair_open_cpo, 2>;
38 using base_t::base_t;
39
44 template <typename alphabet_t>
45 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
46 /*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
47 );
48
53 template <typename alphabet_t>
54 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
55 /*return*/ is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
56 );
57
62 template <typename alphabet_t>
63 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
64 /*return*/ std::forward<alphabet_t>(alphabet).is_pair_open() == true /*;*/
65 );
66};
67
68} // namespace seqan3::detail::adl_only
69
70namespace seqan3
71{
103inline constexpr auto is_pair_open = detail::adl_only::is_pair_open_cpo{};
104
105} // namespace seqan3
106
107// ============================================================================
108// is_pair_close()
109// ============================================================================
110
111namespace seqan3::detail::adl_only
112{
113
115template <typename... args_t>
116void is_pair_close(args_t...) = delete;
117
121struct is_pair_close_cpo : public detail::customisation_point_object<is_pair_close_cpo, 2>
122{
124 using base_t = detail::customisation_point_object<is_pair_close_cpo, 2>;
126 using base_t::base_t;
127
132 template <typename alphabet_t>
133 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
134 /*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
135 );
136
141 template <typename alphabet_t>
142 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
143 /*return*/ is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
144 );
145
150 template <typename alphabet_t>
151 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
152 /*return*/ std::forward<alphabet_t>(alphabet).is_pair_close() == true /*;*/
153 );
154};
155
156} // namespace seqan3::detail::adl_only
157
158namespace seqan3
159{
191inline constexpr auto is_pair_close = detail::adl_only::is_pair_close_cpo{};
192
193} // namespace seqan3
194
195// ============================================================================
196// is_unpaired()
197// ============================================================================
198
199namespace seqan3::detail::adl_only
200{
201
203template <typename... args_t>
204void is_unpaired(args_t...) = delete;
205
209struct is_unpaired_cpo : public detail::customisation_point_object<is_unpaired_cpo, 2>
210{
212 using base_t = detail::customisation_point_object<is_unpaired_cpo, 2>;
214 using base_t::base_t;
215
220 template <typename alphabet_t>
221 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
222 /*return*/ seqan3::custom::alphabet<alphabet_t>::is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
223 );
224
229 template <typename alphabet_t>
230 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
231 /*return*/ is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
232 );
233
238 template <typename alphabet_t>
239 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
240 /*return*/ std::forward<alphabet_t>(alphabet).is_unpaired() == true /*;*/
241 );
242};
243
244} // namespace seqan3::detail::adl_only
245
246namespace seqan3
247{
279inline constexpr auto is_unpaired = detail::adl_only::is_unpaired_cpo{};
280
281} // namespace seqan3
282
283// ============================================================================
284// max_pseudoknot_depth
285// ============================================================================
286
287namespace seqan3::detail::adl_only
288{
289
291template <typename... args_t>
292void max_pseudoknot_depth(args_t...) = delete;
293
298template <typename alphabet_t>
299struct max_pseudoknot_depth_cpo : public detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>
300{
302 using base_t = detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>;
304 using base_t::base_t;
305
309 template <typename alphabet_type>
310 using alphabet_or_type_identity =
312 && seqan3::is_constexpr_default_constructible_v<std::remove_cvref_t<alphabet_type>>,
315
319 template <typename alphabet_type = alphabet_t>
320 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>)(
322 );
323
333 template <typename alphabet_type = alphabet_t>
334 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>)(
335 /*return*/ max_pseudoknot_depth(alphabet_or_type_identity<alphabet_type>{}) /*;*/
336 );
337
341 template <typename alphabet_type = alphabet_t>
342 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>)(
344 );
345};
346
347} // namespace seqan3::detail::adl_only
348
349namespace seqan3
350{
391template <typename alph_t>
392 requires requires {
393 { detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}() };
394 }
395inline constexpr auto max_pseudoknot_depth = detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}();
396
397} // namespace seqan3
398
399// ============================================================================
400// pseudoknot_id()
401// ============================================================================
402
403namespace seqan3::detail::adl_only
404{
405
407template <typename... args_t>
408void pseudoknot_id(args_t...) = delete;
409
412struct pseudoknot_id_cpo : public detail::customisation_point_object<pseudoknot_id_cpo, 2>
413{
415 using base_t = detail::customisation_point_object<pseudoknot_id_cpo, 2>;
417 using base_t::base_t;
418
423 template <typename alphabet_t>
424 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
425 /*return*/ seqan3::custom::alphabet<alphabet_t>::pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
426 );
427
432 template <typename alphabet_t>
433 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
434 /*return*/ pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
435 );
436
441 template <typename alphabet_t>
442 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
443 /*return*/ std::forward<alphabet_t>(alphabet).pseudoknot_id() /*;*/
444 );
445};
446
447} // namespace seqan3::detail::adl_only
448
449namespace seqan3
450{
484inline constexpr auto pseudoknot_id = detail::adl_only::pseudoknot_id_cpo{};
485
486} // namespace seqan3
487
488// ============================================================================
489// rna_structure_alphabet concept
490// ============================================================================
491
492namespace seqan3
493{
527template <typename t>
528concept rna_structure_alphabet = seqan3::alphabet<t> && requires (t val) {
529 { seqan3::is_pair_open(val) };
530 { seqan3::is_pair_close(val) };
531 { seqan3::is_unpaired(val) };
532 { seqan3::pseudoknot_id(val) };
533
534 // this is delegated to a static class variable, which must not be 0
535 requires seqan3::max_pseudoknot_depth<t> > 0;
536};
538
539} // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
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:104
constexpr auto is_unpaired
Check whether the given character represents an unpaired nucleotide in an RNA structure.
Definition alphabet/structure/concept.hpp:261
constexpr auto pseudoknot_id
Retrieve an id for the level of a pseudoknotted interaction (also known as 'page number').
Definition alphabet/structure/concept.hpp:454
constexpr auto is_pair_close
Check whether the given character represents a leftward interaction in an RNA structure.
Definition alphabet/structure/concept.hpp:179
constexpr auto max_pseudoknot_depth
A type trait that holds the ability of the structure alphabet to represent pseudoknots,...
Definition alphabet/structure/concept.hpp:371
constexpr auto is_pair_open
Check whether the given character represents a rightward interaction in an RNA structure.
Definition alphabet/structure/concept.hpp:97
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:26
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition alphabet/concept.hpp:46
Hide me