joshuak94 / BAMIntervalTree

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Fix bugs related to read lengths. #43

Closed joshuak94 closed 2 years ago

joshuak94 commented 2 years ago

Fixed two bugs:

  1. Previously, we were updating the node's end position with every record parsed, not considering a record might end before the previous record ends. Now it only stores the end if it's after the current end.
  2. Previously weren't filtering reads out for overlap queries which were in the node but not intersecting the query itself.
joshuak94 commented 2 years ago

@eseiler Do you know why the following gives an error on gcc10:

                              | std::views::filter([start](auto & rec) {return !unmapped(rec);})
                              | std::views::filter([start](auto & rec) {return std::make_tuple(rec.reference_id().value(), get_length((rec).cigar_sequence()) + rec.reference_position().value()) >= start;})
```cpp

But then this doesn't:
```cpp
                              | std::views::filter([start](auto & rec) {return !unmapped(rec) && std::make_tuple(rec.reference_id().value(), get_length((rec).cigar_sequence()) + rec.reference_position().value()) >= start;})
eseiler commented 2 years ago

I'm not sure, probably some quirk :D

The second version is better anyway, since you only need to create one filter, and the condition is short-circuited, i.e., if !unmapped(rec) is false, the rest is not evaluated.

joshuak94 commented 2 years ago

Good catch, thanks!