diff --git a/include/utilities/threshold/basics.hpp b/include/utilities/threshold/basics.hpp index de705be3..8969e3bb 100644 --- a/include/utilities/threshold/basics.hpp +++ b/include/utilities/threshold/basics.hpp @@ -107,7 +107,6 @@ inline uint64_t combinations(size_t const k, size_t const n) return 0; } -enum search_kind {LEMMA, HEURISTIC, STELLAR}; +enum class search_kind {LEMMA, HEURISTIC, STELLAR}; } //namespace valik - diff --git a/include/utilities/threshold/search_kmer_profile.hpp b/include/utilities/threshold/search_kmer_profile.hpp index 39a61d6e..04db133c 100644 --- a/include/utilities/threshold/search_kmer_profile.hpp +++ b/include/utilities/threshold/search_kmer_profile.hpp @@ -25,7 +25,7 @@ struct search_error_profile { param_set params; search_pattern pattern; - search_kind search_type{LEMMA}; + search_kind search_type{search_kind::LEMMA}; double fnr; double fp_per_pattern; uint64_t max_segment_len; @@ -44,7 +44,7 @@ struct search_error_profile search_error_profile(param_set const & best_params, search_pattern const & eps_pattern, search_kind const which_search) : params(best_params), pattern(eps_pattern), search_type(which_search) { - if (which_search != STELLAR) + if (which_search != search_kind::STELLAR) throw std::runtime_error("Provide FNR, FPR and maximum segment length."); fnr = 0.0; } @@ -59,15 +59,19 @@ struct search_error_profile void print() { - if (search_type == STELLAR) - std::cout << "stellar-only" << "\tN/A\t" << fnr << "\tN/A\tN/A\n"; - else + switch (search_type) { - if (search_type == HEURISTIC) - std::cout << "heuristic"; - else - std::cout << "kmer lemma"; - std::cout << '\t' << std::to_string(params.t) << '\t' << fnr << '\t' << fp_per_pattern << '\t' << max_segment_len << '\n'; + case search_kind::STELLAR: std::cout << "stellar-only" << "\tN/A\t" << fnr << "\tN/A\tN/A\n"; break; + default: + { + switch (search_type) + { + case search_kind::HEURISTIC: std::cout << "heuristic"; break; + case search_kind::LEMMA: std::cout << "kmer lemma"; break; + default: break; + } + std::cout << '\t' << std::to_string(params.t) << '\t' << fnr << '\t' << fp_per_pattern << '\t' << max_segment_len << '\n'; + } } } }; diff --git a/include/valik/search/search_local.hpp b/include/valik/search/search_local.hpp index 2f7d4c1a..39c3c1bf 100644 --- a/include/valik/search/search_local.hpp +++ b/include/valik/search/search_local.hpp @@ -91,7 +91,7 @@ bool search_local(search_arguments & arguments, search_time_statistics & time_st param_space space; param_set params(arguments.shape_size, arguments.threshold, space); filtering_request request(pattern, ref_meta, query_meta.value()); - if ((request.fpr(params) > 0.2) && (arguments.search_type != STELLAR)) + if ((request.fpr(params) > 0.2) && (arguments.search_type != search_kind::STELLAR)) std::cerr << "WARNING: Prefiltering will be inefficient for a high error rate.\n"; if (arguments.verbose) @@ -102,8 +102,9 @@ bool search_local(search_arguments & arguments, search_time_statistics & time_st std::cout << "kmer size " << std::to_string(arguments.shape_size) << '\n'; switch (arguments.search_type) { - case HEURISTIC: std::cout << "heuristic "; break; - case LEMMA: std::cout << "k-mer lemma "; break; + case search_kind::LEMMA: std::cout << "k-mer lemma "; break; + //case search_kind::MINIMISER: std::cout << "minimiser "; break; + case search_kind::HEURISTIC: std::cout << "heuristic "; break; default: break; } std::cout << "threshold "; diff --git a/include/valik/shared.hpp b/include/valik/shared.hpp index c0a8c5c5..6f9b13ad 100644 --- a/include/valik/shared.hpp +++ b/include/valik/shared.hpp @@ -136,7 +136,7 @@ struct search_profile_arguments bool split_query{false}; bool manual_parameters{false}; //!TODO: make fourth option: MINIMISER - search_kind search_type{LEMMA}; + search_kind search_type{search_kind::LEMMA}; double fnr; protected: diff --git a/src/argument_parsing/search.cpp b/src/argument_parsing/search.cpp index b3610edf..7be85dc1 100644 --- a/src/argument_parsing/search.cpp +++ b/src/argument_parsing/search.cpp @@ -128,6 +128,7 @@ void init_search_parser(sharg::parser & parser, search_arguments & arguments) .long_id = "max-queued-carts", .description = "Maximal number of carts that are full and are waiting to be processed.", .advanced = true}); + //!TODO: add section for stellar options parser.add_option(arguments.disableThresh, sharg::config{.short_id = '\0', .long_id = "disableThresh", @@ -324,7 +325,7 @@ void run_search(sharg::parser & parser) search_error_profile error_profile = search_profile.get_error_profile(arguments.errors); // seg_count is inferred in metadata constructor arguments.search_type = error_profile.search_type; - if (arguments.search_type == STELLAR) + if (arguments.search_type == search_kind::STELLAR) { std::cout << "Can not prefilter matches of length " << std::to_string(error_profile.pattern.l) << " with " << std::to_string(error_profile.pattern.e) << " errors. Searching without prefiltering.\n"; diff --git a/src/threshold/find.cpp b/src/threshold/find.cpp index 12d578ad..8fa50e48 100755 --- a/src/threshold/find.cpp +++ b/src/threshold/find.cpp @@ -97,13 +97,14 @@ search_kmer_profile find_thresholds_for_kmer_size(metadata const & ref_meta, for (uint8_t errors{0}; errors <= max_errors && errors <= space.max_errors; errors++) { search_pattern pattern(errors, ref_meta.pattern_size); - search_kind search_type{LEMMA}; + search_kind search_type{search_kind::LEMMA}; auto best_params = param_set(attr.k, kmer_lemma_threshold(pattern.l, attr.k, errors), space); + //!TODO: determine suitable parameters if ((best_params.t < 4) || - (1 - pow(1 - ref_meta.pattern_spurious_match_prob(best_params), 5e3) > 0.05)) + ((1 - pow(1 - ref_meta.pattern_spurious_match_prob(best_params), 5e3)) > 0.05)) { - search_type = HEURISTIC; + search_type = search_kind::HEURISTIC; double best_score = pattern.l; for (uint8_t t{1}; t <= space.max_thresh; t++) { @@ -117,10 +118,11 @@ search_kmer_profile find_thresholds_for_kmer_size(metadata const & ref_meta, } } + //!TODO: find segment length cutoff uint64_t max_len = ref_meta.max_segment_len(best_params); if ((pattern.l * 100) > max_len) { - search_type = STELLAR; + search_type = search_kind::STELLAR; kmer_thresh.add_error_rate(errors, {best_params, pattern, search_type}); } else diff --git a/src/valik_search.cpp b/src/valik_search.cpp index b32ccfe1..3b2c29ad 100644 --- a/src/valik_search.cpp +++ b/src/valik_search.cpp @@ -55,7 +55,7 @@ void valik_search(search_arguments & arguments) runtime_to_compile_time([&]() { failed = search_local(arguments, time_statistics); - }, arguments.compressed, arguments.split_query, (arguments.search_type == STELLAR)); + }, arguments.compressed, arguments.split_query, (arguments.search_type == search_kind::STELLAR)); } // Consolidate matches (not necessary when searching a metagenomic database)