samtools / htslib

C library for high-throughput sequencing data formats
Other
783 stars 447 forks source link

Make BAM zero-length intervals work like CRAM #1787

Closed whitwham closed 3 weeks ago

whitwham commented 1 month ago

For a BED file with: chr1 1000 1000

samtools view -M -L intervals.bed $infile worked with CRAM multi-region iterator but not with BAM. This change makes them work the same. Fixes samtools/samtools#2060.

NB Even though BED file format (spec) has a 0-based, half-open coordinate system, having the same beginning and end coordinate is valid.

jkbonfield commented 3 weeks ago

Ironically I just hit this very same bug! (Thanks for the fix.)

The test data in https://github.com/samtools/samtools/issues/2063 demonstrates this as it includes chr7 34925 34925 in the test.bed file. It worked on CRAM, but died on BAM for the same data. Curious timing, but saved me some deep diving. :)