Skip to content

Commit

Permalink
Removed bulges and tips tehmselves from lists of corrections.
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonBankevich committed Nov 24, 2024
1 parent ad659b0 commit 8701862
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
17 changes: 10 additions & 7 deletions src/projects/error_correction/correction_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace dbg {
}
}
}
return std::move(res);
return oneline::removeValue(res.begin(), res.end(), path);
}

GraphPath FindReliableExtension(Vertex &start, size_t len, double min_cov) {
Expand Down Expand Up @@ -153,7 +153,7 @@ namespace dbg {
}
}
}
return std::move(res);
return oneline::removeValue(res.begin(), res.end(), path);
}

GraphPath FindLongestCoveredForwardExtension(Edge &start, size_t max_size, double min_rel_cov, double max_err_cov) {
Expand Down Expand Up @@ -199,8 +199,9 @@ namespace dbg {
}

std::vector<GraphPath>
SuffixSupportedBulgeAlternatives(const ag::SuffixTracker<DBGTraits> &tracker, Vertex &start, Vertex &end, size_t threshold) {
// lock();
SuffixSupportedBulgeAlternatives(const ag::SuffixTracker<DBGTraits> &tracker, const GraphPath &bulge, size_t threshold) {
Vertex &start = bulge.getStart();
Vertex &end = bulge.getFinish();
std::vector<std::pair<Sequence, int>> candidates;
for(Edge &first_edge : start) {
if(first_edge.getFinish() == end) {
Expand Down Expand Up @@ -236,7 +237,7 @@ namespace dbg {
}
cnt += candidates[i].second;
}
return std::move(res);
return oneline::removeValue(res.begin(), res.end(), bulge);
}

EdgeId SuffixSupportedExtension(const ag::SuffixRecord<DBGTraits> &record, const GraphPath &start, size_t min_good,
Expand Down Expand Up @@ -278,7 +279,9 @@ namespace dbg {
}

std::vector<GraphPath>
SuffixSupportedTipAlternatives(const ag::SuffixTracker<DBGTraits> &tracker, Vertex &start, size_t len, double threshold) {
SuffixSupportedTipAlternatives(const ag::SuffixTracker<DBGTraits> &tracker, const GraphPath &tip, double threshold) {
Vertex &start = tip.getStart();
size_t len = tip.truncLen();
len += std::max<size_t>(30, len / 20);
std::vector<std::pair<Sequence, int>> candidates;
for(Edge &first_edge : start) {
Expand Down Expand Up @@ -314,6 +317,6 @@ namespace dbg {
}
cnt += candidates[i].second;
}
return std::move(res);
return oneline::removeValue(res.begin(), res.end(), tip);
}
}
4 changes: 2 additions & 2 deletions src/projects/error_correction/correction_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace dbg {
GraphPath FindLongestCoveredForwardExtension(Edge &start, size_t max_len, double min_rel_cov, double max_err_cov);
GraphPath FindLongestCoveredExtension(Edge &start, size_t max_len, double min_rel_cov, double max_err_cov);

std::vector<GraphPath> SuffixSupportedBulgeAlternatives(const ag::SuffixTracker<DBGTraits> &tracker, Vertex &start, Vertex &end, size_t threshold);
std::vector<GraphPath> SuffixSupportedBulgeAlternatives(const ag::SuffixTracker<DBGTraits> &tracker, const GraphPath &bulge, size_t threshold);
EdgeId SuffixSupportedExtension(const ag::SuffixRecord<DBGTraits> &record, const GraphPath &start, size_t min_good, size_t max_bad);
GraphPath FullSuffixSupportedExtension(const ag::SuffixRecord<DBGTraits> &record, GraphPath start, size_t min_good_cov,
size_t max_bad_cov, size_t max_size = size_t(-1));
std::vector<GraphPath> SuffixSupportedTipAlternatives(const ag::SuffixTracker<DBGTraits> &record, Vertex &start, size_t len, double threshold);
std::vector<GraphPath> SuffixSupportedTipAlternatives(const ag::SuffixTracker<DBGTraits> &record, const GraphPath &tip, double threshold);
}
2 changes: 1 addition & 1 deletion src/projects/error_correction/manyk_correction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace dbg {
dbg::GraphPath ManyKCorrector::correctBulgeByBridging(const ManyKCorrector::Bulge &bulge) const {
VERIFY(bulge.bulge.truncLen() < K);
std::vector<dbg::GraphPath> alternatives1 =
SuffixSupportedBulgeAlternatives(reads.getSuffixes(), bulge.bulge.getStart(), bulge.bulge.getFinish(), 4);
SuffixSupportedBulgeAlternatives(reads.getSuffixes(), bulge.bulge, 4);
std::vector<dbg::GraphPath> alternatives;
for (dbg::GraphPath &al: alternatives1) {
if (al.truncLen() + 100 < bulge.bulge.truncLen() && bulge.bulge.truncLen() < al.truncLen() + 100)
Expand Down
8 changes: 4 additions & 4 deletions src/projects/error_correction/tournament_correction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ namespace dbg {
dbg::GraphPath tip = badPath.RC();
std::vector<dbg::GraphPath> alternatives;
if (checkTipSize(tip))
alternatives = SuffixSupportedTipAlternatives(reads_storage.getSuffixes(), tip.getStart(), tip.truncLen(), threshold);
alternatives = SuffixSupportedTipAlternatives(reads_storage.getSuffixes(), tip, threshold);
if (alternatives.empty())
alternatives = FindPlausibleTipAlternatives(tip, std::max<size_t>(size * 3 / 100, 100), 3);
std::string new_message = "";
Expand All @@ -216,7 +216,7 @@ namespace dbg {
dbg::GraphPath tip = badPath;
std::vector<dbg::GraphPath> alternatives;
if (checkTipSize(tip))
alternatives = SuffixSupportedTipAlternatives(reads_storage.getSuffixes(), tip.getStart(), tip.truncLen(), threshold);
alternatives = SuffixSupportedTipAlternatives(reads_storage.getSuffixes(), tip, threshold);
if (alternatives.empty())
alternatives = FindPlausibleTipAlternatives(tip, std::max<size_t>(size * 3 / 100, 100), 3);
std::string new_message = "";
Expand All @@ -232,7 +232,7 @@ namespace dbg {
std::string new_message = "br";
if (checkTipSize(badPath))
read_alternatives = SuffixSupportedBulgeAlternatives(reads_storage.getSuffixes(),
badPath.getStart(), badPath.getFinish(), threshold);
badPath, threshold);
if (read_alternatives.empty()) {
new_message = "bp";
read_alternatives = FindPlausibleBulgeAlternatives(badPath,
Expand All @@ -255,7 +255,7 @@ namespace dbg {
path_pos = front_pos - 1;
}
if (!messages.empty()) {
VERIFY(path != corrected_path);
VERIFY_MSG(path != corrected_path, join("_", messages));
path = std::move(corrected_path);
}
return join("_", messages);
Expand Down
5 changes: 5 additions & 0 deletions src/tools/common/oneline_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ namespace oneline {
return std::move(result);
}

template<class V, class I>
std::vector<V> removeValue(I begin, I end, const V &to_remove) {
return filter<V, I>(begin, end, [&to_remove](const V &val){return val != to_remove;});
}

template<class V, class C>
C filter(const C&container, const std::function<bool(const V&)> &f) {
return std::move(filter<V, typename C::const_iterator>(container.begin(), container.getFinish(), f));
Expand Down

0 comments on commit 8701862

Please sign in to comment.