Skip to content

Commit

Permalink
tbrekalo-generate-consensus-overload: added GenerateConsensus with mi…
Browse files Browse the repository at this point in the history
…n_coverage and summary

Added an for Graph::GenerateConsensus that takes min_coverage argument and accepts pointer to coverage summary vector.
The goal is to use this overload with new racon version.

tbrekalo-generate-consensus-overload: formatting

tbrekalo-generate-consensus-overload: addressing PR comments
  • Loading branch information
tbrekalo authored and rvaser committed Nov 27, 2023
1 parent fd3a5c5 commit 4d8805d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/spoa/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ class Graph {

std::string GenerateConsensus(std::int32_t min_coverage);

std::string GenerateConsensus(
std::int32_t min_coverage,
std::vector<std::uint32_t> *summary);

std::string GenerateConsensus(
std::vector<std::uint32_t>* summary,
bool verbose = false);
Expand Down
22 changes: 22 additions & 0 deletions src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,28 @@ std::string Graph::GenerateConsensus(std::int32_t min_coverage) {
return dst;
}

std::string Graph::GenerateConsensus(std::int32_t min_coverage,
std::vector<std::uint32_t> *summary) {
if (!summary) {
throw std::invalid_argument(
"[spoa::Graph::GenerateConsensus] error: invalid ptr to summary");
}
summary->clear();

auto dst = GenerateConsensus(min_coverage);
for (const auto &it : consensus_) {
if (static_cast<std::int32_t>(it->Coverage()) >= min_coverage) {
summary->emplace_back(0);
summary->back() += it->Coverage();
for (const auto &jt : it->aligned_nodes) {
summary->back() += jt->Coverage();
}
}
}

return dst;
}

std::string Graph::GenerateConsensus(
std::vector<std::uint32_t>* summary,
bool verbose) {
Expand Down

0 comments on commit 4d8805d

Please sign in to comment.