Skip to content

Commit

Permalink
Optimizations for IAF (#553) (#559)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Wenocur <[email protected]>
Co-authored-by: Adam Wenocur <[email protected]>
  • Loading branch information
3 people authored Aug 7, 2023
1 parent c545215 commit 16387a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apis/python/tests/test_tiledbvcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def test_ingest_with_stats(tmp_path):
data_frame[
(data_frame["sample_name"] == "second") & (data_frame["pos_start"] == 4)
]["info_TILEDB_IAF"].iloc[0][0]
== 0.0625
== 0.125
)


Expand Down
8 changes: 4 additions & 4 deletions libtiledbvcf/src/read/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,10 @@ bool Reader::process_query_results_v4() {
const auto& regions = regions_indexes->second;

bool apply_af_filter = af_filter_enabled();
size_t num_samples = 0;
if (params_.scan_all_samples) {
num_samples = dataset_->sample_names().size();
}
for (; read_state_.cell_idx < num_cells; read_state_.cell_idx++) {
// For easy reference
const uint64_t i = params_.sort_real_start_pos ?
Expand Down Expand Up @@ -1283,10 +1287,6 @@ bool Reader::process_query_results_v4() {

read_state_.query_results.af_values.clear();
int allele_index = 0;
size_t num_samples = 0;
if (params_.scan_all_samples) {
num_samples = dataset_->sample_names().size();
}
bool is_ref = true;
for (auto&& allele : alleles) {
auto [allele_passes, af] = af_filter_->pass(
Expand Down
2 changes: 1 addition & 1 deletion libtiledbvcf/src/stats/variant_stats_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class AFMap {
if (next_allele == pos_map.second.end()) {
return 0;
}
return 1.0 * next_allele->second / pos_map.first;
return 1.0 * next_allele->second / num_samples;
}

/**
Expand Down

0 comments on commit 16387a3

Please sign in to comment.