Skip to content

Commit

Permalink
Fixed a bug of divide-and-conquer that lead to missed phylo-k-mers
Browse files Browse the repository at this point in the history
  • Loading branch information
nromashchenko committed Apr 1, 2022
1 parent 49507a7 commit 797a195
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
5 changes: 1 addition & 4 deletions build/src/db_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ namespace xpas
const auto original_node_postorder_id = _extended_mapping.at(node_group[0]);
node_postorder_ids[i] = original_node_postorder_id;


/// Get sub-matrices of probabilities for the group
const auto matrices = get_submatrices(node_group);

Expand Down Expand Up @@ -447,14 +448,10 @@ namespace xpas
{
const auto& node_entry = node_entry_ref.get();

//std::cout << node_entry.get_label() << std::endl;
for (auto& window : chain_windows(node_entry, _kmer_size, log_threshold))
{
//std::cout << "\tWINDOW " << window.get_start_pos() << std::endl;
for (const auto& kmer : window)
{
//std::cout << "\t\t" << kmer.key << " " << xpas::decode_kmer(kmer.key, _kmer_size) << " -> "
// << kmer.score << " " << std::pow(10, kmer.score) << std::endl;
xpas::put(hash_maps[kmer_batch(kmer.key, _num_batches)], kmer);
++count;
}
Expand Down
15 changes: 4 additions & 11 deletions build/src/node_entry_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ unpositioned_phylo_kmer dac_kmer_iterator::_next_phylokmer()
/*std::cout << "\t\tpairing "
<< xpas::decode_kmer(prefix.key, _prefix_size) << " " << std::pow(10, prefix.score) << " "
<< xpas::decode_kmer(suffix.key, _kmer_size - _prefix_size) << " " << std::pow(10, suffix.score) << " "
<< "= " << xpas::decode_kmer(full_key, _kmer_size) << " " << std::pow(10, full_score) << std::endl;*/
<< "= " << xpas::decode_kmer(full_key, _kmer_size) << " " << std::pow(10, full_score) << std::endl;
*/
return make_phylo_kmer<unpositioned_phylo_kmer>(full_key, full_score, 0);
}
}
Expand All @@ -245,8 +246,8 @@ unpositioned_phylo_kmer dac_kmer_iterator::_next_phylokmer()
void dac_kmer_iterator::_select_suffix_bound()
{
const auto residual_threshold = _threshold - _prefix_it->score;
_last_suffix_it = ::std::lower_bound(_suffixes.begin(), _suffixes.end(),
make_phylo_kmer<unpositioned_phylo_kmer>(0, residual_threshold, 0), kmer_score_comparator);
_last_suffix_it = std::partition(_suffixes.begin(), _suffixes.end(),
[residual_threshold](auto pk) { return pk.score >= residual_threshold;});
}

void dac_kmer_iterator::_finish_iterator()
Expand Down Expand Up @@ -285,25 +286,17 @@ node_entry_view::node_entry_view(const node_entry_view& other) noexcept
node_entry_view::iterator node_entry_view::begin()
{
const auto kmer_size = size_t{ (size_t)_end - _start + 1};
//const node_entry* entry, size_t kmer_size, phylo_kmer::score_type threshold,
// phylo_kmer::pos_type start_pos, stack_type&& stack)

// DAC-CW:
return { this, kmer_size, _threshold, _start, _prefix_size, std::move(_prefixes) };

// DAC:
//return { this, kmer_size, _threshold, _start, _prefix_size, {} };

// BNB:
//return make_bnb_begin_iterator(_entry, _start, kmer_size, _threshold);
}

node_entry_view::iterator node_entry_view::end() const noexcept
{
// DAC:
return make_dac_end_iterator();
// BNB:
//return make_bnb_end_iterator();
}

node_entry_view& node_entry_view::operator=(node_entry_view&& other) noexcept
Expand Down

0 comments on commit 797a195

Please sign in to comment.