Skip to content

Commit

Permalink
restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
smehringer committed Sep 7, 2024
1 parent 19fb420 commit bdb53fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 0 additions & 2 deletions include/hibf/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ struct config
*/
double relaxed_fpr{0.3};

double relaxed_fpr_correction_factor{};

/*!\brief The number of threads to use during construction. [RECOMMENDED_TO_ADAPT]
*
* Using more threads increases the memory consumption during construction because the threads hold local
Expand Down
6 changes: 4 additions & 2 deletions include/hibf/layout/hierarchical_binning.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class hierarchical_binning
private:
//!\brief The user config passed down from the command line.
seqan::hibf::config config{};
//!\brief The correction factor for merged bins which are allowed to have a relaxed FPR
double relaxed_fpr_correction_factor{};
//!\brief Stores all data that is needed to compute the layout, e.g. the counts, sketches and the layout::layout.
data_store * data{nullptr};

Expand Down Expand Up @@ -87,8 +89,8 @@ class hierarchical_binning
std::log1p(-std::exp(std::log(config_.maximum_fpr) / config_.number_of_hash_functions));
double const denominator =
std::log1p(-std::exp(std::log(config_.relaxed_fpr) / config_.number_of_hash_functions));
config.relaxed_fpr_correction_factor = numerator / denominator;
assert(config.relaxed_fpr_correction_factor <= 1.0);
relaxed_fpr_correction_factor = numerator / denominator;
assert(relaxed_fpr_correction_factor <= 1.0);
assert(data != nullptr);
}

Expand Down
8 changes: 4 additions & 4 deletions src/layout/hierarchical_binning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void hierarchical_binning::initialization(std::vector<std::vector<size_t>> & mat
for (size_t j = 1; j < num_user_bins; ++j)
{
sum += (*data->kmer_counts)[data->positions[j]];
matrix[0][j] = data->union_estimates[j] * config.relaxed_fpr_correction_factor;
matrix[0][j] = data->union_estimates[j] * relaxed_fpr_correction_factor;
ll_matrix[0][j] = max_merge_levels(j + 1) * sum;
trace[0][j] = {0u, j - 1}; // unnecessary?
}
Expand All @@ -130,7 +130,7 @@ void hierarchical_binning::initialization(std::vector<std::vector<size_t>> & mat
assert(j < data->positions.size());
assert(data->positions[j] < data->kmer_counts->size());
sum += (*data->kmer_counts)[data->positions[j]];
matrix[0][j] = sum * config.relaxed_fpr_correction_factor;
matrix[0][j] = sum * relaxed_fpr_correction_factor;
ll_matrix[0][j] = max_merge_levels(j + 1) * sum;
trace[0][j] = {0u, j - 1}; // unnecessary?
}
Expand Down Expand Up @@ -212,7 +212,7 @@ void hierarchical_binning::recursion(std::vector<std::vector<size_t>> & matrix,
// union_estimates[j_prime] is the union of {j_prime, ..., j}
// the + 1 is necessary because j_prime is decremented directly after weight is updated
size_t const uncorrected = config.disable_estimate_union ? weight : data->union_estimates[j_prime + 1];
return config.relaxed_fpr_correction_factor * uncorrected;
return relaxed_fpr_correction_factor * uncorrected;
};

// if the user bin j-1 was not split into multiple technical bins!
Expand Down Expand Up @@ -279,7 +279,7 @@ void hierarchical_binning::backtrack_merged_bin(size_t trace_j,
if (!config.disable_estimate_union)
kmer_count = sketch.estimate(); // overwrite kmer_count high_level_max_id/size bin

max_tracker.update_max(bin_id, kmer_count * config.relaxed_fpr_correction_factor);
max_tracker.update_max(bin_id, kmer_count * relaxed_fpr_correction_factor);
// std::cout << "]: " << kmer_count << std::endl;
}

Expand Down

0 comments on commit bdb53fe

Please sign in to comment.