Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gmod/bbi

Package Overview
Dependencies
Maintainers
6
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gmod/bbi - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

dist/block-view.d.ts

13

CHANGELOG.md

@@ -1,12 +0,17 @@

## [3.0.1](https://github.com/GMOD/bbi-js/compare/v3.0.0...v3.0.1) (2023-04-21)
# [4.0.0](https://github.com/GMOD/bbi-js/compare/v3.0.1...v4.0.0) (2023-05-05)
### Features
* explicit buffer import ([#53](https://github.com/GMOD/bbi-js/issues/53)) ([2699c98](https://github.com/GMOD/bbi-js/commit/2699c983dea380bbb56773058ba3f233c833d9c8))
- Improve typescripting, refactoring
- Options argument only accepts {signal}, not just signal now
## [3.0.1](https://github.com/GMOD/bbi-js/compare/v3.0.0...v3.0.1) (2023-04-21)
### Features
- Add explicit Buffer import
- explicit buffer import ([#53](https://github.com/GMOD/bbi-js/issues/53))
([2699c98](https://github.com/GMOD/bbi-js/commit/2699c983dea380bbb56773058ba3f233c833d9c8))
* Add explicit Buffer import
# [3.0.0](https://github.com/GMOD/bbi-js/compare/v2.0.5...v3.0.0) (2023-01-11)

@@ -13,0 +18,0 @@

import { GenericFilehandle } from 'generic-filehandle';
import { Observable } from 'rxjs';
import { BlockView } from './blockView';
import { BlockView } from './block-view';
export interface Feature {

@@ -54,4 +54,4 @@ start: number;

protected renameRefSeqs: (a: string) => string;
getHeader(opts?: RequestOptions | AbortSignal): Promise<Header>;
constructor(options?: {
getHeader(opts?: RequestOptions): Promise<Header>;
constructor(args: {
filehandle?: GenericFilehandle;

@@ -66,4 +66,4 @@ path?: string;

private _readChromTree;
protected getUnzoomedView(opts: RequestOptions): Promise<BlockView>;
protected abstract getView(scale: number, opts: RequestOptions): Promise<BlockView>;
protected getUnzoomedView(opts?: RequestOptions): Promise<BlockView>;
protected abstract getView(scale: number, opts?: RequestOptions): Promise<BlockView>;
/**

@@ -70,0 +70,0 @@ * Gets features from a BigWig file

@@ -18,3 +18,3 @@ "use strict";

const operators_1 = require("rxjs/operators");
const blockView_1 = require("./blockView");
const block_view_1 = require("./block-view");
const BIG_WIG_MAGIC = -2003829722;

@@ -87,6 +87,5 @@ const BIG_BED_MAGIC = -2021002517;

*/
getHeader(opts = {}) {
const options = 'aborted' in opts ? { signal: opts } : opts;
getHeader(opts) {
if (!this.headerP) {
this.headerP = this._getHeader(options).catch(e => {
this.headerP = this._getHeader(opts).catch(e => {
this.headerP = undefined;

@@ -104,4 +103,4 @@ throw e;

*/
constructor(options = {}) {
const { filehandle, renameRefSeqs = s => s, path, url } = options;
constructor(args) {
const { filehandle, renameRefSeqs = s => s, path, url } = args;
this.renameRefSeqs = renameRefSeqs;

@@ -237,3 +236,3 @@ if (filehandle) {

const { unzoomedIndexOffset, refsByName, uncompressBufSize, isBigEndian, fileType, } = yield this.getHeader(opts);
return new blockView_1.BlockView(this.bbi, refsByName, unzoomedIndexOffset, isBigEndian, uncompressBufSize > 0, fileType);
return new block_view_1.BlockView(this.bbi, refsByName, unzoomedIndexOffset, isBigEndian, uncompressBufSize > 0, fileType);
});

@@ -249,5 +248,3 @@ }

*/
getFeatureStream(refName, start, end, opts = {
scale: 1,
}) {
getFeatureStream(refName, start, end, opts) {
return __awaiter(this, void 0, void 0, function* () {

@@ -257,7 +254,8 @@ yield this.getHeader(opts);

let view;
if (opts.basesPerSpan) {
view = yield this.getView(1 / opts.basesPerSpan, opts);
const { basesPerSpan, scale } = opts || {};
if (basesPerSpan) {
view = yield this.getView(1 / basesPerSpan, opts);
}
else if (opts.scale) {
view = yield this.getView(opts.scale, opts);
else if (scale) {
view = yield this.getView(scale, opts);
}

@@ -267,6 +265,3 @@ else {

}
if (!view) {
throw new Error('unable to get block view for data');
}
return new rxjs_1.Observable((observer) => {
return new rxjs_1.Observable(observer => {
view.readWigData(chrName, start, end, observer, opts);

@@ -276,5 +271,3 @@ });

}
getFeatures(refName, start, end, opts = {
scale: 1,
}) {
getFeatures(refName, start, end, opts) {
return __awaiter(this, void 0, void 0, function* () {

@@ -281,0 +274,0 @@ const ob = yield this.getFeatureStream(refName, start, end, opts);

@@ -0,8 +1,14 @@

import AbortablePromiseCache from 'abortable-promise-cache';
import { BBI, Feature, RequestOptions } from './bbi';
import { BlockView } from './blockView';
interface Index {
type: number;
fieldcount: number;
offset: number;
field: number;
}
export declare function filterUndef<T>(ts: (T | undefined)[]): T[];
export declare class BigBed extends BBI {
readIndicesCache: any;
readIndices(opts?: AbortSignal | RequestOptions): any;
protected getView(_scale: number, opts: RequestOptions): Promise<BlockView>;
readIndicesCache: AbortablePromiseCache<RequestOptions, Index[]>;
readIndices(opts?: RequestOptions): Promise<Index[]>;
protected getView(_scale: number, opts?: RequestOptions): Promise<import("./block-view").BlockView>;
private _readIndices;

@@ -12,1 +18,2 @@ private searchExtraIndexBlocks;

}
export {};

@@ -11,2 +11,13 @@ "use strict";

};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -33,16 +44,11 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

cache: new quick_lru_1.default({ maxSize: 1 }),
fill: (args, signal) => __awaiter(this, void 0, void 0, function* () {
return this._readIndices(Object.assign(Object.assign({}, args), { signal }));
}),
fill: (args, signal) => this._readIndices(Object.assign(Object.assign({}, args), { signal })),
});
}
readIndices(opts = {}) {
const options = 'aborted' in opts ? { signal: opts } : opts;
return this.readIndicesCache.get(JSON.stringify(options), options, options.signal);
const { signal } = opts, rest = __rest(opts, ["signal"]);
return this.readIndicesCache.get(JSON.stringify(rest), opts, signal);
}
/*
* retrieve unzoomed view for any scale
* @param scale - unused
* @param abortSignal - an optional AbortSignal to kill operation
* @return promise for a BlockView
*/

@@ -104,3 +110,3 @@ getView(_scale, opts) {

const indices = yield this.readIndices(opts);
if (!indices.length) {
if (indices.length === 0) {
return [];

@@ -187,3 +193,3 @@ }

const blocks = yield this.searchExtraIndexBlocks(name, opts);
if (!blocks.length) {
if (blocks.length === 0) {
return [];

@@ -196,4 +202,4 @@ }

}).pipe((0, operators_1.reduce)((acc, curr) => acc.concat(curr)), (0, operators_1.map)(x => {
for (let i = 0; i < x.length; i += 1) {
x[i].field = block.field;
for (const element of x) {
element.field = block.field;
}

@@ -200,0 +206,0 @@ return x;

@@ -1,2 +0,2 @@

import { BlockView } from './blockView';
import { BlockView } from './block-view';
import { BBI, RequestOptions } from './bbi';

@@ -3,0 +3,0 @@ export declare class BigWig extends BBI {

@@ -13,3 +13,3 @@ "use strict";

exports.BigWig = void 0;
const blockView_1 = require("./blockView");
const block_view_1 = require("./block-view");
const bbi_1 = require("./bbi");

@@ -36,3 +36,3 @@ class BigWig extends bbi_1.BBI {

const indexOffset = Number(zh.indexOffset);
return new blockView_1.BlockView(this.bbi, refsByName, indexOffset, isBigEndian, uncompressBufSize > 0, 'summary');
return new block_view_1.BlockView(this.bbi, refsByName, indexOffset, isBigEndian, uncompressBufSize > 0, 'summary');
}

@@ -39,0 +39,0 @@ }

@@ -62,3 +62,3 @@ "use strict";

intersection(arg) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
// eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment
let s0 = this;

@@ -99,4 +99,3 @@ let s1 = arg;

const rl = this.ranges();
for (let ri = 0; ri < rl.length; ri += 1) {
const r = rl[ri];
for (const r of rl) {
tot += r.max() - r.min() + 1;

@@ -111,3 +110,3 @@ }

b = a;
// eslint-disable-next-line @typescript-eslint/no-this-alias
// eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment
a = this;

@@ -114,0 +113,0 @@ }

@@ -1,2 +0,1 @@

import { inflateSync } from 'zlib';
export { inflateSync as unzip };
export { inflateSync as unzip } from 'zlib';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unzip = void 0;
const zlib_1 = require("zlib");
var zlib_1 = require("zlib");
Object.defineProperty(exports, "unzip", { enumerable: true, get: function () { return zlib_1.inflateSync; } });
//# sourceMappingURL=unzip.js.map

@@ -28,17 +28,17 @@ "use strict";

let lastBlockEnd;
for (let i = 0; i < blocks.length; i += 1) {
for (const block of blocks) {
if (lastBlock &&
lastBlockEnd &&
Number(blocks[i].offset) - lastBlockEnd <= 2000) {
Number(block.offset) - lastBlockEnd <= 2000) {
lastBlock.length = BigInt(Number(lastBlock.length) +
Number(blocks[i].length) -
Number(block.length) -
lastBlockEnd +
Number(blocks[i].offset));
lastBlock.blocks.push(blocks[i]);
Number(block.offset));
lastBlock.blocks.push(block);
}
else {
blockGroups.push((lastBlock = {
blocks: [blocks[i]],
length: blocks[i].length,
offset: blocks[i].offset,
blocks: [block],
length: block.length,
offset: block.offset,
}));

@@ -68,6 +68,3 @@ }

// console.log('bam aborted!')
if (typeof DOMException !== 'undefined') {
throw new DOMException('aborted', 'AbortError');
}
else {
if (typeof DOMException === 'undefined') {
const e = new AbortError('aborted');

@@ -77,2 +74,5 @@ e.code = 'ERR_ABORTED';

}
else {
throw new DOMException('aborted', 'AbortError');
}
}

@@ -79,0 +79,0 @@ }

import { GenericFilehandle } from 'generic-filehandle';
import { Observable } from 'rxjs';
import { BlockView } from './blockView';
import { BlockView } from './block-view';
export interface Feature {

@@ -54,4 +54,4 @@ start: number;

protected renameRefSeqs: (a: string) => string;
getHeader(opts?: RequestOptions | AbortSignal): Promise<Header>;
constructor(options?: {
getHeader(opts?: RequestOptions): Promise<Header>;
constructor(args: {
filehandle?: GenericFilehandle;

@@ -66,4 +66,4 @@ path?: string;

private _readChromTree;
protected getUnzoomedView(opts: RequestOptions): Promise<BlockView>;
protected abstract getView(scale: number, opts: RequestOptions): Promise<BlockView>;
protected getUnzoomedView(opts?: RequestOptions): Promise<BlockView>;
protected abstract getView(scale: number, opts?: RequestOptions): Promise<BlockView>;
/**

@@ -70,0 +70,0 @@ * Gets features from a BigWig file

@@ -6,3 +6,3 @@ import { Buffer } from 'buffer';

import { toArray } from 'rxjs/operators';
import { BlockView } from './blockView';
import { BlockView } from './block-view';
const BIG_WIG_MAGIC = -2003829722;

@@ -75,6 +75,5 @@ const BIG_BED_MAGIC = -2021002517;

*/
getHeader(opts = {}) {
const options = 'aborted' in opts ? { signal: opts } : opts;
getHeader(opts) {
if (!this.headerP) {
this.headerP = this._getHeader(options).catch(e => {
this.headerP = this._getHeader(opts).catch(e => {
this.headerP = undefined;

@@ -92,4 +91,4 @@ throw e;

*/
constructor(options = {}) {
const { filehandle, renameRefSeqs = s => s, path, url } = options;
constructor(args) {
const { filehandle, renameRefSeqs = s => s, path, url } = args;
this.renameRefSeqs = renameRefSeqs;

@@ -228,13 +227,12 @@ if (filehandle) {

*/
async getFeatureStream(refName, start, end, opts = {
scale: 1,
}) {
async getFeatureStream(refName, start, end, opts) {
await this.getHeader(opts);
const chrName = this.renameRefSeqs(refName);
let view;
if (opts.basesPerSpan) {
view = await this.getView(1 / opts.basesPerSpan, opts);
const { basesPerSpan, scale } = opts || {};
if (basesPerSpan) {
view = await this.getView(1 / basesPerSpan, opts);
}
else if (opts.scale) {
view = await this.getView(opts.scale, opts);
else if (scale) {
view = await this.getView(scale, opts);
}

@@ -244,12 +242,7 @@ else {

}
if (!view) {
throw new Error('unable to get block view for data');
}
return new Observable((observer) => {
return new Observable(observer => {
view.readWigData(chrName, start, end, observer, opts);
});
}
async getFeatures(refName, start, end, opts = {
scale: 1,
}) {
async getFeatures(refName, start, end, opts) {
const ob = await this.getFeatureStream(refName, start, end, opts);

@@ -256,0 +249,0 @@ const ret = await firstValueFrom(ob.pipe(toArray()));

@@ -0,8 +1,14 @@

import AbortablePromiseCache from 'abortable-promise-cache';
import { BBI, Feature, RequestOptions } from './bbi';
import { BlockView } from './blockView';
interface Index {
type: number;
fieldcount: number;
offset: number;
field: number;
}
export declare function filterUndef<T>(ts: (T | undefined)[]): T[];
export declare class BigBed extends BBI {
readIndicesCache: any;
readIndices(opts?: AbortSignal | RequestOptions): any;
protected getView(_scale: number, opts: RequestOptions): Promise<BlockView>;
readIndicesCache: AbortablePromiseCache<RequestOptions, Index[]>;
readIndices(opts?: RequestOptions): Promise<Index[]>;
protected getView(_scale: number, opts?: RequestOptions): Promise<import("./block-view").BlockView>;
private _readIndices;

@@ -12,1 +18,2 @@ private searchExtraIndexBlocks;

}
export {};

@@ -16,16 +16,11 @@ import { Buffer } from 'buffer';

cache: new QuickLRU({ maxSize: 1 }),
fill: async (args, signal) => {
return this._readIndices({ ...args, signal });
},
fill: (args, signal) => this._readIndices({ ...args, signal }),
});
}
readIndices(opts = {}) {
const options = 'aborted' in opts ? { signal: opts } : opts;
return this.readIndicesCache.get(JSON.stringify(options), options, options.signal);
const { signal, ...rest } = opts;
return this.readIndicesCache.get(JSON.stringify(rest), opts, signal);
}
/*
* retrieve unzoomed view for any scale
* @param scale - unused
* @param abortSignal - an optional AbortSignal to kill operation
* @return promise for a BlockView
*/

@@ -82,3 +77,3 @@ async getView(_scale, opts) {

const indices = await this.readIndices(opts);
if (!indices.length) {
if (indices.length === 0) {
return [];

@@ -163,3 +158,3 @@ }

const blocks = await this.searchExtraIndexBlocks(name, opts);
if (!blocks.length) {
if (blocks.length === 0) {
return [];

@@ -172,4 +167,4 @@ }

}).pipe(reduce((acc, curr) => acc.concat(curr)), map(x => {
for (let i = 0; i < x.length; i += 1) {
x[i].field = block.field;
for (const element of x) {
element.field = block.field;
}

@@ -176,0 +171,0 @@ return x;

@@ -1,2 +0,2 @@

import { BlockView } from './blockView';
import { BlockView } from './block-view';
import { BBI, RequestOptions } from './bbi';

@@ -3,0 +3,0 @@ export declare class BigWig extends BBI {

@@ -1,2 +0,2 @@

import { BlockView } from './blockView';
import { BlockView } from './block-view';
import { BBI } from './bbi';

@@ -3,0 +3,0 @@ export class BigWig extends BBI {

@@ -60,3 +60,3 @@ /* eslint prefer-rest-params:0, no-nested-ternary:0 */

intersection(arg) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
// eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment
let s0 = this;

@@ -97,4 +97,3 @@ let s1 = arg;

const rl = this.ranges();
for (let ri = 0; ri < rl.length; ri += 1) {
const r = rl[ri];
for (const r of rl) {
tot += r.max() - r.min() + 1;

@@ -109,3 +108,3 @@ }

b = a;
// eslint-disable-next-line @typescript-eslint/no-this-alias
// eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment
a = this;

@@ -112,0 +111,0 @@ }

@@ -1,2 +0,1 @@

import { inflateSync } from 'zlib';
export { inflateSync as unzip };
export { inflateSync as unzip } from 'zlib';

@@ -1,3 +0,2 @@

import { inflateSync } from 'zlib';
export { inflateSync as unzip };
export { inflateSync as unzip } from 'zlib';
//# sourceMappingURL=unzip.js.map

@@ -15,17 +15,17 @@ /* eslint no-bitwise: ["error", { "allow": ["|"] }] */

let lastBlockEnd;
for (let i = 0; i < blocks.length; i += 1) {
for (const block of blocks) {
if (lastBlock &&
lastBlockEnd &&
Number(blocks[i].offset) - lastBlockEnd <= 2000) {
Number(block.offset) - lastBlockEnd <= 2000) {
lastBlock.length = BigInt(Number(lastBlock.length) +
Number(blocks[i].length) -
Number(block.length) -
lastBlockEnd +
Number(blocks[i].offset));
lastBlock.blocks.push(blocks[i]);
Number(block.offset));
lastBlock.blocks.push(block);
}
else {
blockGroups.push((lastBlock = {
blocks: [blocks[i]],
length: blocks[i].length,
offset: blocks[i].offset,
blocks: [block],
length: block.length,
offset: block.offset,
}));

@@ -54,6 +54,3 @@ }

// console.log('bam aborted!')
if (typeof DOMException !== 'undefined') {
throw new DOMException('aborted', 'AbortError');
}
else {
if (typeof DOMException === 'undefined') {
const e = new AbortError('aborted');

@@ -63,2 +60,5 @@ e.code = 'ERR_ABORTED';

}
else {
throw new DOMException('aborted', 'AbortError');
}
}

@@ -65,0 +65,0 @@ }

{
"name": "@gmod/bbi",
"version": "3.0.1",
"version": "4.0.0",
"description": "Parser for BigWig/BigBed files",

@@ -46,2 +46,3 @@ "license": "MIT",

"binary-parser": "^2.1.0",
"eslint-plugin-unicorn": "^46.0.0",
"generic-filehandle": "^3.0.0",

@@ -54,20 +55,19 @@ "pako": "^2.0.0",

"@gmod/bed": "^2.1.2",
"@types/jest": "^29.2.4",
"@types/jest": "^29.5.0",
"@types/long": "^5.0.0",
"@types/node": "^18.11.15",
"@types/node": "^18.15.7",
"@types/pako": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^5.46.1",
"@typescript-eslint/parser": "^5.46.1",
"cross-fetch": "^3.0.2",
"eslint": "^8.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",
"prettier": "^2.8.1",
"rimraf": "^3.0.2",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"prettier": "^2.8.7",
"rimraf": "^5.0.0",
"standard-changelog": "^2.0.11",
"ts-jest": "^29.0.3",
"typescript": "^4.9.4"
"ts-jest": "^29.0.5",
"typescript": "^5.0.2"
},

@@ -74,0 +74,0 @@ "publishConfig": {

import { Buffer } from 'buffer'
import { Parser } from 'binary-parser'
import { LocalFile, RemoteFile, GenericFilehandle } from 'generic-filehandle'
import { firstValueFrom, Observable, Observer } from 'rxjs'
import { firstValueFrom, Observable } from 'rxjs'
import { toArray } from 'rxjs/operators'
import { BlockView } from './blockView'
import { BlockView } from './block-view'

@@ -133,6 +133,5 @@ const BIG_WIG_MAGIC = -2003829722

*/
public getHeader(opts: RequestOptions | AbortSignal = {}) {
const options = 'aborted' in opts ? { signal: opts as AbortSignal } : opts
public getHeader(opts?: RequestOptions) {
if (!this.headerP) {
this.headerP = this._getHeader(options).catch(e => {
this.headerP = this._getHeader(opts).catch(e => {
this.headerP = undefined

@@ -151,11 +150,9 @@ throw e

*/
public constructor(
options: {
filehandle?: GenericFilehandle
path?: string
url?: string
renameRefSeqs?: (a: string) => string
} = {},
) {
const { filehandle, renameRefSeqs = s => s, path, url } = options
public constructor(args: {
filehandle?: GenericFilehandle
path?: string
url?: string
renameRefSeqs?: (a: string) => string
}) {
const { filehandle, renameRefSeqs = s => s, path, url } = args
this.renameRefSeqs = renameRefSeqs

@@ -173,3 +170,3 @@ if (filehandle) {

private async _getHeader(opts: RequestOptions) {
private async _getHeader(opts?: RequestOptions) {
const header = await this._getMainHeader(opts)

@@ -181,3 +178,3 @@ const chroms = await this._readChromTree(header, opts)

private async _getMainHeader(
opts: RequestOptions,
opts?: RequestOptions,
requestSize = 2000,

@@ -215,3 +212,3 @@ ): Promise<Header> {

private _isBigEndian(buffer: Buffer): boolean {
private _isBigEndian(buffer: Buffer) {
let ret = buffer.readInt32LE(0)

@@ -229,3 +226,6 @@ if (ret === BIG_WIG_MAGIC || ret === BIG_BED_MAGIC) {

// todo: add progress if long running
private async _readChromTree(header: Header, opts: { signal?: AbortSignal }) {
private async _readChromTree(
header: Header,
opts?: { signal?: AbortSignal },
) {
const isBE = header.isBigEndian

@@ -308,3 +308,3 @@ const le = isBE ? 'big' : 'little'

*/
protected async getUnzoomedView(opts: RequestOptions): Promise<BlockView> {
protected async getUnzoomedView(opts?: RequestOptions) {
const {

@@ -332,3 +332,3 @@ unzoomedIndexOffset,

scale: number,
opts: RequestOptions,
opts?: RequestOptions,
): Promise<BlockView>

@@ -348,14 +348,13 @@

end: number,
opts: RequestOptions & { scale?: number; basesPerSpan?: number } = {
scale: 1,
},
): Promise<Observable<Feature[]>> {
opts?: RequestOptions & { scale?: number; basesPerSpan?: number },
) {
await this.getHeader(opts)
const chrName = this.renameRefSeqs(refName)
let view: BlockView
const { basesPerSpan, scale } = opts || {}
if (opts.basesPerSpan) {
view = await this.getView(1 / opts.basesPerSpan, opts)
} else if (opts.scale) {
view = await this.getView(opts.scale, opts)
if (basesPerSpan) {
view = await this.getView(1 / basesPerSpan, opts)
} else if (scale) {
view = await this.getView(scale, opts)
} else {

@@ -365,6 +364,3 @@ view = await this.getView(1, opts)

if (!view) {
throw new Error('unable to get block view for data')
}
return new Observable((observer: Observer<Feature[]>): void => {
return new Observable<Feature[]>(observer => {
view.readWigData(chrName, start, end, observer, opts)

@@ -378,5 +374,3 @@ })

end: number,
opts: RequestOptions & { scale?: number; basesPerSpan?: number } = {
scale: 1,
},
opts?: RequestOptions & { scale?: number; basesPerSpan?: number },
) {

@@ -383,0 +377,0 @@ const ob = await this.getFeatureStream(refName, start, end, opts)

@@ -9,3 +9,2 @@ import { Buffer } from 'buffer'

import { BBI, Feature, RequestOptions } from './bbi'
import { BlockView } from './blockView'

@@ -31,16 +30,11 @@ interface Loc {

export class BigBed extends BBI {
public readIndicesCache = new AbortablePromiseCache({
public readIndicesCache = new AbortablePromiseCache<RequestOptions, Index[]>({
cache: new QuickLRU({ maxSize: 1 }),
fill: async (args: any, signal?: AbortSignal) => {
return this._readIndices({ ...args, signal })
},
fill: (args: RequestOptions, signal?: AbortSignal) =>
this._readIndices({ ...args, signal }),
})
public readIndices(opts: AbortSignal | RequestOptions = {}) {
const options = 'aborted' in opts ? { signal: opts } : opts
return this.readIndicesCache.get(
JSON.stringify(options),
options,
options.signal,
)
public readIndices(opts: RequestOptions = {}) {
const { signal, ...rest } = opts
return this.readIndicesCache.get(JSON.stringify(rest), opts, signal)
}

@@ -50,10 +44,4 @@

* retrieve unzoomed view for any scale
* @param scale - unused
* @param abortSignal - an optional AbortSignal to kill operation
* @return promise for a BlockView
*/
protected async getView(
_scale: number,
opts: RequestOptions,
): Promise<BlockView> {
protected async getView(_scale: number, opts?: RequestOptions) {
return this.getUnzoomedView(opts)

@@ -127,3 +115,3 @@ }

const indices = await this.readIndices(opts)
if (!indices.length) {
if (indices.length === 0) {
return []

@@ -226,3 +214,3 @@ }

const blocks = await this.searchExtraIndexBlocks(name, opts)
if (!blocks.length) {
if (blocks.length === 0) {
return []

@@ -237,4 +225,4 @@ }

map(x => {
for (let i = 0; i < x.length; i += 1) {
x[i].field = block.field
for (const element of x) {
element.field = block.field
}

@@ -241,0 +229,0 @@ return x

@@ -1,2 +0,2 @@

import { BlockView } from './blockView'
import { BlockView } from './block-view'
import { BBI, RequestOptions } from './bbi'

@@ -3,0 +3,0 @@

@@ -72,3 +72,3 @@ /* eslint prefer-rest-params:0, no-nested-ternary:0 */

public intersection(arg: Range): Range {
// eslint-disable-next-line @typescript-eslint/no-this-alias
// eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment
let s0 = this

@@ -113,4 +113,3 @@ let s1 = arg

const rl = this.ranges()
for (let ri = 0; ri < rl.length; ri += 1) {
const r = rl[ri]
for (const r of rl) {
tot += r.max() - r.min() + 1

@@ -126,3 +125,3 @@ }

b = a
// eslint-disable-next-line @typescript-eslint/no-this-alias
// eslint-disable-next-line @typescript-eslint/no-this-alias,unicorn/no-this-assignment
a = this

@@ -129,0 +128,0 @@ }

@@ -1,2 +0,1 @@

import { inflateSync } from 'zlib'
export { inflateSync as unzip }
export { inflateSync as unzip } from 'zlib'

@@ -18,21 +18,21 @@ /* eslint no-bitwise: ["error", { "allow": ["|"] }] */

let lastBlockEnd
for (let i = 0; i < blocks.length; i += 1) {
for (const block of blocks) {
if (
lastBlock &&
lastBlockEnd &&
Number(blocks[i].offset) - lastBlockEnd <= 2000
Number(block.offset) - lastBlockEnd <= 2000
) {
lastBlock.length = BigInt(
Number(lastBlock.length) +
Number(blocks[i].length) -
Number(block.length) -
lastBlockEnd +
Number(blocks[i].offset),
Number(block.offset),
)
lastBlock.blocks.push(blocks[i])
lastBlock.blocks.push(block)
} else {
blockGroups.push(
(lastBlock = {
blocks: [blocks[i]],
length: blocks[i].length,
offset: blocks[i].offset,
blocks: [block],
length: block.length,
offset: block.offset,
}),

@@ -65,8 +65,8 @@ )

// console.log('bam aborted!')
if (typeof DOMException !== 'undefined') {
throw new DOMException('aborted', 'AbortError')
} else {
if (typeof DOMException === 'undefined') {
const e = new AbortError('aborted')
e.code = 'ERR_ABORTED'
throw e
} else {
throw new DOMException('aborted', 'AbortError')
}

@@ -73,0 +73,0 @@ }

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc