Skip to content
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

[MISC] Reintroduce seqan3::literals #2568

Merged
merged 13 commits into from
Apr 28, 2021
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ regression test suite and patches at https://github.com/seqan/seqan3/tree/master
`seqan3::phred68legacy(phred_type)`.
* Renamed `seqan3::quality_base` to `seqan3::phred_base`
([\#2539](https://github.com/seqan/seqan3/pull/2539)).
* Added the `seqan3::literals` namespace containing all literals. This adds the option to use
`using namespace seqan3::literals` to import literal operators. The old way of explicitly importing specific
operators via `using seqan3::operator""_{dna4, rna4, ...}` is not affected by this change
([\#2568](https://github.com/seqan/seqan3/pull/2568)).

#### Argument Parser

Expand Down
3 changes: 2 additions & 1 deletion doc/tutorial/alphabet/alphabet_gc_content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/range/views/all.hpp> // optional: use views to convert the input string to a dna5 sequence

using seqan3::operator""_dna5;

int main (int argc, char * argv[])
{
using namespace seqan3::literals;

std::string input{};
seqan3::argument_parser parser("GC-Content", argc, argv);
parser.add_positional_option(input, "Specify an input sequence.");
Expand Down
11 changes: 5 additions & 6 deletions doc/tutorial/alphabet/alphabet_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
//! [create]
#include <seqan3/alphabet/all.hpp> // for working with alphabets directly

using seqan3::operator""_dna4;

int main ()
{
using namespace seqan3::literals;

// Two objects of seqan3::dna4 alphabet constructed with a char literal.
seqan3::dna4 ade = 'A'_dna4;
seqan3::dna4 gua = 'G'_dna4;
Expand Down Expand Up @@ -79,8 +79,7 @@ int main ()
assert(some_nucl == "AGT"_dna4);

//! [phred]
using seqan3::operator""_dna4;
using seqan3::operator""_phred42;
using namespace seqan3::literals;

seqan3::phred42 phred;
phred.assign_phred(2);
Expand All @@ -98,7 +97,7 @@ int main ()
// Assign a gap symbol to a gapped RNA alphabet.
seqan3::gapped<seqan3::rna5> sym = seqan3::gap{}; // => -

using seqan3::operator""_rna5;
using namespace seqan3::literals;
// Each seqan3::rna5 symbol is still valid.
sym = 'U'_rna5; // => U

Expand All @@ -108,7 +107,7 @@ int main ()
assert(size2 == 6u);

//! [containers]
using seqan3::operator""_dna5;
using namespace seqan3::literals;

// Examples of different container types with SeqAn's alphabets.
std::vector<seqan3::dna5> dna_sequence{"GATTANAG"_dna5};
Expand Down
5 changes: 2 additions & 3 deletions doc/tutorial/concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ Write a small program, similar to the one above with the following "skeleton":
```cpp
// which includes?

using seqan3::operator""_dna5;
using seqan3::operator""_aa27;

// Add one or more `void print` function template(s) here //

int main()
{
using namespace seqan3::literals;

auto d = 'A'_dna5;
auto a = 'L'_aa27;
auto g = seqan3::gap{};
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/concepts/overloading_solution1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ void print(t const v)
std::cout << "I am an alphabet and my value as char is: " << seqan3::to_char(v) << '\n';
}

using seqan3::operator""_dna5;
using seqan3::operator""_aa27;

int main()
{
using namespace seqan3::literals;

auto d = 'A'_dna5;
auto a = 'L'_aa27;
auto g = seqan3::gap{};
Expand Down
5 changes: 2 additions & 3 deletions doc/tutorial/concepts/overloading_solution2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ void print(t const v)
<< " and my complement is: " << seqan3::to_char(seqan3::complement(v)) << '\n';
}

using seqan3::operator""_dna5;
using seqan3::operator""_aa27;

int main()
{
using namespace seqan3::literals;

auto d = 'A'_dna5;
auto a = 'L'_aa27;
auto g = seqan3::gap{};
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/introduction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ to learn more.
\note
We encourage you to avoid declaring `using namespace seqan3;`. This has the additional benefit of easily distinguishing
between library features and standard C++. The only exception are string literals, where we often use
`using seqan3::operator""_dna4;` for convenience.
`using namespace seqan3::literals` for convenience.

\note
We use a lot of Modern C++ in SeqAn so some things might look alien at first,
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/introduction/introduction_align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

int main()
{
using namespace seqan3::literals;

auto tmp_dir = std::filesystem::temp_directory_path();
std::string filename{tmp_dir/"seq.fasta"};
{
// Create a /tmp/seq.fasta file.
seqan3::sequence_file_output file_out{filename};

using seqan3::operator""_dna5;

file_out.emplace_back("ACGTGATG"_dna5, std::string{"seq1"});
file_out.emplace_back("AGTGATACT"_dna5, std::string{"seq2"});
}
Expand Down
3 changes: 1 addition & 2 deletions doc/tutorial/pairwise_alignment/configurations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ int main()

{
//! [scoring_scheme]
using seqan3::operator""_dna4;
using seqan3::operator""_aa27;
using namespace seqan3::literals;

// Define a simple scoring scheme with match and mismatch cost and get the score.
seqan3::nucleotide_scoring_scheme nc_scheme{seqan3::match_score{4}, seqan3::mismatch_score{-5}};
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/pairwise_alignment/pa_assignment_3_solution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <seqan3/alphabet/all.hpp>
#include <seqan3/core/debug_stream.hpp>

using seqan3::operator""_aa27;

int main()
{
using namespace seqan3::literals;

std::vector vec{"MANLGYZW"_aa27,
"LCKRLGNM"_aa27,
"KPSKPRDYEDG"_aa27,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/core/debug_stream.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

seqan3::dna4_vector s1 = "ACGTGAACTGACT"_dna4;
seqan3::dna4_vector s2 = "ACGAAGACCGAT"_dna4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/range/views/pairwise_combine.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

std::vector vec{"ACGTGAACTGACT"_dna4,
"ACGAAGACCGAT"_dna4,
"ACGTGACTGACT"_dna4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/range/views/pairwise_combine.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

std::vector vec{"ACGTGAACTGACT"_dna4,
"ACGAAGACCGAT"_dna4,
"ACGTGACTGACT"_dna4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include <seqan3/alphabet/aminoacid/aa27.hpp> // for seqan3::operator""_aa27
#include <seqan3/core/debug_stream.hpp>

using seqan3::operator""_aa27;

int main()
{
using namespace seqan3::literals;

auto seq1 = "QFSEEILSDIYCWMLQCGQERAV"_aa27;
auto seq2 = "AFLPGWQEENKLSKIWMKDCGCLW"_aa27;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/core/debug_stream.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

auto seq1 = "TTACGTACGGACTAGCTACAACATTACGGACTAC"_dna4;
auto seq2 = "GGACGACATGACGTACGACTTTACGTACGACTAGC"_dna4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/core/debug_stream.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

auto seq1 = "TTACGTACGGACTAGCTACAACATTACGGACTAC"_dna4;
auto seq2 = "GGACGACATGACGTACGACTTTACGTACGACTAGC"_dna4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/range/views/pairwise_combine.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

std::vector vec{"ACGTGACTGACT"_dna4,
"ACGAAGACCGAT"_dna4,
"ACGTGACTGACT"_dna4,
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/ranges/range_solution4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#include <seqan3/core/debug_stream.hpp> // for debug_stream
#include <seqan3/range/container/bitcompressed_vector.hpp> // include bitcompressed vector

using seqan3::operator""_dna4;

int main(int argc, char ** argv)
{
using namespace seqan3::literals;

seqan3::argument_parser myparser("Vector-implementations-comparison", argc, argv);
size_t size{};
bool use_bitvector{};
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/sam_file/sam_file_snippets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int main()

{
//![alignments_with_ref]
using seqan3::operator""_dna5;
using namespace seqan3::literals;

auto filename = std::filesystem::temp_directory_path()/"example.sam";

Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/sam_file/sam_file_solution3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/io/sam_file/all.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

std::vector<std::string> ids = {"read1", "read2"};
std::vector<std::vector<seqan3::dna4>> seqs = {"ACGATCGACTAGCTACGATCAGCTAGCAG"_dna4,
"AGAAAGAGCGAGGCTATTTTAGCGAGTTA"_dna4};
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/search/search_solution1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ seqan3::cleanup index_file{"index.file"};

#include <seqan3/search/fm_index/fm_index.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

seqan3::dna4_vector
text{"CGCTGTCTGAAGGATGAGTGTCAGCCAGTGTAACCCGATGAGCTACCCAGTAGTCGAACTGGGCCAGACAACCCGGCGCTAATGCACTCA"_dna4};
seqan3::fm_index index{text};
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/search/search_solution2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <seqan3/search/search.hpp>
#include <seqan3/search/fm_index/fm_index.hpp>

using seqan3::operator""_dna4;
using namespace seqan3::literals;

void run_text_single()
{
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/search/search_solution3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include <seqan3/search/fm_index/fm_index.hpp>
#include <seqan3/std/span>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

seqan3::dna4_vector
text{"CGCTGTCTGAAGGATGAGTGTCAGCCAGTGTAACCCGATGAGCTACCCAGTAGTCGAACTGGGCCAGACAACCCGGCGCTAATGCACTCA"_dna4};
seqan3::fm_index index{text};
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial/search/search_solution4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <seqan3/search/search.hpp>
#include <seqan3/search/fm_index/fm_index.hpp>

using seqan3::operator""_dna4;

int main()
{
using namespace seqan3::literals;

seqan3::dna4_vector
text{"CGCTGTCTGAAGGATGAGTGTCAGCCAGTGTAACCCGATGAGCTACCCAGTAGTCGAACTGGGCCAGACAACCCGGCGCTAATGCACTCA"_dna4};
seqan3::dna4_vector query{"GCT"_dna4};
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/search/search_solution5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <seqan3/search/fm_index/fm_index.hpp>
#include <seqan3/std/span>

using seqan3::operator""_dna4;
using namespace seqan3::literals;

// Define the pairwise alignment configuration globally.
inline constexpr auto align_config = seqan3::align_cfg::method_global{
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/search/views/minimiser/minimiser_snippets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <seqan3/search/views/kmer_hash.hpp>
#include <seqan3/search/views/minimiser.hpp>

using seqan3::operator""_dna4;
using namespace seqan3::literals;

int main()
{
Irallia marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/search/views/minimiser_hash.hpp>

using seqan3::operator""_dna4;
using namespace seqan3::literals;

int main()
{
Expand Down
3 changes: 1 addition & 2 deletions doc/tutorial/search/views/minimiser/minimiser_solution2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/search/views/minimiser_hash.hpp>

using seqan3::operator""_dna4;
using seqan3::operator""_shape;
using namespace seqan3::literals;

int main()
{
Expand Down
3 changes: 1 addition & 2 deletions doc/tutorial/search/views/minimiser/minimiser_solution3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <seqan3/search/views/kmer_hash.hpp>
#include <seqan3/search/views/minimiser.hpp>

using seqan3::operator""_dna4;
using seqan3::operator""_shape;
using namespace seqan3::literals;

int main()
{
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/search/views/minimiser/seed_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/search/views/minimiser_hash.hpp>

using seqan3::operator""_dna4;
using namespace seqan3::literals;

int main()
{
Expand Down
Loading