Skip to content

Commit

Permalink
Merge pull request #4385 from vgteam/inject-off-end
Browse files Browse the repository at this point in the history
Allow reads to softclip at the end of a path in `vg inject`
  • Loading branch information
adamnovak authored Sep 10, 2024
2 parents f05d396 + 0f6364b commit 95bcbb4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2689,9 +2689,22 @@ Alignment target_alignment(const PathPositionHandleGraph* graph, const path_hand
size_t node_pos = pos1 - graph->get_position_of_step(step);
while (edit_idx < cigar_mapping.edit_size()) {
if (step == graph->path_end(path)) {
cerr << "error: walked to end of path before exhausting CIGAR on read:" << endl;
cerr << pb2json(cigar_mapping) << endl;
exit(1);
const auto& edit = cigar_mapping.edit(edit_idx);
if (edit.from_length() == 0 && aln.path().mapping_size() != 0) {
// This is a softclip off the end of the contig.
// We can add it to the last mapping as an edit
assert(offset_in_edit == 0);
Mapping* last_mapping = aln.mutable_path()->mutable_mapping(aln.path().mapping_size() - 1);
*last_mapping->add_edit() = edit;
++edit_idx;
continue;
} else {
// We've gone off the end of the contig with something other than a softclip
throw std::runtime_error("Reached unexpected end of path " + graph->get_path_name(path) +
" at edit " + std::to_string(edit_idx) +
"/" + std::to_string(cigar_mapping.edit_size()) +
" for alignment of feature " + feature);
}
}
handle_t h = graph->get_handle_of_step(step);
string seq = graph->get_sequence(h);
Expand Down

1 comment on commit 95bcbb4

@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 merge to master. View the full report here.

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

Please sign in to comment.