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

@gmod/bbi

Package Overview
Dependencies
Maintainers
5
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 1.0.11 to 1.0.12

dist/declares.d.js

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## [1.0.12](https://github.com/GMOD/bbi-js/compare/v1.0.11...v1.0.12) (2019-04-12)
## [1.0.11](https://github.com/GMOD/bbi-js/compare/v1.0.10...v1.0.11) (2019-04-10)

@@ -2,0 +6,0 @@

78

dist/bbi.js
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

@@ -26,10 +24,6 @@

var Long = _interopRequireWildcard(require("long"));
var _genericFilehandle = require("generic-filehandle");
var _blockView = _interopRequireDefault(require("./blockView"));
var _localFile = _interopRequireDefault(require("./localFile"));
var _remoteFile = _interopRequireDefault(require("./remoteFile"));
var _util = require("./util");

@@ -108,5 +102,5 @@

} else if (url) {
this.bbi = new _remoteFile.default(url);
this.bbi = new _genericFilehandle.RemoteFile(url);
} else if (path) {
this.bbi = new _localFile.default(path);
this.bbi = new _genericFilehandle.LocalFile(path);
} else {

@@ -274,60 +268,9 @@ throw new Error('no file given');

var le = isBE ? 'big' : 'little';
/* istanbul ignore next */
var headerParser = new _binaryParser.Parser().endianess(le).int32('magic').uint16('version').uint16('numZoomLevels').buffer('chromTreeOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).buffer('unzoomedDataOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).buffer('unzoomedIndexOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).uint16('fieldCount').uint16('definedFieldCount').buffer('asOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).buffer('totalSummaryOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).uint32('uncompressBufSize').skip(8) // reserved
var headerParser = new _binaryParser.Parser().endianess(le).int32('magic').uint16('version').uint16('numZoomLevels').uint64('chromTreeOffset').uint64('unzoomedDataOffset').uint64('unzoomedIndexOffset').uint16('fieldCount').uint16('definedFieldCount').uint64('asOffset').uint64('totalSummaryOffset').uint32('uncompressBufSize').skip(8) // reserved
.array('zoomLevels', {
length: 'numZoomLevels',
type: new _binaryParser.Parser().uint32('reductionLevel').uint32('reserved').buffer('dataOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).buffer('indexOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
})
type: new _binaryParser.Parser().uint32('reductionLevel').uint32('reserved').uint64('dataOffset').uint64('indexOffset')
});
/* istanbul ignore next */
var totalSummaryParser = new _binaryParser.Parser().endianess(le).buffer('basesCovered', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).double('scoreMin').double('scoreMax').double('scoreSum').double('scoreSumSquares');
/* istanbul ignore next */
var chromTreeParser = new _binaryParser.Parser().endianess(le).uint32('magic').uint32('blockSize').uint32('keySize').uint32('valSize').buffer('itemCount', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
});
var totalSummaryParser = new _binaryParser.Parser().endianess(le).uint64('basesCovered').double('scoreMin').double('scoreMax').double('scoreSum').double('scoreSumSquares');
var chromTreeParser = new _binaryParser.Parser().endianess(le).uint32('magic').uint32('blockSize').uint32('keySize').uint32('valSize').uint64('itemCount');
var isLeafNode = new _binaryParser.Parser().endianess(le).uint8('isLeafNode').skip(1).uint16('cnt');

@@ -390,8 +333,3 @@ return {

}).uint32('refId').uint32('refSize');
nonleafNodeParser = new _binaryParser.Parser().endianess(le).skip(ret.keySize).buffer('childOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
});
nonleafNodeParser = new _binaryParser.Parser().endianess(le).skip(ret.keySize).uint64('childOffset');
rootNodeOffset = 32;

@@ -398,0 +336,0 @@

@@ -28,2 +28,4 @@ "use strict";

var _util = require("./util");
var BigBed =

@@ -107,3 +109,4 @@ /*#__PURE__*/

var opts,
observables,
features,
ob,
_args2 = arguments;

@@ -114,11 +117,23 @@ return _regenerator.default.wrap(function _callee2$(_context2) {

case 0:
opts = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
_context2.next = 3;
opts = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {
scale: 1
};
features = [];
_context2.next = 4;
return this.getFeatureStream(refName, start, end, opts);
case 3:
observables = _context2.sent;
return _context2.abrupt("return", observables.toPromise());
case 4:
ob = _context2.sent;
return _context2.abrupt("return", new Promise(function (resolve, reject) {
// prettier-ignore
ob.subscribe(function (feats) {
return features = features.concat(feats);
}, function (error) {
return reject(error);
}, function () {
resolve((0, _util.flatten)(features));
});
}));
case 5:
case 6:
case "end":

@@ -125,0 +140,0 @@ return _context2.stop();

@@ -28,7 +28,3 @@ "use strict";

function flatten(items) {
return items.reduce(function (prev, next) {
return prev.concat(next);
}, []);
}
var _util = require("./util");

@@ -168,3 +164,3 @@ var BigWig =

}, function () {
resolve(flatten(features));
resolve((0, _util.flatten)(features));
});

@@ -171,0 +167,0 @@ }));

@@ -26,4 +26,2 @@ "use strict";

var Long = _interopRequireWildcard(require("long"));
var zlib = _interopRequireWildcard(require("zlib"));

@@ -188,4 +186,2 @@

var data = cirBlockData.slice(offset);
/* istanbul ignore next */
var parser = new _binaryParser.Parser().endianess(this.opts.isBigEndian ? 'big' : 'little').uint8('isLeaf').skip(1).uint16('cnt').choice({

@@ -196,22 +192,7 @@ tag: 'isLeaf',

length: 'cnt',
type: new _binaryParser.Parser().uint32('startChrom').uint32('startBase').uint32('endChrom').uint32('endBase').buffer('blockOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
}).buffer('blockSize', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
})
type: new _binaryParser.Parser().uint32('startChrom').uint32('startBase').uint32('endChrom').uint32('endBase').uint64('blockOffset').uint64('blockSize')
}),
0: new _binaryParser.Parser().array('recurOffsets', {
length: 'cnt',
type: new _binaryParser.Parser().uint32('startChrom').uint32('startBase').uint32('endChrom').uint32('endBase').buffer('blockOffset', {
length: 8,
formatter: function formatter(buf) {
return Long.fromBytes(buf, true, this.endian === 'le').toNumber();
}
})
type: new _binaryParser.Parser().uint32('startChrom').uint32('startBase').uint32('endChrom').uint32('endBase').uint64('blockOffset')
})

@@ -218,0 +199,0 @@ }

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

exports.abortBreakPoint = abortBreakPoint;
exports.flatten = flatten;
exports.AbortError = void 0;

@@ -139,2 +140,8 @@

return _abortBreakPoint.apply(this, arguments);
}
function flatten(items) {
return items.reduce(function (prev, next) {
return prev.concat(next);
}, []);
}
{
"name": "@gmod/bbi",
"version": "1.0.11",
"version": "1.0.12",
"description": "Parser for BigWig/BigBed files",

@@ -41,3 +41,3 @@ "license": "MIT",

"@babel/runtime": "^7.4.2",
"@gmod/binary-parser": "^1.3.4",
"@gmod/binary-parser": "^1.3.5",
"abortable-promise-cache": "^1.0.1",

@@ -47,3 +47,3 @@ "buffer-crc32": "^0.2.13",

"es6-promisify": "^6.0.1",
"long": "^4.0.0",
"generic-filehandle": "^1.0.2",
"quick-lru": "^3.0.0",

@@ -65,3 +65,2 @@ "rxjs": "^6.4.0"

"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"babel-preset-typescript": "^7.0.0-alpha.19",

@@ -68,0 +67,0 @@ "documentation": "^9.3.1",

@@ -27,5 +27,5 @@ # bbi-js

* path - uses the LocalFile class in this repo
* url - uses the RemoteFile class in this repo
* filehandle - accepts some custom file handle class that you provide
* path - path to a local file
* url - path to a url
* filehandle - a filehandle instance that you can implement as a custom class yourself. path and url are based on https://www.npmjs.com/package/generic-filehandle but by implementing a class containing the Filehandle interface specified therein, you can pass it to this module

@@ -40,6 +40,7 @@

* end - a 0-based half open end coordinate
* opts.scale - 1 is the maximum zoom level, fractional values indicate a accessing multiple zoom levels based on pixelsPerBp
* opts.signal - an AbortSignal to halt processing
* opts.basesPerScale - inverse of opts.scale
* opts.scale - indicates zoom level to use, specified as pixels per basepair, e.g. being zoomed out, you might have 100bp per pixel so opts.scale would be 1/100. the zoom level that is returned is the one which has reductionLevel<=2/opts.scale (reductionLevel is a property of the zoom level structure in the bigwig file data)
* opts.basesPerScale - optional, just the inverse of opts.scale. one of opts.scale or opts.basesPerScale can be specified, otherwise the most granular zoom level is used
* opts.signal - optional, an AbortSignal to halt processing
Returns a promise to an array of features.

@@ -70,12 +71,17 @@

* end - a 0-based half open end coordinate
* opts.signal - an AbortSignal to halt processing
* opts.signal - optional, an AbortSignal to halt processing
returns a promise to an array of features
returns a promise to an array of features. no concept of zoom levels is used with bigwig data
#### note about BigBed file processing
#### getFeatureStream(refName, start, end, opts)
The BigBed line contents can be parsed by @gmod/bed, it is not integrated with this module by default but for example
Similar to BigWig, returns an RxJS observable for a observable stream
#### how to parse BigBed results
The BigBed line contents are returned as a raw text line e.g. {start: 0, end:100, rest: "ENST00000456328.2\t1000\t..."} where "rest" contains tab delimited text for the fields from 4 and on in the BED format. The rest line can be parsed by the @gmod/bed module, which is not by integrated with this module, but can be combined with it as follows
```js
import {BigBed} from '@gmod/bed'
import {BigBed} from '@gmod/bbi'
import BED from '@gmod/bed'

@@ -89,3 +95,4 @@

const parser = new BED({autoSql})
const lines = feats.map(f => parser.parseBedText('chr7', f.start, f.end, f.rest, 3))
const lines = feats.map(f => parser.parseBedText('chr7', f.start, f.end, f.rest, 3)) // 3 indicates skipping first 3 columns of the autoSql since these are provided by BigBed
```

@@ -92,0 +99,0 @@

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