Skip to content

[MISC] rename seqan3::views::trim to seqan3::views::trim_quality #2025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Note that 3.1.0 will be the first API stable release and interfaces in this rele
([\#1654](https://github.com/seqan/seqan3/pull/1654)).
* Added `seqan3::views::minimiser_hash`, a view that computes the minimisers of a range of type seqan3::semialphabet.
([\#1721](https://https://github.com/seqan/seqan3/pull/1721)).
* `seqan3::views:trim` has been renamed to `seqan3::views:trim_quality`.

#### Search

Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/ranges/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ We provide overview tables for all our view adaptors that document which concept
## Views in the standard library and in SeqAn

The standard library in C++20 provides a number of useful views and SeqAn provides many views, as well.
Most views provided by SeqAn3 are specific to biological operations, like seqan3::views::trim which trims sequences
Most views provided by SeqAn3 are specific to biological operations, like seqan3::views::trim_quality which trims sequences
based on the quality or seqan3::views::complement which generates the complement of a nucleotide sequence.
But SeqAn3 also provides some general purpose views.

Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/range/views/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <seqan3/range/views/to_char.hpp>
#include <seqan3/range/views/to_rank.hpp>
#include <seqan3/range/views/translate.hpp>
#include <seqan3/range/views/trim.hpp>
#include <seqan3/range/views/trim_quality.hpp>

/*!\defgroup views Views
* \brief Views are "lazy range combinators" that offer modified views onto other ranges.
Expand All @@ -52,7 +52,7 @@
*
* See the \link range range module \endlink for how views relate to containers and decorators.
*
* Most views provided by SeqAn are specific to biological operations, like seqan3::views::trim which trims
* Most views provided by SeqAn are specific to biological operations, like seqan3::views::trim_quality which trims
* sequences based on the quality or seqan3::views::complement which generates the complement of a nucleotide sequence.
* But SeqAn also provides some general purpose views.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/*!\file
* \author Hannes Hauswedell <hannes.hauswedell AT fu-berlin.de>
* \brief Provides seqan3::views::trim.
* \brief Provides seqan3::views::trim_quality.
*/

#pragma once
Expand All @@ -20,7 +20,7 @@
namespace seqan3::detail
{

/*!\brief The underlying type of seqan3::views::trim.
/*!\brief The underlying type of seqan3::views::trim_quality.
* \ingroup views
*
* Under the hood this delegates to views::take_until.
Expand All @@ -39,15 +39,15 @@ struct trim_fn
}

/*!\brief Trim based on minimum phred score.
* \tparam irng_t The type of the range being processed. See seqan3::views::trim for requirements.
* \tparam irng_t The type of the range being processed. See seqan3::views::trim_quality for requirements.
* \param irange The range being processed.
* \param threshold The minimum quality as a phred score [integral type].
*/
template <std::ranges::input_range irng_t, typename threshold_t>
constexpr auto operator()(irng_t && irange, threshold_t const threshold) const
{
static_assert(quality_alphabet<std::remove_reference_t<std::ranges::range_reference_t<irng_t>>>,
"views::trim can only operate on ranges over seqan3::quality_alphabet.");
"views::trim_quality can only operate on ranges over seqan3::quality_alphabet.");
static_assert(std::same_as<remove_cvref_t<threshold_t>,
remove_cvref_t<std::ranges::range_reference_t<irng_t>>> ||
std::integral<remove_cvref_t<threshold_t>>,
Expand Down Expand Up @@ -90,7 +90,7 @@ namespace seqan3::views
*
* \details
*
* \header_file{seqan3/range/views/trim.hpp}
* \header_file{seqan3/range/views/trim_quality.hpp}
*
* This view can be used to do easy quality based trimming of sequences.
*
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace seqan3::views
* \hideinitializer
*/

inline constexpr auto trim = deep{seqan3::detail::trim_fn{}};
inline constexpr auto trim_quality = deep{seqan3::detail::trim_fn{}};

//!\}

Expand Down
8 changes: 4 additions & 4 deletions test/snippet/range/views/trim_dna5q.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <seqan3/alphabet/nucleotide/dna5.hpp>
#include <seqan3/alphabet/quality/aliases.hpp>
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/range/views/trim.hpp>
#include <seqan3/range/views/trim_quality.hpp>
#include <seqan3/range/views/to_char.hpp>
#include <seqan3/range/views/to.hpp>

Expand All @@ -23,14 +23,14 @@ int main()
{'A'_dna5, '5'_phred42}};

// trim by phred_value
auto v1 = vec | seqan3::views::trim(20u);
auto v1 = vec | seqan3::views::trim_quality(20u);
assert((v1 | seqan3::views::to<std::vector>) == cmp);

// trim by quality character; in this case the nucleotide part of the character is irrelevant
auto v2 = vec | seqan3::views::trim(seqan3::dna5q{'C'_dna5, '5'_phred42});
auto v2 = vec | seqan3::views::trim_quality(seqan3::dna5q{'C'_dna5, '5'_phred42});
assert((v2 | seqan3::views::to<std::vector>) == cmp);

// combinability
auto v3 = seqan3::views::trim(vec, 20u) | seqan3::views::to_char;
auto v3 = seqan3::views::trim_quality(vec, 20u) | seqan3::views::to_char;
assert(std::ranges::equal(std::string{"AGGA"}, v3 | seqan3::views::to<std::string>));
}
10 changes: 5 additions & 5 deletions test/snippet/range/views/trim_phred42.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <vector>

#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/range/views/trim.hpp>
#include <seqan3/range/views/trim_quality.hpp>
#include <seqan3/range/views/to_char.hpp>

int main()
Expand All @@ -11,14 +11,14 @@ int main()
seqan3::phred42{20}, seqan3::phred42{10}};

// trim by phred_value
auto v1 = vec | seqan3::views::trim(20u); // == ['I','I','?','5']
auto v1 = vec | seqan3::views::trim_quality(20u); // == ['I','I','?','5']

// trim by quality character
auto v2 = vec | seqan3::views::trim(seqan3::phred42{40}); // == ['I','I']
auto v2 = vec | seqan3::views::trim_quality(seqan3::phred42{40}); // == ['I','I']

// function syntax
auto v3 = seqan3::views::trim(vec, 20u); // == ['I','I','?','5']
auto v3 = seqan3::views::trim_quality(vec, 20u); // == ['I','I','?','5']

// combinability
auto v4 = seqan3::views::trim(vec, 20u) | seqan3::views::to_char; // == "II?5"
auto v4 = seqan3::views::trim_quality(vec, 20u) | seqan3::views::to_char; // == "II?5"
}
20 changes: 10 additions & 10 deletions test/unit/range/views/view_trim_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <seqan3/range/concept.hpp>
#include <seqan3/range/views/to_char.hpp>
#include <seqan3/range/views/to.hpp>
#include <seqan3/range/views/trim.hpp>
#include <seqan3/range/views/trim_quality.hpp>
#include <seqan3/std/ranges>

using seqan3::operator""_dna5;
Expand All @@ -27,19 +27,19 @@ TEST(view_trim, standalone)
std::vector<seqan3::phred42> cmp2{seqan3::phred42{40}, seqan3::phred42{40}};

// trim by phred_value
auto v1 = vec | seqan3::views::trim(20u); // == ['I','I','?','5']
auto v1 = vec | seqan3::views::trim_quality(20u); // == ['I','I','?','5']
EXPECT_EQ(v1 | seqan3::views::to<std::vector>, cmp1);

// trim by quality character
auto v2 = vec | seqan3::views::trim(seqan3::phred42{40}); // == ['I','I']
auto v2 = vec | seqan3::views::trim_quality(seqan3::phred42{40}); // == ['I','I']
EXPECT_EQ(v2 | seqan3::views::to<std::vector>, cmp2);

// function syntax
auto v3 = seqan3::views::trim(vec, 20u); // == ['I','I','?','5']
auto v3 = seqan3::views::trim_quality(vec, 20u); // == ['I','I','?','5']
EXPECT_EQ(v3 | seqan3::views::to<std::vector>, cmp1);

// combinability
std::string v4 = seqan3::views::trim(vec, 20u) | seqan3::views::to_char | seqan3::views::to<std::string>; //=="II?5"
std::string v4 = seqan3::views::trim_quality(vec, 20u) | seqan3::views::to_char | seqan3::views::to<std::string>; //=="II?5"
EXPECT_EQ("II?5", v4);
}

Expand All @@ -58,19 +58,19 @@ TEST(view_trim, qualified)
{'G'_dna5, seqan3::phred42{40}}};

// trim by phred_value
auto v1 = vec | seqan3::views::trim(20u);
auto v1 = vec | seqan3::views::trim_quality(20u);
EXPECT_EQ(v1 | seqan3::views::to<std::vector>, cmp1);

// trim by quality character
auto v2 = vec | seqan3::views::trim(seqan3::dna5q{'C'_dna5, seqan3::phred42{40}});
auto v2 = vec | seqan3::views::trim_quality(seqan3::dna5q{'C'_dna5, seqan3::phred42{40}});
EXPECT_EQ(v2 | seqan3::views::to<std::vector>, cmp2);

// function syntax
auto v3 = seqan3::views::trim(vec, 20u);
auto v3 = seqan3::views::trim_quality(vec, 20u);
EXPECT_EQ(v3 | seqan3::views::to<std::vector>, cmp1);

// combinability
std::string v4 = seqan3::views::trim(vec, 20u) | seqan3::views::to_char | seqan3::views::to<std::string>;
std::string v4 = seqan3::views::trim_quality(vec, 20u) | seqan3::views::to_char | seqan3::views::to<std::string>;
EXPECT_EQ("AGGA", v4);
}

Expand All @@ -88,7 +88,7 @@ TEST(view_trim, concepts)
EXPECT_TRUE((std::ranges::output_range<decltype(vec), seqan3::dna5q>));
EXPECT_TRUE(std::ranges::sized_range<decltype(vec)>);

auto v1 = vec | seqan3::views::trim(20u);
auto v1 = vec | seqan3::views::trim_quality(20u);
EXPECT_TRUE(std::ranges::input_range<decltype(v1)>);
EXPECT_TRUE(std::ranges::forward_range<decltype(v1)>);
EXPECT_TRUE(std::ranges::random_access_range<decltype(v1)>);
Expand Down