Skip to content

Commit

Permalink
Make sure to adopt the node offset when adopting the initial node
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnovak committed Jul 15, 2022
1 parent a2bb88a commit 1b51465
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/gbwt_extender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,14 @@ void WFAAlignment::join(const WFAAlignment& second) {
if (second.edits.empty()) {
throw std::runtime_error("Cannot join alignments because second alignment has no edits");
}

if (!second.unlocalized_insertion()) {
// The second alignment has a path
if (second.node_offset == 0 || unlocalized_insertion()) {
if (unlocalized_insertion()) {
// We don't, so include the first handle and copy the offset on it.
node_offset = second.node_offset
path.push_back(second.path.front());
} else if (second.node_offset == 0) {
// Include the first handle from the second alignment because it can't be shared
path.push_back(second.path.front());
} else {
Expand Down
1 change: 1 addition & 0 deletions src/gbwt_extender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ struct WFAAlignment {
std::vector<std::pair<Edit, uint32_t>> edits;

/// Starting offset in the initial node.
/// If there is no initial node, the value stored is undefined.
uint32_t node_offset = 0;

/// Starting offset in the sequence.
Expand Down
2 changes: 1 addition & 1 deletion src/minimizer_mapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ Alignment MinimizerMapper::find_chain_alignment(
} else {
// No left tail to start with.
// Just use an empty starting alignment, which is OK.
aligned = WFAAlignment::make_empty();
aligned = WFAAlignment::make_empty();
}

while(next_it != chain.end()) {
Expand Down

0 comments on commit 1b51465

Please sign in to comment.