| 1 |
// (Based on the original "Partial Order Aligner" by Lee, Grasso, and Sharlow, |
| 2 |
// and an implementation in C# by Patrick Marks) |
| 3 |
|
| 4 |
#include <pbcopper/poa/PoaGraph.h> |
| 5 |
|
| 6 |
#include <pbcopper/poa/PoaConsensus.h> |
| 7 |
#include "PoaGraphImpl.h" |
| 8 |
|
| 9 |
namespace PacBio { |
| 10 |
namespace Poa { |
| 11 |
|
| 12 |
// |
| 13 |
// PIMPL idiom delegation |
| 14 |
// |
| 15 |
void PoaGraph::AddRead(const std::string& sequence, const Align::AlignConfig& config, |
| 16 |
detail::SdpRangeFinder* rangeFinder, std::vector<Vertex>* readPathOutput) |
| 17 |
{ |
| 18 |
impl_->AddRead(sequence, config, rangeFinder, readPathOutput); |
| 19 |
} |
| 20 |
|
| 21 |
void PoaGraph::AddFirstRead(const std::string& sequence, std::vector<Vertex>* readPathOutput) |
| 22 |
{ |
| 23 |
impl_->AddFirstRead(sequence, readPathOutput); |
| 24 |
} |
| 25 |
|
| 26 |
PoaAlignmentMatrix* PoaGraph::TryAddRead(const std::string& sequence, |
| 27 |
const Align::AlignConfig& config, |
| 28 |
detail::SdpRangeFinder* const rangeFinder) const |
| 29 |
{ |
| 30 |
return impl_->TryAddRead(sequence, config, rangeFinder).release(); |
| 31 |
} |
| 32 |
|
| 33 |
void PoaGraph::CommitAdd(PoaAlignmentMatrix* mat, std::vector<Vertex>* readPathOutput) |
| 34 |
{ |
| 35 |
impl_->CommitAdd(mat, readPathOutput); |
| 36 |
} |
| 37 |
|
| 38 |
void PoaGraph::PruneGraph(const int minCoverage) { impl_->PruneGraph(minCoverage); } |
| 39 |
|
| 40 |
size_t PoaGraph::NumReads() const { return impl_->NumReads(); } |
| 41 |
|
| 42 |
const PoaConsensus* PoaGraph::FindConsensus(const Align::AlignConfig& config, int minCoverage) const |
| 43 |
{ |
| 44 |
return impl_->FindConsensus(config, minCoverage).release(); |
| 45 |
} |
| 46 |
|
| 47 |
std::string PoaGraph::ToGraphViz(int flags, const PoaConsensus* pc) const |
| 48 |
{ |
| 49 |
return impl_->ToGraphViz(flags, pc); |
| 50 |
} |
| 51 |
|
| 52 |
void PoaGraph::WriteGraphVizFile(const std::filesystem::path& filename, int flags, |
| 53 |
const PoaConsensus* pc) const |
| 54 |
{ |
| 55 |
impl_->WriteGraphVizFile(filename, flags, pc); |
| 56 |
} |
| 57 |
|
| 58 |
void PoaGraph::WriteGraphCsvFile(const std::filesystem::path& filename) const |
| 59 |
{ |
| 60 |
impl_->WriteGraphCsvFile(filename); |
| 61 |
} |
| 62 |
|
| 63 |
PoaGraph::PoaGraph() : impl_{std::make_unique<detail::PoaGraphImpl>()} {} |
| 64 |
|
| 65 |
PoaGraph::PoaGraph(const PoaGraph& other) |
| 66 |
: impl_{std::make_unique<detail::PoaGraphImpl>(*other.impl_)} |
| 67 |
{} |
| 68 |
|
| 69 |
PoaGraph& PoaGraph::operator=(const PoaGraph& other) |
| 70 |
{ |
| 71 |
// check for self-assignment |
| 72 |
if (&other != this) { |
| 73 |
impl_ = std::make_unique<detail::PoaGraphImpl>(*other.impl_); |
| 74 |
} |
| 75 |
|
| 76 |
return *this; |
| 77 |
} |
| 78 |
|
| 79 |
PoaGraph::PoaGraph(PoaGraph&&) noexcept = default; |
| 80 |
|
| 81 |
PoaGraph& PoaGraph::operator=(PoaGraph&&) noexcept = default; |
| 82 |
|
| 83 |
PoaGraph::PoaGraph(const detail::PoaGraphImpl& o) : impl_{std::make_unique<detail::PoaGraphImpl>(o)} |
| 84 |
{} |
| 85 |
|
| 86 |
PoaGraph::~PoaGraph() = default; |
| 87 |
|
| 88 |
} // namespace Poa |
| 89 |
} // namespace PacBio |