File: range_solution3.cpp

package info (click to toggle)
seqan3 3.0.2%2Bds-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,052 kB
  • sloc: cpp: 144,641; makefile: 1,288; ansic: 294; sh: 228; xml: 217; javascript: 50; python: 27; php: 25
file content (36 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <seqan3/core/debug_stream.hpp>
#include <seqan3/argument_parser/all.hpp>       // optional: include the argument_parser
#include <seqan3/range/views/all.hpp>           // include all of SeqAn's views
#include <seqan3/std/ranges>                    // include all of the standard library's views


int main(int argc, char** argv)
{
    // We use the seqan3::argument_parser which was introduced in the second chapter 
    // of the tutorial: "Parsing command line arguments with SeqAn".
    seqan3::argument_parser myparser{"Assignment-3", argc, argv}; // initialize
    std::string s{};

    myparser.add_positional_option(s, "Please specify the DNA string.");

    try
    {
       myparser.parse();
    }
    catch (seqan3::argument_parser_error const & ext) // the user did something wrong
    {
       std::cerr << "[PARSER ERROR]" << ext.what() << '\n'; // you can customize your error message
       return 0;
    }

    auto s_as_dna = s | seqan3::views::char_to<seqan3::dna5>;
    // Bonus:
    //auto s_as_dna = s | std::views::transform([] (char const c)
    //{
    //    return seqan3::assign_char_strictly_to(c, seqan3::dna5{});
    //});

    seqan3::debug_stream << "Original: " << s_as_dna << '\n';
    seqan3::debug_stream << "RevComp:  " << (s_as_dna | std::views::reverse | seqan3::views::complement) << '\n';
    seqan3::debug_stream << "Frames:   " << (s_as_dna | seqan3::views::translate) << '\n';
}