Views are "lazy range combinators" that offer modified views onto other ranges.
More...
|
auto constexpr | seqan3::view::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 . More...
|
|
|
template<typename out_t > |
auto const | seqan3::view::convert |
| A view that converts each element in the input range (implicitly or via static_cast ). More...
|
|
template<size_t index> |
auto const | seqan3::view::get |
| A view calling std::get on each element in a range. More...
|
|
auto constexpr | seqan3::view::persist |
| A view adaptor that wraps rvalue references of non-views. More...
|
|
constexpr auto | seqan3::view::single_pass_input |
| A view adapter that decays most of the range properties and adds single pass behavior. More...
|
|
auto constexpr | seqan3::view::take |
| A view adaptor that returns the first size elements from the underlying range (or less if the underlying range is shorter). More...
|
|
auto constexpr | seqan3::view::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. More...
|
|
auto constexpr | seqan3::view::take_line |
| A view adaptor that returns a single line from the underlying range or the full range if there is no newline. More...
|
|
auto constexpr | seqan3::view::take_line_or_throw |
| A view adaptor that returns a single line from the underlying range (throws if there is no end-of-line). More...
|
|
auto constexpr | seqan3::view::take_until |
| A view adaptor that returns elements from the underlying range until the functor evaluates to true (or the end of the underlying range is reached). More...
|
|
auto constexpr | seqan3::view::take_until_or_throw |
| A view adaptor that returns elements from the underlying range until the functor evaluates to true (throws if the end of the underlying range is reached). More...
|
|
Views are "lazy range combinators" that offer modified views onto other ranges.
SeqAn3 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 SeqAn3 are specific to biological operations, like seqan3::view::trim which trims sequences based on the quality or seqan3::view::complement which generates the complement of a nucleotide sequence. But SeqAn3 also provides some general purpose views.
Namespaces
Example
Functional and pipe notations:
Re-transform into a distinct container:
assert(complemented == "TGCCAG"_dna4);
assert(reversed == "CTGGCA"_dna4);
Composability:
Views vs view adaptors
When talking about views, two different entities are often conflated:
- 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)
- 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
view::reverse
and view::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 documention, though, we always document view::foo
, independent of whether view::foo
is the adaptor that returns the "foo type" or whether view::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. ranges::view::single
, ranges::view::concat
and ranges::view::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 seqan3::view::deep to make any view (adaptor) deep. See seqan3::view::deep for more details.
For all views the following are documented:
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::InputRange
, but many have stronger requirements, e.g. std::ranges::RandomAccessRange
. 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::ViewableRange 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 view::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::InputRange
and also std::ranges::View
(and conversely also std::ranges::ViewableRange
, because all views are viewable). Most views also preserve stronger properties, e.g. std::ranges::RandomAccessRange
, but this depends on the view. Some views also add properties not present on the input range, e.g. the range returned by ranges::view::take_exactly
meets std::ranges::SizedRange
, independent of whether this was met by the input range.
- preserved in this context means that the returned range satisfies this concept if it is also satisfied by the underlying range.
- lost means that this concept is never satisfied by the returned range, independent of whether the underlying range supports it.
- guaranteed means that this concept is always satisfied by the returned range, independent of whether the underlying range supports it.
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 SeqAn specific views additional concept requirements are defined for the input range's reference type, e.g. seqan3::view::complement can only operate on ranges whose elements are nucleotides (meet seqan3::nucleotide_concept_check). In some case the type may even be a specific type or the result of a metafunction.
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. seqan3::view::complement operates on nucleotides and of course also returns nucleotides and "seqan3::reference_t<urng_t>" would imply that the reference type is the same. However, and this is important to note, the reference type of seqan3::view::complement has any actual &
removed from the underlying ranges' reference type (if originally present), this goes hand-in-hand with std::ranges::OutputRange being lost → original elements cannot be written to through this view. This is because new elements are being generated. Other views like view::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::OutputRange), but through others you can't.
- See also
- https://ericniebler.github.io/range-v3/index.html#range-views
◆ char_to
template<alphabet_concept alphabet_type>
auto const seqan3::view::char_to |
|
inline |
A view over an alphabet, given a range of characters.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
alphabet_t | The alphabet to convert to; must satisfy seqan3::alphabet_concept. |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of converted elements. See below for the properties of the returned 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).
See the view submodule documentation for detailed descriptions of the view properties.
Example
std::string s{"ACTTTGATAN"};
auto v1 = s | view::char_to<dna4>;
auto v2 = s | view::char_to<dna5>;
◆ complement
auto const seqan3::view::complement |
|
inline |
A view that converts a range of nucleotides to their complement.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of converted elements. See below for the properties of the returned range.
Calls seqan3::nucleotide_concept::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).
See the view submodule documentation for detailed descriptions of the view properties.
Example
dna5_vector foo{"ACGTA"_dna5};
◆ convert
template<typename out_t >
auto const seqan3::view::convert |
A view that converts each element in the input range (implicitly or via static_cast
).
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of converted elements. See below for the properties of the returned range.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
Example
Convert from int
to bool
:
std::vector<int> vec{7, 5, 0, 5, 0, 0, 4, 8, -3};
auto v = vec | view::convert<bool>;
std::vector<bool> v2(view::convert<bool>(vec));
Convert from seqan3::dna15 to seqan3::dna5:
dna15_vector vec2{"ACYGTN"_dna15};
auto v4 = vec2 | view::convert<dna5>;
◆ get
template<size_t index>
auto const seqan3::view::get |
|
inline |
A view calling std::get on each element in a range.
- Template Parameters
-
size_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
index | The index to get. |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of elements where every element is the result of calling std::get<index> on the underlying element. See below for the properties of the returned range.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
Example
std::vector<dna4q> qv{{'A'_dna4, phred42{0}}, {'C'_dna4, phred42{1}}, {'G'_dna4, phred42{2}}, {'T'_dna4, phred42{3}}};
debug_stream << (qv | view::get<0> |
view::to_char) << std::endl;
debug_stream << (qv | view::get<1> |
view::to_char) << std::endl;
◆ kmer_hash
auto constexpr seqan3::view::kmer_hash |
|
inline |
A view that calls std::hash on each substring of length k in the input range.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of unsigned integral values where each value is the hash of the resp. k-mer. See below for the properties of the returned range.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
Example
int main()
{
std::vector<dna4> text{"ACGTAGC"_dna4};
}
◆ persist
auto constexpr seqan3::view::persist |
|
inline |
A view adaptor that wraps rvalue references of non-views.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range wrapped in a view (even if it doesn't model std::ranges::ViewableRange).
For ranges that model std::ranges::ViewableRange, this adaptor just returns std::view::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
See the view submodule documentation for detailed descriptions of the view properties.
Example
◆ rank_to
template<typename alphabet_type >
auto const seqan3::view::rank_to |
|
inline |
A view over an alphabet, given a range of ranks.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
alphabet_t | The alphabet to convert to; must satisfy seqan3::alphabet_concept. |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of converted elements. See below for the properties of the returned 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).
See the view submodule documentation for detailed descriptions of the view properties.
- Example
std::vector<int> vec{0, 1, 3, 3, 3, 2, 0, 3, 0};
auto v1 = vec | view::rank_to<dna4>;
auto v2 = vec | view::rank_to<dna5>;
◆ single_pass_input
constexpr auto seqan3::view::single_pass_input |
|
inline |
A view adapter that decays most of the range properties and adds single pass behavior.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. |
- Parameters
-
[in] | urange | The range being processed. |
- Returns
- A range with single pass input behavior. See below for the properties of the returned range.
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
See the view 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
std::string str{"hello"};
◆ take
auto constexpr seqan3::view::take |
|
inline |
A view adaptor that returns the first size
elements from the underlying range (or less if the underlying range is shorter).
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
[in] | size | The target size of the view. |
- Returns
- Up to
size
elements of the underlying range.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
Example
std::string vec{"foobar"};
◆ take_exactly
auto constexpr seqan3::view::take_exactly |
|
inline |
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_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
[in] | size | The target size of the view. |
- Returns
- Up to
size
elements of the underlying range.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
The difference to seqan3::view::take is that this view always exposes size information (while seqan3::view::take never does so). You should only use this if you know that the underlying range will always be at least size
long.
For seqan3::view::take_exactly if the underlying range is shorter than size
, the behaviour is undefined. seqan3::view::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
std::string vec{"foobar"};
The behaviour differs when the underlying sequence is shorter:
std::string vec{"foo"};
try
{
}
catch (std::invalid_argument &)
{}
◆ take_exactly_or_throw
auto constexpr seqan3::view::take_exactly_or_throw |
|
inline |
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
-
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
[in] | size | The target size of the view. |
- Returns
- Up to
size
elements of the underlying range.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
The difference to seqan3::view::take is that this view always exposes size information (while seqan3::view::take never does so). You should only use this if you know that the underlying range will always be at least size
long.
For seqan3::view::take_exactly if the underlying range is shorter than size
, the behaviour is undefined. seqan3::view::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
std::string vec{"foobar"};
The behaviour differs when the underlying sequence is shorter:
std::string vec{"foo"};
try
{
}
catch (std::invalid_argument &)
{}
◆ take_line
auto constexpr seqan3::view::take_line |
|
inline |
A view adaptor that returns a single line from the underlying range or the full range if there is no newline.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- All characters of the underlying range up until, but excluding a unix or windows end-line (
\n
or \r\n
). See below for the properties of the returned range.
This adaptor returns a single line excluding the end-line character(s), but moving the cursor behind them for single-pass ranges. I.e. for all ranges that satisfy std::ranges::ForwardRange this is the same as calling
ranges::view::take_while([] (auto const & l) { return (l != '\r') && (l != '\n'); });
but for single pass input ranges this means that the endline is also consumed.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
Example
Behaviour on std::ranges::ForwardRange:
std::string vec{"foo\nbar"};
On single pass std::ranges::InputRange it can be used to tokenise the input stream line-wise:
std::string vec{"foo\nbar"};
◆ take_line_or_throw
auto constexpr seqan3::view::take_line_or_throw |
|
inline |
A view adaptor that returns a single line from the underlying range (throws if there is no end-of-line).
- Exceptions
-
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- All characters of the underlying range up until, but excluding a unix or windows end-line (
\n
or \r\n
). See below for the properties of the returned range.
This adaptor returns a single line excluding the end-line character(s), but moving the cursor behind them for single-pass ranges. I.e. for all ranges that satisfy std::ranges::ForwardRange this is the same as calling
ranges::view::take_while([] (auto const & l) { return (l != '\r') && (l != '\n'); });
but for single pass input ranges this means that the endline is also consumed.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
Example
Behaviour on std::ranges::ForwardRange:
std::string vec{"foo\nbar"};
On single pass std::ranges::InputRange it can be used to tokenise the input stream line-wise:
std::string vec{"foo\nbar"};
◆ take_until
auto constexpr seqan3::view::take_until |
|
inline |
A view adaptor that returns elements from the underlying range until the functor evaluates to true (or the end of the underlying range is reached).
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
fun_t | The type of the functor; must model std::Invocable with seqan3::reference_t<urng_t> and return a type convertible to bool . |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
[in] | fun | The functor. |
- Returns
- All elements of the underlying range up until (but excluding) the element that evaluates the functor to true.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
This view only preserves certain concepts if the specified functor models seqan3::regular_std::Invocable<fun_t, reference_t<urng_t>, i.e. applying the functor doesn't change the functor. If the functor only models std::Invocable and not seqan3::regular_invocable_concept these concepts are lost.
Example
std::string vec{"foo\nbar"};
◆ take_until_or_throw
auto constexpr seqan3::view::take_until_or_throw |
|
inline |
A view adaptor that returns elements from the underlying range until the functor evaluates to true (throws if the end of the underlying range is reached).
- Exceptions
-
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
fun_t | The type of the functor; must model std::Invocable with seqan3::reference_t<urng_t> and return a type convertible to bool . |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
[in] | fun | The functor. |
- Returns
- All elements of the underlying range up until (but excluding) the element that evaluates the functor to true.
View properties
See the view submodule documentation for detailed descriptions of the view properties.
This view only preserves certain concepts if the specified functor models seqan3::regular_std::Invocable<fun_t, reference_t<urng_t>, i.e. applying the functor doesn't change the functor. If the functor only models std::Invocable and not seqan3::regular_invocable_concept these concepts are lost.
Example
std::string vec{"foo\nbar"};
◆ to_char
auto const seqan3::view::to_char |
|
inline |
A view that calls seqan3::to_char() on each element in the input range.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of converted elements. See below for the properties of the returned 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).
See the view submodule documentation for detailed descriptions of the view properties.
Example
dna4_vector vec = "ACTTTGATA"_dna4;
std::vector<phred42> qvec{{0}, {7}, {5}, {3}, {7}, {4}, {30}, {16}, {23}};
std::vector<dna4q> qcvec{{'C'_dna4, phred42{0}}, {'A'_dna4, phred42{7}}, {'G'_dna4, phred42{5}}, {'T'_dna4, phred42{3}},
{'G'_dna4, phred42{7}}, {'A'_dna4, phred42{4}}, {'C'_dna4, phred42{30}}, {'T'_dna4, phred42{16}}, {'A'_dna4, phred42{23}}};
◆ to_rank
auto const seqan3::view::to_rank |
|
inline |
A view that calls seqan3::to_rank() on each element in the input range.
- Template Parameters
-
urng_t | The type of the range being processed. See below for requirements. [template parameter is omitted in pipe notation] |
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
- Returns
- A range of converted elements. See below for the properties of the returned 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).
See the view submodule documentation for detailed descriptions of the view properties.
- Example
dna4_vector vec = "ACTTTGATA"_dna4;
std::vector<phred42> qvec{{0}, {7}, {5}, {3}, {7}, {4}, {30}, {16}, {23}};
std::vector<dna4q> qcvec{{'C'_dna4, phred42{0}}, {'A'_dna4, phred42{7}}, {'G'_dna4, phred42{5}}, {'T'_dna4, phred42{3}},
{'G'_dna4, phred42{7}}, {'A'_dna4, phred42{4}}, {'C'_dna4, phred42{30}}, {'T'_dna4, phred42{16}}, {'A'_dna4, phred42{23}}};
We also convert to unsigned here, because the seqan3::underlying_rank_t is often uint8_t
which is often implemented as unsigned char
and thus will not be printed as a number by default.
◆ translate
constexpr auto seqan3::view::translate |
|
inline |
A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames.
- Template Parameters
-
urng_t | The type of the range being processed. |
- Parameters
-
[in] | urange | The range being processed. |
[in] | tf | A value of seqan3::tanslation_frames that indicates the desired frames. |
- Returns
- A range of ranges containing frames with aminoacid sequence. See below for the properties of the returned range.
This view can be used to translate nucleotide sequences into aminoacid sequences (see translation_frames for possible combination of frames).
View properties
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 View.
Example
Operating on a range of seqan3::dna5:
dna5_vector vec{"ACGTACGTACGTA"_dna5};
◆ translate_single
constexpr auto seqan3::view::translate_single |
|
inline |
A view that translates nucleotide into aminoacid alphabet for one of the six frames.
- Template Parameters
-
urng_t | The type of the range being processed. |
- Parameters
-
- Returns
- A range containing frames with aminoacid sequence. See below for the properties of the returned range.
This view can be used to translate nucleotide sequences into aminoacid sequences (see translation_frames for possible combination of frames).
View properties
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 View.
Example
Operating on a range of seqan3::dna5:
dna5_vector vec{"ACGTACGTACGTA"_dna5};
◆ trim
constexpr auto seqan3::view::trim |
|
inline |
A view that does quality-threshold trimming on a range of seqan3::quality_concept.
- Template Parameters
-
- Parameters
-
[in] | urange | The range being processed. [parameter is omitted in pipe notation] |
[in] | threshold | The minimum quality. |
- Returns
- A trimmed range. See below for the properties of the returned range.
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).
See the view submodule documentation for detailed descriptions of the view properties.
- Example
Operating on a range of seqan3::phred42:
std::vector<phred42> vec{phred42{40}, phred42{40}, phred42{30}, phred42{20}, phred42{10}};
Or operating on a range of seqan3::dna5q:
std::vector<dna5q> vec{{'A'_dna5, phred42{40}}, {'G'_dna5, phred42{40}}, {'G'_dna5, phred42{30}},
{'A'_dna5, phred42{20}}, {'T'_dna5, phred42{10}}};
std::vector<dna5q> cmp{{'A'_dna5, phred42{40}}, {'G'_dna5, phred42{40}}, {'G'_dna5, phred42{30}},
{'A'_dna5, phred42{20}}};
assert(std::vector<dna5q>(v1) == cmp);
assert(std::vector<dna5q>(v2) == cmp);
EXPECT_EQ("AGGA", v3);