Comparing version 4.0.4 to 4.0.5
@@ -0,1 +1,5 @@ | ||
## [4.0.5](https://github.com/GMOD/bbi-js/compare/v4.0.4...v4.0.5) (2024-06-19) | ||
## [4.0.4](https://github.com/GMOD/bbi-js/compare/v4.0.3...v4.0.4) (2024-3-5) | ||
@@ -2,0 +6,0 @@ |
@@ -26,2 +26,3 @@ import { GenericFilehandle } from 'generic-filehandle'; | ||
export interface Header { | ||
version: number; | ||
autoSql: string; | ||
@@ -39,8 +40,4 @@ totalSummary: Statistics; | ||
fileType: string; | ||
refsByName: { | ||
[key: string]: number; | ||
}; | ||
refsByNumber: { | ||
[key: number]: RefInfo; | ||
}; | ||
refsByName: Record<string, number>; | ||
refsByNumber: Record<number, RefInfo>; | ||
} | ||
@@ -47,0 +44,0 @@ export interface RequestOptions { |
@@ -24,3 +24,4 @@ "use strict"; | ||
} | ||
/* get the compiled parsers for different sections of the bigwig file | ||
/** | ||
* get the compiled parsers for different sections of the bigwig file | ||
* | ||
@@ -83,6 +84,2 @@ * @param isBE - is big endian, typically false | ||
class BBI { | ||
/* fetch and parse header information from a bigwig or bigbed file | ||
* @param abortSignal - abort the operation, can be null | ||
* @return a Header object | ||
*/ | ||
getHeader(opts) { | ||
@@ -130,4 +127,4 @@ if (!this.headerP) { | ||
} | ||
_getMainHeader(opts, requestSize = 2000) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
_getMainHeader(opts_1) { | ||
return __awaiter(this, arguments, void 0, function* (opts, requestSize = 2000) { | ||
const { buffer } = yield this.bbi.read(buffer_1.Buffer.alloc(requestSize), 0, requestSize, 0, opts); | ||
@@ -269,3 +266,5 @@ const isBigEndian = this._isBigEndian(buffer); | ||
return new rxjs_1.Observable(observer => { | ||
view.readWigData(chrName, start, end, observer, opts); | ||
view | ||
.readWigData(chrName, start, end, observer, opts) | ||
.catch(e => observer.error(e)); | ||
}); | ||
@@ -272,0 +271,0 @@ }); |
@@ -104,4 +104,4 @@ "use strict"; | ||
*/ | ||
searchExtraIndexBlocks(name, opts = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
searchExtraIndexBlocks(name_1) { | ||
return __awaiter(this, arguments, void 0, function* (name, opts = {}) { | ||
const { isBigEndian } = yield this.getHeader(opts); | ||
@@ -158,14 +158,13 @@ const indices = yield this.readIndices(opts); | ||
let lastOffset; | ||
for (let i = 0; i < node.leafkeys.length; i += 1) { | ||
const { key } = node.leafkeys[i]; | ||
for (const { key, offset } of node.leafkeys) { | ||
if (name.localeCompare(key) < 0 && lastOffset) { | ||
return bptReadNode(lastOffset); | ||
} | ||
lastOffset = node.leafkeys[i].offset; | ||
lastOffset = offset; | ||
} | ||
return bptReadNode(lastOffset); | ||
} | ||
for (let i = 0; i < node.keys.length; i += 1) { | ||
if (node.keys[i].key === name) { | ||
return Object.assign(Object.assign({}, node.keys[i]), { field }); | ||
for (const n of node.keys) { | ||
if (n.key === name) { | ||
return Object.assign(Object.assign({}, n), { field }); | ||
} | ||
@@ -182,4 +181,5 @@ } | ||
/* | ||
* retrieve the features from the bigbed data that were found through the lookup of the extraIndex | ||
* note that there can be multiple extraIndex, see the BigBed specification and the -extraIndex argument to bedToBigBed | ||
* retrieve the features from the bigbed data that were found through the | ||
* lookup of the extraIndex note that there can be multiple extraIndex, see | ||
* the BigBed specification and the -extraIndex argument to bedToBigBed | ||
* | ||
@@ -190,4 +190,4 @@ * @param name - the name to search for | ||
*/ | ||
searchExtraIndex(name, opts = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
searchExtraIndex(name_1) { | ||
return __awaiter(this, arguments, void 0, function* (name, opts = {}) { | ||
const blocks = yield this.searchExtraIndexBlocks(name, opts); | ||
@@ -200,3 +200,3 @@ if (blocks.length === 0) { | ||
return new rxjs_1.Observable(observer => { | ||
view.readFeatures(observer, [block], opts); | ||
view.readFeatures(observer, [block], opts).catch(e => observer.error(e)); | ||
}).pipe((0, operators_1.reduce)((acc, curr) => acc.concat(curr)), (0, operators_1.map)(x => { | ||
@@ -203,0 +203,0 @@ for (const element of x) { |
@@ -8,5 +8,7 @@ import { BlockView } from './block-view'; | ||
* @param scale - number | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use | ||
* | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) | ||
* or scale used to infer the zoomLevel to use | ||
*/ | ||
protected getView(scale: number, opts: RequestOptions): Promise<BlockView>; | ||
} |
@@ -20,3 +20,5 @@ "use strict"; | ||
* @param scale - number | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use | ||
* | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) | ||
* or scale used to infer the zoomLevel to use | ||
*/ | ||
@@ -23,0 +25,0 @@ getView(scale, opts) { |
@@ -181,3 +181,3 @@ "use strict"; | ||
.filter(f => filterFeats(f)) | ||
.map((l) => ({ | ||
.map(l => ({ | ||
offset: l.blockOffset, | ||
@@ -238,2 +238,3 @@ length: l.blockSize, | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
spans.getRanges().map(fr => cirFobStartFetch(offset, fr, level)); | ||
@@ -358,4 +359,4 @@ } | ||
} | ||
readFeatures(observer, blocks, opts = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
readFeatures(observer_1, blocks_1) { | ||
return __awaiter(this, arguments, void 0, function* (observer, blocks, opts = {}) { | ||
try { | ||
@@ -362,0 +363,0 @@ const { blockType, isCompressed } = this; |
"use strict"; | ||
/* eslint prefer-rest-params:0, no-nested-ternary:0 */ | ||
/** | ||
* Adapted from a combination of Range and _Compound in the | ||
* Dalliance Genome Explorer, (c) Thomas Down 2006-2010. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -51,4 +54,3 @@ class Range { | ||
let current = ranges[0]; | ||
for (let i = 1; i < ranges.length; i += 1) { | ||
const nxt = ranges[i]; | ||
for (const nxt of ranges) { | ||
if (nxt.min > current.max + 1) { | ||
@@ -55,0 +57,0 @@ oranges.push(current); |
@@ -26,2 +26,3 @@ import { GenericFilehandle } from 'generic-filehandle'; | ||
export interface Header { | ||
version: number; | ||
autoSql: string; | ||
@@ -39,8 +40,4 @@ totalSummary: Statistics; | ||
fileType: string; | ||
refsByName: { | ||
[key: string]: number; | ||
}; | ||
refsByNumber: { | ||
[key: number]: RefInfo; | ||
}; | ||
refsByName: Record<string, number>; | ||
refsByNumber: Record<number, RefInfo>; | ||
} | ||
@@ -47,0 +44,0 @@ export interface RequestOptions { |
@@ -12,3 +12,4 @@ import { Buffer } from 'buffer'; | ||
} | ||
/* get the compiled parsers for different sections of the bigwig file | ||
/** | ||
* get the compiled parsers for different sections of the bigwig file | ||
* | ||
@@ -71,6 +72,2 @@ * @param isBE - is big endian, typically false | ||
export class BBI { | ||
/* fetch and parse header information from a bigwig or bigbed file | ||
* @param abortSignal - abort the operation, can be null | ||
* @return a Header object | ||
*/ | ||
getHeader(opts) { | ||
@@ -247,3 +244,5 @@ if (!this.headerP) { | ||
return new Observable(observer => { | ||
view.readWigData(chrName, start, end, observer, opts); | ||
view | ||
.readWigData(chrName, start, end, observer, opts) | ||
.catch(e => observer.error(e)); | ||
}); | ||
@@ -250,0 +249,0 @@ } |
@@ -125,14 +125,13 @@ import { Buffer } from 'buffer'; | ||
let lastOffset; | ||
for (let i = 0; i < node.leafkeys.length; i += 1) { | ||
const { key } = node.leafkeys[i]; | ||
for (const { key, offset } of node.leafkeys) { | ||
if (name.localeCompare(key) < 0 && lastOffset) { | ||
return bptReadNode(lastOffset); | ||
} | ||
lastOffset = node.leafkeys[i].offset; | ||
lastOffset = offset; | ||
} | ||
return bptReadNode(lastOffset); | ||
} | ||
for (let i = 0; i < node.keys.length; i += 1) { | ||
if (node.keys[i].key === name) { | ||
return { ...node.keys[i], field }; | ||
for (const n of node.keys) { | ||
if (n.key === name) { | ||
return { ...n, field }; | ||
} | ||
@@ -148,4 +147,5 @@ } | ||
/* | ||
* retrieve the features from the bigbed data that were found through the lookup of the extraIndex | ||
* note that there can be multiple extraIndex, see the BigBed specification and the -extraIndex argument to bedToBigBed | ||
* retrieve the features from the bigbed data that were found through the | ||
* lookup of the extraIndex note that there can be multiple extraIndex, see | ||
* the BigBed specification and the -extraIndex argument to bedToBigBed | ||
* | ||
@@ -164,3 +164,3 @@ * @param name - the name to search for | ||
return new Observable(observer => { | ||
view.readFeatures(observer, [block], opts); | ||
view.readFeatures(observer, [block], opts).catch(e => observer.error(e)); | ||
}).pipe(reduce((acc, curr) => acc.concat(curr)), map(x => { | ||
@@ -167,0 +167,0 @@ for (const element of x) { |
@@ -8,5 +8,7 @@ import { BlockView } from './block-view'; | ||
* @param scale - number | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use | ||
* | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) | ||
* or scale used to infer the zoomLevel to use | ||
*/ | ||
protected getView(scale: number, opts: RequestOptions): Promise<BlockView>; | ||
} |
@@ -8,3 +8,5 @@ import { BlockView } from './block-view'; | ||
* @param scale - number | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use | ||
* | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) | ||
* or scale used to infer the zoomLevel to use | ||
*/ | ||
@@ -11,0 +13,0 @@ async getView(scale, opts) { |
@@ -165,3 +165,3 @@ import { Buffer } from 'buffer'; | ||
.filter(f => filterFeats(f)) | ||
.map((l) => ({ | ||
.map(l => ({ | ||
offset: l.blockOffset, | ||
@@ -225,2 +225,3 @@ length: l.blockSize, | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
spans.getRanges().map(fr => cirFobStartFetch(offset, fr, level)); | ||
@@ -227,0 +228,0 @@ } |
@@ -1,2 +0,5 @@ | ||
/* eslint prefer-rest-params:0, no-nested-ternary:0 */ | ||
/** | ||
* Adapted from a combination of Range and _Compound in the | ||
* Dalliance Genome Explorer, (c) Thomas Down 2006-2010. | ||
*/ | ||
export default class Range { | ||
@@ -49,4 +52,3 @@ constructor(arg1) { | ||
let current = ranges[0]; | ||
for (let i = 1; i < ranges.length; i += 1) { | ||
const nxt = ranges[i]; | ||
for (const nxt of ranges) { | ||
if (nxt.min > current.max + 1) { | ||
@@ -53,0 +55,0 @@ oranges.push(current); |
{ | ||
"name": "@gmod/bbi", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"description": "Parser for BigWig/BigBed files", | ||
@@ -25,3 +25,3 @@ "license": "MIT", | ||
"coverage": "npm test -- --coverage", | ||
"lint": "eslint --report-unused-disable-directives --max-warnings 0 --ext .js,.ts src", | ||
"lint": "eslint --report-unused-disable-directives --max-warnings 0 src", | ||
"format": "prettier", | ||
@@ -58,8 +58,8 @@ "clean": "rimraf dist esm", | ||
"@types/pako": "^2.0.0", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"eslint": "^8.46.0", | ||
"@typescript-eslint/eslint-plugin": "^7.3.1", | ||
"@typescript-eslint/parser": "^7.3.1", | ||
"eslint": "^9.0.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-plugin-unicorn": "^51.0.0", | ||
"eslint-plugin-unicorn": "^54.0.0", | ||
"jest": "^29.6.2", | ||
@@ -69,3 +69,3 @@ "jest-environment-jsdom": "^29.6.2", | ||
"rimraf": "^5.0.1", | ||
"standard-changelog": "^5.0.0", | ||
"standard-changelog": "^6.0.0", | ||
"ts-jest": "^29.1.2", | ||
@@ -72,0 +72,0 @@ "typescript": "^5.1.6" |
@@ -38,2 +38,3 @@ import { Buffer } from 'buffer' | ||
export interface Header { | ||
version: number | ||
autoSql: string | ||
@@ -51,7 +52,8 @@ totalSummary: Statistics | ||
fileType: string | ||
refsByName: { [key: string]: number } | ||
refsByNumber: { [key: number]: RefInfo } | ||
refsByName: Record<string, number> | ||
refsByNumber: Record<number, RefInfo> | ||
} | ||
/* get the compiled parsers for different sections of the bigwig file | ||
/** | ||
* get the compiled parsers for different sections of the bigwig file | ||
* | ||
@@ -131,6 +133,2 @@ * @param isBE - is big endian, typically false | ||
/* fetch and parse header information from a bigwig or bigbed file | ||
* @param abortSignal - abort the operation, can be null | ||
* @return a Header object | ||
*/ | ||
public getHeader(opts?: RequestOptions) { | ||
@@ -238,6 +236,7 @@ if (!this.headerP) { | ||
const le = isBE ? 'big' : 'little' | ||
const refsByNumber: { | ||
[key: number]: { name: string; id: number; length: number } | ||
} = [] | ||
const refsByName: { [key: string]: number } = {} | ||
const refsByNumber: Record< | ||
number, | ||
{ name: string; id: number; length: number } | ||
> = [] | ||
const refsByName: Record<string, number> = {} | ||
@@ -368,3 +367,5 @@ let unzoomedDataOffset = Number(header.unzoomedDataOffset) | ||
return new Observable<Feature[]>(observer => { | ||
view.readWigData(chrName, start, end, observer, opts) | ||
view | ||
.readWigData(chrName, start, end, observer, opts) | ||
.catch(e => observer.error(e)) | ||
}) | ||
@@ -371,0 +372,0 @@ } |
@@ -177,14 +177,13 @@ import { Buffer } from 'buffer' | ||
let lastOffset | ||
for (let i = 0; i < node.leafkeys.length; i += 1) { | ||
const { key } = node.leafkeys[i] | ||
for (const { key, offset } of node.leafkeys) { | ||
if (name.localeCompare(key) < 0 && lastOffset) { | ||
return bptReadNode(lastOffset) | ||
} | ||
lastOffset = node.leafkeys[i].offset | ||
lastOffset = offset | ||
} | ||
return bptReadNode(lastOffset) | ||
} | ||
for (let i = 0; i < node.keys.length; i += 1) { | ||
if (node.keys[i].key === name) { | ||
return { ...node.keys[i], field } | ||
for (const n of node.keys) { | ||
if (n.key === name) { | ||
return { ...n, field } | ||
} | ||
@@ -202,4 +201,5 @@ } | ||
/* | ||
* retrieve the features from the bigbed data that were found through the lookup of the extraIndex | ||
* note that there can be multiple extraIndex, see the BigBed specification and the -extraIndex argument to bedToBigBed | ||
* retrieve the features from the bigbed data that were found through the | ||
* lookup of the extraIndex note that there can be multiple extraIndex, see | ||
* the BigBed specification and the -extraIndex argument to bedToBigBed | ||
* | ||
@@ -218,3 +218,3 @@ * @param name - the name to search for | ||
return new Observable<Feature[]>(observer => { | ||
view.readFeatures(observer, [block], opts) | ||
view.readFeatures(observer, [block], opts).catch(e => observer.error(e)) | ||
}).pipe( | ||
@@ -221,0 +221,0 @@ reduce((acc, curr) => acc.concat(curr)), |
@@ -9,3 +9,5 @@ import { BlockView } from './block-view' | ||
* @param scale - number | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use | ||
* | ||
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) | ||
* or scale used to infer the zoomLevel to use | ||
*/ | ||
@@ -12,0 +14,0 @@ protected async getView(scale: number, opts: RequestOptions) { |
@@ -238,3 +238,3 @@ import { Buffer } from 'buffer' | ||
.filter(f => filterFeats(f)) | ||
.map((l: { blockOffset: bigint; blockSize: bigint }) => ({ | ||
.map(l => ({ | ||
offset: l.blockOffset, | ||
@@ -310,2 +310,3 @@ length: l.blockSize, | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
spans.getRanges().map(fr => cirFobStartFetch(offset, fr, level)) | ||
@@ -312,0 +313,0 @@ } catch (e) { |
@@ -1,3 +0,1 @@ | ||
/* eslint prefer-rest-params:0, no-nested-ternary:0 */ | ||
/** | ||
@@ -48,3 +46,3 @@ * Adapted from a combination of Range and _Compound in the | ||
public union(s1: Range): Range { | ||
public union(s1: Range) { | ||
const ranges = [...this.getRanges(), ...s1.getRanges()].sort((a, b) => { | ||
@@ -63,7 +61,6 @@ if (a.min < b.min) { | ||
}) | ||
const oranges = [] | ||
const oranges = [] as Range[] | ||
let current = ranges[0] | ||
for (let i = 1; i < ranges.length; i += 1) { | ||
const nxt = ranges[i] | ||
for (const nxt of ranges) { | ||
if (nxt.min > current.max + 1) { | ||
@@ -70,0 +67,0 @@ oranges.push(current) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4015
239611