38 template <std::ranges::View urng_t>
42 NucleotideAlphabet<reference_t<urng_t>>
46 template <std::ranges::View urng_t>
50 NucleotideAlphabet<reference_t<urng_t>>
52 class view_translate_single;
96 template <
bool single>
107 return detail::adaptor_from_functor{*
this, tf};
115 template <std::ranges::Range urng_t>
116 constexpr
auto operator()(urng_t && urange,
translation_frames const tf = default_frames)
const 119 "The range parameter to view::translate[_single] cannot be a temporary of a non-view range.");
121 "The range parameter to view::translate[_single] must model std::ranges::SizedRange.");
123 "The range parameter to view::translate[_single] must model std::ranges::RandomAccessRange.");
125 "The range parameter to view::translate[_single] must be over elements of seqan3::NucleotideAlphabet.");
128 return detail::view_translate_single{std::forward<urng_t>(urange), tf};
130 return detail::view_translate{std::forward<urng_t>(urange), tf};
134 template <std::ranges::Range urng_t>
135 constexpr
friend auto operator|(urng_t && urange, translate_fn
const & me)
137 return me(std::forward<urng_t>(urange));
151 template <std::ranges::View urng_t>
157 class view_translate_single :
public ranges::view_base
165 static constexpr
small_string multiple_frame_error{
"Error: Invalid type of frame. Choose one out of FWD_FRAME_0, " 166 "REV_FRAME_0, FWD_FRAME_1, REV_FRAME_1, FWD_FRAME_2 and " 183 using iterator = detail::random_access_iterator<view_translate_single>;
185 using const_iterator = detail::random_access_iterator<view_translate_single const>;
191 view_translate_single() noexcept =
default;
192 constexpr view_translate_single(view_translate_single
const & rhs) noexcept =
default;
193 constexpr view_translate_single(view_translate_single && rhs) noexcept =
default;
194 constexpr view_translate_single & operator=(view_translate_single
const & rhs) noexcept =
default;
195 constexpr view_translate_single & operator=(view_translate_single && rhs) noexcept =
default;
196 ~view_translate_single() noexcept =
default;
208 : urange{std::move(_urange)}, tf{_tf}
210 if (__builtin_popcount(static_cast<uint8_t>(_tf)) > 1)
224 template <
typename rng_t>
231 : view_translate_single{
std::view::all(std::forward<rng_t>(_urange)), _tf}
251 iterator
begin() noexcept
257 const_iterator
begin()
const noexcept
263 const_iterator
cbegin()
const noexcept
281 iterator
end() noexcept
283 return {*
this,
size()};
287 const_iterator
end()
const noexcept
289 return {*
this,
size()};
293 const_iterator
cend()
const noexcept
385 return translate_triplet((urange)[n * 3], (urange)[n * 3 + 1], (urange)[n * 3 + 2]);
391 return translate_triplet((urange)[n * 3 + 1], (urange)[n * 3 + 2], (urange)[n * 3 + 3]);
397 return translate_triplet((urange)[n * 3 + 2], (urange)[n * 3 + 3], (urange)[n * 3 + 4]);
415 return translate_triplet((urange)[n * 3], (urange)[n * 3 + 1], (urange)[n * 3 + 2]);
421 return translate_triplet((urange)[n * 3 + 1], (urange)[n * 3 + 2], (urange)[n * 3 + 3]);
427 return translate_triplet((urange)[n * 3 + 2], (urange)[n * 3 + 3], (urange)[n * 3 + 4]);
441 template <
typename urng_t>
442 view_translate_single(urng_t &&,
translation_frames const) -> view_translate_single<std::ranges::all_view<urng_t>>;
446 template <
typename urng_t>
447 view_translate_single(urng_t &&) -> view_translate_single<std::ranges::all_view<urng_t>>;
526 template <std::ranges::View urng_t>
532 class view_translate :
public ranges::view_base
546 using reference = view_translate_single<urng_t>;
557 using iterator = detail::random_access_iterator<view_translate>;
559 using const_iterator = detail::random_access_iterator<view_translate const>;
569 template <
typename t>
570 requires (dimension_v<t> == dimension_v<value_type> + 1) &&
571 std::is_same_v<remove_cvref_t<innermost_value_type_t<value_type>>,
573 static constexpr
bool is_compatible_this_aux =
true;
582 view_translate() noexcept =
default;
583 constexpr view_translate(view_translate
const & rhs) noexcept =
default;
584 constexpr view_translate(view_translate && rhs) noexcept =
default;
585 constexpr view_translate & operator=(view_translate
const & rhs) noexcept =
default;
586 constexpr view_translate & operator=(view_translate && rhs) noexcept =
default;
587 ~view_translate() noexcept =
default;
594 : urange{std::move(_urange)}, tf{_tf}
597 selected_frames.push_back(translation_frames::FWD_FRAME_0);
599 selected_frames.push_back(translation_frames::FWD_FRAME_1);
601 selected_frames.push_back(translation_frames::FWD_FRAME_2);
603 selected_frames.push_back(translation_frames::REV_FRAME_0);
605 selected_frames.push_back(translation_frames::REV_FRAME_1);
607 selected_frames.push_back(translation_frames::REV_FRAME_2);
614 template <
typename rng_t>
621 : view_translate{
std::view::all(std::forward<rng_t>(_urange)), _tf}
641 iterator
begin() noexcept
647 const_iterator
begin()
const noexcept
653 const_iterator
cbegin()
const noexcept
671 iterator
end() noexcept
673 return {*
this,
size()};
677 const_iterator
end()
const noexcept
679 return {*
this,
size()};
683 const_iterator
cend()
const noexcept
702 return (
size_type) selected_frames.size();
708 return (
size_type) selected_frames.size();
745 template <
typename urng_t>
Provides seqan3::add_enum_bitwise_operators.
constexpr bool add_enum_bitwise_operators< translation_frames >
Enable bitwise operators for enum translation_frames.
Definition: translate.hpp:82
::ranges::cbegin cbegin
Alias for ranges::cbegin. Returns an iterator to the beginning of a range.
Definition: ranges:209
constexpr auto complement
Return the complement of a nucleotide object.
Definition: concept.hpp:104
constexpr auto translate_single
A view that translates nucleotide into aminoacid alphabet for one of the six frames.
Definition: translate.hpp:507
constexpr auto translate
A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames.
Definition: translate.hpp:811
decltype(view::all(declval< R >())) all_view
The type that would be returned by the std::view::all adaptor.
Definition: ranges:397
Provides seqan3::aa27, container aliases and string literals.
constexpr auto all
A view adaptor that behaves like std::view:all, but type erases contiguous ranges.
Definition: view_all.hpp:160
Provides the seqan3::detail::random_access_iterator class.
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
The main SeqAn3 namespace.
Provides seqan3::dna5, container aliases and string literals.
typename difference_type< t >::type difference_type_t
Shortcut for seqan3::difference_type (TransformationTrait shortcut).
Definition: pre.hpp:166
Implements a small string that can be used for compile time computations.
Definition: small_string.hpp:43
constexpr auto single
Given a value, produces a view that contains exactly one element.
Definition: ranges:756
The twenty-seven letter amino acid alphabet.
Definition: aa27.hpp:43
A concept that indicates whether an alphabet represents nucleotides.
Provides seqan3::view::deep.
Exposes the difference_type of another type.
Definition: pre.hpp:159
Auxiliary header for the view submodule .
Adaptations of concepts from the Ranges TS.
::ranges::begin begin
Alias for ranges::begin. Returns an iterator to the beginning of a range.
Definition: ranges:174
The first third and third reverse frame.
The SeqAn3 namespace for views.
Exposes the size_type of another type.
Definition: pre.hpp:188
The second forward and second reverse frame.
Specifies requirements of a Range type for which begin returns a type that models std::RandomAccessIt...
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
A constexpr vector implementation with dynamic size at compile time.
Definition: small_vector.hpp:47
Specifies the requirements of a Range type that is either a std::ranges::View or an lvalue-reference...
typename size_type< t >::type size_type_t
Shortcut for seqan3::size_type (TransformationTrait shortcut).
Definition: pre.hpp:195
The second forward frame starting at position 1.
Definition: aligned_sequence_concept.hpp:35
A constexpr string implementation to manipulate string literals at compile time.
auto operator|(validator1_type &&vali1, validator2_type &&vali2)
Enables the chaining of validators.
Definition: validators.hpp:889
Exposes the const_reference of another type.
Definition: pre.hpp:130
The first forward and first reverse frame.
A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view...
Definition: deep.hpp:101
Exposes the reference of another type.
Definition: pre.hpp:70
Provides various transformation traits used by the range module.
typename reference< t >::type reference_t
Shortcut for seqan3::reference (TransformationTrait shortcut).
Definition: pre.hpp:77
constexpr aa27 translate_triplet(nucl_type const &n1, nucl_type const &n2, nucl_type const &n3) noexcept
Translate one nucleotide triplet into single amino acid (single nucleotide interface).
Definition: translation.hpp:56
The third forward frame starting at position 2.
The first forward frame starting at position 0.
::ranges::cend cend
Alias for ranges::cend. Returns an iterator to the end of a range.
Definition: ranges:214
The second reverse frame starting at position 1.
Adaptations of concepts from the standard library.
Exposes the value_type of another type.
Definition: pre.hpp:41
Provides functions for translating a triplet of nucleotides into an amino acid.
Specifies the requirements of a Range type that knows its size in constant time with the size functio...
The first reverse frame starting at position 0.
translation_frames
Specialisation values for single and multiple translation frames.
Definition: translate.hpp:64
::ranges::end end
Alias for ranges::end. Returns an iterator to the end of a range.
Definition: ranges:179
The third reverse frame starting at position 2.
The std::Constructible concept specifies that a variable of type T can be initialized with the given ...