Skip to content

Commit

Permalink
Properly measure leftmost and fix test sign
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnovak committed Jan 31, 2025
1 parent 5b18933 commit 6382d4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,10 @@ pair<int32_t, int32_t> compute_template_lengths(const int64_t& pos1, const vecto
// And find the distance
int32_t dist = max_end - min_start;

if (pos1 < pos2) {
// Count read 1 as the overall "leftmost", so its value will be positive
if (bounds1.first < bounds2.first || (bounds1.first == bounds2.first && bounds1.second < bounds2.second)) {
// Count read 1 as the overall "leftmost" if it starts earlier or
// starts at the same point and ends earlier, so its value will be
// positive
return make_pair(dist, -dist);
} else {
// Count read 2 as the overall leftmost
Expand Down
4 changes: 2 additions & 2 deletions src/unittest/alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ TEST_CASE("Template length for HTS output formats is outermost to outermost when

TEST_CASE("Template length for HTS output formats is outermost to outermost when read 2 is a suffix of read 1", "[alignment][tlen]") {
auto lengths = compute_template_lengths(1000, {{151, 'M'}}, 1141, {{10, 'M'}});
REQUIRE(lengths.first == -151); // Read 1 is the leftmost since it starts earliest
REQUIRE(lengths.second == 151);
REQUIRE(lengths.first == 151); // Read 1 is the leftmost since it starts earliest
REQUIRE(lengths.second == -151);
}

TEST_CASE("Template length for HTS output formats is outermost to outermost when read 1 and read 2 have identical coordinates", "[alignment][tlen]") {
Expand Down

1 comment on commit 6382d4e

@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 fix-overlapped-tlen. View the full report here.

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

Please sign in to comment.