Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include <iostream>
- #include <string>
- #include <vector>
- #include <seqan3/argument_parser/argument_parser.hpp>
- #include <seqan3/io/sequence_file/input.hpp>
- #include <seqan3/io/stream/debug_stream.hpp>
- #include <seqan3/search/all.hpp>
- #include <seqan3/range/all.hpp>
- #include <seqan3/range/view/convert.hpp>
- #include <seqan3/range/view/get.hpp>
- #include <range/v3/action/slice.hpp>
- using namespace std;
- using namespace seqan3;
- using namespace seqan3::search_cfg;
- int main(int argc, const char** argv) {
- argument_parser parser("simple_read_mapper", argc, argv);
- string genomeFName;
- string readsFName;
- string outFName;
- int maxError = 42;
- parser.add_option(maxError, 'm', "max_error", "Maximum error tolerance");
- parser.add_positional_option(genomeFName, "Genome filename");
- parser.add_positional_option(readsFName, "Reads filename");
- parser.add_positional_option(outFName, "Output filename");
- try {
- parser.parse();
- } catch (parser_invalid_argument const& e) {
- cerr << "You provided an invalid argument: " << e.what() << endl;
- return 1;
- } catch (parser_interruption const& e) {
- cerr << "I see you have interrupted the parser. Be careful!" << endl;
- return 0; // SeqAn has already printed --help output or whatever
- }
- cout << "The maximum error tolerance is " << maxError << endl;
- // Read in the input files
- sequence_file_input genomeFile { genomeFName, fields<field::SEQ>{} };
- vector<dna5> genomeSeq = get<field::SEQ>(*begin(genomeFile));
- debug_stream << "First 10 characters of the genome are <" << view::take(genomeSeq, 10) << '>' << '\n';
- // Build an index on the genome
- seqan3::detail::configuration indexCfg = max_error(total { maxError }, substitution { maxError }, insertion { maxError }, deletion { maxError }) | mode(best);
- fm_index index(genomeSeq);
- sequence_file_input readsFile { readsFName, fields<field::SEQ_QUAL>{} };
- for (auto& rec : readsFile) {
- vector<dna5q> x = get<field::SEQ_QUAL>(rec);
- debug_stream << "First read sequence: <" << x << ">\n";
- vector<dna5> y = (x | view::convert<dna5>); // (1)
- //auto y = (x | view::convert<dna5>); // (2)
- auto results = search(index, y, indexCfg);
- for (size_t position: results)
- {
- debug_stream << "FROM THE GENOME: " << (genomeSeq | ::ranges::view::slice(position, position + x.size() + maxError)) << '\n';
- }
- debug_stream << results << '\n';
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment