SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
seqan3::views Namespace Reference

The SeqAn namespace for views. More...

Classes

class  deep
 A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view. More...
 

Variables

template<simd::simd_concept simd_t>
constexpr auto to_simd
 A view that transforms a range of ranges into chunks of seqan3::simd vectors. More...
 
General purpose views
const auto as_const
 A view that provides only const & to elements of the underlying range. More...
 
constexpr auto async_input_buffer
 A view adapter that returns a concurrent-queue-like view over the underlying range. More...
 
template<typename out_t >
const auto convert
 A view that converts each element in the input range (implicitly or via static_cast). More...
 
constexpr auto drop
 A view adaptor that returns all elements after n from the underlying range (or an empty range if the underlying range is shorter). More...
 
constexpr auto enforce_random_access
 A view adaptor that converts a pseudo random access range to a std::random_access_range. More...
 
template<auto index>
const auto get
 A view calling std::get on each element in a range. More...
 
constexpr auto interleave
 A view that interleaves a given range into another range at regular intervals. More...
 
constexpr auto istreambuf
 A view factory that returns a view over the stream buffer of an input stream. More...
 
const auto move
 A view that turns lvalue-references into rvalue-references. More...
 
constexpr auto pairwise_combine
 A view adaptor that generates all pairwise combinations of the elements of the underlying range. More...
 
constexpr auto persist
 A view adaptor that wraps rvalue references of non-views. More...
 
constexpr detail::repeat_fn repeat
 A view factory that repeats a given value infinitely. More...
 
constexpr auto repeat_n
 A view factory that repeats a given value n times. More...
 
constexpr auto single_pass_input
 A view adapter that decays most of the range properties and adds single pass behavior. More...
 
constexpr auto slice
 A view adaptor that returns a half-open interval on the underlying range. More...
 
constexpr auto take
 A view adaptor that returns the first size elements from the underlying range (or less if the underlying range is shorter). More...
 
constexpr auto 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...
 
constexpr auto 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...
 
constexpr auto take_line = views::take_until_and_consume(is_char<'\r'> || is_char<'\n'>)
 A view adaptor that returns a single line from the underlying range or the full range if there is no newline. More...
 
constexpr auto take_line_or_throw = views::take_until_or_throw_and_consume(is_char<'\r'> || is_char<'\n'>)
 A view adaptor that returns a single line from the underlying range (throws if there is no end-of-line). More...
 
constexpr auto 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...
 
constexpr auto 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...
 
constexpr auto take_until_and_consume
 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; consumes end in single-pass ranges). More...
 
constexpr auto take_until_or_throw_and_consume
 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; consumes end in single-pass ranges). More...
 
const auto to_lower
 A view that calls seqan3::to_lower() on each element in the input range. More...
 
const auto to_upper
 A view that calls seqan3::to_upper() on each element in the input range. More...
 
constexpr auto type_reduce
 A view adaptor that behaves like std::views::all, but type erases certain ranges. More...
 
Alphabet related views
template<alphabet alphabet_type>
const auto char_to
 A view over an alphabet, given a range of characters. More...
 
const auto complement
 A view that converts a range of nucleotides to their complement. More...
 
constexpr auto kmer_hash
 Computes hash values for each position of a range via a given shape. More...
 
template<typename alphabet_type >
const auto rank_to
 A view over an alphabet, given a range of ranks. More...
 
const auto to_char
 A view that calls seqan3::to_char() on each element in the input range. More...
 
const auto to_rank
 A view that calls seqan3::to_rank() on each element in the input range. More...
 
constexpr auto translate_single
 A view that translates nucleotide into aminoacid alphabet for one of the six frames. More...
 
constexpr auto translate
 A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames. More...
 
constexpr auto 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. More...
 
constexpr auto trim
 A view that does quality-threshold trimming on a range of seqan3::quality_alphabet. More...
 

Detailed Description

The SeqAn namespace for views.

Since views often have name clashes with regular functions and ranges they are implemented in the sub namespace view.

See the views submodule of the range module for more details.

Variable Documentation

◆ to_simd

template<simd::simd_concept simd_t>
constexpr auto seqan3::views::to_simd
inlineconstexpr

A view that transforms a range of ranges into chunks of seqan3::simd vectors.

Template Parameters
urng_tThe type of the range being processed.
simd_tThe target simd vector type.
Parameters
[in]urangeThe range being processed.
[in]paddingAn optional padding value.
Returns
A range of ranges with the original sequences transformed into simd vectors.

Header File

#include <seqan3/core/simd/view_to_simd.hpp>

This view can be used to transform a collection of sequences into chunks of simd vectors. This transformation is also known as Array-of-Structure to Structure-of-Array transformation. It is used to transform the memory layout of the sequences to a more efficient form when used in vectorised algorithms. The number of sequences contained in the range to be transformed cannot be larger than the number of elements stored in the target simd vector, i.e. the size of urange <= simd_traits<simd_t>::length. After applying the transformation one column of the outer range is transposed into a simd vector. This means that the characters of all sequences at a given position x are stored in a simd vector retaining the original order. The returned range itself is a range-of-ranges. When dereferencing the iterator a std::span over a std::array with at most simd length many vectors is returned. If a sequence is empty or ends before the largest sequence in the collection, it can be padded with an optional value.

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 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 preserved (iff std::ranges::sized_range<value_type_t<urng_t>> is true)
std::ranges::common_range lost
std::ranges::output_range lost
seqan3::const_iterable_range lost
std::ranges::range_reference_t std::span<simd_t>
  • urng_t is the type of the range modified by this view (input).
  • the expression std::ranges::input_range<value_type_t<urng_t> must evaluate to true
  • the expression std::default_constructible<value_type_t<urng_t>> must evaluate to true
  • the expression semialphabet<value_type_t<value_type_t<urng_t>>> must evaluate to true
  • rrng_type is the type of the range returned by this view.
  • for more details, see Views.

Example

#include <vector>
using uint16x8_t = seqan3::simd_type_t<uint16_t, 8>;
int main()
{
using seqan3::operator""_dna4;
// Adds 7 sequences. The eighth will be defaulted.
batch.push_back("ACGTACGTACGTACGATCG"_dna4);
batch.push_back("AGTGAGCTACGGACTAGCTACGACT"_dna4);
batch.push_back("GACTAGCACGAGCGAGATCG"_dna4);
batch.push_back("GGATCGACGGACTAGC"_dna4);
batch.push_back("ACGTACGACGGACGTACGAGCGAGCTACGAGC"_dna4);
batch.push_back("ACGATCGACGACTAGCGAC"_dna4);
batch.push_back("GTACGGATGGTAAACCGCACAT"_dna4);
// Applies lazy transformation using `8` as a padding symbol if a sequence ends early.
auto to_soa = batch | seqan3::views::to_simd<uint16x8_t>(8);
size_t chunk_count = 0;
for (auto && chunk : to_soa)
{
seqan3::debug_stream << "Chunk " << chunk_count++ << ":\n";
for (auto & vec : chunk)
seqan3::debug_stream << vec << '\n';
}
return 0;
}

The output is as follows:

Chunk 0:
[0,0,2,2,0,0,2,8]
[1,2,0,2,1,1,3,8]
[2,3,1,0,2,2,0,8]
[3,2,3,3,3,0,1,8]
[0,0,0,1,0,3,2,8]
[1,2,2,2,1,1,2,8]
[2,1,1,0,2,2,0,8]
[3,3,0,1,0,0,3,8]
Chunk 1:
[0,0,1,2,1,1,2,8]
[1,1,2,2,2,2,2,8]
[2,2,0,0,2,0,3,8]
[3,2,2,1,0,1,0,8]
[0,0,1,3,1,3,0,8]
[1,1,2,0,2,0,0,8]
[2,3,0,2,3,2,1,8]
[0,0,2,1,0,1,1,8]
Chunk 2:
[3,2,0,8,1,2,2,8]
[1,1,3,8,2,0,1,8]
[2,3,1,8,0,1,0,8]
[8,0,2,8,2,8,1,8]
[8,1,8,8,1,8,0,8]
[8,2,8,8,2,8,3,8]
[8,0,8,8,0,8,8,8]
[8,1,8,8,2,8,8,8]
Chunk 3:
[8,3,8,8,1,8,8,8]
[8,8,8,8,3,8,8,8]
[8,8,8,8,0,8,8,8]
[8,8,8,8,1,8,8,8]
[8,8,8,8,2,8,8,8]
[8,8,8,8,0,8,8,8]
[8,8,8,8,2,8,8,8]
[8,8,8,8,1,8,8,8]
dna4.hpp
Provides seqan3::dna4, container aliases and string literals.
vector
std::vector::push_back
T push_back(T... args)
all.hpp
Meta-header for the simd module.
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:39