Skip to content

Commit

Permalink
Make WFAExtender apply full length bonuses even though it doesn't use…
Browse files Browse the repository at this point in the history
… them internally
  • Loading branch information
adamnovak committed May 6, 2024
1 parent 39745aa commit d9487ef
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 62 deletions.
13 changes: 12 additions & 1 deletion src/gbwt_extender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,14 @@ WFAAlignment WFAExtender::connect(std::string sequence, pos_t from, pos_t to) co
}

WFAAlignment WFAExtender::suffix(const std::string& sequence, pos_t from) const {
return this->connect(sequence, from, pos_t(0, false, 0));
WFAAlignment result = this->connect(sequence, from, pos_t(0, false, 0));

if (!result.edits.empty() && result.length == sequence.length() && (result.edits.back().first == WFAAlignment::match || result.edits.back().first == WFAAlignment::mismatch)) {
// The alignment used all of the sequence and has a match/mismatch at the appropriate end
result.score += this->aligner->full_length_bonus;
}

return result;
}

WFAAlignment WFAExtender::prefix(const std::string& sequence, pos_t to) const {
Expand All @@ -2297,6 +2304,10 @@ WFAAlignment WFAExtender::prefix(const std::string& sequence, pos_t to) const {
WFAAlignment result = this->connect(reverse_complement(sequence), to, pos_t(0, false, 0));
result.flip(*(this->graph), sequence);

if (!result.edits.empty() && result.length == sequence.length() && (result.edits.front().first == WFAAlignment::match || result.edits.front().first == WFAAlignment::mismatch)) {
result.score += this->aligner->full_length_bonus;
}

return result;
}

Expand Down
8 changes: 6 additions & 2 deletions src/gbwt_extender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,11 @@ class WFAExtender {
* entire sequence with an acceptable score, returns the highest-scoring
* partial alignment, which may be empty.
*
* Applies the full-length bonus if the result ends with a match or mismatch.
* TODO: Use the full-length bonus to determine the optimal alignment.
*
* NOTE: This creates a suffix of the full alignment by aligning a
* prefix of the sequence.
* TODO: Should we use full-length bonuses?
*/
WFAAlignment suffix(const std::string& sequence, pos_t from) const;

Expand All @@ -424,9 +426,11 @@ class WFAExtender {
* sequence with an acceptable score, returns the highest-scoring partial
* alignment, which may be empty.
*
* Applies the full-length bonus if the result begins with a match or mismatch.
* TODO: Use the full-length bonus to determine the optimal alignment.
*
* NOTE: This creates a prefix of the full alignment by aligning a suffix
* of the sequence.
* TODO: Should we use full-length bonuses?
*/
WFAAlignment prefix(const std::string& sequence, pos_t to) const;

Expand Down
Loading

1 comment on commit d9487ef

@adamnovak
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for branch wfa-full-length-bonus. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 17316 seconds

Please sign in to comment.