Skip to content

Commit

Permalink
Merge pull request #111 from GMOD/fix_off_by_one
Browse files Browse the repository at this point in the history
Fix off-by-one in CRAM range request
  • Loading branch information
rbuels authored May 16, 2022
2 parents 8e61079 + 22ba4ea commit dafd115
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/craiIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class CraiIndex {
const compare = entry => {
const entryStart = entry.start
const entryEnd = entry.start + entry.span
if (entryStart >= queryEnd) {
if (entryStart > queryEnd) {
return -1
} // entry is ahead of query
if (entryEnd <= queryStart) {
Expand Down
Binary file added test/data/volvox-long-reads-sv.cram
Binary file not shown.
Binary file added test/data/volvox-long-reads-sv.cram.crai
Binary file not shown.
12 changes: 12 additions & 0 deletions test/indexedfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,15 @@ describe('cram31', () => {
expect(feature).toMatchSnapshot()
})
})

test('start of chr', async () => {
const cram = new IndexedCramFile({
cramFilehandle: testDataFile('volvox-long-reads-sv.cram'),
index: new CraiIndex({
filehandle: testDataFile('volvox-long-reads-sv.cram.crai'),
}),
})

const feats = await cram.getRecordsForRange(0, 0, 1)
expect(feats.length).toBe(13)
})

0 comments on commit dafd115

Please sign in to comment.