Loading...
Searching...
No Matches
alphabet/structure/concept.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <concepts>
#include <optional>
#include <type_traits>
#include <seqan3/alphabet/concept.hpp>
#include <seqan3/core/detail/customisation_point.hpp>
// ============================================================================
// is_pair_open()
// ============================================================================
namespace seqan3::detail::adl_only
{
template <typename... args_t>
void is_pair_open(args_t...) = delete;
struct is_pair_open_cpo : public detail::customisation_point_object<is_pair_open_cpo, 2>
{
using base_t = detail::customisation_point_object<is_pair_open_cpo, 2>;
using base_t::base_t;
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
/*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
/*return*/ is_pair_open(std::forward<alphabet_t>(alphabet)) == true /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
/*return*/ std::forward<alphabet_t>(alphabet).is_pair_open() == true /*;*/
);
};
} // namespace seqan3::detail::adl_only
namespace seqan3
{
inline constexpr auto is_pair_open = detail::adl_only::is_pair_open_cpo{};
} // namespace seqan3
// ============================================================================
// is_pair_close()
// ============================================================================
namespace seqan3::detail::adl_only
{
template <typename... args_t>
void is_pair_close(args_t...) = delete;
struct is_pair_close_cpo : public detail::customisation_point_object<is_pair_close_cpo, 2>
{
using base_t = detail::customisation_point_object<is_pair_close_cpo, 2>;
using base_t::base_t;
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
/*return*/ seqan3::custom::alphabet<alphabet_t>::is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
/*return*/ is_pair_close(std::forward<alphabet_t>(alphabet)) == true /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
/*return*/ std::forward<alphabet_t>(alphabet).is_pair_close() == true /*;*/
);
};
} // namespace seqan3::detail::adl_only
namespace seqan3
{
inline constexpr auto is_pair_close = detail::adl_only::is_pair_close_cpo{};
} // namespace seqan3
// ============================================================================
// is_unpaired()
// ============================================================================
namespace seqan3::detail::adl_only
{
template <typename... args_t>
void is_unpaired(args_t...) = delete;
struct is_unpaired_cpo : public detail::customisation_point_object<is_unpaired_cpo, 2>
{
using base_t = detail::customisation_point_object<is_unpaired_cpo, 2>;
using base_t::base_t;
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
/*return*/ seqan3::custom::alphabet<alphabet_t>::is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
/*return*/ is_unpaired(std::forward<alphabet_t>(alphabet)) == true /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
/*return*/ std::forward<alphabet_t>(alphabet).is_unpaired() == true /*;*/
);
};
} // namespace seqan3::detail::adl_only
namespace seqan3
{
inline constexpr auto is_unpaired = detail::adl_only::is_unpaired_cpo{};
} // namespace seqan3
// ============================================================================
// max_pseudoknot_depth
// ============================================================================
namespace seqan3::detail::adl_only
{
template <typename... args_t>
void max_pseudoknot_depth(args_t...) = delete;
template <typename alphabet_t>
struct max_pseudoknot_depth_cpo : public detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>
{
using base_t = detail::customisation_point_object<max_pseudoknot_depth_cpo<alphabet_t>, 2>;
using base_t::base_t;
template <typename alphabet_type>
using alphabet_or_type_identity =
std::conditional_t<std::is_nothrow_default_constructible_v<std::remove_cvref_t<alphabet_type>>
&& seqan3::is_constexpr_default_constructible_v<std::remove_cvref_t<alphabet_type>>,
std::remove_cvref_t<alphabet_type>,
std::type_identity<alphabet_type>>;
template <typename alphabet_type = alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>)(
/*return*/ seqan3::custom::alphabet<alphabet_type>::max_pseudoknot_depth /*;*/
);
template <typename alphabet_type = alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>)(
/*return*/ max_pseudoknot_depth(alphabet_or_type_identity<alphabet_type>{}) /*;*/
);
template <typename alphabet_type = alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>)(
/*return*/ std::remove_cvref_t<alphabet_type>::max_pseudoknot_depth /*;*/
);
};
} // namespace seqan3::detail::adl_only
namespace seqan3
{
template <typename alph_t>
requires requires {
{ detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}() };
}
inline constexpr auto max_pseudoknot_depth = detail::adl_only::max_pseudoknot_depth_cpo<alph_t>{}();
} // namespace seqan3
// ============================================================================
// pseudoknot_id()
// ============================================================================
namespace seqan3::detail::adl_only
{
template <typename... args_t>
void pseudoknot_id(args_t...) = delete;
struct pseudoknot_id_cpo : public detail::customisation_point_object<pseudoknot_id_cpo, 2>
{
using base_t = detail::customisation_point_object<pseudoknot_id_cpo, 2>;
using base_t::base_t;
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
/*return*/ seqan3::custom::alphabet<alphabet_t>::pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
/*return*/ pseudoknot_id(std::forward<alphabet_t>(alphabet)) /*;*/
);
template <typename alphabet_t>
static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
/*return*/ std::forward<alphabet_t>(alphabet).pseudoknot_id() /*;*/
);
};
} // namespace seqan3::detail::adl_only
namespace seqan3
{
inline constexpr auto pseudoknot_id = detail::adl_only::pseudoknot_id_cpo{};
} // namespace seqan3
// ============================================================================
// rna_structure_alphabet concept
// ============================================================================
namespace seqan3
{
template <typename t>
concept rna_structure_alphabet = seqan3::alphabet<t> && requires (t val) {
{ seqan3::is_pair_open(val) };
{ seqan3::is_pair_close(val) };
{ seqan3::is_unpaired(val) };
{ seqan3::pseudoknot_id(val) };
// this is delegated to a static class variable, which must not be 0
requires seqan3::max_pseudoknot_depth<t> > 0;
};
} // namespace seqan3
concept.hpp
Core alphabet concept and free function/type trait wrappers.
customisation_point.hpp
Helper utilities for defining customisation point objects (CPOs).
SEQAN3_CPO_OVERLOAD
#define SEQAN3_CPO_OVERLOAD(...)
A macro that helps to define a seqan3::detail::customisation_point_object.
Definition customisation_point.hpp:106
std::forward
T forward(T... args)
seqan3::is_unpaired
constexpr auto is_unpaired
Check whether the given character represents an unpaired nucleotide in an RNA structure.
Definition alphabet/structure/concept.hpp:261
seqan3::pseudoknot_id
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
seqan3::is_pair_close
constexpr auto is_pair_close
Check whether the given character represents a leftward interaction in an RNA structure.
Definition alphabet/structure/concept.hpp:179
seqan3::max_pseudoknot_depth
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
seqan3::is_pair_open
constexpr auto is_pair_open
Check whether the given character represents a rightward interaction in an RNA structure.
Definition alphabet/structure/concept.hpp:97
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
optional
type_traits
Hide me