Skip to content

Commit

Permalink
Segment FPR function
Browse files Browse the repository at this point in the history
  • Loading branch information
eaasna committed May 8, 2024
1 parent 04288ab commit cb4abb9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions include/utilities/threshold/filtering_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ struct filtering_request
{
double pattern_p = ref_meta.pattern_spurious_match_prob(params);
uint64_t patterns_per_segment = std::round((query_meta.total_len / (double) query_meta.seg_count - pattern.l + 1) / (double) query_every);
double none_match_p = pow(1 - pattern_p, patterns_per_segment);
return std::min(1 - none_match_p, 1.0);
return segment_fpr(pattern_p, patterns_per_segment);
}

};
Expand Down
9 changes: 9 additions & 0 deletions include/utilities/threshold/find.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
namespace valik
{

/**
* @brief The false positive probability of a query segment that contains partially overlapping patterns.
*/
inline double segment_fpr(double const pattern_p, size_t const patterns_per_segment)
{
double none_match_p = pow(1 - pattern_p, patterns_per_segment);
return std::min(1 - none_match_p, 1.0);
}

/**
* @brief Score of the objective function for a parameter set. Smaller values are better.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/threshold/find.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ search_kmer_profile find_thresholds_for_kmer_size(metadata const & ref_meta,
auto best_params = param_set(attr.k, kmer_lemma_threshold(pattern.l, attr.k, errors), space);

if ((best_params.t < THRESH_LOWER) ||
(1 - pow(1 - ref_meta.pattern_spurious_match_prob(best_params), PATTERNS_PER_SEGMENT)) > FPR_UPPER)
segment_fpr(ref_meta.pattern_spurious_match_prob(best_params), PATTERNS_PER_SEGMENT) > FPR_UPPER)
{
search_type = search_kind::HEURISTIC;
double best_score = pattern.l;
Expand Down

0 comments on commit cb4abb9

Please sign in to comment.