Skip to content

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 26, 2024
1 parent 65cda07 commit 5e6c181
Show file tree
Hide file tree
Showing 8 changed files with 371 additions and 369 deletions.
12 changes: 7 additions & 5 deletions src/cramFile/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ export default class CramFile {
position = block._endPosition
}
} else {
// otherwise, just traverse to the next container using the container's length
// otherwise, just traverse to the next container using the container's
// length
position += currentHeader._size + currentHeader.length
}
}
Expand Down Expand Up @@ -226,9 +227,9 @@ export default class CramFile {
if (!currentHeader) {
break
}
// if this is the first container, read all the blocks in the
// container, because we cannot trust the container
// header's given length due to a bug somewhere in htslib
// if this is the first container, read all the blocks in the container,
// because we cannot trust the container header's given length due to a
// bug somewhere in htslib
if (containerCount === 0) {
position = currentHeader._endPosition
for (let j = 0; j < currentHeader.numBlocks; j++) {
Expand All @@ -239,7 +240,8 @@ export default class CramFile {
position = block._endPosition
}
} else {
// otherwise, just traverse to the next container using the container's length
// otherwise, just traverse to the next container using the container's
// length
position += currentHeader._size + currentHeader.length
}
containerCount += 1
Expand Down
Binary file added test/data/hts-specs/3.1/passed/level-1.cram
Binary file not shown.
Binary file added test/data/hts-specs/3.1/passed/level-2.cram
Binary file not shown.
Binary file added test/data/hts-specs/3.1/passed/level-3.cram
Binary file not shown.
Binary file added test/data/hts-specs/3.1/passed/level-4.cram
Binary file not shown.
25 changes: 25 additions & 0 deletions test/dump3.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @ts-nocheck
import { test, expect } from 'vitest'

Check warning on line 2 in test/dump3.test.ts

View workflow job for this annotation

GitHub Actions / Lint, build, and test on node 20.x and ubuntu-latest

'expect' is defined but never used
import { t3 as testFileList } from './lib/testFileList'
import { testDataFile } from './lib/util'
import { dumpWholeFile } from './lib/dumpFile'
import { CramFile } from '../src/index'
import { FetchableSmallFasta } from './lib/fasta'

testFileList.forEach(filename => {
test(`can dump the whole ${filename} without error`, async () => {
let seqFetch
if (filename.includes('#')) {
const referenceFileName = filename.replace(/#.+$/, '.fa')
const fasta = new FetchableSmallFasta(testDataFile(referenceFileName))
seqFetch = fasta.fetch.bind(fasta)
}

const filehandle = testDataFile(filename)
const file = new CramFile({
filehandle,
seqFetch,
})
await dumpWholeFile(file) // just try to decode it, no snapshot test for now as it is large
}, 10000)
})
13 changes: 12 additions & 1 deletion test/lib/testFileList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,15 @@ grc37-1#HG03297.mapped.ILLUMINA.bwa.ESN.low_coverage.20130415.bam.cram
.split(/\s+/)
.filter(f => !!f)

export { t1, t2 }
const t3 = `
hts-specs/0902_comp_bz2.cram
hts-specs/0903_comp_lzma.cram
hts-specs/3.1/passed/level-3.cram
hts-specs/3.1/passed/level-4.cram
hts-specs/3.1/passed/level-1.cram
hts-specs/3.1/passed/level-2.cram
`
.split(/\s+/)
.filter(f => !!f)

export { t1, t2, t3 }
690 changes: 327 additions & 363 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit 5e6c181

Please sign in to comment.