Skip to content

Commit

Permalink
Wow
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Dec 11, 2023
1 parent 20bae27 commit eb3ff89
Show file tree
Hide file tree
Showing 4 changed files with 1,731 additions and 1,743 deletions.
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,32 @@
"genomics"
],
"dependencies": {
"@gmod/bgzf-filehandle": "^1.4.4",
"@gmod/bgzf-filehandle": "^1.4.7",
"abortable-promise-cache": "^1.5.0",
"buffer-crc32": "^0.2.13",
"generic-filehandle": "^3.0.0",
"generic-filehandle": "^3.1.1",
"long": "^4.0.0",
"quick-lru": "^4.0.0"
},
"devDependencies": {
"@types/buffer-crc32": "^0.2.2",
"@types/jest": "^29.5.1",
"@types/buffer-crc32": "^0.2.4",
"@types/jest": "^29.5.11",
"@types/long": "^4.0.0",
"@types/node": "^18.16.0",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unicorn": "^47.0.0",
"jest": "^29.5.0",
"@types/node": "^20.10.4",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-unicorn": "^49.0.0",
"jest": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"standard-changelog": "^2.0.27",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"standard-changelog": "^5.0.0",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
},
"publishConfig": {
"access": "public"
Expand Down
11 changes: 7 additions & 4 deletions src/bamFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const BAM_MAGIC = 21840194

const blockLen = 1 << 16

function isGzip(buf: Buffer) {
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8
}

async function gen2array<T>(gen: AsyncIterable<T[]>): Promise<T[]> {
let out: T[] = []
for await (const x of gen) {
Expand Down Expand Up @@ -157,7 +161,7 @@ export default class BamFile {
buffer = (await this.bam.readFile(opts)) as Buffer
}

const uncba = await unzip(buffer)
const uncba = isGzip(buffer) ? await unzip(buffer) : buffer

if (uncba.readInt32LE(0) !== BAM_MAGIC) {
throw new Error('Not a BAM file')
Expand Down Expand Up @@ -215,9 +219,8 @@ export default class BamFile {
if (!bytesRead) {
throw new Error('Error reading refseqs from header')
}
const uncba = await unzip(
buffer.subarray(0, Math.min(bytesRead, refSeqBytes)),
)
const ret = buffer.subarray(0, Math.min(bytesRead, refSeqBytes))
const uncba = isGzip(ret) ? await unzip(ret) : ret
const nRef = uncba.readInt32LE(start)
let p = start + 4
const chrToIndex: { [key: string]: number } = {}
Expand Down
1 change: 0 additions & 1 deletion src/record.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-empty-function */
import Constants from './constants'

const SEQRET_DECODER = '=ACMGRSVTWYHKDBN'.split('')
Expand Down
Loading

0 comments on commit eb3ff89

Please sign in to comment.