26namespace bio::ranges::detail
31struct reverse_complement_or_not_fn
35 static auto func_nop(
auto && urange,
size_t pos) {
return urange[pos]; }
38 static auto func_revcomp(
auto && urange,
size_t pos)
45 constexpr auto operator()(
bool const transform)
const {
return detail::adaptor_from_functor{*
this,
transform}; }
52 template <std::ranges::range urng_t>
53 constexpr auto operator()(urng_t && urange,
bool const transform)
const
55 static_assert(std::ranges::viewable_range<urng_t>,
56 "The range parameter to views::reverse_complement_or_not cannot be a temporary of a non-view "
58 static_assert(std::ranges::sized_range<urng_t>,
59 "The range parameter to views::reverse_complement_or_not must model std::ranges::sized_range.");
60 static_assert(std::ranges::random_access_range<urng_t>,
61 "The range parameter to views::reverse_complement_or_not must model "
62 "std::ranges::random_access_range.");
63 static_assert(alphabet::nucleotide<std::ranges::range_reference_t<urng_t>>,
64 "The range parameter to views::reverse_complement_or_not must be over elements of "
65 "bio::alphabet::nucleotide.");
67 auto l = &func_nop<std::views::all_t<urng_t>
const &>;
69 l = &func_revcomp<std::views::all_t<urng_t>
const &>;
122inline constexpr auto reverse_complement_or_not = views::deep{reverse_complement_or_not_fn{}};
130class add_reverse_complement_fn :
public detail::adaptor_base<add_reverse_complement_fn>
134 using base_type = detail::adaptor_base<add_reverse_complement_fn>;
143 template <std::ranges::range urng_t>
144 static auto impl(urng_t && urange)
146 static_assert(range_dimension_v<urng_t> == 2,
147 "This adaptor only handles range-of-range (two dimensions) as input.");
148 static_assert(std::ranges::viewable_range<urng_t>,
149 "The range parameter to views::add_reverse_complement cannot be a temporary of a non-view "
151 static_assert(std::ranges::viewable_range<std::ranges::range_reference_t<urng_t>>,
152 "The inner range of the range parameter to views::add_reverse_complement cannot be a temporary "
154 "a non-view range.");
155 static_assert(std::ranges::sized_range<urng_t>,
156 "The range parameter to views::add_reverse_complement must model std::ranges::sized_range.");
157 static_assert(std::ranges::sized_range<std::ranges::range_reference_t<urng_t>>,
158 "The inner range of the range parameter to views::add_reverse_complement must model "
159 "std::ranges::sized_range.");
160 static_assert(std::ranges::random_access_range<urng_t>,
161 "The range parameter to views::add_reverse_complement must model "
162 "std::ranges::random_access_range.");
163 static_assert(std::ranges::random_access_range<std::ranges::range_reference_t<urng_t>>,
164 "The inner range of the range parameter to views::add_reverse_complement must model "
165 "std::ranges::random_access_range.");
166 static_assert(alphabet::nucleotide<std::ranges::range_reference_t<std::ranges::range_reference_t<urng_t>>>,
167 "The range parameter to views::add_reverse_complement must be over elements of "
168 "bio::alphabet::nucleotide.");
170 return std::forward<urng_t>(urange) |
172 {
return urange[pos / 2] | reverse_complement_or_not(pos % 2 == 1); },
173 [](
auto && urange) {
return std::ranges::size(urange) * 2; });
181 constexpr add_reverse_complement_fn() =
default;
183 constexpr add_reverse_complement_fn(add_reverse_complement_fn
const &)
noexcept =
default;
185 constexpr add_reverse_complement_fn(add_reverse_complement_fn &&) noexcept = default;
187 constexpr add_reverse_complement_fn & operator=(add_reverse_complement_fn const &) noexcept = default;
189 constexpr add_reverse_complement_fn & operator=(add_reverse_complement_fn &&) noexcept = default;
191 ~add_reverse_complement_fn() noexcept = default;
194 using base_type::base_type;
204namespace
bio::ranges::views
Provides bio::alphabet::nucleotide.
Provides bio::views::deep.
constexpr auto complement
Return the complement of a nucleotide object.
Definition: concept.hpp:68
constexpr auto transform_by_pos
A view adaptor similar to std::views::transform. Calls the invocable with two arguments: underlying r...
Definition: transform_by_pos.hpp:313
constexpr auto add_reverse_complement
A view that adds the reverse complement of every inner range in a range-of-ranges after the respectiv...
Definition: add_reverse_complement.hpp:253
The main BioC++ namespace.
Definition: aa10li.hpp:23