@gmod/cram
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -11,10 +11,5 @@ 'use strict'; | ||
var BetaCodec = require('./beta'); | ||
var GammaCodec = require('./gamma'); | ||
var SubexpCodec = require('./subexp'); | ||
// class GolombCodec extends CramCodec {} | ||
// class ByteArrayLengthCodec extends CramCodec {} | ||
// class BetaCodec extends CramCodec {} | ||
// class SubexpCodec extends CramCodec {} | ||
// class GolombRiceCodec extends CramCodec {} | ||
// class GammaCodec extends CramCodec {} | ||
var codecClasses = { | ||
@@ -26,6 +21,6 @@ 1: ExternalCodec, | ||
5: ByteArrayStopCodec, | ||
6: BetaCodec | ||
// 7: SubexpCodec, | ||
6: BetaCodec, | ||
7: SubexpCodec, | ||
// 8: GolombRiceCodec, | ||
// 9: GammaCodec, | ||
9: GammaCodec | ||
}; | ||
@@ -32,0 +27,0 @@ |
@@ -221,3 +221,3 @@ 'use strict'; | ||
6: new Parser().itf8('offset').itf8('length'), // BETA | ||
7: new Parser().itf8('offset').itf8('K'), | ||
7: new Parser().itf8('offset').itf8('K'), // SUBEXP | ||
8: new Parser().itf8('offset').itf8('log2m'), // GOLOMB_RICE | ||
@@ -224,0 +224,0 @@ 9: new Parser().itf8('offset') // GAMMA |
@@ -7,2 +7,6 @@ 'use strict'; | ||
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray'); | ||
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); | ||
var _parseInt = require('babel-runtime/core-js/number/parse-int'); | ||
@@ -160,2 +164,17 @@ | ||
function thingToString(thing) { | ||
if (thing instanceof Buffer) { | ||
return readNullTerminatedStringFromBuffer(thing); | ||
} else if (thing.length && thing.indexOf) { | ||
// array-like | ||
if (!thing[thing.length - 1]) { | ||
// trim zeroes off the end if necessary | ||
var termIndex = thing.indexOf(0); | ||
return String.fromCharCode.apply(String, (0, _toConsumableArray3.default)(thing.slice(0, termIndex))); | ||
} | ||
return String.fromCharCode.apply(String, (0, _toConsumableArray3.default)(thing)); | ||
} | ||
return String(thing); | ||
} | ||
function decodeRecord(slice, decodeDataSeries, compressionScheme, sliceHeader, coreDataBlock, blocksByContentId, cursors, majorVersion, recordNumber) { | ||
@@ -180,3 +199,3 @@ var cramRecord = new CramRecord(); | ||
if (compressionScheme.readNamesIncluded) cramRecord.readName = decodeDataSeries('RN').toString('utf8'); // new String(readNameCodec.readData(), charset) | ||
if (compressionScheme.readNamesIncluded) cramRecord.readName = thingToString(decodeDataSeries('RN')); | ||
@@ -188,3 +207,5 @@ // mate record | ||
mate.flags = decodeDataSeries('MF'); | ||
if (!compressionScheme.readNamesIncluded) cramRecord.mate.readName = decodeDataSeries('RN'); // new String(readNameCodec.readData(), charset) | ||
if (!compressionScheme.readNamesIncluded) { | ||
mate.readName = thingToString(decodeDataSeries('RN')); | ||
} | ||
mate.sequenceId = decodeDataSeries('NS'); | ||
@@ -191,0 +212,0 @@ mate.alignmentStart = decodeDataSeries('NP'); |
@@ -107,3 +107,4 @@ 'use strict'; | ||
sequenceId: mateRecord.sequenceId, | ||
alignmentStart: mateRecord.alignmentStart | ||
alignmentStart: mateRecord.alignmentStart, | ||
uniqueId: mateRecord.uniqueId | ||
}; | ||
@@ -118,3 +119,4 @@ if (mateRecord.readName) thisRecord.mate.readName = mateRecord.readName; | ||
sequenceId: thisRecord.sequenceId, | ||
alignmentStart: thisRecord.alignmentStart | ||
alignmentStart: thisRecord.alignmentStart, | ||
uniqueId: thisRecord.uniqueId | ||
}; | ||
@@ -588,2 +590,3 @@ if (thisRecord.readName) mateRecord.mate.readName = thisRecord.readName; | ||
if (!codec) throw new CramMalformedError('no codec defined for ' + dataSeriesName + ' data series'); | ||
// console.log(dataSeriesName, Object.getPrototypeOf(codec)) | ||
return codec.decode(_this, coreDataBlock, blocksByContentId, cursors); | ||
@@ -604,3 +607,3 @@ }; | ||
records[i] = decodeRecord(this, decodeDataSeries, compressionScheme, sliceHeader, coreDataBlock, blocksByContentId, cursors, majorVersion, i); | ||
records[i].uniqueId = sliceHeader.content.recordCounter + i; | ||
records[i].uniqueId = sliceHeader.content.recordCounter + i + 1; | ||
_context7.next = 45; | ||
@@ -607,0 +610,0 @@ break; |
{ | ||
"name": "@gmod/cram", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "read CRAM files with pure Javascript", | ||
@@ -30,3 +30,3 @@ "license": "MIT", | ||
"build": "babel src -d dist", | ||
"built-tests": "rm -rf built-tests; babel test -d built-tests; ln -s ../test/data built-tests/data; mocha built-tests", | ||
"built-tests": "rm -rf built-tests; mkdir built-tests; ln -s ../test/data built-tests/data; babel test -d built-tests; mocha built-tests", | ||
"watch": "npm-watch", | ||
@@ -33,0 +33,0 @@ "prepublishOnly": "npm test && npm run build && cp dist/errors.js errors.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
241672
40
5326