BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
Views

Views are "lazy range combinators" that offer modified views onto other ranges. More...

+ Collaboration diagram for Views:

Files

file  detail.hpp
 Auxiliary header for the views submodule .
 

Namespaces

namespace  bio::ranges::views
 The BioC++ namespace for views.
 

Classes

class  bio::ranges::views::deep< underlying_adaptor_t >
 A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view. More...
 

Typedefs

template<alphabet::alphabet alph_t>
using bio::ranges::views::char_conversion_view_t = decltype(std::string_view{}|bio::views::char_strictly_to< alph_t >)
 A shortcut for decltype(std::string_view{} | bio::views::char_strictly_to<alph_t>).
 

Alphabet related views

constexpr auto bio::ranges::views::add_reverse_complement
 A view that adds the reverse complement of every inner range in a range-of-ranges after the respective inner range.
 
template<typename alphabet_type >
auto const bio::ranges::views::char_strictly_to
 A view over an alphabet, given a range of characters.
 
template<typename alphabet_type >
constexpr auto bio::ranges::views::char_to
 A view over an alphabet, given a range of characters.
 
auto const bio::ranges::views::complement
 A view that converts a range of nucleotides to their complement.
 
template<typename alphabet_type >
auto const bio::ranges::views::rank_to
 A view over an alphabet, given a range of ranks.
 
auto const bio::ranges::views::to_char
 A view that calls bio::alphabet::to_char() on each element in the input range.
 
auto const bio::ranges::views::to_rank
 A view that calls bio::alphabet::to_rank() on each element in the input range.
 
constexpr auto bio::ranges::views::translate
 A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames.
 
constexpr auto bio::ranges::views::translate_join
 A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames. Input and output range are always two-dimensional.
 
constexpr auto bio::ranges::views::translate_single
 A view that translates nucleotide into aminoacid alphabet for one of the six frames.
 
constexpr auto bio::ranges::views::trim_quality
 A view that does quality-threshold trimming on a range of bio::alphabet::quality.
 
template<alphabet::alphabet alphabet_type>
auto const bio::ranges::views::validate_char_for
 An identity view that throws if an encountered character is not valid for the given alphabet.
 

General purpose views

template<typename out_t >
auto const bio::ranges::views::convert
 A view that converts each element in the input range (implicitly or via static_cast).
 
constexpr auto bio::ranges::views::interleave
 A view that interleaves a given range into another range at regular intervals.
 
constexpr auto bio::ranges::views::pairwise_combine
 A view adaptor that generates all pairwise combinations of the elements of the underlying range.
 
constexpr auto bio::ranges::views::persist
 A view adaptor that wraps rvalue references of non-views.
 
constexpr detail::repeat_fn bio::ranges::views::repeat
 A view factory that repeats a given value infinitely.
 
constexpr auto bio::ranges::views::repeat_n
 A view factory that repeats a given value n times.
 
constexpr auto bio::ranges::views::single_pass_input
 A view adapter that decays most of the range properties and adds single pass behavior.
 
constexpr auto bio::ranges::views::slice
 A view adaptor that returns a half-open interval on the underlying range.
 
constexpr auto bio::ranges::views::take_exactly
 A view adaptor that returns the first size elements from the underlying range (or less if the underlying range is shorter); also provides size information.
 
constexpr auto bio::ranges::views::take_exactly_or_throw
 A view adaptor that returns the first size elements from the underlying range and also exposes size information; throws if the underlying range is smaller than size.
 
auto const bio::ranges::views::to_lower
 A view that converts each element to lower case.
 
auto const bio::ranges::views::to_upper
 A view that converts each element to upper case.
 
constexpr auto bio::ranges::views::transform_by_pos
 A view adaptor similar to std::views::transform. Calls the invocable with two arguments: underlying range and position.
 
constexpr auto bio::ranges::views::type_reduce
 A view adaptor that behaves like std::views::all, but type erases certain ranges.
 

Detailed Description

Views are "lazy range combinators" that offer modified views onto other ranges.

BioC++ makes heavy use of views as defined in the Ranges Technical Specification. From the original documentation: "A view is a lightweight wrapper that presents a view of an underlying sequence of elements in some custom way without mutating or copying it. Views are cheap to create and copy, and have non-owning reference semantics. [...] The big advantage of ranges over iterators is their composability. They permit a functional style of programming where data is manipulated by passing it through a series of combinators. In addition, the combinators can be lazy, only doing work when the answer is requested, and purely functional, without mutating the original data. This makes it easier to reason about your code, especially when writing concurrent programs."

See the range module for how views relate to containers and decorators.

Most views provided by BioC++ are specific to biological operations, like bio::views::trim_quality which trims sequences based on the quality or bio::views::complement which generates the complement of a nucleotide sequence. But BioC++ also provides some general purpose views.

Namespaces

Example

Functional and pipe notations:

int main()
{
using namespace bio::alphabet::literals;
// these are synonymous:
auto vec_view1 = vec | bio::views::complement;
auto vec_view2 = bio::views::complement(vec);
// both views "behave" like a collection of the elements 'T', 'G', 'C', 'C', 'A', 'G'
// but can be copied cheaply et cetera
}
Provides bio::views::complement.
Provides bio::alphabet::dna4, container aliases and string literals.
An inline namespace for alphabet literals. It exists to safely allow using namespace.
Definition: aa10li.hpp:183

Re-transform into a distinct container:

#include <ranges>
int main()
{
using namespace bio::alphabet::literals;
auto vec_view2 = bio::views::complement(vec);
// re-convert to container
std::vector<bio::alphabet::dna4> complemented = vec_view2 | bio::ranges::to<std::vector<bio::alphabet::dna4>>();
assert(complemented == "TGCCAG"_dna4);
// also possible in one step
std::vector<bio::alphabet::dna4> reversed = vec | std::views::reverse | bio::ranges::to<std::vector<bio::alphabet::dna4>>();
assert(reversed == "CTGGCA"_dna4);
}
An implementation of C++23's std::ranges::to.

Composability:

#include <ranges>
int main()
{
using namespace bio::alphabet::literals;
// views can be composed iteratively
auto vec_view3 = vec | std::views::reverse;
auto vec_view4 = vec_view3 | bio::views::complement;
// or in one line similar to the unix command line
auto vec_view5 = vec | bio::views::complement | std::views::reverse;
// vec_view4 and vec_view5 are the reverse complement of "ACGGTC": "GACCGT"
}

Views vs view adaptors

When talking about views, two different entities are often conflated:

  1. the view (this is the type that is a range and meets std::ranges::view; it is what we refer to with auto vec_view above)
  2. the view adaptor (this is the functor that returns the actual view based on it's parameters, including the underlying range; in the above example views::reverse and views::complement are view adaptors)

The view adaptor also facilitates the piping behaviour. It is the only entity that is publicly documented and the actual view type (the range type returned by the adaptor) is considered implementation defined. The properties of the returned range are however specified and documented as part of the adaptor, see below.

An exception to this rule are views that don't work on an underlying range and can only be placed at the beginning of a pipe of operations; they do not need an adaptor, because their constructor is sufficient. This is not relevant for the documentation, though, we always document views::foo, independent of whether views::foo is the adaptor that returns the "foo type" or whether views::foo is the "foo type".

View properties

There are three view properties that are documented for a view, only if that view fulfills them:

Source-only views: Most views operate on an underlying range and return a (modified) range, i.e. they can be placed at the beginning, middle or end of a "pipe" of view operations. However, some views are limited to being at the front ("source"), e.g. std::views::single, ranges::view::concat and std::views::ints. These views are marked as "source-only" and have no urng_t column in the second table.

Sink-only views: The opposite of a source-only view. It can only be placed at the end of a pipe, i.e. it operates on views, but does not actually return a range (has no rrng_t column in the second table).

Deep views: Some views are declared as "deeps views". This means, that in case they are given a range-of-range as input (as opposed to just a range), they will apply their transformation on the innermost range (instead of the outermost range which would be default). Most alphabet-based transformations are defined as deep, but you can use bio::views::deep to make any view (adaptor) deep. See bio::views::deep for more details.

For all views the following are documented:

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range [required] (usually) [preserved|lost|guaranteed] (usually preserved)
std::ranges::forward_range [required] (or not) [preserved|lost|guaranteed]
std::ranges::bidirectional_range [required] (or not) [preserved|lost|guaranteed]
std::ranges::random_access_range [required] (or not) [preserved|lost|guaranteed]
std::ranges::contiguous_range [required] (or not) [preserved|lost|guaranteed] (usually lost)
std::ranges::viewable_range [required] (usually) [preserved|lost|guaranteed] (usually guaranteed)
std::ranges::view [required] (or not) [preserved|lost|guaranteed] (usually guaranteed)
std::ranges::sized_range [required] (or not) [preserved|lost|guaranteed]
std::ranges::common_range [required] (or not) [preserved|lost|guaranteed]
std::ranges::output_range [required] (or not) [preserved|lost|guaranteed]
bio::ranges::const_iterable_range [required] (or not) [preserved|lost]
std::ranges::range_reference_t optionally a type or concept optionally a type or concept

Underlying range requirements: All view adaptors that are not source-only make certain assumptions about their underlying range. The most basic assumption is that the range satisfies std::ranges::input_range, but many have stronger requirements, e.g. std::ranges::random_access_range. The concepts in the first block all build up on each other, i.e. requiring one implies requiring those above; the other concepts are mostly independent of each other. Most views also require that the underlying range satisfy std::ranges::viewable_range which means they don't accept temporary range objects other than views (because they are cheap to copy). A prominent exception to the latter is views::persist that exists exactly for this purpose. Note that these being requirements means that they are the minimal set of properties assumed. Views may very well make use of stronger properties if available.

Return range guarantees: All view adaptors that are not sink-only return a range that meets at least std::ranges::input_range and also std::ranges::view (and conversely also std::ranges::viewable_range, because all views are viewable). Most views also preserve stronger properties, e.g. std::ranges::random_access_range, but this depends on the view. Some views also add properties not present on the input range, e.g. the range returned by std::views::take_exactly meets std::ranges::sized_range, independent of whether this was met by the input range.

Underlying range's reference type: The reference type is the type the elements of the underlying range are accessed by (since dereferencing an iterator or calling operator[] returns the reference type). The reference type may or may not actually contain a & (see below). For many BioC++ specific views additional concept requirements are defined for the input range's reference type, e.g. bio::views::complement can only operate on ranges whose elements are nucleotides (meet bio::alphabet::nucleotide_check). In some case the type may even be a specific type or the result of a type trait.

Returned range's reference type: Conversely certain views make guarantees on the concepts satisfied by the return range's reference type or even always have a fixed type, e.g. bio::views::complement operates on nucleotides and of course also returns nucleotides and "std::ranges::range_reference_t<urng_t>" would imply that the reference type is the same. However, and this is important to note, the reference type of bio::views::complement has any actual & removed from the underlying ranges' reference type (if originally present), this goes hand-in-hand with std::ranges::output_range being lost → original elements cannot be written to through this view. This is because new elements are being generated. Other views like views::reverse also preserve the & (if originally present), because the elements in the return view still point to the elements in the original range (just in different order). This has the effect that through some combinations of views you can modify the elements in the original range (if all views in the pipe preserve std::ranges::output_range), but through others you can't.

See also
https://ericniebler.github.io/range-v3/index.html#range-views

Variable Documentation

◆ add_reverse_complement

constexpr auto bio::ranges::views::add_reverse_complement
inlineconstexpr

A view that adds the reverse complement of every inner range in a range-of-ranges after the respective inner range.

Template Parameters
urng_tThe type of the range being processed.
Parameters
[in]urangeThe range being processed.
Returns
A range that contains the original as well as the reverse complemented inner ranges. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/add_reverse_complement.hpp>

This view adds the reverse complement of each inner range. The resulting output range is twice as large as the input range.

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range required preserved
std::ranges::random_access_range required preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range required preserved
std::ranges::common_range guaranteed
std::ranges::output_range lost
bio::ranges::const_iterable_range required preserved
std::ranges::range_reference_t bio::alphabet::alphabet::nucleotide std::remove_reference_t<std::ranges::range_reference_t<urng_t>>
  • urng_t is the type of the range modified by this view (input).
  • rrng_type is the type of the range returned by this view.
  • for more details, see Views.

Example

Operating on a range of bio::alphabet::dna5:

#include <ranges>
#include <vector>
int main()
{
using namespace bio::alphabet::literals;
std::vector<std::vector<bio::alphabet::dna5>> vec{{"ACGTACGTACGTA"_dna5},
{"TCGAGAGCTTTAGC"_dna5}};
// pipe notation
auto v1 = vec | bio::views::add_reverse_complement;
// == [ACGTACGTACGTA, TACGTACGTACGT, TCGAGAGCTTTAGC, GCTAAAGCTCTCGA]
// function notation
auto v2(bio::views::add_reverse_complement(vec));
// == [ACGTACGTACGTA, TACGTACGTACGT, TCGAGAGCTTTAGC, GCTAAAGCTCTCGA]
// combinability
auto v3 = vec | bio::views::complement | bio::views::add_reverse_complement;
// == [TGCATGCATGCAT, ATGCATGCATGCA, AGCTCTCGAAATCG, CGATTTCGAGAGCT]
}
Provides bio::views::add_reverse_complement.
Provides bio::alphabet::dna5, container aliases and string literals.

◆ char_strictly_to

template<typename alphabet_type >
auto const bio::ranges::views::char_strictly_to
inline

A view over an alphabet, given a range of characters.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
alphabet_tThe alphabet to convert to; must satisfy bio::alphabet::alphabet.
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.
Exceptions
bio::alphabet::invalid_char_assignmentif an invalid character is encountered.

Header File

#include <bio/ranges/views/char_strictly_to.hpp>

This adaptor returns a view that transforms strings into ranges over alphabet_t.

This view differs from bio::ranges::views::char_to in that it throws an exception if an invalid character conversion happens. See bio::alphabet::assign_char_strictly_to for more details.

View properties (generic case)

This view is a deep view: Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
std::ranges::borrowed_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::char_t<alphabet_t> alphabet_t

See the views submodule documentation for detailed descriptions of the view properties.

View properties (NOOP case)

If a range is given whose value_type is the same its alphabet type (e.g. std::string), a simple view to the range is returned and no transformation happens. See bio::ranges::views::type_reduce.

View properties (bio::alphabet::cigar)

This range adaptor can be applied to ranges over bio::alphabet::cigar (although that type does not model bio::alphabet::alphabet). The returned view is weaker than in the generic case, and it is not a deep view.

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range lost
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range lost
std::ranges::common_range preserved
std::ranges::output_range lost
std::ranges::borrowed_range preserved
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t char bio::alphabet::cigar

Since this transformation comes with noticeable overhead anyway, this conversion is always strict, i.e. bio::views::char_to<bio::alphabet::cigar> and bio::views::char_strictly_to<bio::alphabet::cigar> are identical.

Example

int main()
{
std::string_view str{"ACTTTGATAN"};
try
{
fmt::print("{}", str | bio::ranges::views::char_strictly_to<bio::alphabet::dna4>); // ACTTTGATA
}
{
fmt::print("\n[ERROR] Invalid char!\n"); // Will throw on parsing 'N'
}
}
Provides bio::ranges::views::char_strictly_to.
Core alphabet concept and free function/type trait wrappers.
An exception typically thrown by bio::alphabet::assign_char_strict.
Definition: exception.hpp:27

◆ char_to

template<typename alphabet_type >
constexpr auto bio::ranges::views::char_to
inlineconstexpr

A view over an alphabet, given a range of characters.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
alphabet_tThe alphabet to convert to; must satisfy bio::alphabet::alphabet.
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/char_to.hpp>

This adaptor returns a view that transforms strings into ranges over alphabet_t.

View properties (generic case)

This view is a deep view: Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
std::ranges::borrowed_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::char_t<alphabet_t> alphabet_t

See the views submodule documentation for detailed descriptions of the view properties.

View properties (NOOP case)

If a range is given whose value_type is the same its alphabet type (e.g. std::string), a simple view to the range is returned and no transformation happens. See bio::ranges::views::type_reduce.

View properties (bio::alphabet::cigar)

This range adaptor can be applied to ranges over bio::alphabet::cigar (although that type does not model bio::alphabet::alphabet). The returned view is weaker than in the generic case, and it is not a deep view.

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range lost
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range lost
std::ranges::common_range preserved
std::ranges::output_range lost
std::ranges::borrowed_range preserved
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t char bio::alphabet::cigar

Since this transformation comes with noticeable overhead anyway, this conversion is always strict, i.e. bio::views::char_to<bio::alphabet::cigar> and bio::views::char_strictly_to<bio::alphabet::cigar> are identical.

Example

#include <string>
int main()
{
std::string s{"ACTTTGATAN"};
auto v1 = s | bio::views::char_to<bio::alphabet::dna4>; // == "ACTTTGATAA"_dna4
auto v2 = s | bio::views::char_to<bio::alphabet::dna5>; // == "ACTTTGATAN"_dna5
}
Provides bio::views::char_to.

◆ complement

auto const bio::ranges::views::complement
inline

A view that converts a range of nucleotides to their complement.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/complement.hpp>

Calls bio::alphabet::nucleotide::complement() on every element of the input range.

View properties

This view is a deep view Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::nucleotide std::remove_reference_t<std::ranges::range_reference_t<urng_t>>

See the views submodule documentation for detailed descriptions of the view properties.

Example

#include <ranges>
int main()
{
using namespace bio::alphabet::literals;
// pipe notation
auto v = foo | bio::views::complement; // == "TGCAT"
// function notation
auto v2(bio::views::complement(foo)); // == "TGCAT"
// generate the reverse complement:
auto v3 = foo | bio::views::complement | std::views::reverse; // == "TACGT"
}

◆ convert

template<typename out_t >
auto const bio::ranges::views::convert

A view that converts each element in the input range (implicitly or via static_cast).

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/convert.hpp>

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost¹
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost¹
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::convertible_to<out_t> out_t

¹ These are preserved if out_t is the same as std::ranges::range_reference_t<urng_t>, i.e. no conversion takes place.

See the views submodule documentation for detailed descriptions of the view properties.

Example

Convert from int to bool:

#include <vector>
#include <ranges>
int main()
{
// convert from int to bool
std::vector<int> vec{7, 5, 0, 5, 0, 0, 4, 8, -3};
// pipe notation
auto v = vec | bio::views::convert<bool>; // == [1, 1, 0, 1, 0, 0, 1, 1, 1];
// function notation and immediate conversion to vector again
auto v2 = bio::views::convert<bool>(vec) | bio::ranges::to<std::vector<bool>>();
// combinability
auto v3 = vec | bio::views::convert<bool> | std::views::reverse; // == [1, 1, 1, 0, 0, 1, 0, 1, 1];
}
Provides bio::alphabet::dna15, container aliases and string literals.
Provides bio::views::convert.

Convert from bio::alphabet::dna15 to bio::alphabet::dna5:

int main()
{
using namespace bio::alphabet::literals;
std::vector<bio::alphabet::dna15> vec2{"ACYGTN"_dna15};
auto v4 = vec2 | bio::views::convert<bio::alphabet::dna5>; // == "ACNGTN"_dna5
}

◆ interleave

constexpr auto bio::ranges::views::interleave
inlineconstexpr

A view that interleaves a given range into another range at regular intervals.

Template Parameters
urng_tThe type of the range being processed.
inserted_rng_tThe type of the range being inserted.
Parameters
[in]urangeThe range being processed.
[in]inserted_rangeThe range being inserted.
[in]step_sizeA value of size_t which indicates the interval to insert the inserted_range.
Returns
A range with the second range inserted at regular intervals. See below for properties of said range.

Header File

#include <bio/ranges/views/interleave.hpp>

This view can be used to insert one range into another range at regular intervals. It behaves essentially like | std::views::chunk(step_size) | std::views::join_with(inserted_range) (avaiable in C++23), except that it requires the underlying range and the inserted range to model std::ranges::random_access_range and std::ranges::sized_range; and that the view itself also models these concepts.

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range required preserved
std::ranges::random_access_range required preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range required preserved
std::ranges::common_range guaranteed
std::ranges::output_range see below
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t see below

The range_reference_t of the view is the common reference type of the reference types of urng_t and std::views::all_t<inserted_rng_t> const, e.g. if urange is a std::string, and inserted_range is a std::string lvalue, the reference type of this view is char &; if inserted_range is in rvalue, the reference type of this view is char const & (because of weird implementation detail of views). As a rule-of-thumb, assume that T & will turn to T const & and the output_range property is lost.

Example

#include <string>
int main()
{
std::string u{"FOOBARBAXBAT"};
std::string i{"in"};
size_t s = 3;
auto v = u | bio::views::interleave(s, i);
fmt::print("{}\n", v); // prints FOOinBARinBAXinBAT
}
Provides bio::views::interleave.

◆ pairwise_combine

constexpr auto bio::ranges::views::pairwise_combine
inlineconstexpr

A view adaptor that generates all pairwise combinations of the elements of the underlying range.

Template Parameters
urng_tThe type of the range being processed. See below for requirements.
Parameters
[in]urangeThe range being processed.
Returns
A view over all pairwise combinations of the elements of the underlying range. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/pairwise_combine.hpp>

This view generates two-element tuples representing all unique combinations of the elements of the underlying range (the order of the elements is undefined). If the underlying range has less than two elements the returned range is empty, otherwise the size of the returned range corresponds to the binomial coefficient n choose 2, where n is the size of the underlying range. The reference type of this range is a tuple over the reference type of the underlying range. In order to receive the end iterator in constant time an iterator pointing to the last element of the underlying range will be cached upon construction of this view. This construction takes linear time for underlying ranges that do not model std::ranges::bidirectional_range.

Iterator

The returned iterator from begin does not model Cpp17Iterator since it does not return a reference to the represented type but a prvalue. Thus this iterator might not be usable within some legacy algorithms of the STL. But it is guaranteed to work with the ranges algorithms.

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range required guaranteed
std::ranges::output_range preserved
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t common_tuple<std::ranges::range_reference_t<urng_t>, std::ranges::range_reference_t<urng_t>>

See the views submodule documentation for detailed descriptions of the view properties.

Thread safety

Concurrent access to this view, e.g. while iterating over it, is thread-safe and must not be protected externally.

Example

#include <vector>
int main()
{
std::vector vec{'a', 'b', 'c', 'd'};
for (auto res : vec | bio::views::pairwise_combine)
{
fmt::print("{}\n", res);
}
}
Provides bio::views::pairwise_combine.
Attention
This view cannot be chained immediately with an infinite range, because upon construction it will take forever to reach the last element of the view.

◆ persist

constexpr auto bio::ranges::views::persist
inlineconstexpr

A view adaptor that wraps rvalue references of non-views.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range wrapped in a view (even if it doesn't model std::ranges::viewable_range).

Header File

#include <bio/ranges/views/persist.hpp>

For ranges that model std::ranges::viewable_range, this adaptor just returns std::views::all. However this adaptor can also take ranges that are not "viewable", e.g. temporaries of containers. It wraps them in a shared pointer internally so all view requirements like constant copy are satisfied. However construction and copying might be slightly slower, because of reference counting.

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range preserved
std::ranges::viewable_range not required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range preserved
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

Example

int main()
{
using namespace bio::alphabet::literals;
// explicitly create an l-value of our dna vector:
auto vec = "ACGT"_dna4;
auto v = vec | bio::views::to_char;
// using bio::views::persist you can bind the temporary directly:
auto v2 = "ACGT"_dna4 | bio::views::persist | bio::views::to_char;
// note that bio::views::persist must follow immediately after the temporary,
// thus the function notation might be more intuitive:
auto v3 = bio::views::persist("ACGT"_dna4) | bio::views::to_char;
}
Provides bio::views::persist.
Provides bio::views::to_char.

◆ rank_to

template<typename alphabet_type >
auto const bio::ranges::views::rank_to
inline

A view over an alphabet, given a range of ranks.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
alphabet_tThe alphabet to convert to; must satisfy bio::alphabet::writable_semialphabet.
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/rank_to.hpp>

View properties

This view is a deep view Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::rank_t<alphabet_t> alphabet_t

See the views submodule documentation for detailed descriptions of the view properties.

Example

#include <vector>
int main()
{
std::vector<int> vec{0, 1, 3, 3, 3, 2, 0, 3, 0};
auto v1 = vec | bio::views::rank_to<bio::alphabet::dna4>; // == "ACTTTGATA"_dna4
auto v2 = vec | bio::views::rank_to<bio::alphabet::dna5>; // == "ACTTTGATA"_dna5
}
Provides bio::views::rank_to.

◆ repeat

constexpr detail::repeat_fn bio::ranges::views::repeat
inlineconstexpr

A view factory that repeats a given value infinitely.

Template Parameters
value_tThe type of value to repeat wrapped in a std::views::single; must model std::copy_constructible.
Parameters
[in]valueThe value to repeat.
Returns
An infinite range over value.

Header File

#include <bio/ranges/views/repeat.hpp>

View properties

This view is source-only, it can only be at the beginning of a pipe of range transformations.

Concepts and traits rrng_t (returned range type)
std::ranges::input_range guaranteed
std::ranges::forward_range guaranteed
std::ranges::bidirectional_range guaranteed
std::ranges::random_access_range guaranteed
std::ranges::contiguous_range
std::ranges::viewable_range guaranteed
std::ranges::view guaranteed
std::ranges::sized_range
std::ranges::common_range
std::ranges::output_range guaranteed
bio::ranges::const_iterable_range guaranteed
std::ranges::range_reference_t std::remove_reference_t<value_t> &

See the views submodule documentation for detailed descriptions of the view properties.

Attention
The given value to repeat is always copied into the range.

Example

#include <ranges>
int main()
{
auto v = bio::views::repeat('A');
fmt::print("{}\n", *std::ranges::begin(v)); // prints 'A'
fmt::print("{}\n", v[12355]); // also prints 'A'. It always prints 'A'
v[1345] = 'C';
// Now it always prints 'C'
fmt::print("{}\n", *std::ranges::begin(v)); // prints 'C'
fmt::print("{}\n", v[12355]); // prints 'C'
}
T begin(T... args)
Provides the views::repeat_view.

◆ repeat_n

constexpr auto bio::ranges::views::repeat_n
inlineconstexpr

A view factory that repeats a given value n times.

Template Parameters
value_tThe type of value to repeat; must be std::copy_constructible.
Parameters
[in]valueThe value to repeat.
[in]countThe number of times to repeat value.
Returns
A range of size count, where each element equals value.

Header File

#include <bio/ranges/views/repeat_n.hpp>

View properties

This view is source-only, it can only be at the beginning of a pipe of range transformations.

Concepts and traits rrng_t (returned range type)
std::ranges::input_range guaranteed
std::ranges::forward_range guaranteed
std::ranges::bidirectional_range guaranteed
std::ranges::random_access_range guaranteed
std::ranges::contiguous_range
std::ranges::viewable_range guaranteed
std::ranges::view guaranteed
std::ranges::sized_range guaranteed
std::ranges::common_range
std::ranges::output_range guaranteed
bio::ranges::const_iterable_range guaranteed
std::ranges::range_reference_t std::remove_reference_t<value_t> &

See the views submodule documentation for detailed descriptions of the view properties.

Attention
The given value to repeat is always copied into the range.

Example

#include <string>
#include <ranges>
int main()
{
auto v = bio::views::repeat_n(std::string{"foo"}, 5);
fmt::print("{}\n", v.size()); // prints 5
fmt::print("{}\n", v); // prints ["foo", "foo", "foo", "foo", "foo"]
v[0] = std::string{"foobar"};
// Now it always prints "foobar"
fmt::print("{}\n", *std::ranges::begin(v)); // prints "foobar"
fmt::print("{}\n", v.size()); // prints 5; Note: the size cannot be changed anymore
}
Provides bio::views::repeat_n.

◆ single_pass_input

constexpr auto bio::ranges::views::single_pass_input
inlineconstexpr

A view adapter that decays most of the range properties and adds single pass behavior.

Template Parameters
urng_tThe type of the range being processed. See below for requirements.
Parameters
[in]urangeThe range being processed.
Returns
A range with single pass input behavior. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/single_pass_input.hpp>

This view adds single-pass semantics to any input view. This means, that begin always returns the iterator to the current location in the underlying range after k elements have been already consumed and not to the begin of the underlying range, i.e. it mirrors the behavior of an input stream. Note, the view updates an internal state after moving the associated iterator. Thus, the const begin and const end are explicitly deleted.

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range lost
std::ranges::bidirectional_range lost
std::ranges::random_access_range lost
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range lost
std::ranges::common_range lost
std::ranges::output_range preserved
bio::ranges::const_iterable_range lost
std::ranges::range_reference_t std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

Thread safety

Concurrent access to this view, e.g. while iterating over it, is not thread-safe and must be protected externally.

Example

#include <string>
int main()
{
std::string str{"hello"};
auto v = str | bio::views::single_pass_input;
auto b = v.begin();
fmt::print("{}\n", *b); // prints 'h'
fmt::print("{}\n", *(++b)); // prints 'e'
fmt::print("{}\n", *(++b)); // prints 'l'
fmt::print("{}\n", *(++b)); // prints 'l'
fmt::print("{}\n", *(++b)); // prints 'o'
}
Provides bio::alphabet::single_pass_input_view.

◆ slice

constexpr auto bio::ranges::views::slice
inlineconstexpr

A view adaptor that returns a half-open interval on the underlying range.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
[in]begin_posThe beginning of the interval (index of first element returned).
[in]end_posThe end of the interval (index behind the last element returned).
Returns
Up to end_pos - begin_pos elements of the underlying range.
Exceptions
std::invalid_argumentIf end_pos < begin_pos.

Header File

#include <bio/ranges/views/slice.hpp>

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range preserved
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range preserved
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

This adaptor is a combination of std::views::drop, std::views::take and bio::views::type_reduce.

If begin_pos is larger than the size of the underlying range an empty range is returned. If end_pos is larger than the size of the underlying range all elements are returned.

If end_pos < begin_pos an exception of type std::invalid_argument is thrown.

Return type

urng_t (underlying range type) rrng_t (returned range type)
std::basic_string const & or std::basic_string_view std::basic_string_view
std::ranges::borrowed_range && std::ranges::sized_range && std::ranges::contiguous_range std::span
std::ranges::borrowed_range && std::ranges::sized_range && std::ranges::random_access_range std::ranges::subrange
else implementation defined type

The adaptor returns exactly the type specified above.

Complexity

Construction of the returned view is in $ O(begin\_pos) $ for some views, see bio::views::drop.

Example

#include <string>
#include <bio/ranges/views/slice.hpp> // provides views::slice
#include <ranges> // provides std::views::reverse
int main()
{
std::string s{"foobar"};
auto v = s | bio::views::slice(1,4);
fmt::print("{}\n", v); // "oob"
auto v2 = s | std::views::reverse | bio::views::slice(1, 4);
fmt::print("{}\n", v2); // "abo"
}
Provides bio::views::slice.

◆ take_exactly

constexpr auto bio::ranges::views::take_exactly
inlineconstexpr

A view adaptor that returns the first size elements from the underlying range (or less if the underlying range is shorter); also provides size information.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
[in]sizeThe target size of the view.
Returns
Up to size elements of the underlying range.

Header File

#include <bio/ranges/views/take_exactly.hpp>

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range preserved
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range guaranteed
std::ranges::common_range preserved
std::ranges::output_range preserved except if urng_t is std::basic_string
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

The difference to bio::views::take is that this view always exposes size information – even if the underlying range is not sized. You should only use this if you know that the underlying range will always be at least size long.

For bio::views::take_exactly if the underlying range is shorter than size, the behaviour is undefined. bio::views::take_exactly_or_throw is a safer alternative, because it throws an exception when an iterator before the size-th one compares equal to the end sentinel; and it also throws on construction if it knows that the underlying range is smaller.

Example

#include <string>
#include <bio/ranges/views/take_exactly.hpp> // provides views::take_exactly and views::take_exactly_or_throw
int main()
{
std::string vec{"foobar"};
auto v = vec | bio::views::take_exactly(3); // or bio::views::take_exactly_or_throw
fmt::print("{}\n", v); // "foo"
fmt::print("{}\n", std::ranges::size(v)); // 3
auto v2 = vec | bio::views::take_exactly(9);
fmt::print("{}\n", std::ranges::size(v2)); // 9 <- here be dragons!
}
Provides bio::views::take_exactly and bio::views::take_exactly_or_throw.

◆ take_exactly_or_throw

constexpr auto bio::ranges::views::take_exactly_or_throw
inlineconstexpr

A view adaptor that returns the first size elements from the underlying range and also exposes size information; throws if the underlying range is smaller than size.

Exceptions
bio::alphabet::unexpected_end_of_inputIf the underlying range is smaller than size.
Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
[in]sizeThe target size of the view.
Returns
Up to size elements of the underlying range.

Header File

#include <bio/ranges/views/take_exactly.hpp>

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range preserved
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range guaranteed
std::ranges::common_range preserved
std::ranges::output_range preserved except if urng_t is std::basic_string
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

The difference to bio::views::take is that this view always exposes size information – even if the underlying range is not sized. You should only use this if you know that the underlying range will always be at least size long.

For bio::views::take_exactly if the underlying range is shorter than size, the behaviour is undefined. bio::views::take_exactly_or_throw is a safer alternative, because it throws an exception when an iterator before the size-th one compares equal to the end sentinel; and it also throws on construction if it knows that the underlying range is smaller.

Example

#include <string>
#include <bio/ranges/views/take_exactly.hpp> // provides views::take_exactly and views::take_exactly_or_throw
int main()
{
std::string vec{"foobar"};
auto v = vec | bio::views::take_exactly(3); // or bio::views::take_exactly_or_throw
fmt::print("{}\n", v); // "foo"
fmt::print("{}\n", std::ranges::size(v)); // 3
auto v2 = vec | bio::views::take_exactly(9);
fmt::print("{}\n", std::ranges::size(v2)); // 9 <- here be dragons!
}

◆ to_char

auto const bio::ranges::views::to_char
inline

A view that calls bio::alphabet::to_char() on each element in the input range.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/to_char.hpp>

View properties (generic case)

This view is a deep view Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::alphabet bio::alphabet::char_t<std::ranges::range_value_t<urng_t>>

See the views submodule documentation for detailed descriptions of the view properties.

View properties (NOOP case)

If a range is given whose value_type is the same its alphabet type (e.g. std::string), a simple view to the range is returned and no transformation happens. See bio::ranges::views::type_reduce.

View properties (bio::alphabet::cigar)

This range adaptor can be applied to ranges over bio::alphabet::cigar (although that type does not model bio::alphabet::alphabet). The returned view is weaker than in the generic case:

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range lost
std::ranges::bidirectional_range lost
std::ranges::random_access_range lost
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range lost
std::ranges::common_range lost
std::ranges::output_range lost
bio::ranges::const_iterable_range lost
std::ranges::range_reference_t bio::alphabet::cigar char

Example

#include <vector>
#include <bio/alphabet/quality/aliases.hpp> // includes bio::alphabet::dna4q
int main()
{
using namespace bio::alphabet::literals;
std::vector<bio::alphabet::dna4> vec = "ACTTTGATA"_dna4;
auto v = vec | bio::views::to_char;
fmt::print("{}\n", v); // [A,C,T,T,T,G,A,T,A]
std::vector<bio::alphabet::phred42> qvec{{0}, {7}, {5}, {3}, {7}, {4}, {30}, {16}, {23}};
auto v3 = qvec | bio::views::to_char;
fmt::print("{}\n", v3); // [!,(,&,$,(,%,?,1,8]
{'G'_dna4, bio::alphabet::phred42{5}}, {'T'_dna4, bio::alphabet::phred42{3}},
{'G'_dna4, bio::alphabet::phred42{7}}, {'A'_dna4, bio::alphabet::phred42{4}},
{'C'_dna4, bio::alphabet::phred42{30}}, {'T'_dna4, bio::alphabet::phred42{16}},
{'A'_dna4, bio::alphabet::phred42{23}}};
auto v4 = qcvec | bio::views::to_char;
fmt::print("{}\n", v4); // [C,A,G,T,G,A,C,T,A]
}
Provides aliases for qualified.
Quality type for traditional Sanger and modern Illumina Phred scores (typical range)....
Definition: phred42.hpp:45
Provides bio::alphabet::phred42 quality scores.

◆ to_lower

auto const bio::ranges::views::to_lower
inline

A view that converts each element to lower case.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/to_lower.hpp>

View properties

This view is a deep view Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::meta::builtin_character bio::alphabet::remove_reference_t<std::ranges::range_reference_t<urngt_>>

See the views submodule documentation for detailed descriptions of the view properties.

Example

#include <string>
#include <vector>
int main()
{
std::string s{"CHanGED!"};
std::vector<std::string> sv{"CHANGED", "unchanged!"};
auto v1 = s | bio::views::to_lower;
auto v2 = sv | bio::views::to_lower;
fmt::print("{}\n", v1); // => "changed!"
fmt::print("{}\n", v2); // => ["changed", "unchanged!"]
}
Provides bio::views::to_lower.

◆ to_rank

auto const bio::ranges::views::to_rank
inline

A view that calls bio::alphabet::to_rank() on each element in the input range.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/to_rank.hpp>

View properties

This view is a deep view Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::alphabet bio::alphabet::rank_t<std::ranges::range_value_t<urng_t>>

See the views submodule documentation for detailed descriptions of the view properties.

Example

#include <vector>
int main()
{
using namespace bio::alphabet::literals;
std::vector<bio::alphabet::dna4> vec = "ACTTTGATA"_dna4;
auto v = vec | bio::views::to_rank | bio::views::convert<unsigned>;
fmt::print("{}\n", v); // [0,1,3,3,3,2,0,3,0]
std::vector<bio::alphabet::phred42> qvec{{0}, {7}, {5}, {3}, {7}, {4}, {30}, {16}, {23}};
auto v3 = qvec | bio::views::to_rank | bio::views::convert<unsigned>;
fmt::print("{}\n", v3); // [0,7,5,3,7,4,30,16,23]
{'G'_dna4, bio::alphabet::phred42{5}}, {'T'_dna4, bio::alphabet::phred42{3}},
{'G'_dna4, bio::alphabet::phred42{7}}, {'A'_dna4, bio::alphabet::phred42{4}},
{'C'_dna4, bio::alphabet::phred42{30}}, {'T'_dna4, bio::alphabet::phred42{16}},
{'A'_dna4, bio::alphabet::phred42{23}}};
auto v4 = qcvec | bio::views::to_rank | bio::views::convert<unsigned>;
fmt::print("{}\n", v4); // [1,28,22,15,30,16,121,67,92]
}
Provides bio::views::to_rank.

We also convert to unsigned here, because the bio::alphabet::rank_t is often uint8_t which is often implemented as unsigned char and thus will not be printed as a number by default.

◆ to_upper

auto const bio::ranges::views::to_upper
inline

A view that converts each element to upper case.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
A range of converted elements. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/to_upper.hpp>

View properties

This view is a deep view Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range lost
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::meta::builtin_character bio::alphabet::remove_reference_t<std::ranges::range_reference_t<urngt_>>

See the views submodule documentation for detailed descriptions of the view properties.

Example

#include <string>
#include <vector>
int main()
{
std::string s{"CHanGED!"};
std::vector<std::string> sv{"changed", "UNCHANGED!"};
auto v1 = s | bio::views::to_upper;
auto v2 = sv | bio::views::to_upper;
fmt::print("{}\n", v1); // => "CHANGED!"
fmt::print("{}\n", v2); // => ["CHANGED", "UNCHANGED!"]
}
Provides bio::views::to_upper.

◆ transform_by_pos

constexpr auto bio::ranges::views::transform_by_pos
inlineconstexpr

A view adaptor similar to std::views::transform. Calls the invocable with two arguments: underlying range and position.

Template Parameters
urng_tThe type of the range being processed.
Parameters
[in]urangeThe range being processed.
[in]fnInvocable that takes (urng_t &, size_t) as arguments and returns transformed element.
[in]size_fnInvocable that takes (urng_t &) as argument and returns size of new range. [optional]
Returns
A range of the transformed elements.

Header File

#include <bio/ranges/views/transform_by_pos.hpp>

This view can be used to create more elaborate transformations than are possible with std::views::transform, but it only works on sized, random-access ranges.

If you want the returned range to be const-iterable, the fn that you pass should be able to handle both urng_t & and urng_t const & as arguments.

The size_fn parameter is optional; if it is omitted, the size of the returned range will be the same as the size of the underlying range. Note that the size is computed only once on construction of the returned range (and then cached).

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range required preserved
std::ranges::random_access_range required preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range required preserved
std::ranges::common_range guaranteed
std::ranges::output_range depends on fn
bio::ranges::const_iterable_range depends on fn
std::ranges::range_reference_t depends on fn
std::ranges::range_value_t std::remove_cvref_t<std::ranges::range_reference_t<rrng_t>>
  • urng_t is the type of the range adapted by this view (input).
  • rrng_t is the type of the range returned by this view.
  • for more details, see Views.

Example

Implementation of a "reverse view":

#include <iostream>
using namespace bio::alphabet::literals;
int main()
{
std::vector vec = "ACGT"_dna5;
auto rev = [] (auto && urange, size_t const pos) -> std::ranges::range_reference_t<decltype(urange)>
{
return urange[std::ranges::size(urange) - 1 - pos];
};
auto v = vec | bio::views::transform_by_pos(rev);
fmt::print("{}\n", v); // prints: TGCA
return 0;
}
Meta-header for the nucleotide submodule; includes all headers from alphabet/nucleotide/.
Provides bio::views::transform_by_pos.

◆ translate

constexpr auto bio::ranges::views::translate
inlineconstexpr

A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames.

Template Parameters
urng_tThe type of the range being processed.
Parameters
[in]urangeThe range being processed.
[in]tfA value of bio::alphabet::tanslation_frames that indicates the desired frames. [optional, SIX_FRAME by default]
Returns
A range of ranges containing frames with aminoacid sequence. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/translate.hpp>

This view can be used to translate nucleotide sequences into aminoacid sequences (see alphabet::translation_frames for possible combination of frames).

Note that the dimension of the input is always increased by one, i.e. if you pass a single sequence, you will get multiple frames; if you pass muliple sequences, you get a as many ranges of frames.

There are also two other views for creating translations:

  1. bio::views::translate_single: 1 sequence → 1 frame [range → range OR range-of-ranges → range-of-ranges]
  2. bio::views::translate: 1 sequence → n frames [range → range-of-ranges OR range-of-ranges → ranges-of-ranges-of-ranges]]
  3. bio::views::translate_join: n sequences → n*m frames [range-of-ranges → range-of-ranges]

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range required preserved
std::ranges::random_access_range required preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range required preserved
std::ranges::common_range guaranteed
std::ranges::output_range lost
bio::ranges::const_iterable_range required preserved
std::ranges::range_reference_t bio::alphabet::alphabet::nucleotide std::ranges::view && std::ranges::random_access_range && std::ranges::sized_range
  • urng_t is the type of the range modified by this view (input).
  • rrng_type is the type of the range returned by this view.
  • for more details, see Views.

Example

Operating on a range of bio::alphabet::dna5:

int main()
{
using namespace bio::alphabet::literals;
std::vector<bio::alphabet::dna5> vec{"ACGTACGTACGTA"_dna5};
// default frame translation
auto v1 = vec | bio::views::translate;
// == [[T,Y,V,R],[R,T,Y,V],[V,R,T],[Y,V,R,T],[T,Y,V,R],[R,T,Y]]
// single frame translation
auto v2 = vec | bio::views::translate(bio::alphabet::translation_frames::FWD_FRAME_0);
// == [[T,Y,V,R]]
// reverse translation
auto v3 = vec | bio::views::translate(bio::alphabet::translation_frames::FWD_REV_0);
// == [[T,Y,V,R],[Y,V,R,T]]
// forward frames translation
auto v4 = vec | bio::views::translate(bio::alphabet::translation_frames::FWD);
// == [[T,Y,V,R],[R,T,Y,V],[V,R,T]]
// six frame translation
auto v5 = vec | bio::views::translate(bio::alphabet::translation_frames::SIX_FRAME);
// == [[T,Y,V,R],[R,T,Y,V],[V,R,T],[Y,V,R,T],[T,Y,V,R],[R,T,Y]]
// function syntax
auto v6 = bio::views::translate(vec, bio::alphabet::translation_frames::FWD_REV_0);
// == [[T,Y,V,R],[Y,V,R,T]]
// combinability
auto v7 = vec | bio::views::complement | bio::views::translate(bio::alphabet::translation_frames::FWD_REV_0);
// == [[C,M,H,A],[M,H,A,C]]
}
@ FWD_REV_0
The first forward and first reverse frame.
@ FWD_FRAME_0
The first forward frame starting at position 0.
Provides bio::views::translate and bio::views::translate_single.

◆ translate_join

constexpr auto bio::ranges::views::translate_join
inlineconstexpr

A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames. Input and output range are always two-dimensional.

Template Parameters
urng_tThe type of the range being processed.
Parameters
[in]urangeThe range being processed. Needs to be a range of ranges (two-dimensional).
[in]tfA value of bio::alphabet::tanslation_frames that indicates the desired frames. [optional, SIX_FRAME by default]
Returns
A range of ranges containing frames with aminoacid sequence. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/translate_join.hpp>

This view can be used to translate nucleotide sequences into aminoacid sequences (see alphabet::translation_frames for possible combination of frames). This view only operates on two-dimensional input (range of ranges) and outputs a range of ranges no matter the number of input sequences or the number of translation frames given. Therefore, it has the same capabilities as the standard view_translate but concatenates the different frames of the different input sequences rather than having a separate range for each input sequence containing the translated frames. In the output, frames are ordered in a way, that all requested frames are listed per sequence directly after each other in the order of input sequences. improved and efficient downstream post-processing if needed. However, the index of a frame for a specific sequence needs to be calculated via modulo operations in this case. The i-th frame of the j-th sequence can be calculated by n = (i * s) + j, where s is the number of frames used for translation (index starting at zero).

In short, this views behaves the same as:

auto v = vec | bio::views::translate | std::views::join;
Except that the performance is better and the returned range still models std::ranges::random_access_range and std::ranges::sized_range.

There are also two other views for creating translations:

  1. bio::views::translate_single: 1 sequence → 1 frame [range → range OR range-of-ranges → range-of-ranges]
  2. bio::views::translate: 1 sequence → n frames [range → range-of-ranges OR range-of-ranges → range-of-ranges-of-ranges]]
  3. bio::views::translate_join: n sequences → n*m frames [range-of-ranges → range-of-ranges]

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range required preserved
std::ranges::random_access_range required preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range required preserved
std::ranges::common_range guaranteed
std::ranges::output_range lost
bio::ranges::const_iterable_range required preserved
std::ranges::range_reference_t bio::alphabet::nucleotide std::ranges::view && std::ranges::random_access_range && std::ranges::sized_range
  • urng_t is the type of the range modified by this view (input).
  • rrng_t is the type of the range returned by this view.
  • for more details, see Views.

Example

Operating on a range of bio::alphabet::dna5:

#include <iostream>
using namespace bio::alphabet::literals;
int main()
{
// Input range needs to be two-dimensional
std::vector<std::vector<bio::alphabet::dna4> > vec{"ACGTACGTACGTA"_dna4, "TCGAGAGCTTTAGC"_dna4};
// Translation with default parameters
auto v1 = vec | bio::views::translate_join;
fmt::print("{}\n", v1); // [TYVR,RTYV,VRT,YVRT,TYVR,RTY,SRAL,REL*,ESFS,AKAL,LKLS,*SSR]
// Access the third forward frame (index_frame 2) of the second input sequence (index_seq 1)
// Required frames per sequence s = 6
// n = (index_seq * s) + j
// = 1 * 6 + 2
// = 8
auto third_frame_second_seq = v1[1 * 6 + 2];
fmt::print("{}\n", third_frame_second_seq); // ESFS
// Translation with custom translation frame
auto v2 = vec | bio::views::translate_join(bio::alphabet::translation_frames::FWD_FRAME_0);
fmt::print("{}\n", v2); // [TYVR,SRAL]
return 0;
}
Provides bio::views::translate_join.

◆ translate_single

constexpr auto bio::ranges::views::translate_single
inlineconstexpr

A view that translates nucleotide into aminoacid alphabet for one of the six frames.

Template Parameters
urng_tThe type of the range being processed.
Parameters
[in]urangeThe range being processed.
[in]tfA value of bio::alphabet::alphabet::translation_frames that indicates the desired frames. [optional, FWD_FRAME_0 by default]
Returns
A range containing frames with aminoacid sequence. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/translate_single.hpp>

This view can be used to translate nucleotide sequences into aminoacid sequences (see alphabet::translation_frames for possible frames). Note that only single frames values are are valid here.

There are also two other views for creating translations:

  1. bio::views::translate_single: 1 sequence → 1 frame [range → range OR range-of-ranges → range-of-ranges]
  2. bio::views::translate: 1 sequence → m frames [range → range-of-ranges OR range-of-ranges → ranges-of-ranges-of-ranges]]
  3. bio::views::translate_join: n sequences → n*m frames [range-of-ranges → range-of-ranges]

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range required preserved
std::ranges::bidirectional_range required preserved
std::ranges::random_access_range required preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range required preserved
std::ranges::common_range guaranteed
std::ranges::output_range lost
bio::ranges::const_iterable_range required preserved
std::ranges::range_reference_t bio::alphabet::alphabet::nucleotide bio::alphabet::aa27
  • urng_t is the type of the range modified by this view (input).
  • rrng_type is the type of the range returned by this view.
  • for more details, see Views.

Example

Operating on a range of bio::alphabet::dna5:

int main()
{
using namespace bio::alphabet::literals;
std::vector<bio::alphabet::dna5> vec{"ACGTACGTACGTA"_dna5};
// Default (first forward frame)
auto v1 = vec | bio::views::translate_single;
// == [T,Y,V,R]
fmt::print("{}\n", v1[1]);
// First forward frame
auto v2 = vec | bio::views::translate_single(bio::alphabet::translation_frames::FWD_FRAME_0);
// == [T,Y,V,R]
// First reverse frame
auto v3 = vec | bio::views::translate_single(bio::alphabet::translation_frames::REV_FRAME_0);
// == [Y,V,R,T]
// Second forward frame
auto v4 = vec | bio::views::translate_single(bio::alphabet::translation_frames::FWD_FRAME_1);
// == [R,T,Y,V]
// Second reverse frame
auto v5 = vec | bio::views::translate_single(bio::alphabet::translation_frames::REV_FRAME_1);
// == [T,Y,V,R]
// Third forward frame
auto v6 = vec | bio::views::translate_single(bio::alphabet::translation_frames::FWD_FRAME_2);
// == [V,R,T]
// Third reverse frame
auto v7 = vec | bio::views::translate_single(bio::alphabet::translation_frames::REV_FRAME_2);
// == [R,T,Y]
// function syntax
auto v8 = bio::views::translate_single(vec, bio::alphabet::translation_frames::FWD_FRAME_0);
// == [T,Y,V,R]
// combinability
auto v9 = vec | bio::views::complement | bio::views::translate_single(bio::alphabet::translation_frames::REV_FRAME_0);
// == [M,H,A,C]
// combinability with default parameter
auto v10 = vec | bio::views::complement | bio::views::translate_single;
// == [C,M,H,A]
// combinability with default parameter
auto v11 = vec | bio::views::complement | bio::views::translate_single();
// == [C,M,H,A]
}
@ REV_FRAME_0
The first reverse frame starting at position 0.
@ REV_FRAME_1
The second reverse frame starting at position 1.
@ FWD_FRAME_2
The third forward frame starting at position 2.
@ FWD_FRAME_1
The second forward frame starting at position 1.
@ REV_FRAME_2
The third reverse frame starting at position 2.
Provides bio::views::translate and bio::views::translate_single.

◆ trim_quality

constexpr auto bio::ranges::views::trim_quality
inlineconstexpr

A view that does quality-threshold trimming on a range of bio::alphabet::quality.

Template Parameters
urng_tThe type of the range being processed. See below for requirements.
threshold_tEither std::ranges::range_value_t<urng_t> or bio::alphabet::phred_t<std::ranges::range_value_t<urng_t>>.
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
[in]thresholdThe minimum quality.
Returns
A trimmed range. See below for the properties of the returned range.

Header File

#include <bio/ranges/views/trim_quality.hpp>

This view can be used to do easy quality based trimming of sequences.

View properties

This view is a deep view Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::view guaranteed
std::ranges::sized_range lost
std::ranges::common_range lost
std::ranges::output_range preserved
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::quality std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

Example

Operating on a range of bio::alphabet::phred42:

#include <string>
#include <vector>
int main()
{
// trim by phred_value
auto v1 = vec | bio::views::trim_quality(20u); // == ['I','I','?','5']
// trim by quality character
auto v2 = vec | bio::views::trim_quality(bio::alphabet::phred42{40}); // == ['I','I']
// function syntax
auto v3 = bio::views::trim_quality(vec, 20u); // == ['I','I','?','5']
// combinability
auto v4 = bio::views::trim_quality(vec, 20u) | bio::views::to_char; // == "II?5"
}
Provides bio::views::trim_quality.

Or operating on a range of bio::alphabet::dna5q:

#include <string>
#include <vector>
int main()
{
using namespace bio::alphabet::literals;
using namespace bio::alphabet::literals;
std::vector<bio::alphabet::dna5q> vec{{'A'_dna5, 'I'_phred42},
{'G'_dna5, 'I'_phred42},
{'G'_dna5, '?'_phred42},
{'A'_dna5, '5'_phred42},
{'T'_dna5, '+'_phred42}};
std::vector<bio::alphabet::dna5q> cmp{{'A'_dna5, 'I'_phred42},
{'G'_dna5, 'I'_phred42},
{'G'_dna5, '?'_phred42},
{'A'_dna5, '5'_phred42}};
// trim by phred_value
auto v1 = vec | bio::views::trim_quality(20u);
assert((v1 | bio::ranges::to<std::vector>()) == cmp);
// trim by quality character; in this case the nucleotide part of the character is irrelevant
auto v2 = vec | bio::views::trim_quality(bio::alphabet::dna5q{'C'_dna5, '5'_phred42});
assert((v2 | bio::ranges::to<std::vector>()) == cmp);
// combinability
auto v3 = bio::views::trim_quality(vec, 20u) | bio::views::to_char;
assert(std::ranges::equal(std::string{"AGGA"}, v3 | bio::ranges::to<std::string>()));
}
Joins an arbitrary alphabet with a quality alphabet.
Definition: qualified.hpp:59
T equal(T... args)

◆ type_reduce

constexpr auto bio::ranges::views::type_reduce
inlineconstexpr

A view adaptor that behaves like std::views::all, but type erases certain ranges.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
The range turned into a view.

Header File

#include <bio/ranges/views/view_type_reduce.hpp>

View properties

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range preserved
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range preserved
bio::ranges::const_iterable_range preserved
std::ranges::range_reference_t std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

Return type

urng_t (underlying range type) rrng_t (returned range type)
std::ranges::view urng_t
std::basic_string const & or std::basic_string_view std::basic_string_view
std::ranges::borrowed_range && std::ranges::sized_range && std::ranges::contiguous_range std::span
std::ranges::borrowed_range && std::ranges::sized_range && std::ranges::random_access_range std::ranges::subrange
else std::ranges::ref_view<urng_t>

This adaptor is different from std::views::all in that it performs type erasure for some underlying ranges; std::views::all always returns std::ranges::ref_view<urng_t> or the type itself if it already is a view.

Example

#include <string>
#include <vector>
int main()
{
std::string const vec{"foobar"};
auto v = vec | bio::views::type_reduce; // pipe notation; v is of type std::string_view
fmt::print("{}\n", v); // "foobar"
std::vector vec2{1, 2, 3};
auto v2 = bio::views::type_reduce(vec2); // functional notation; v2 is of type std::span
fmt::print("{}\n", v2); // "[1, 2, 3]"
}
Provides bio::views::type_reduce.

◆ validate_char_for

template<alphabet::alphabet alphabet_type>
auto const bio::ranges::views::validate_char_for
inline

An identity view that throws if an encountered character is not valid for the given alphabet.

Template Parameters
urng_tThe type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation]
alphabet_tThe alphabet to check validity for; must satisfy biocpp::alphabet::alphabet.
Parameters
[in]urangeThe range being processed. [parameter is omitted in pipe notation]
Returns
The range of input values. See below for the properties of the returned range.
Exceptions
bio::alphabet::invalid_char_assignmentif an invalid character is encountered.

Header File

#include <bio/ranges/views/validate_char_for.hpp>

This view throws if it encounters a character that is not in the valid set of an alphabet. It performs no transformation on the elements of the view itself. However, the contiguous property is lost due to the way it is currently implemented.

View properties

This view is a deep view. Given a range-of-range as input (as opposed to just a range), it will apply the transformation on the innermost range (instead of the outermost range).

Concepts and traits urng_t (underlying range type) rrng_t (returned range type)
std::ranges::input_range required preserved
std::ranges::forward_range preserved
std::ranges::bidirectional_range preserved
std::ranges::random_access_range preserved
std::ranges::contiguous_range lost
std::ranges::viewable_range required guaranteed
std::ranges::view guaranteed
std::ranges::sized_range preserved
std::ranges::common_range preserved
std::ranges::output_range preserved
std::semiregular preserved
biocpp::ranges::const_iterable_range preserved
std::ranges::range_reference_t bio::alphabet::char_t<alphabet_t> std::ranges::range_reference_t<urng_t>

See the views submodule documentation for detailed descriptions of the view properties.

Example

int main()
{
std::string_view str{"ACTTTGATAN"};
try
{
fmt::print("{}", str | bio::ranges::views::validate_char_for<bio::alphabet::dna4>);
//prints: ACTTTGATA
}
// Will throw on parsing 'N'
{
fmt::print("\n[ERROR] Invalid char!\n");
}
}
Provides bio::ranges::views::validate_char_for.