Loading...
Searching...
No Matches
Views
Alphabet

Alphabet related views. More...

Collaboration diagram for Views:

## Variables

template<alphabet alphabet_type>
auto const | seqan3::views::char_strictly_to
| A view over an alphabet, given a range of characters.
template<alphabet alphabet_type>
auto const | seqan3::views::char_to
| A view over an alphabet, given a range of characters.
auto const | seqan3::views::complement
| A view that converts a range of nucleotides to their complement.
template<typename alphabet_type>
auto const | seqan3::views::rank_to
| A view over an alphabet, given a range of ranks.
auto const | seqan3::views::to_char
| A view that calls seqan3::to_char() on each element in the input range.
auto const | seqan3::views::to_rank
| A view that calls seqan3::to_rank() on each element in the input range.
constexpr auto | seqan3::views::translate
| A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames.
constexpr auto | seqan3::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 | seqan3::views::trim_quality
| A view that does quality-threshold trimming on a range of seqan3::quality_alphabet.
template<alphabet alphabet_type>
auto const | seqan3::views::validate_char_for
| An identity view that throws if an encountered character is not valid for the given alphabet.

## Alphabet related views

constexpr auto | seqan3::views::translate_single
| A view that translates nucleotide into aminoacid alphabet for one of the six frames.
constexpr auto | seqan3::views::minimiser_hash
| Computes minimisers for a range with a given shape, window size and seed.

## Detailed Description

Alphabet related views.

See also
  alphabet

## Variable Documentation

## char_strictly_to

template<alphabet alphabet_type>

auto const seqan3::views::char_strictly_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.

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.

Exceptions

  seqan3::invalid_char_assignment | if an invalid character is encountered.

Header File

`#include <seqan3/alphabet/views/char_strictly_to.hpp>`

This view differs from seqan3::views::chars_to in that it throws an exception if an invalid character conversion happens. See seqan3::char_strictly_to for more details.

### 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
std::semiregular |  | preserved
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::alphabet_char_t<alphabet_t> | alphabet_t

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

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/views/char_strictly_to.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
std::string_view str{"ACTTTGATAN"};
try
{
seqan3::debug_stream << (str | seqan3::views::char_strictly_to<seqan3::dna4>); // ACTTTGATA
}
catch (seqan3::invalid_char_assignment const &)
{
seqan3::debug_stream << "\n[ERROR] Invalid char!\n"; // Will throw on parsing 'N'
}
}
std::string_view
char_strictly_to.hpp
Provides seqan3::views::char_strictly_to.
debug_stream.hpp
Provides seqan3::debug_stream and related types.
dna4.hpp
Provides seqan3::dna4, container aliases and string literals.
seqan3::views::char_strictly_to
auto const char_strictly_to
A view over an alphabet, given a range of characters.
Definition char_strictly_to.hpp:69
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:38
seqan3::invalid_char_assignment
An exception typically thrown by seqan3::alphabet::assign_char_strict.
Definition alphabet/exception.hpp:27

This entity is experimental and subject to change in the future. Experimental since version 3.2.

## char_to

template<alphabet alphabet_type>

auto const seqan3::views::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.

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.

Header File

`#include <seqan3/alphabet/views/char_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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::alphabet_char_t<alphabet_t> | alphabet_t

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

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/views/char_to.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
std::string str{"ACTTTGATAN"};
seqan3::debug_stream << (str | seqan3::views::char_to<seqan3::dna4>) << '\n'; // ACTTTGATAA
seqan3::debug_stream << (str | seqan3::views::char_to<seqan3::dna5>) << '\n'; // ACTTTGATAN
}
std::string
char_to.hpp
Provides seqan3::views::char_to.
dna5.hpp
Provides seqan3::dna5, container aliases and string literals.
seqan3::views::char_to
auto const char_to
A view over an alphabet, given a range of characters.
Definition char_to.hpp:64

This entity is stable. Since version 3.1.

## complement

auto const seqan3::views::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.

Header File

`#include <seqan3/alphabet/views/complement.hpp>`

Calls seqan3::nucleotide_alphabet::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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::nucleotide_alphabet | std::remove_reference_t<std::ranges::range_reference_t<urng_t>>

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

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/views/complement.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::dna5_vector foo{"ACGTA"_dna5};
// pipe notation
auto v = foo | seqan3::views::complement;
seqan3::debug_stream << v << '\n'; // TGCAT
// function notation
auto v2(seqan3::views::complement(foo));
seqan3::debug_stream << v2 << '\n'; // TGCAT
// generate the reverse complement:
auto v3 = foo | seqan3::views::complement | std::views::reverse;
seqan3::debug_stream << v3 << '\n'; // TACGT
}
complement.hpp
Provides seqan3::views::complement.
seqan3::views::complement
auto const complement
A view that converts a range of nucleotides to their complement.
Definition complement.hpp:64
seqan3::literals
The SeqAn namespace for literals.

This entity is stable. Since version 3.1.

## minimiser_hash

auto seqan3::views::minimiser_hash

inline constexpr

Computes minimisers for a range with a given shape, window size and seed.

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] | shape | The seqan3::shape that determines how to compute the hash value.
  [in] | window_size | The window size to use.
  [in] | seed | The seed used to skew the hash values. Default: 0x8F3F73B5CF1C9ADE.

Returns
  A range of size_t where each value is the minimiser of the resp. window. See below for the properties of the returned range.

A sequence can be presented by a small number of k-mers (minimisers). For a given shape and window size all k-mers are determined in the forward strand and the backward strand and only the lexicographically smallest k-mer is returned for one window. This process is repeated over every possible window of a sequence. If consecutive windows share a minimiser, it is saved only once. For example, in the sequence "TAAAGTGCTAAA" for an ungapped shape of length 3 and a window size of 5 the first, the second and the last window contain the same minimiser "AAA". Because the minimisers of the first two consecutive windows also share the same position, storing this minimiser twice is redundant and it is stored only once. The "AAA" minimiser of the last window on the other hand is stored, since it is located at an other position than the previous "AAA" minimiser and hence storing the second "AAA"-minimiser is not redundant but necessary.

### Non-lexicographical Minimisers by skewing the hash value with a seed

It might happen that a minimiser changes only slightly when sliding the window over the sequence. For instance, when a minimiser starts with a repetition of A’s, then in the next window it is highly likely that the minimiser will start with a repetition of A’s as well. Because it is only one A shorter, depending on how long the repetition is this might go on for multiple window shifts. Saving these only slightly different minimiser makes no sense because they contain no new information about the underlying sequence. Additionally, sequences with a repetition of A’s will be seen as more similar to each other than they actually are. As Marçais et al. have shown, randomizing the order of the k-mers can solve this problem. Therefore, a random seed is used to XOR all k-mers, thereby randomizing the order. The user can change the seed to any other value he or she thinks is useful. A seed of 0 is returning the lexicographical order.

See also
  seqan3::views::minimiser_view

Attention
  Be aware of the requirements of the seqan3::views::kmer_hash view.

This entity is experimental and subject to change in the future.

### 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 |  | 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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::semialphabet | std::size_t

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

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/search/views/minimiser_hash.hpp>
using namespace seqan3::literals;
int main()
{
std::vector<seqan3::dna4> text{"CCACGTCGACGGTT"_dna4};
// Here a consecutive shape with size 4 (so the k-mer size is 4) and a window size of 8 is used. The seed is set
// to 0, so lexicographical ordering is used for demonstration purposes.
auto minimisers =
text
| seqan3::views::minimiser_hash(seqan3::shape{seqan3::ungapped{4}}, seqan3::window_size{8}, seqan3::seed{0});
seqan3::debug_stream << minimisers << '\n';
// This leads to [27,97,26,22,5] representing the k-mers [ACGT, CGAC, ACGG, accg, aacc], smaller case k-mers are
// coming from the reverse strand.
// Here a gapped shape with size 5 (and a k-mer size of 3) and a window size of 8 is used. The seed is set
// to 0, so lexicographical ordering is used for demonstration purposes.
auto minimisers2 = text | seqan3::views::minimiser_hash(0b1'0101_shape, seqan3::window_size{8}, seqan3::seed{0});
seqan3::debug_stream << minimisers2 << '\n';
// This leads to [9, 18, 7, 6] representing the k-mers [A.G.C, C.A.G, a.c.t, a.c.g]
}
seqan3::shape
A class that defines which positions of a pattern to hash.
Definition shape.hpp:57
seqan3::views::minimiser_hash
constexpr auto minimiser_hash
Computes minimisers for a range with a given shape, window size and seed.
Definition minimiser_hash.hpp:190
minimiser_hash.hpp
Provides seqan3::views::minimiser_hash.
seqan3::seed
strong_type for seed.
Definition minimiser_hash.hpp:22
seqan3::ungapped
A strong type of underlying type uint8_t that represents the ungapped shape size.
Definition shape.hpp:22
seqan3::window_size
strong_type for the window_size.
Definition minimiser_hash.hpp:29
std::vector

This entity is experimental and subject to change in the future. Experimental since version 3.1.

## rank_to

template<typename alphabet_type>

auto const seqan3::views::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::writable_semialphabet.

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.

Header File

`#include <seqan3/alphabet/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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::alphabet_rank_t<alphabet_t> | alphabet_t

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

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <vector>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/views/rank_to.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
std::vector<int> vec{0, 1, 3, 3, 3, 2, 0, 3, 0};
seqan3::debug_stream << (vec | seqan3::views::rank_to<seqan3::dna4>) << '\n'; // ACTTTGATA
seqan3::debug_stream << (vec | seqan3::views::rank_to<seqan3::dna5>) << '\n'; // ACNNNGANA
}
seqan3::views::rank_to
auto const rank_to
A view over an alphabet, given a range of ranks.
Definition rank_to.hpp:63
rank_to.hpp
Provides seqan3::views::rank_to.

This entity is stable. Since version 3.1.

## to_char

auto const seqan3::views::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.

Header File

`#include <seqan3/alphabet/views/to_char.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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::alphabet | seqan3::alphabet_char_t<std::ranges::range_value_t<urng_t>>

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

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <vector>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/quality/aliases.hpp> // includes seqan3::dna4q
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::dna4_vector vec = "ACTTTGATA"_dna4;
auto v = vec | seqan3::views::to_char;
seqan3::debug_stream << v << '\n'; // [A,C,T,T,T,G,A,T,A]
std::vector<seqan3::phred42> qvec{seqan3::phred42{}.assign_phred(0),
seqan3::phred42{}.assign_phred(7),
seqan3::phred42{}.assign_phred(5),
seqan3::phred42{}.assign_phred(3),
seqan3::phred42{}.assign_phred(7),
seqan3::phred42{}.assign_phred(4),
seqan3::phred42{}.assign_phred(30),
seqan3::phred42{}.assign_phred(16),
seqan3::phred42{}.assign_phred(23)};
auto v3 = qvec | seqan3::views::to_char;
seqan3::debug_stream << v3 << '\n'; // [!,(,&,$,(,%,?,1,8]
std::vector<seqan3::dna4q> qcvec{{'C'_dna4, '!'_phred42},
{'A'_dna4, '('_phred42},
{'G'_dna4, '&'_phred42},
{'T'_dna4, '$'_phred42},
{'G'_dna4, '('_phred42},
{'A'_dna4, '%'_phred42},
{'C'_dna4, '?'_phred42},
{'T'_dna4, '1'_phred42},
{'A'_dna4, '8'_phred42}};
auto v4 = qcvec | seqan3::views::to_char;
seqan3::debug_stream << v4 << '\n'; // [C,A,G,T,G,A,C,T,A]
}
aliases.hpp
Provides aliases for qualified.
seqan3::phred42
Quality type for traditional Sanger and modern Illumina Phred scores.
Definition phred42.hpp:44
seqan3::phred_base::assign_phred
constexpr derived_type & assign_phred(phred_type const p) noexcept
Assign from the numeric Phred score value.
Definition phred_base.hpp:123
seqan3::views::to_char
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition to_char.hpp:60
phred42.hpp
Provides seqan3::phred42 quality scores.
to_char.hpp
Provides seqan3::views::to_char.

This entity is stable. Since version 3.1.

## to_rank

auto const seqan3::views::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.

Header File

`#include <seqan3/alphabet/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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::alphabet | seqan3::alphabet_rank_t<std::ranges::range_value_t<urng_t>>

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

### Example

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <vector>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/quality/aliases.hpp>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/views/to_rank.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::dna4_vector vec = "ACTTTGATA"_dna4;
auto v = vec | seqan3::views::to_rank;
seqan3::debug_stream << v << '\n'; // [0,1,3,3,3,2,0,3,0]
std::vector<seqan3::phred42> qvec{seqan3::phred42{}.assign_phred(0),
seqan3::phred42{}.assign_phred(7),
seqan3::phred42{}.assign_phred(5),
seqan3::phred42{}.assign_phred(3),
seqan3::phred42{}.assign_phred(7),
seqan3::phred42{}.assign_phred(4),
seqan3::phred42{}.assign_phred(30),
seqan3::phred42{}.assign_phred(16),
seqan3::phred42{}.assign_phred(23)};
auto v3 = qvec | seqan3::views::to_rank;
seqan3::debug_stream << v3 << '\n'; // [0,7,5,3,7,4,30,16,23]
std::vector<seqan3::dna4q> qcvec{{'C'_dna4, '!'_phred42},
{'A'_dna4, '('_phred42},
{'G'_dna4, '&'_phred42},
{'T'_dna4, '$'_phred42},
{'G'_dna4, '('_phred42},
{'A'_dna4, '%'_phred42},
{'C'_dna4, '?'_phred42},
{'T'_dna4, '1'_phred42},
{'A'_dna4, '8'_phred42}};
auto v4 = qcvec | seqan3::views::to_rank;
seqan3::debug_stream << v4 << '\n'; // [42,7,89,129,91,4,72,142,23]
}
seqan3::views::to_rank
auto const to_rank
A view that calls seqan3::to_rank() on each element in the input range.
Definition to_rank.hpp:63
to_rank.hpp
Provides seqan3::views::to_rank.

We also convert to unsigned here, because the seqan3::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.

This entity is stable. Since version 3.1.

## translate

auto seqan3::views::translate

inline constexpr

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.

Header File

`#include <seqan3/alphabet/views/translate.hpp>`

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

### 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
seqan3::const_iterable_range | required | preserved
std::ranges::range_reference_t | seqan3::nucleotide_alphabet | 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 seqan3::dna5:

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/views/complement.hpp>
#include <seqan3/alphabet/views/translate.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::dna5_vector vec{"ACGTACGTACGTA"_dna5};
// default frame translation
auto v1 = vec | seqan3::views::translate;
seqan3::debug_stream << v1 << '\n'; // [TYVR,RTYV,VRT,YVRT,TYVR,RTY]
// single frame translation
auto v2 = vec | seqan3::views::translate(seqan3::translation_frames::forward_frame0);
seqan3::debug_stream << v2 << '\n'; // [TYVR]
// reverse translation
auto v3 = vec | seqan3::views::translate(seqan3::translation_frames::forward_reverse0);
seqan3::debug_stream << v3 << '\n'; // [TYVR,YVRT]
// forward frames translation
auto v4 = vec | seqan3::views::translate(seqan3::translation_frames::forward_frames);
seqan3::debug_stream << v4 << '\n'; // [TYVR,RTYV,VRT]
// six frame translation
auto v5 = vec | seqan3::views::translate(seqan3::translation_frames::six_frames);
seqan3::debug_stream << v5 << '\n'; // [TYVR,RTYV,VRT,YVRT,TYVR,RTY]
// function syntax
auto v6 = seqan3::views::translate(vec, seqan3::translation_frames::forward_reverse0);
seqan3::debug_stream << v6 << '\n'; // [TYVR,YVRT]
// combinability
auto v7 = vec | seqan3::views::complement | seqan3::views::translate(seqan3::translation_frames::forward_reverse0);
seqan3::debug_stream << v7 << '\n'; // [CMHA,MHAC]
}
seqan3::views::translate
constexpr auto translate
A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames.
Definition translate.hpp:800
seqan3::translation_frames::forward_frame0
@ forward_frame0
The first forward frame starting at position 0.
Definition translate.hpp:60
seqan3::translation_frames::forward_frames
@ forward_frames
All forward frames.
Definition translate.hpp:69
seqan3::translation_frames::six_frames
@ six_frames
All frames.
Definition translate.hpp:71
seqan3::translation_frames::forward_reverse0
@ forward_reverse0
The first forward and first reverse frame.
Definition translate.hpp:66
translate.hpp
Provides seqan3::views::translate and seqan3::views::translate_single.

See also
  seqan3::translate_triplet
  seqan3::views::translate_single
  seqan3::views::translate_join

This entity is experimental and subject to change in the future. Experimental since version 3.1.

## translate_join

auto seqan3::views::translate_join

inline constexpr

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_t | The type of the range being processed.

Parameters

  [in] | urange | The range being processed. Needs to be a range of ranges (two-dimensional).
  [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.

Header File

`#include <seqan3/alphabet/views/translate_join.hpp>`

This view can be used to translate nucleotide sequences into aminoacid sequences (see 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:

std::vector<std::vector<dna5>> vec {...};
auto v = vec | 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.

### 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
seqan3::const_iterable_range | required | preserved
std::ranges::range_reference_t | seqan3::nucleotide_alphabet | 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 seqan3::dna5:

#include <iostream>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/views/char_to.hpp>
#include <seqan3/alphabet/views/translate_join.hpp>
#include <seqan3/core/debug_stream.hpp>
using namespace seqan3::literals;
int main()
{
// Input range needs to be two-dimensional
std::vector<std::vector<seqan3::dna4>> vec{"ACGTACGTACGTA"_dna4, "TCGAGAGCTTTAGC"_dna4};
// Translation with default parameters
auto v1 = vec | seqan3::views::translate_join;
seqan3::debug_stream << v1 << "\n"; // [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];
seqan3::debug_stream << third_frame_second_seq << "\n"; // ESFS
// Translation with custom translation frame
auto v2 = vec | seqan3::views::translate_join(seqan3::translation_frames::forward_frame0);
seqan3::debug_stream << v2 << "\n"; // [TYVR,SRAL]
return 0;
}

This entity is experimental and subject to change in the future. Experimental since version 3.1.

## translate_single

auto seqan3::views::translate_single

inline constexpr

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

  [in] | urange | The range being processed.
  [in] | tf | A value of seqan3::translation_frames that indicates the desired frames.

Returns
  A range containing frames with aminoacid sequence. See below for the properties of the returned range.

Header File

`#include <seqan3/alphabet/views/translate.hpp>`

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

### 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
seqan3::const_iterable_range | required | preserved
std::ranges::range_reference_t | seqan3::nucleotide_alphabet | seqan3::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 seqan3::dna5:

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/views/complement.hpp>
#include <seqan3/alphabet/views/translate.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
using namespace seqan3::literals;
seqan3::dna5_vector vec{"ACGTACGTACGTA"_dna5};
// Default (first forward frame)
auto v1 = vec | seqan3::views::translate_single;
// == [T,Y,V,R]
seqan3::debug_stream << v1[1] << '\n';
// First forward frame
auto v2 = vec | seqan3::views::translate_single(seqan3::translation_frames::forward_frame0);
// == [T,Y,V,R]
// First reverse frame
auto v3 = vec | seqan3::views::translate_single(seqan3::translation_frames::reverse_frame0);
// == [Y,V,R,T]
// Second forward frame
auto v4 = vec | seqan3::views::translate_single(seqan3::translation_frames::forward_frame1);
// == [R,T,Y,V]
// Second reverse frame
auto v5 = vec | seqan3::views::translate_single(seqan3::translation_frames::reverse_frame1);
// == [T,Y,V,R]
// Third forward frame
auto v6 = vec | seqan3::views::translate_single(seqan3::translation_frames::forward_frame2);
// == [V,R,T]
// Third reverse frame
auto v7 = vec | seqan3::views::translate_single(seqan3::translation_frames::reverse_frame2);
// == [R,T,Y]
// function syntax
auto v8 = seqan3::views::translate_single(vec, seqan3::translation_frames::forward_frame0);
// == [T,Y,V,R]
// combinability
auto v9 =
vec | seqan3::views::complement | seqan3::views::translate_single(seqan3::translation_frames::reverse_frame0);
// == [M,H,A,C]
// combinability with default parameter
auto v10 = vec | seqan3::views::complement | seqan3::views::translate_single;
// == [C,M,H,A]
// combinability with default parameter
auto v11 = vec | seqan3::views::complement | seqan3::views::translate_single();
// == [C,M,H,A]
}
seqan3::views::translate_single
constexpr auto translate_single
A view that translates nucleotide into aminoacid alphabet for one of the six frames.
Definition translate.hpp:520
seqan3::translation_frames::forward_frame2
@ forward_frame2
The third forward frame starting at position 2.
Definition translate.hpp:62
seqan3::translation_frames::reverse_frame0
@ reverse_frame0
The first reverse frame starting at position 0.
Definition translate.hpp:63
seqan3::translation_frames::reverse_frame2
@ reverse_frame2
The third reverse frame starting at position 2.
Definition translate.hpp:65
seqan3::translation_frames::forward_frame1
@ forward_frame1
The second forward frame starting at position 1.
Definition translate.hpp:61
seqan3::translation_frames::reverse_frame1
@ reverse_frame1
The second reverse frame starting at position 1.
Definition translate.hpp:64

This entity is experimental and subject to change in the future. Experimental since version 3.1.

## trim_quality

auto seqan3::views::trim_quality

inline constexpr

A view that does quality-threshold trimming on a range of seqan3::quality_alphabet.

Template Parameters

  urng_t | The type of the range being processed. See below for requirements.
  threshold_t | Either std::ranges::range_value_t<urng_t> or seqan3::alphabet_phred_t<std::ranges::range_value_t<urng_t>>.

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.

Header File

`#include <seqan3/alphabet/views/trim_quality.hpp>`

This view can be used to trim sequences based on quality. Only bases at the end of the sequence not meeting the specified threshold are discarded.

### 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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::quality_alphabet | 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 seqan3::phred42:

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <string>
#include <vector>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/alphabet/views/trim_quality.hpp>
#include <seqan3/core/debug_stream.hpp>
using namespace seqan3::literals;
int main()
{
std::vector<seqan3::phred42> vec{"II?5+"_phred42};
// trim by phred_value
auto v1 = vec | seqan3::views::trim_quality(20u);
seqan3::debug_stream << v1 << '\n'; // II?5
// trim by quality character
auto v2 = vec | seqan3::views::trim_quality('I'_phred42);
seqan3::debug_stream << v2 << '\n'; // II
// function syntax
auto v3 = seqan3::views::trim_quality(vec, '5'_phred42);
seqan3::debug_stream << v3 << '\n'; // II?5
// combinability
auto v4 = seqan3::views::trim_quality(vec, 20u) | seqan3::views::to_char;
seqan3::debug_stream << v4 << '\n'; // II?5
}
seqan3::views::trim_quality
constexpr auto trim_quality
A view that does quality-threshold trimming on a range of seqan3::quality_alphabet.
Definition trim_quality.hpp:126
string
trim_quality.hpp
Provides seqan3::views::trim_quality.

Or operating on a range of seqan3::dna5q:

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <string>
#include <vector>
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/quality/aliases.hpp>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/alphabet/views/trim_quality.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
using namespace seqan3::literals;
std::vector<seqan3::dna5q> vec{{'A'_dna5, 'I'_phred42},
{'G'_dna5, 'I'_phred42},
{'G'_dna5, '?'_phred42},
{'A'_dna5, '5'_phred42},
{'T'_dna5, '+'_phred42}};
// trim by phred_value
auto v1 = vec | seqan3::views::trim_quality(20u);
seqan3::debug_stream << v1 << '\n'; // AGGA
// trim by quality character; in this case the nucleotide part of the character is irrelevant
auto v2 = vec | seqan3::views::trim_quality(seqan3::dna5q{'C'_dna5, '5'_phred42});
seqan3::debug_stream << v2 << '\n'; // AGGA
// combinability
auto v3 = seqan3::views::trim_quality(vec, 20u) | seqan3::views::to_char;
seqan3::debug_stream << v3 << '\n'; // AGGA
}
seqan3::dna5q
qualified< dna5, phred42 > dna5q
An alphabet that stores a seqan3::dna5 letter and an seqan3::phred42 letter at each position.
Definition aliases.hpp:38

This entity is experimental and subject to change in the future. Experimental since version 3.1.

## validate_char_for

template<alphabet alphabet_type>

auto const seqan3::views::validate_char_for

inline

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

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 check validity for; must satisfy seqan3::alphabet.

Parameters

  [in] | urange | The 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

  seqan3::invalid_char_assignment | if an invalid character is encountered.

Header File

`#include <seqan3/alphabet/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
seqan3::const_iterable_range |  | preserved
std::ranges::range_reference_t | seqan3::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

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/alphabet/views/validate_char_for.hpp>
#include <seqan3/core/debug_stream.hpp>
int main()
{
std::string_view str{"ACTTTGATAN"};
try
{
seqan3::debug_stream << (str | seqan3::views::validate_char_for<seqan3::dna4>); // ACTTTGATA
}
catch (seqan3::invalid_char_assignment const &)
{
seqan3::debug_stream << "\n[ERROR] Invalid char!\n"; // Will throw on parsing 'N'
}
}
seqan3::views::validate_char_for
auto const validate_char_for
An identity view that throws if an encountered character is not valid for the given alphabet.
Definition validate_char_for.hpp:70
validate_char_for.hpp
Provides seqan3::views::validate_char_for.

This entity is experimental and subject to change in the future. Experimental since version 3.2.

Hide me