SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches

Alphabet related views. More...

+ Collaboration diagram for Views:

Classes

struct  seqan3::detail::trim_fn
 The underlying type of seqan3::views::trim_quality. More...
 
class  seqan3::detail::view_translate< urng_t >
 The return type of seqan3::views::translate. More...
 
class  seqan3::detail::view_translate_join< urng_t >
 The return type of seqan3::views::translate_join. More...
 
class  seqan3::detail::view_translate_single< urng_t >
 The return type of seqan3::views::translate_single. More...
 

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_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 seqan3::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
seqan3::invalid_char_assignmentif 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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
std::string_view str{"ACTTTGATAN"};
try
{
seqan3::debug_stream << (str | seqan3::views::char_strictly_to<seqan3::dna4>); // ACTTTGATA
}
{
seqan3::debug_stream << "\n[ERROR] Invalid char!\n"; // Will throw on parsing 'N'
}
}
Provides seqan3::views::char_strictly_to.
Provides seqan3::debug_stream and related types.
Provides seqan3::dna4, container aliases and string literals.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37
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_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 seqan3::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 <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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
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
}
Provides seqan3::views::char_to.
Provides seqan3::dna5, container aliases and string literals.

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_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 <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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
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
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
}
Provides seqan3::views::complement.
auto const complement
A view that converts a range of nucleotides to their complement.
Definition complement.hpp:64
The SeqAn namespace for literals.

This entity is stable. Since version 3.1.

◆ minimiser_hash

constexpr auto seqan3::views::minimiser_hash
inlineconstexpr

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

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]shapeThe seqan3::shape that determines how to compute the hash value.
[in]window_sizeThe window size to use.
[in]seedThe 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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
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::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(0b10101_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]
}
A class that defines which positions of a pattern to hash.
Definition shape.hpp:57
constexpr auto minimiser_hash
Computes minimisers for a range with a given shape, window size and seed.
Definition minimiser_hash.hpp:190
Provides seqan3::views::minimiser_hash.
strong_type for seed.
Definition minimiser_hash.hpp:22
A strong type of underlying type uint8_t that represents the ungapped shape size.
Definition shape.hpp:22
strong_type for the window_size.
Definition minimiser_hash.hpp:29

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_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 seqan3::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 <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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <vector>
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
}
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_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 <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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <vector>
#include <seqan3/alphabet/quality/aliases.hpp> // includes seqan3::dna4q
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]
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]
}
Provides aliases for qualified.
Quality type for traditional Sanger and modern Illumina Phred scores.
Definition phred42.hpp:44
constexpr derived_type & assign_phred(phred_type const p) noexcept
Assign from the numeric Phred score value.
Definition phred_base.hpp:123
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition to_char.hpp:60
Provides seqan3::phred42 quality scores.
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_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 <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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <vector>
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]
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]
}
auto const to_rank
A view that calls seqan3::to_rank() on each element in the input range.
Definition to_rank.hpp:63
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

constexpr auto seqan3::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 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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
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
seqan3::debug_stream << v2 << '\n'; // [TYVR]
// reverse translation
seqan3::debug_stream << v3 << '\n'; // [TYVR,YVRT]
// forward frames translation
seqan3::debug_stream << v4 << '\n'; // [TYVR,RTYV,VRT]
// six frame translation
seqan3::debug_stream << v5 << '\n'; // [TYVR,RTYV,VRT,YVRT,TYVR,RTY]
// function syntax
seqan3::debug_stream << v6 << '\n'; // [TYVR,YVRT]
// combinability
seqan3::debug_stream << v7 << '\n'; // [CMHA,MHAC]
}
constexpr auto translate
A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames.
Definition translate.hpp:800
@ forward_frame0
The first forward frame starting at position 0.
@ forward_frames
All forward frames.
@ forward_reverse0
The first forward and first reverse frame.
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

constexpr auto seqan3::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 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:

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>
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
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
seqan3::debug_stream << v2 << "\n"; // [TYVR,SRAL]
return 0;
}
constexpr auto translate_join
A view that translates nucleotide into aminoacid alphabet with 1, 2, 3 or 6 frames....
Definition translate_join.hpp:378
Provides seqan3::views::translate_join.

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

◆ translate_single

constexpr auto seqan3::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 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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
using namespace seqan3::literals;
seqan3::dna5_vector vec{"ACGTACGTACGTA"_dna5};
// Default (first forward frame)
// == [T,Y,V,R]
seqan3::debug_stream << v1[1] << '\n';
// First forward frame
// == [T,Y,V,R]
// First reverse frame
// == [Y,V,R,T]
// Second forward frame
// == [R,T,Y,V]
// Second reverse frame
// == [T,Y,V,R]
// Third forward frame
// == [V,R,T]
// Third reverse frame
// == [R,T,Y]
// function syntax
// == [T,Y,V,R]
// combinability
auto v9 =
// == [M,H,A,C]
// combinability with default parameter
// == [C,M,H,A]
// combinability with default parameter
// == [C,M,H,A]
}
constexpr auto translate_single
A view that translates nucleotide into aminoacid alphabet for one of the six frames.
Definition translate.hpp:520
@ forward_frame2
The third forward frame starting at position 2.
@ reverse_frame0
The first reverse frame starting at position 0.
@ reverse_frame2
The third reverse frame starting at position 2.
@ forward_frame1
The second forward frame starting at position 1.
@ reverse_frame1
The second reverse frame starting at position 1.

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

◆ trim_quality

constexpr auto seqan3::views::trim_quality
inlineconstexpr

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

Template Parameters
urng_tThe type of the range being processed. See below for requirements.
threshold_tEither std::ranges::range_value_t<urng_t> or seqan3::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 <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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <string>
#include <vector>
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
seqan3::debug_stream << v4 << '\n'; // II?5
}
constexpr auto trim_quality
A view that does quality-threshold trimming on a range of seqan3::quality_alphabet.
Definition trim_quality.hpp:126
Provides seqan3::views::trim_quality.

Or operating on a range of seqan3::dna5q:

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <string>
#include <vector>
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
seqan3::debug_stream << v3 << '\n'; // AGGA
}
Joins an arbitrary alphabet with a quality alphabet.
Definition qualified.hpp:59

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_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 seqan3::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
seqan3::invalid_char_assignmentif 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-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
std::string_view str{"ACTTTGATAN"};
try
{
seqan3::debug_stream << (str | seqan3::views::validate_char_for<seqan3::dna4>); // ACTTTGATA
}
{
seqan3::debug_stream << "\n[ERROR] Invalid char!\n"; // Will throw on parsing 'N'
}
}
Provides seqan3::views::validate_char_for.

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

Hide me