Raptor 3.0.0-rc.1
A fast and space-efficient pre-filter for querying very large collections of nucleotide sequences
 
shared.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/raptor/blob/main/LICENSE.md
6// --------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <sharg/parser.hpp>
16
19
20namespace raptor
21{
22
23template <typename argument_t>
24 requires std::same_as<argument_t, build_arguments> || std::same_as<argument_t, prepare_arguments>
25void validate_shape(sharg::parser & parser, argument_t & arguments)
26{
27 if (parser.is_option_set("shape"))
28 {
29 if (parser.is_option_set("kmer"))
30 throw sharg::parser_error{"You cannot set both shape and k-mer arguments."};
31
32 uint64_t tmp{};
33
34 std::from_chars(arguments.shape_string.data(),
35 arguments.shape_string.data() + arguments.shape_string.size(),
36 tmp,
37 2);
38
39 arguments.shape = seqan3::shape{seqan3::bin_literal{tmp}};
40 }
41 else
42 {
43 arguments.shape = seqan3::shape{seqan3::ungapped{arguments.kmer_size}};
44 }
45
46 if (!parser.is_option_set("window"))
47 arguments.window_size = arguments.shape.size();
48 else if (arguments.shape.size() > arguments.window_size)
49 throw sharg::parser_error{"The k-mer size cannot be bigger than the window size."};
50}
51
52} // namespace raptor
Provides raptor::build_arguments.
T from_chars(T... args)
Provides raptor::prepare_arguments.