diff --git a/include/spoa/graph.hpp b/include/spoa/graph.hpp index 63d6d88..5645766 100644 --- a/include/spoa/graph.hpp +++ b/include/spoa/graph.hpp @@ -168,6 +168,10 @@ class Graph { std::string GenerateConsensus(std::int32_t min_coverage); + std::string GenerateConsensus( + std::int32_t min_coverage, + std::vector *summary); + std::string GenerateConsensus( std::vector* summary, bool verbose = false); diff --git a/src/graph.cpp b/src/graph.cpp index b0b6534..44cedd6 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -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 *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(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* summary, bool verbose) {