Skip to content

Commit

Permalink
[MISC] Deprecate seqan3::views::get
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Apr 26, 2021
1 parent c25182c commit 57a5098
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 34 deletions.
1 change: 0 additions & 1 deletion doc/tutorial/sam_file/sam_file_solution1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ write_file_dummy_struct go{};

#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/sam_file/all.hpp>
#include <seqan3/range/views/get.hpp>

int main()
{
Expand Down
10 changes: 5 additions & 5 deletions doc/tutorial/sequence_file/sequence_file_solution3.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <seqan3/std/filesystem>
#include <fstream>

#include <seqan3/core/debug_stream.hpp>
#include <seqan3/std/filesystem>

struct write_file_dummy_struct
{
Expand Down Expand Up @@ -51,12 +51,12 @@ IIIIIHIIJJIIIII
write_file_dummy_struct go{};

//![solution]
#include <seqan3/std/filesystem>
#include <seqan3/std/ranges>

#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/sequence_file/all.hpp>
#include <seqan3/range/views/get.hpp>
#include <seqan3/range/views/move.hpp>
#include <seqan3/std/filesystem>
#include <seqan3/std/ranges>

int main()
{
Expand All @@ -83,7 +83,7 @@ int main()
| std::views::take(2) // take first two records
| std::views::transform(&decltype(fin)::record_type::id) // select only ID from record
// this is the same as writing:
// | std::views::transform([](auto && record)
// | std::views::transform([](auto && record)
// {
// return record.id();
// })
Expand Down
5 changes: 2 additions & 3 deletions include/seqan3/alignment/pairwise/alignment_algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <seqan3/core/detail/empty_type.hpp>
#include <seqan3/range/container/aligned_allocator.hpp>
#include <seqan3/range/views/drop.hpp>
#include <seqan3/range/views/get.hpp>
#include <seqan3/range/views/take.hpp>
#include <seqan3/utility/simd/concept.hpp>
#include <seqan3/utility/simd/simd.hpp>
Expand Down Expand Up @@ -204,8 +203,8 @@ class alignment_algorithm :
static_assert(simd_concept<typename traits_t::trace_type>, "Expected simd trace type.");

// Extract the batch of sequences for the first and the second sequence.
auto sequence1_range = indexed_sequence_pairs | views::get<0> | views::get<0>;
auto sequence2_range = indexed_sequence_pairs | views::get<0> | views::get<1>;
auto sequence1_range = indexed_sequence_pairs | std::views::elements<0> | std::views::elements<0>;
auto sequence2_range = indexed_sequence_pairs | std::views::elements<0> | std::views::elements<1>;

// Initialise the find_optimum policy in the simd case.
this->initialise_find_optimum_policy(sequence1_range,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/core/detail/empty_type.hpp>
#include <seqan3/range/container/aligned_allocator.hpp>
#include <seqan3/range/views/get.hpp>
#include <seqan3/utility/detail/type_name_as_string.hpp>
#include <seqan3/utility/simd/views/to_simd.hpp>

Expand Down Expand Up @@ -161,8 +160,8 @@ class pairwise_alignment_algorithm : protected policies_t...
using original_score_t = typename traits_type::original_score_type;

// Extract the batch of sequences for the first and the second sequence.
auto seq1_collection = indexed_sequence_pairs | views::get<0> | views::get<0>;
auto seq2_collection = indexed_sequence_pairs | views::get<0> | views::get<1>;
auto seq1_collection = indexed_sequence_pairs | std::views::elements<0> | std::views::elements<0>;
auto seq2_collection = indexed_sequence_pairs | std::views::elements<0> | std::views::elements<1>;

this->initialise_tracker(seq1_collection, seq2_collection);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class pairwise_alignment_algorithm_banded :
using original_score_t = typename traits_type::original_score_type;

// Extract the batch of sequences for the first and the second sequence.
auto seq1_collection = indexed_sequence_pairs | views::get<0> | views::get<0>;
auto seq2_collection = indexed_sequence_pairs | views::get<0> | views::get<1>;
auto seq1_collection = indexed_sequence_pairs | std::views::elements<0> | std::views::elements<0>;
auto seq2_collection = indexed_sequence_pairs | std::views::elements<0> | std::views::elements<1>;

this->initialise_tracker(seq1_collection, seq2_collection);

Expand Down
5 changes: 2 additions & 3 deletions include/seqan3/io/sequence_file/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <seqan3/io/sequence_file/output_format_concept.hpp>
#include <seqan3/io/sequence_file/output_options.hpp>
#include <seqan3/io/stream/concept.hpp>
#include <seqan3/range/views/get.hpp>
#include <seqan3/utility/tuple/concept.hpp>
#include <seqan3/utility/type_list/traits.hpp>
#include <seqan3/utility/views/convert.hpp>
Expand Down Expand Up @@ -603,9 +602,9 @@ class sequence_file_output
{
f.write_sequence_record(*secondary_stream,
options,
seq_qual | views::get<0>,
seq_qual | std::views::elements<0>,
id,
seq_qual | views::get<1>);
seq_qual | std::views::elements<1>);
}
else
{
Expand Down
5 changes: 2 additions & 3 deletions include/seqan3/io/structure_file/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <seqan3/io/structure_file/output_format_concept.hpp>
#include <seqan3/io/structure_file/output_options.hpp>
#include <seqan3/io/structure_file/format_vienna.hpp>
#include <seqan3/range/views/get.hpp>
#include <seqan3/utility/tuple/concept.hpp>
#include <seqan3/utility/type_list/traits.hpp>
#include <seqan3/utility/views/convert.hpp>
Expand Down Expand Up @@ -627,10 +626,10 @@ class structure_file_output
{
f.write_structure_record(*secondary_stream,
options,
structured_seq | views::get<0>,
structured_seq | std::views::elements<0>,
id,
bpp,
structured_seq | views::get<1>,
structured_seq | std::views::elements<1>,
energy,
react,
react_error,
Expand Down
1 change: 0 additions & 1 deletion include/seqan3/range/views/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <seqan3/alphabet/views/trim_quality.hpp>
#include <seqan3/range/views/complement.hpp>
#include <seqan3/range/views/enforce_random_access.hpp>
#include <seqan3/range/views/get.hpp>
#include <seqan3/range/views/interleave.hpp>
#include <seqan3/range/views/istreambuf.hpp>
#include <seqan3/range/views/move.hpp>
Expand Down
11 changes: 8 additions & 3 deletions include/seqan3/range/views/get.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/*!\file
* \author Joshua Kim <joshua.kim AT fu-berlin.de>
* \brief Provides seqan3::views::get.
* \brief [DEPRECATED] Provides seqan3::views::get.
*/

#pragma once
Expand Down Expand Up @@ -59,11 +59,15 @@ namespace seqan3::views
*
* ### Example
*
* \include test/snippet/range/views/get.cpp
* \snippet test/snippet/range/views/get.cpp snippet
* \hideinitializer
*
* \deprecated Use `std::views::elements<index>` if index is a size type, otherwise use
* `std::views::transform([] (auto && tuple) { using std::get; return get<index>(tuple); });`.
*/
#ifdef SEQAN3_DEPRECATED_310
template <auto index>
inline auto const get = std::views::transform([] (auto && in) -> decltype(auto)
SEQAN3_DEPRECATED_310 inline constexpr auto get = std::views::transform([] (auto && in) -> decltype(auto)
{
using std::get;
using seqan3::get;
Expand All @@ -76,6 +80,7 @@ inline auto const get = std::views::transform([] (auto && in) -> decltype(auto)
using ret_type = remove_rvalue_reference_t<decltype(get<index>(std::forward<decltype(in)>(in)))>;
return static_cast<ret_type>(get<index>(std::forward<decltype(in)>(in)));
});
#endif // SEQAN3_DEPRECATED_310

//!\}

Expand Down
4 changes: 1 addition & 3 deletions test/snippet/argument_parser/custom_enumeration.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include <seqan3/argument_parser/all.hpp>
#include <seqan3/range/views/all.hpp>
#include <seqan3/range/views/get.hpp>

namespace foo
{
Expand Down Expand Up @@ -29,7 +27,7 @@ int main(int argc, char const * argv[])
// Because of the enumeration_names function
// you can now add an option that takes a value of type bar:
parser.add_option(value, 'f', "foo", "Give me a foo value.", seqan3::option_spec::standard,
seqan3::value_list_validator{(seqan3::enumeration_names<foo::bar> | seqan3::views::get<1>)});
seqan3::value_list_validator{(seqan3::enumeration_names<foo::bar> | std::views::values)});

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/sequence_file/input.hpp>
#include <seqan3/range/views/get.hpp>

auto input = R"(> TEST1
ACGT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <seqan3/alphabet/quality/phred42.hpp>
#include <seqan3/alphabet/quality/qualified.hpp>
#include <seqan3/io/sequence_file/output.hpp>
#include <seqan3/range/views/get.hpp>

int main()
{
Expand All @@ -26,8 +25,8 @@ int main()
{'A'_dna5, '1'_phred42},
{'C'_dna5, '3'_phred42}};

auto view_on_seq = seqan3::views::get<0>(seq_qual);
auto view_on_qual = seqan3::views::get<1>(seq_qual);
auto view_on_seq = std::views::elements<0>(seq_qual);
auto view_on_qual = std::views::elements<1>(seq_qual);

// ...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <seqan3/alphabet/views/to_char.hpp>
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/io/structure_file/input.hpp>
#include <seqan3/range/views/get.hpp>

auto input = R"(> S.cerevisiae_tRNA-PHE M10740/1-73
GCGGAUUUAGCUCAGUUGGGAGAGCGCCAGACUGAAGAUUUGGAGGUCCUGUGUUCGAUCCACAGAAUUCGCA
Expand All @@ -26,7 +25,7 @@ int main()
seqan3::debug_stream << "ID: " << id << '\n';
// sequence and structure are part of the same vector, of type std::vector<structured_rna<rna5, wuss51>>
// sequence and structure strings are extracted and converted to char on-the-fly
seqan3::debug_stream << "SEQ: " << (struc_seq | seqan3::views::get<0> | seqan3::views::to_char) << '\n';
seqan3::debug_stream << "STRUCTURE: " << (struc_seq | seqan3::views::get<1> | seqan3::views::to_char) << '\n';
seqan3::debug_stream << "SEQ: " << (struc_seq | std::views::elements<0> | seqan3::views::to_char) << '\n';
seqan3::debug_stream << "STRUCTURE: " << (struc_seq | std::views::elements<1> | seqan3::views::to_char) << '\n';
}
}
7 changes: 7 additions & 0 deletions test/snippet/range/views/get.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#ifdef SEQAN3_DEPRECATED_310
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
//![snippet]
#include <vector>

#include <seqan3/alphabet/nucleotide/dna4.hpp>
Expand All @@ -21,3 +25,6 @@ int main()
seqan3::debug_stream << (qv | seqan3::views::get<0> | seqan3::views::to_char) << '\n'; // Prints [A,C,G,T]
seqan3::debug_stream << (qv | seqan3::views::get<1> | seqan3::views::to_char) << '\n'; // Prints [!,",#,$]
}
//![snippet]
#pragma GCC diagnostic pop
#endif // SEQAN3_DEPRECATED_310
7 changes: 7 additions & 0 deletions test/unit/range/views/get_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
using seqan3::operator""_dna4;
using seqan3::operator""_phred42;

#ifdef SEQAN3_DEPRECATED_310
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

TEST(view_get, basic)
{
// TODO remove const-ness from input vector once alphabet_proxy's complement doesnt cause ICE
Expand Down Expand Up @@ -142,3 +146,6 @@ TEST(view_get, nested_zip_view)

EXPECT_EQ(vec1[0], -1);
}

#pragma GCC diagnostic pop
#endif // SEQAN3_DEPRECATED_310

0 comments on commit 57a5098

Please sign in to comment.