@jbrowse/plugin-alignments 1.6.9 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.d.ts +6 -6
- package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +216 -0
- package/dist/AlignmentsFeatureDetail/index.d.ts +13 -13
- package/dist/AlignmentsFeatureDetail/index.js +63 -0
- package/dist/AlignmentsFeatureDetail/index.test.js +60 -0
- package/dist/AlignmentsTrack/index.d.ts +2 -2
- package/dist/AlignmentsTrack/index.js +37 -0
- package/dist/BamAdapter/BamAdapter.d.ts +40 -30
- package/dist/BamAdapter/BamAdapter.js +598 -0
- package/dist/BamAdapter/BamAdapter.test.js +177 -0
- package/dist/BamAdapter/BamSlightlyLazyFeature.d.ts +33 -33
- package/dist/BamAdapter/BamSlightlyLazyFeature.js +176 -0
- package/dist/BamAdapter/MismatchParser.d.ts +28 -28
- package/dist/BamAdapter/MismatchParser.js +384 -0
- package/dist/BamAdapter/MismatchParser.test.js +259 -0
- package/dist/BamAdapter/configSchema.d.ts +2 -2
- package/dist/BamAdapter/configSchema.js +48 -0
- package/dist/BamAdapter/index.d.ts +3 -3
- package/dist/BamAdapter/index.js +36 -0
- package/dist/CramAdapter/CramAdapter.d.ts +52 -43
- package/dist/CramAdapter/CramAdapter.js +660 -0
- package/dist/CramAdapter/CramAdapter.test.js +138 -0
- package/dist/CramAdapter/CramSlightlyLazyFeature.d.ts +49 -49
- package/dist/CramAdapter/CramSlightlyLazyFeature.js +447 -0
- package/dist/CramAdapter/CramTestAdapters.d.ts +29 -29
- package/dist/CramAdapter/CramTestAdapters.js +234 -0
- package/dist/CramAdapter/configSchema.d.ts +3 -3
- package/dist/CramAdapter/configSchema.js +40 -0
- package/dist/CramAdapter/index.d.ts +3 -3
- package/dist/CramAdapter/index.js +36 -0
- package/dist/HtsgetBamAdapter/HtsgetBamAdapter.d.ts +9 -9
- package/dist/HtsgetBamAdapter/HtsgetBamAdapter.js +97 -0
- package/dist/HtsgetBamAdapter/configSchema.d.ts +2 -2
- package/dist/HtsgetBamAdapter/configSchema.js +31 -0
- package/dist/HtsgetBamAdapter/index.d.ts +3 -3
- package/dist/HtsgetBamAdapter/index.js +42 -0
- package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +7 -7
- package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +69 -0
- package/dist/LinearAlignmentsDisplay/index.d.ts +2 -2
- package/dist/LinearAlignmentsDisplay/index.js +31 -0
- package/dist/LinearAlignmentsDisplay/models/configSchema.d.ts +4 -4
- package/dist/LinearAlignmentsDisplay/models/configSchema.js +25 -0
- package/dist/LinearAlignmentsDisplay/models/configSchema.test.js +83 -0
- package/dist/LinearAlignmentsDisplay/models/model.d.ts +105 -105
- package/dist/LinearAlignmentsDisplay/models/model.js +250 -0
- package/dist/LinearPileupDisplay/components/ColorByModifications.d.ts +14 -14
- package/dist/LinearPileupDisplay/components/ColorByModifications.js +123 -0
- package/dist/LinearPileupDisplay/components/ColorByTag.d.ts +9 -9
- package/dist/LinearPileupDisplay/components/ColorByTag.js +98 -0
- package/dist/LinearPileupDisplay/components/FilterByTag.d.ts +18 -18
- package/dist/LinearPileupDisplay/components/FilterByTag.js +203 -0
- package/dist/LinearPileupDisplay/components/LinearPileupDisplayBlurb.d.ts +13 -13
- package/dist/LinearPileupDisplay/components/LinearPileupDisplayBlurb.js +32 -0
- package/dist/LinearPileupDisplay/components/SetFeatureHeight.d.ts +16 -16
- package/dist/LinearPileupDisplay/components/SetFeatureHeight.js +99 -0
- package/dist/LinearPileupDisplay/components/SetMaxHeight.d.ts +10 -10
- package/dist/LinearPileupDisplay/components/SetMaxHeight.js +90 -0
- package/dist/LinearPileupDisplay/components/SortByTag.d.ts +9 -9
- package/dist/LinearPileupDisplay/components/SortByTag.js +95 -0
- package/dist/LinearPileupDisplay/configSchema.d.ts +6 -6
- package/dist/LinearPileupDisplay/configSchema.js +47 -0
- package/dist/LinearPileupDisplay/configSchema.test.js +92 -0
- package/dist/LinearPileupDisplay/index.d.ts +2 -2
- package/dist/LinearPileupDisplay/index.js +30 -0
- package/dist/LinearPileupDisplay/model.d.ts +319 -321
- package/dist/LinearPileupDisplay/model.js +602 -0
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.d.ts +10 -10
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.js +63 -0
- package/dist/LinearSNPCoverageDisplay/index.d.ts +2 -2
- package/dist/LinearSNPCoverageDisplay/index.js +30 -0
- package/dist/LinearSNPCoverageDisplay/models/configSchema.d.ts +2 -2
- package/dist/LinearSNPCoverageDisplay/models/configSchema.js +57 -0
- package/dist/LinearSNPCoverageDisplay/models/configSchema.test.js +62 -0
- package/dist/LinearSNPCoverageDisplay/models/model.d.ts +346 -96
- package/dist/LinearSNPCoverageDisplay/models/model.js +237 -0
- package/dist/NestedFrequencyTable.d.ts +14 -14
- package/dist/NestedFrequencyTable.js +152 -0
- package/dist/PileupRPC/rpcMethods.d.ts +34 -34
- package/dist/PileupRPC/rpcMethods.js +285 -0
- package/dist/PileupRenderer/PileupLayoutSession.d.ts +29 -29
- package/dist/PileupRenderer/PileupLayoutSession.js +79 -0
- package/dist/PileupRenderer/PileupRenderer.d.ts +125 -125
- package/dist/PileupRenderer/PileupRenderer.js +1220 -0
- package/dist/PileupRenderer/components/PileupRendering.d.ts +23 -23
- package/dist/PileupRenderer/components/PileupRendering.js +270 -0
- package/dist/PileupRenderer/components/PileupRendering.test.js +36 -0
- package/dist/PileupRenderer/configSchema.d.ts +2 -2
- package/dist/PileupRenderer/configSchema.js +72 -0
- package/dist/PileupRenderer/index.d.ts +2 -2
- package/dist/PileupRenderer/index.js +25 -0
- package/dist/PileupRenderer/sortUtil.d.ts +8 -8
- package/dist/PileupRenderer/sortUtil.js +112 -0
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.d.ts +67 -71
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js +606 -0
- package/dist/SNPCoverageAdapter/configSchema.d.ts +3 -3
- package/dist/SNPCoverageAdapter/configSchema.js +22 -0
- package/dist/SNPCoverageAdapter/index.d.ts +3 -3
- package/dist/SNPCoverageAdapter/index.js +45 -0
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.d.ts +20 -20
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.js +296 -0
- package/dist/SNPCoverageRenderer/configSchema.d.ts +2 -2
- package/dist/SNPCoverageRenderer/configSchema.js +40 -0
- package/dist/SNPCoverageRenderer/index.d.ts +3 -3
- package/dist/SNPCoverageRenderer/index.js +34 -0
- package/dist/declare.d.js +1 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.js +154 -6
- package/dist/index.test.js +26 -0
- package/dist/shared.d.ts +25 -25
- package/dist/shared.js +96 -0
- package/dist/util.d.ts +19 -19
- package/dist/util.js +135 -0
- package/package.json +5 -8
- package/src/BamAdapter/BamAdapter.ts +35 -8
- package/src/CramAdapter/CramAdapter.ts +42 -15
- package/src/LinearPileupDisplay/components/SetMaxHeight.tsx +1 -1
- package/src/LinearPileupDisplay/model.ts +2 -22
- package/src/LinearSNPCoverageDisplay/models/model.ts +6 -36
- package/src/PileupRenderer/PileupRenderer.tsx +3 -6
- package/src/SNPCoverageAdapter/SNPCoverageAdapter.ts +11 -17
- package/dist/AlignmentsFeatureDetail/index.test.d.ts +0 -1
- package/dist/LinearAlignmentsDisplay/models/configSchema.test.d.ts +0 -1
- package/dist/LinearPileupDisplay/configSchema.test.d.ts +0 -1
- package/dist/LinearSNPCoverageDisplay/models/configSchema.test.d.ts +0 -1
- package/dist/PileupRenderer/components/PileupRendering.test.d.ts +0 -1
- package/dist/plugin-alignments.cjs.development.js +0 -8438
- package/dist/plugin-alignments.cjs.development.js.map +0 -1
- package/dist/plugin-alignments.cjs.production.min.js +0 -2
- package/dist/plugin-alignments.cjs.production.min.js.map +0 -1
- package/dist/plugin-alignments.esm.js +0 -8430
- package/dist/plugin-alignments.esm.js.map +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _operators = require("rxjs/operators");
|
|
10
|
+
|
|
11
|
+
var _genericFilehandle = require("generic-filehandle");
|
|
12
|
+
|
|
13
|
+
var _PluginManager = _interopRequireDefault(require("@jbrowse/core/PluginManager"));
|
|
14
|
+
|
|
15
|
+
var _CramAdapter = _interopRequireDefault(require("./CramAdapter"));
|
|
16
|
+
|
|
17
|
+
var _CramTestAdapters = require("./CramTestAdapters");
|
|
18
|
+
|
|
19
|
+
var _configSchema = _interopRequireDefault(require("./configSchema"));
|
|
20
|
+
|
|
21
|
+
var pluginManager = new _PluginManager["default"]();
|
|
22
|
+
var configSchema = pluginManager.load(_configSchema["default"]);
|
|
23
|
+
|
|
24
|
+
var getVolvoxSequenceSubAdapter = /*#__PURE__*/function () {
|
|
25
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
26
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
27
|
+
while (1) {
|
|
28
|
+
switch (_context.prev = _context.next) {
|
|
29
|
+
case 0:
|
|
30
|
+
return _context.abrupt("return", {
|
|
31
|
+
dataAdapter: new _CramTestAdapters.SequenceAdapter(new _genericFilehandle.LocalFile(require.resolve('../../test_data/volvox.fa'))),
|
|
32
|
+
sessionIds: new Set()
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
case 1:
|
|
36
|
+
case "end":
|
|
37
|
+
return _context.stop();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}, _callee);
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
return function getVolvoxSequenceSubAdapter() {
|
|
44
|
+
return _ref.apply(this, arguments);
|
|
45
|
+
};
|
|
46
|
+
}();
|
|
47
|
+
|
|
48
|
+
test('adapter can fetch features from volvox-sorted.cram', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
49
|
+
var adapter, features, featuresArray, featuresJsonArray;
|
|
50
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
51
|
+
while (1) {
|
|
52
|
+
switch (_context2.prev = _context2.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
adapter = new _CramAdapter["default"](configSchema.create({
|
|
55
|
+
cramLocation: {
|
|
56
|
+
localPath: require.resolve('../../test_data/volvox-sorted.cram'),
|
|
57
|
+
locationType: 'LocalPathLocation'
|
|
58
|
+
},
|
|
59
|
+
craiLocation: {
|
|
60
|
+
localPath: require.resolve('../../test_data/volvox-sorted.cram.crai'),
|
|
61
|
+
locationType: 'LocalPathLocation'
|
|
62
|
+
}
|
|
63
|
+
}), getVolvoxSequenceSubAdapter, pluginManager);
|
|
64
|
+
features = adapter.getFeatures({
|
|
65
|
+
assemblyName: 'volvox',
|
|
66
|
+
refName: 'ctgA',
|
|
67
|
+
start: 0,
|
|
68
|
+
end: 20000
|
|
69
|
+
});
|
|
70
|
+
_context2.next = 4;
|
|
71
|
+
return features.pipe((0, _operators.toArray)()).toPromise();
|
|
72
|
+
|
|
73
|
+
case 4:
|
|
74
|
+
featuresArray = _context2.sent;
|
|
75
|
+
expect(featuresArray[0].get('refName')).toBe('ctgA');
|
|
76
|
+
featuresJsonArray = featuresArray.map(function (f) {
|
|
77
|
+
return f.toJSON();
|
|
78
|
+
});
|
|
79
|
+
expect(featuresJsonArray.length).toEqual(3809);
|
|
80
|
+
expect(featuresJsonArray.slice(1000, 1010)).toMatchSnapshot();
|
|
81
|
+
expect(adapter.refIdToName(0)).toBe('ctgA');
|
|
82
|
+
expect(adapter.refIdToName(1)).toBe(undefined);
|
|
83
|
+
_context2.t0 = expect;
|
|
84
|
+
_context2.next = 14;
|
|
85
|
+
return adapter.hasDataForRefName('ctgA');
|
|
86
|
+
|
|
87
|
+
case 14:
|
|
88
|
+
_context2.t1 = _context2.sent;
|
|
89
|
+
(0, _context2.t0)(_context2.t1).toBe(true);
|
|
90
|
+
|
|
91
|
+
case 16:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context2.stop();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, _callee2);
|
|
97
|
+
})));
|
|
98
|
+
test('test usage of cramSlightlyLazyFeature toJSON (used in the widget)', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
99
|
+
var adapter, features, featuresArray, f;
|
|
100
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
101
|
+
while (1) {
|
|
102
|
+
switch (_context3.prev = _context3.next) {
|
|
103
|
+
case 0:
|
|
104
|
+
adapter = new _CramAdapter["default"](configSchema.create({
|
|
105
|
+
cramLocation: {
|
|
106
|
+
localPath: require.resolve('../../test_data/volvox-sorted.cram'),
|
|
107
|
+
locationType: 'LocalPathLocation'
|
|
108
|
+
},
|
|
109
|
+
craiLocation: {
|
|
110
|
+
localPath: require.resolve('../../test_data/volvox-sorted.cram.crai'),
|
|
111
|
+
locationType: 'LocalPathLocation'
|
|
112
|
+
}
|
|
113
|
+
}), getVolvoxSequenceSubAdapter, pluginManager);
|
|
114
|
+
features = adapter.getFeatures({
|
|
115
|
+
assemblyName: 'volvox',
|
|
116
|
+
refName: 'ctgA',
|
|
117
|
+
start: 0,
|
|
118
|
+
end: 100
|
|
119
|
+
});
|
|
120
|
+
_context3.next = 4;
|
|
121
|
+
return features.pipe((0, _operators.toArray)()).toPromise();
|
|
122
|
+
|
|
123
|
+
case 4:
|
|
124
|
+
featuresArray = _context3.sent;
|
|
125
|
+
f = featuresArray[0].toJSON();
|
|
126
|
+
expect(f.refName).toBe('ctgA');
|
|
127
|
+
expect(f.start).toBe(2);
|
|
128
|
+
expect(f.end).toBe(102); // don't pass the mismatches to the frontend
|
|
129
|
+
|
|
130
|
+
expect(f.mismatches).toEqual(undefined);
|
|
131
|
+
|
|
132
|
+
case 10:
|
|
133
|
+
case "end":
|
|
134
|
+
return _context3.stop();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}, _callee3);
|
|
138
|
+
})));
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util/simpleFeature';
|
|
2
|
-
import CramAdapter from './CramAdapter';
|
|
3
|
-
export interface Mismatch {
|
|
4
|
-
qual?: number;
|
|
5
|
-
start: number;
|
|
6
|
-
length: number;
|
|
7
|
-
type: string;
|
|
8
|
-
base: string;
|
|
9
|
-
altbase?: string;
|
|
10
|
-
seq?: string;
|
|
11
|
-
cliplen?: number;
|
|
12
|
-
}
|
|
13
|
-
export default class CramSlightlyLazyFeature implements Feature {
|
|
14
|
-
private record;
|
|
15
|
-
private _store;
|
|
16
|
-
constructor(record: any, _store: CramAdapter);
|
|
17
|
-
_get_name(): any;
|
|
18
|
-
_get_start(): number;
|
|
19
|
-
_get_end(): number;
|
|
20
|
-
_get_cram_read_features(): any;
|
|
21
|
-
_get_type(): string;
|
|
22
|
-
_get_score(): any;
|
|
23
|
-
_get_flags(): any;
|
|
24
|
-
_get_strand(): 1 | -1;
|
|
25
|
-
_read_group_id(): number | undefined;
|
|
26
|
-
_get_qual(): any;
|
|
27
|
-
qualRaw(): any;
|
|
28
|
-
_get_seq_id(): string | undefined;
|
|
29
|
-
_get_refName(): string | undefined;
|
|
30
|
-
_get_is_paired(): boolean;
|
|
31
|
-
_get_pair_orientation(): any;
|
|
32
|
-
_get_template_length(): any;
|
|
33
|
-
_get_next_seq_id(): string | undefined;
|
|
34
|
-
_get_next_pos(): any;
|
|
35
|
-
_get_next_segment_position(): string | undefined;
|
|
36
|
-
_get_tags(): any;
|
|
37
|
-
_get_seq(): any;
|
|
38
|
-
_get_CIGAR(): string;
|
|
39
|
-
tags(): string[];
|
|
40
|
-
id(): string;
|
|
41
|
-
get(field: string): any;
|
|
42
|
-
parent(): undefined | Feature;
|
|
43
|
-
children(): undefined | Feature[];
|
|
44
|
-
set(): void;
|
|
45
|
-
pairedFeature(): boolean;
|
|
46
|
-
_get_clipPos(): any;
|
|
47
|
-
toJSON(): SimpleFeatureSerialized;
|
|
48
|
-
_get_mismatches(): Mismatch[];
|
|
49
|
-
}
|
|
1
|
+
import { Feature, SimpleFeatureSerialized } from '@jbrowse/core/util/simpleFeature';
|
|
2
|
+
import CramAdapter from './CramAdapter';
|
|
3
|
+
export interface Mismatch {
|
|
4
|
+
qual?: number;
|
|
5
|
+
start: number;
|
|
6
|
+
length: number;
|
|
7
|
+
type: string;
|
|
8
|
+
base: string;
|
|
9
|
+
altbase?: string;
|
|
10
|
+
seq?: string;
|
|
11
|
+
cliplen?: number;
|
|
12
|
+
}
|
|
13
|
+
export default class CramSlightlyLazyFeature implements Feature {
|
|
14
|
+
private record;
|
|
15
|
+
private _store;
|
|
16
|
+
constructor(record: any, _store: CramAdapter);
|
|
17
|
+
_get_name(): any;
|
|
18
|
+
_get_start(): number;
|
|
19
|
+
_get_end(): number;
|
|
20
|
+
_get_cram_read_features(): any;
|
|
21
|
+
_get_type(): string;
|
|
22
|
+
_get_score(): any;
|
|
23
|
+
_get_flags(): any;
|
|
24
|
+
_get_strand(): 1 | -1;
|
|
25
|
+
_read_group_id(): number | undefined;
|
|
26
|
+
_get_qual(): any;
|
|
27
|
+
qualRaw(): any;
|
|
28
|
+
_get_seq_id(): string | undefined;
|
|
29
|
+
_get_refName(): string | undefined;
|
|
30
|
+
_get_is_paired(): boolean;
|
|
31
|
+
_get_pair_orientation(): any;
|
|
32
|
+
_get_template_length(): any;
|
|
33
|
+
_get_next_seq_id(): string | undefined;
|
|
34
|
+
_get_next_pos(): any;
|
|
35
|
+
_get_next_segment_position(): string | undefined;
|
|
36
|
+
_get_tags(): any;
|
|
37
|
+
_get_seq(): any;
|
|
38
|
+
_get_CIGAR(): string;
|
|
39
|
+
tags(): string[];
|
|
40
|
+
id(): string;
|
|
41
|
+
get(field: string): any;
|
|
42
|
+
parent(): undefined | Feature;
|
|
43
|
+
children(): undefined | Feature[];
|
|
44
|
+
set(): void;
|
|
45
|
+
pairedFeature(): boolean;
|
|
46
|
+
_get_clipPos(): any;
|
|
47
|
+
toJSON(): SimpleFeatureSerialized;
|
|
48
|
+
_get_mismatches(): Mismatch[];
|
|
49
|
+
}
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
|
|
22
|
+
/* eslint-disable no-underscore-dangle */
|
|
23
|
+
var CramSlightlyLazyFeature = /*#__PURE__*/function () {
|
|
24
|
+
// uses parameter properties to automatically create fields on the class
|
|
25
|
+
// https://www.typescriptlang.org/docs/handbook/classes.html#parameter-properties
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
function CramSlightlyLazyFeature(record, _store) {
|
|
28
|
+
(0, _classCallCheck2["default"])(this, CramSlightlyLazyFeature);
|
|
29
|
+
this.record = record;
|
|
30
|
+
this._store = _store;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
(0, _createClass2["default"])(CramSlightlyLazyFeature, [{
|
|
34
|
+
key: "_get_name",
|
|
35
|
+
value: function _get_name() {
|
|
36
|
+
return this.record.readName;
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "_get_start",
|
|
40
|
+
value: function _get_start() {
|
|
41
|
+
return this.record.alignmentStart - 1;
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "_get_end",
|
|
45
|
+
value: function _get_end() {
|
|
46
|
+
return this.record.alignmentStart + this.record.lengthOnRef - 1;
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "_get_cram_read_features",
|
|
50
|
+
value: function _get_cram_read_features() {
|
|
51
|
+
return this.record.readFeatures;
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "_get_type",
|
|
55
|
+
value: function _get_type() {
|
|
56
|
+
return 'match';
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "_get_score",
|
|
60
|
+
value: function _get_score() {
|
|
61
|
+
return this.record.mappingQuality;
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "_get_flags",
|
|
65
|
+
value: function _get_flags() {
|
|
66
|
+
return this.record.flags;
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "_get_strand",
|
|
70
|
+
value: function _get_strand() {
|
|
71
|
+
return this.record.isReverseComplemented() ? -1 : 1;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "_read_group_id",
|
|
75
|
+
value: function _read_group_id() {
|
|
76
|
+
var rg = this._store.samHeader.readGroups;
|
|
77
|
+
return rg ? rg[this.record.readGroupId] : undefined;
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "_get_qual",
|
|
81
|
+
value: function _get_qual() {
|
|
82
|
+
return (this.record.qualityScores || []).join(' ');
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "qualRaw",
|
|
86
|
+
value: function qualRaw() {
|
|
87
|
+
return this.record.qualityScores;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "_get_seq_id",
|
|
91
|
+
value: function _get_seq_id() {
|
|
92
|
+
return this._store.refIdToName(this.record.sequenceId);
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "_get_refName",
|
|
96
|
+
value: function _get_refName() {
|
|
97
|
+
return this._get_seq_id();
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "_get_is_paired",
|
|
101
|
+
value: function _get_is_paired() {
|
|
102
|
+
return !!this.record.mate;
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "_get_pair_orientation",
|
|
106
|
+
value: function _get_pair_orientation() {
|
|
107
|
+
return this.record.isPaired() ? this.record.getPairOrientation() : undefined;
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "_get_template_length",
|
|
111
|
+
value: function _get_template_length() {
|
|
112
|
+
return this.record.templateLength || this.record.templateSize;
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "_get_next_seq_id",
|
|
116
|
+
value: function _get_next_seq_id() {
|
|
117
|
+
return this.record.mate ? this._store.refIdToName(this.record.mate.sequenceId) : undefined;
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "_get_next_pos",
|
|
121
|
+
value: function _get_next_pos() {
|
|
122
|
+
return this.record.mate ? this.record.mate.alignmentStart : undefined;
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
key: "_get_next_segment_position",
|
|
126
|
+
value: function _get_next_segment_position() {
|
|
127
|
+
return this.record.mate ? "".concat(this._store.refIdToName(this.record.mate.sequenceId), ":").concat(this.record.mate.alignmentStart) : undefined;
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "_get_tags",
|
|
131
|
+
value: function _get_tags() {
|
|
132
|
+
var RG = this._read_group_id();
|
|
133
|
+
|
|
134
|
+
var tags = this.record.tags; // avoids a tag copy if no RG, but just copy if there is one
|
|
135
|
+
|
|
136
|
+
return RG !== undefined ? _objectSpread(_objectSpread({}, tags), {}, {
|
|
137
|
+
RG: RG
|
|
138
|
+
}) : tags;
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "_get_seq",
|
|
142
|
+
value: function _get_seq() {
|
|
143
|
+
return this.record.getReadBases();
|
|
144
|
+
} // generate a CIGAR, based on code from jkbonfield
|
|
145
|
+
|
|
146
|
+
}, {
|
|
147
|
+
key: "_get_CIGAR",
|
|
148
|
+
value: function _get_CIGAR() {
|
|
149
|
+
var seq = '';
|
|
150
|
+
var cigar = '';
|
|
151
|
+
var op = 'M';
|
|
152
|
+
var oplen = 0; // not sure I should access these, but...
|
|
153
|
+
|
|
154
|
+
var ref = this.record._refRegion.seq;
|
|
155
|
+
var refStart = this.record._refRegion.start;
|
|
156
|
+
var last_pos = this.record.alignmentStart;
|
|
157
|
+
var sublen = 0;
|
|
158
|
+
|
|
159
|
+
if (typeof this.record.readFeatures !== 'undefined') {
|
|
160
|
+
// @ts-ignore
|
|
161
|
+
this.record.readFeatures.forEach(function (_ref) {
|
|
162
|
+
var code = _ref.code,
|
|
163
|
+
refPos = _ref.refPos,
|
|
164
|
+
sub = _ref.sub,
|
|
165
|
+
data = _ref.data;
|
|
166
|
+
sublen = refPos - last_pos;
|
|
167
|
+
seq += ref.substring(last_pos - refStart, refPos - refStart);
|
|
168
|
+
last_pos = refPos;
|
|
169
|
+
|
|
170
|
+
if (oplen && op !== 'M') {
|
|
171
|
+
cigar += oplen + op;
|
|
172
|
+
oplen = 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (sublen) {
|
|
176
|
+
op = 'M';
|
|
177
|
+
oplen += sublen;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (code === 'b') {
|
|
181
|
+
// An array of bases stored verbatim
|
|
182
|
+
var ret = data.split(',');
|
|
183
|
+
var added = String.fromCharCode.apply(String, (0, _toConsumableArray2["default"])(ret));
|
|
184
|
+
seq += added;
|
|
185
|
+
last_pos += added.length;
|
|
186
|
+
oplen += added.length;
|
|
187
|
+
} else if (code === 'B') {
|
|
188
|
+
// Single base (+ qual score)
|
|
189
|
+
seq += sub;
|
|
190
|
+
last_pos++;
|
|
191
|
+
oplen++;
|
|
192
|
+
} else if (code === 'X') {
|
|
193
|
+
// Substitution
|
|
194
|
+
seq += sub;
|
|
195
|
+
last_pos++;
|
|
196
|
+
oplen++;
|
|
197
|
+
} else if (code === 'D' || code === 'N') {
|
|
198
|
+
// Deletion or Ref Skip
|
|
199
|
+
last_pos += data;
|
|
200
|
+
|
|
201
|
+
if (oplen) {
|
|
202
|
+
cigar += oplen + op;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
cigar += data + code;
|
|
206
|
+
oplen = 0;
|
|
207
|
+
} else if (code === 'I' || code === 'S') {
|
|
208
|
+
// Insertion or soft-clip
|
|
209
|
+
seq += data;
|
|
210
|
+
|
|
211
|
+
if (oplen) {
|
|
212
|
+
cigar += oplen + op;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
cigar += data.length + code;
|
|
216
|
+
oplen = 0;
|
|
217
|
+
} else if (code === 'i') {
|
|
218
|
+
// Single base insertion
|
|
219
|
+
seq += data;
|
|
220
|
+
|
|
221
|
+
if (oplen) {
|
|
222
|
+
cigar += oplen + op;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
cigar += "".concat(1, "I");
|
|
226
|
+
oplen = 0;
|
|
227
|
+
} else if (code === 'P') {
|
|
228
|
+
// Padding
|
|
229
|
+
if (oplen) {
|
|
230
|
+
cigar += oplen + op;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
cigar += "".concat(data, "P");
|
|
234
|
+
} else if (code === 'H') {
|
|
235
|
+
// Hard clip
|
|
236
|
+
if (oplen) {
|
|
237
|
+
cigar += oplen + op;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
cigar += "".concat(data, "H");
|
|
241
|
+
oplen = 0;
|
|
242
|
+
} // else q or Q
|
|
243
|
+
|
|
244
|
+
});
|
|
245
|
+
} else {
|
|
246
|
+
sublen = this.record.readLength - seq.length;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (seq.length !== this.record.readLength) {
|
|
250
|
+
sublen = this.record.readLength - seq.length;
|
|
251
|
+
seq += ref.substring(last_pos - refStart, last_pos - refStart + sublen);
|
|
252
|
+
|
|
253
|
+
if (oplen && op !== 'M') {
|
|
254
|
+
cigar += oplen + op;
|
|
255
|
+
oplen = 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
op = 'M';
|
|
259
|
+
oplen += sublen;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (oplen) {
|
|
263
|
+
cigar += oplen + op;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return cigar;
|
|
267
|
+
}
|
|
268
|
+
}, {
|
|
269
|
+
key: "tags",
|
|
270
|
+
value: function tags() {
|
|
271
|
+
var properties = Object.getOwnPropertyNames(CramSlightlyLazyFeature.prototype);
|
|
272
|
+
return properties.filter(function (prop) {
|
|
273
|
+
return prop.startsWith('_get_') && prop !== '_get_mismatches' && prop !== '_get_cram_read_features';
|
|
274
|
+
}).map(function (methodName) {
|
|
275
|
+
return methodName.replace('_get_', '');
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "id",
|
|
280
|
+
value: function id() {
|
|
281
|
+
return "".concat(this._store.id, "-").concat(this.record.uniqueId);
|
|
282
|
+
}
|
|
283
|
+
}, {
|
|
284
|
+
key: "get",
|
|
285
|
+
value: function get(field) {
|
|
286
|
+
var methodName = "_get_".concat(field); // @ts-ignore
|
|
287
|
+
|
|
288
|
+
if (this[methodName]) {
|
|
289
|
+
// @ts-ignore
|
|
290
|
+
return this[methodName]();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "parent",
|
|
297
|
+
value: function parent() {
|
|
298
|
+
return undefined;
|
|
299
|
+
}
|
|
300
|
+
}, {
|
|
301
|
+
key: "children",
|
|
302
|
+
value: function children() {
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
305
|
+
}, {
|
|
306
|
+
key: "set",
|
|
307
|
+
value: function set() {}
|
|
308
|
+
}, {
|
|
309
|
+
key: "pairedFeature",
|
|
310
|
+
value: function pairedFeature() {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
}, {
|
|
314
|
+
key: "_get_clipPos",
|
|
315
|
+
value: function _get_clipPos() {
|
|
316
|
+
var mismatches = this.get('mismatches');
|
|
317
|
+
|
|
318
|
+
if (mismatches.length) {
|
|
319
|
+
var _record = this.get('strand') === -1 ? mismatches[mismatches.length - 1] : mismatches[0];
|
|
320
|
+
|
|
321
|
+
var type = _record.type,
|
|
322
|
+
cliplen = _record.cliplen;
|
|
323
|
+
|
|
324
|
+
if (type === 'softclip' || type === 'hardclip') {
|
|
325
|
+
return cliplen;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return 0;
|
|
330
|
+
}
|
|
331
|
+
}, {
|
|
332
|
+
key: "toJSON",
|
|
333
|
+
value: function toJSON() {
|
|
334
|
+
var _this = this;
|
|
335
|
+
|
|
336
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
337
|
+
var tags = {};
|
|
338
|
+
this.tags().forEach(function (t) {
|
|
339
|
+
var val = _this.get(t);
|
|
340
|
+
|
|
341
|
+
if (val !== undefined) {
|
|
342
|
+
tags[t] = val;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
return _objectSpread(_objectSpread({}, tags), {}, {
|
|
346
|
+
name: this.get('name'),
|
|
347
|
+
type: this.get('type'),
|
|
348
|
+
uniqueId: this.id()
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}, {
|
|
352
|
+
key: "_get_mismatches",
|
|
353
|
+
value: function _get_mismatches() {
|
|
354
|
+
var readFeatures = this.get('cram_read_features');
|
|
355
|
+
var qual = this.qualRaw();
|
|
356
|
+
|
|
357
|
+
if (!readFeatures) {
|
|
358
|
+
return [];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
var start = this.get('start');
|
|
362
|
+
var mismatches = [];
|
|
363
|
+
readFeatures.forEach(function (args) {
|
|
364
|
+
var code = args.code,
|
|
365
|
+
pos = args.pos,
|
|
366
|
+
data = args.data,
|
|
367
|
+
sub = args.sub,
|
|
368
|
+
ref = args.ref;
|
|
369
|
+
var refPos = args.refPos - 1 - start;
|
|
370
|
+
|
|
371
|
+
if (code === 'X') {
|
|
372
|
+
// substitution
|
|
373
|
+
mismatches.push({
|
|
374
|
+
start: refPos,
|
|
375
|
+
length: 1,
|
|
376
|
+
base: sub,
|
|
377
|
+
qual: qual === null || qual === void 0 ? void 0 : qual[pos],
|
|
378
|
+
altbase: ref,
|
|
379
|
+
type: 'mismatch'
|
|
380
|
+
});
|
|
381
|
+
} else if (code === 'I') {
|
|
382
|
+
// insertion
|
|
383
|
+
mismatches.push({
|
|
384
|
+
start: refPos,
|
|
385
|
+
type: 'insertion',
|
|
386
|
+
base: "".concat(data.length),
|
|
387
|
+
length: 0
|
|
388
|
+
});
|
|
389
|
+
} else if (code === 'N') {
|
|
390
|
+
// reference skip
|
|
391
|
+
mismatches.push({
|
|
392
|
+
type: 'skip',
|
|
393
|
+
length: data,
|
|
394
|
+
start: refPos,
|
|
395
|
+
base: 'N'
|
|
396
|
+
});
|
|
397
|
+
} else if (code === 'S') {
|
|
398
|
+
// soft clip
|
|
399
|
+
var len = data.length;
|
|
400
|
+
mismatches.push({
|
|
401
|
+
start: refPos,
|
|
402
|
+
type: 'softclip',
|
|
403
|
+
base: "S".concat(len),
|
|
404
|
+
cliplen: len,
|
|
405
|
+
length: 1
|
|
406
|
+
});
|
|
407
|
+
} else if (code === 'P') {// padding
|
|
408
|
+
} else if (code === 'H') {
|
|
409
|
+
// hard clip
|
|
410
|
+
var _len = data;
|
|
411
|
+
mismatches.push({
|
|
412
|
+
start: refPos,
|
|
413
|
+
type: 'hardclip',
|
|
414
|
+
base: "H".concat(_len),
|
|
415
|
+
cliplen: _len,
|
|
416
|
+
length: 1
|
|
417
|
+
});
|
|
418
|
+
} else if (code === 'D') {
|
|
419
|
+
// deletion
|
|
420
|
+
mismatches.push({
|
|
421
|
+
type: 'deletion',
|
|
422
|
+
length: data,
|
|
423
|
+
start: refPos,
|
|
424
|
+
base: '*'
|
|
425
|
+
});
|
|
426
|
+
} else if (code === 'b') {// stretch of bases
|
|
427
|
+
} else if (code === 'q') {// stretch of qual scores
|
|
428
|
+
} else if (code === 'B') {// a pair of [base, qual]
|
|
429
|
+
} else if (code === 'i') {
|
|
430
|
+
// single-base insertion
|
|
431
|
+
// insertion
|
|
432
|
+
mismatches.push({
|
|
433
|
+
start: refPos,
|
|
434
|
+
type: 'insertion',
|
|
435
|
+
base: data,
|
|
436
|
+
length: 1
|
|
437
|
+
});
|
|
438
|
+
} else if (code === 'Q') {// single quality value
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
return mismatches;
|
|
442
|
+
}
|
|
443
|
+
}]);
|
|
444
|
+
return CramSlightlyLazyFeature;
|
|
445
|
+
}();
|
|
446
|
+
|
|
447
|
+
exports["default"] = CramSlightlyLazyFeature;
|