Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spoa::Graph::GenerateConsensus additional overload #73

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
rvaser marked this conversation as resolved.
Show resolved Hide resolved
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
Loading