@jbrowse/plugin-alignments 1.7.9 → 2.0.0
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.js +192 -207
- package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js.map +1 -0
- package/dist/AlignmentsFeatureDetail/index.d.ts +28 -3
- package/dist/AlignmentsFeatureDetail/index.js +48 -55
- package/dist/AlignmentsFeatureDetail/index.js.map +1 -0
- package/dist/AlignmentsTrack/index.js +24 -32
- package/dist/AlignmentsTrack/index.js.map +1 -0
- package/dist/BamAdapter/BamAdapter.js +345 -585
- package/dist/BamAdapter/BamAdapter.js.map +1 -0
- package/dist/BamAdapter/BamSlightlyLazyFeature.js +143 -174
- package/dist/BamAdapter/BamSlightlyLazyFeature.js.map +1 -0
- package/dist/BamAdapter/MismatchParser.js +340 -416
- package/dist/BamAdapter/MismatchParser.js.map +1 -0
- package/dist/BamAdapter/configSchema.js +33 -46
- package/dist/BamAdapter/configSchema.js.map +1 -0
- package/dist/BamAdapter/index.js +36 -32
- package/dist/BamAdapter/index.js.map +1 -0
- package/dist/CramAdapter/CramAdapter.js +376 -644
- package/dist/CramAdapter/CramAdapter.js.map +1 -0
- package/dist/CramAdapter/CramSlightlyLazyFeature.js +374 -439
- package/dist/CramAdapter/CramSlightlyLazyFeature.js.map +1 -0
- package/dist/CramAdapter/CramTestAdapters.js +169 -227
- package/dist/CramAdapter/CramTestAdapters.js.map +1 -0
- package/dist/CramAdapter/configSchema.js +28 -38
- package/dist/CramAdapter/configSchema.js.map +1 -0
- package/dist/CramAdapter/index.js +37 -32
- package/dist/CramAdapter/index.js.map +1 -0
- package/dist/HtsgetBamAdapter/HtsgetBamAdapter.js +91 -93
- package/dist/HtsgetBamAdapter/HtsgetBamAdapter.js.map +1 -0
- package/dist/HtsgetBamAdapter/configSchema.js +19 -29
- package/dist/HtsgetBamAdapter/configSchema.js.map +1 -0
- package/dist/HtsgetBamAdapter/index.js +44 -38
- package/dist/HtsgetBamAdapter/index.js.map +1 -0
- package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +36 -65
- package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js.map +1 -0
- package/dist/LinearAlignmentsDisplay/index.js +22 -28
- package/dist/LinearAlignmentsDisplay/index.js.map +1 -0
- package/dist/LinearAlignmentsDisplay/models/configSchema.js +12 -23
- package/dist/LinearAlignmentsDisplay/models/configSchema.js.map +1 -0
- package/dist/LinearAlignmentsDisplay/models/model.d.ts +10 -10
- package/dist/LinearAlignmentsDisplay/models/model.js +257 -245
- package/dist/LinearAlignmentsDisplay/models/model.js.map +1 -0
- package/dist/LinearPileupDisplay/components/ColorByModifications.js +98 -116
- package/dist/LinearPileupDisplay/components/ColorByModifications.js.map +1 -0
- package/dist/LinearPileupDisplay/components/ColorByTag.js +82 -91
- package/dist/LinearPileupDisplay/components/ColorByTag.js.map +1 -0
- package/dist/LinearPileupDisplay/components/FilterByTag.js +156 -192
- package/dist/LinearPileupDisplay/components/FilterByTag.js.map +1 -0
- package/dist/LinearPileupDisplay/components/LinearPileupDisplayBlurb.js +15 -29
- package/dist/LinearPileupDisplay/components/LinearPileupDisplayBlurb.js.map +1 -0
- package/dist/LinearPileupDisplay/components/SetFeatureHeight.js +79 -93
- package/dist/LinearPileupDisplay/components/SetFeatureHeight.js.map +1 -0
- package/dist/LinearPileupDisplay/components/SetMaxHeight.js +78 -81
- package/dist/LinearPileupDisplay/components/SetMaxHeight.js.map +1 -0
- package/dist/LinearPileupDisplay/components/SortByTag.js +80 -88
- package/dist/LinearPileupDisplay/components/SortByTag.js.map +1 -0
- package/dist/LinearPileupDisplay/configSchema.js +40 -42
- package/dist/LinearPileupDisplay/configSchema.js.map +1 -0
- package/dist/LinearPileupDisplay/index.js +21 -27
- package/dist/LinearPileupDisplay/index.js.map +1 -0
- package/dist/LinearPileupDisplay/model.d.ts +33 -20
- package/dist/LinearPileupDisplay/model.js +702 -716
- package/dist/LinearPileupDisplay/model.js.map +1 -0
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.d.ts +1 -1
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.js +105 -57
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.js.map +1 -0
- package/dist/LinearSNPCoverageDisplay/index.js +21 -27
- package/dist/LinearSNPCoverageDisplay/index.js.map +1 -0
- package/dist/LinearSNPCoverageDisplay/models/configSchema.js +45 -55
- package/dist/LinearSNPCoverageDisplay/models/configSchema.js.map +1 -0
- package/dist/LinearSNPCoverageDisplay/models/model.d.ts +14 -12
- package/dist/LinearSNPCoverageDisplay/models/model.js +257 -230
- package/dist/LinearSNPCoverageDisplay/models/model.js.map +1 -0
- package/dist/NestedFrequencyTable.js +104 -139
- package/dist/NestedFrequencyTable.js.map +1 -0
- package/dist/PileupRPC/rpcMethods.js +199 -278
- package/dist/PileupRPC/rpcMethods.js.map +1 -0
- package/dist/PileupRenderer/PileupLayoutSession.js +56 -76
- package/dist/PileupRenderer/PileupLayoutSession.js.map +1 -0
- package/dist/PileupRenderer/PileupRenderer.d.ts +56 -11
- package/dist/PileupRenderer/PileupRenderer.js +942 -1134
- package/dist/PileupRenderer/PileupRenderer.js.map +1 -0
- package/dist/PileupRenderer/components/PileupRendering.d.ts +1 -1
- package/dist/PileupRenderer/components/PileupRendering.js +173 -253
- package/dist/PileupRenderer/components/PileupRendering.js.map +1 -0
- package/dist/PileupRenderer/configSchema.js +65 -71
- package/dist/PileupRenderer/configSchema.js.map +1 -0
- package/dist/PileupRenderer/index.js +17 -22
- package/dist/PileupRenderer/index.js.map +1 -0
- package/dist/PileupRenderer/sortUtil.js +83 -107
- package/dist/PileupRenderer/sortUtil.js.map +1 -0
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.d.ts +2 -0
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js +436 -586
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js.map +1 -0
- package/dist/SNPCoverageAdapter/configSchema.js +10 -20
- package/dist/SNPCoverageAdapter/configSchema.js.map +1 -0
- package/dist/SNPCoverageAdapter/index.js +46 -41
- package/dist/SNPCoverageAdapter/index.js.map +1 -0
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.d.ts +1 -1
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.js +265 -290
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.js.map +1 -0
- package/dist/SNPCoverageRenderer/configSchema.js +30 -39
- package/dist/SNPCoverageRenderer/configSchema.js.map +1 -0
- package/dist/SNPCoverageRenderer/index.js +19 -30
- package/dist/SNPCoverageRenderer/index.js.map +1 -0
- package/dist/index.js +135 -152
- package/dist/index.js.map +1 -0
- package/dist/shared.js +84 -92
- package/dist/shared.js.map +1 -0
- package/dist/util.js +130 -121
- package/dist/util.js.map +1 -0
- package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.d.ts +6 -0
- package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js +145 -0
- package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js.map +1 -0
- package/esm/AlignmentsFeatureDetail/index.d.ts +38 -0
- package/esm/AlignmentsFeatureDetail/index.js +23 -0
- package/esm/AlignmentsFeatureDetail/index.js.map +1 -0
- package/esm/AlignmentsTrack/index.d.ts +2 -0
- package/esm/AlignmentsTrack/index.js +23 -0
- package/esm/AlignmentsTrack/index.js.map +1 -0
- package/esm/BamAdapter/BamAdapter.d.ts +40 -0
- package/esm/BamAdapter/BamAdapter.js +173 -0
- package/esm/BamAdapter/BamAdapter.js.map +1 -0
- package/esm/BamAdapter/BamSlightlyLazyFeature.d.ts +33 -0
- package/esm/BamAdapter/BamSlightlyLazyFeature.js +107 -0
- package/esm/BamAdapter/BamSlightlyLazyFeature.js.map +1 -0
- package/esm/BamAdapter/MismatchParser.d.ts +25 -0
- package/esm/BamAdapter/MismatchParser.js +294 -0
- package/esm/BamAdapter/MismatchParser.js.map +1 -0
- package/esm/BamAdapter/configSchema.d.ts +2 -0
- package/esm/BamAdapter/configSchema.js +31 -0
- package/esm/BamAdapter/configSchema.js.map +1 -0
- package/esm/BamAdapter/index.d.ts +3 -0
- package/esm/BamAdapter/index.js +10 -0
- package/esm/BamAdapter/index.js.map +1 -0
- package/esm/CramAdapter/CramAdapter.d.ts +53 -0
- package/esm/CramAdapter/CramAdapter.js +228 -0
- package/esm/CramAdapter/CramAdapter.js.map +1 -0
- package/esm/CramAdapter/CramSlightlyLazyFeature.d.ts +49 -0
- package/esm/CramAdapter/CramSlightlyLazyFeature.js +349 -0
- package/esm/CramAdapter/CramSlightlyLazyFeature.js.map +1 -0
- package/esm/CramAdapter/CramTestAdapters.d.ts +29 -0
- package/esm/CramAdapter/CramTestAdapters.js +70 -0
- package/esm/CramAdapter/CramTestAdapters.js.map +1 -0
- package/esm/CramAdapter/configSchema.d.ts +3 -0
- package/esm/CramAdapter/configSchema.js +26 -0
- package/esm/CramAdapter/configSchema.js.map +1 -0
- package/esm/CramAdapter/index.d.ts +3 -0
- package/esm/CramAdapter/index.js +11 -0
- package/esm/CramAdapter/index.js.map +1 -0
- package/esm/HtsgetBamAdapter/HtsgetBamAdapter.d.ts +9 -0
- package/esm/HtsgetBamAdapter/HtsgetBamAdapter.js +27 -0
- package/esm/HtsgetBamAdapter/HtsgetBamAdapter.js.map +1 -0
- package/esm/HtsgetBamAdapter/configSchema.d.ts +2 -0
- package/esm/HtsgetBamAdapter/configSchema.js +17 -0
- package/esm/HtsgetBamAdapter/configSchema.js.map +1 -0
- package/esm/HtsgetBamAdapter/index.d.ts +3 -0
- package/esm/HtsgetBamAdapter/index.js +16 -0
- package/esm/HtsgetBamAdapter/index.js.map +1 -0
- package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +7 -0
- package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +34 -0
- package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.js.map +1 -0
- package/esm/LinearAlignmentsDisplay/index.d.ts +2 -0
- package/esm/LinearAlignmentsDisplay/index.js +19 -0
- package/esm/LinearAlignmentsDisplay/index.js.map +1 -0
- package/esm/LinearAlignmentsDisplay/models/configSchema.d.ts +4 -0
- package/esm/LinearAlignmentsDisplay/models/configSchema.js +12 -0
- package/esm/LinearAlignmentsDisplay/models/configSchema.js.map +1 -0
- package/esm/LinearAlignmentsDisplay/models/model.d.ts +105 -0
- package/esm/LinearAlignmentsDisplay/models/model.js +181 -0
- package/esm/LinearAlignmentsDisplay/models/model.js.map +1 -0
- package/esm/LinearPileupDisplay/components/ColorByModifications.d.ts +14 -0
- package/esm/LinearPileupDisplay/components/ColorByModifications.js +71 -0
- package/esm/LinearPileupDisplay/components/ColorByModifications.js.map +1 -0
- package/esm/LinearPileupDisplay/components/ColorByTag.d.ts +9 -0
- package/esm/LinearPileupDisplay/components/ColorByTag.js +45 -0
- package/esm/LinearPileupDisplay/components/ColorByTag.js.map +1 -0
- package/esm/LinearPileupDisplay/components/FilterByTag.d.ts +18 -0
- package/esm/LinearPileupDisplay/components/FilterByTag.js +123 -0
- package/esm/LinearPileupDisplay/components/FilterByTag.js.map +1 -0
- package/esm/LinearPileupDisplay/components/LinearPileupDisplayBlurb.d.ts +13 -0
- package/esm/LinearPileupDisplay/components/LinearPileupDisplayBlurb.js +13 -0
- package/esm/LinearPileupDisplay/components/LinearPileupDisplayBlurb.js.map +1 -0
- package/esm/LinearPileupDisplay/components/SetFeatureHeight.d.ts +16 -0
- package/esm/LinearPileupDisplay/components/SetFeatureHeight.js +41 -0
- package/esm/LinearPileupDisplay/components/SetFeatureHeight.js.map +1 -0
- package/esm/LinearPileupDisplay/components/SetMaxHeight.d.ts +10 -0
- package/esm/LinearPileupDisplay/components/SetMaxHeight.js +43 -0
- package/esm/LinearPileupDisplay/components/SetMaxHeight.js.map +1 -0
- package/esm/LinearPileupDisplay/components/SortByTag.d.ts +9 -0
- package/esm/LinearPileupDisplay/components/SortByTag.js +43 -0
- package/esm/LinearPileupDisplay/components/SortByTag.js.map +1 -0
- package/esm/LinearPileupDisplay/configSchema.d.ts +6 -0
- package/esm/LinearPileupDisplay/configSchema.js +41 -0
- package/esm/LinearPileupDisplay/configSchema.js.map +1 -0
- package/esm/LinearPileupDisplay/index.d.ts +2 -0
- package/esm/LinearPileupDisplay/index.js +18 -0
- package/esm/LinearPileupDisplay/index.js.map +1 -0
- package/esm/LinearPileupDisplay/model.d.ts +332 -0
- package/esm/LinearPileupDisplay/model.js +576 -0
- package/esm/LinearPileupDisplay/model.js.map +1 -0
- package/esm/LinearSNPCoverageDisplay/components/Tooltip.d.ts +10 -0
- package/esm/LinearSNPCoverageDisplay/components/Tooltip.js +57 -0
- package/esm/LinearSNPCoverageDisplay/components/Tooltip.js.map +1 -0
- package/esm/LinearSNPCoverageDisplay/index.d.ts +2 -0
- package/esm/LinearSNPCoverageDisplay/index.js +18 -0
- package/esm/LinearSNPCoverageDisplay/index.js.map +1 -0
- package/esm/LinearSNPCoverageDisplay/models/configSchema.d.ts +2 -0
- package/esm/LinearSNPCoverageDisplay/models/configSchema.js +44 -0
- package/esm/LinearSNPCoverageDisplay/models/configSchema.js.map +1 -0
- package/esm/LinearSNPCoverageDisplay/models/model.d.ts +348 -0
- package/esm/LinearSNPCoverageDisplay/models/model.js +185 -0
- package/esm/LinearSNPCoverageDisplay/models/model.js.map +1 -0
- package/esm/NestedFrequencyTable.d.ts +14 -0
- package/esm/NestedFrequencyTable.js +101 -0
- package/esm/NestedFrequencyTable.js.map +1 -0
- package/esm/PileupRPC/rpcMethods.d.ts +34 -0
- package/esm/PileupRPC/rpcMethods.js +70 -0
- package/esm/PileupRPC/rpcMethods.js.map +1 -0
- package/esm/PileupRenderer/PileupLayoutSession.d.ts +32 -0
- package/esm/PileupRenderer/PileupLayoutSession.js +32 -0
- package/esm/PileupRenderer/PileupLayoutSession.js.map +1 -0
- package/esm/PileupRenderer/PileupRenderer.d.ts +182 -0
- package/esm/PileupRenderer/PileupRenderer.js +830 -0
- package/esm/PileupRenderer/PileupRenderer.js.map +1 -0
- package/esm/PileupRenderer/components/PileupRendering.d.ts +23 -0
- package/esm/PileupRenderer/components/PileupRendering.js +138 -0
- package/esm/PileupRenderer/components/PileupRendering.js.map +1 -0
- package/esm/PileupRenderer/configSchema.d.ts +2 -0
- package/esm/PileupRenderer/configSchema.js +64 -0
- package/esm/PileupRenderer/configSchema.js.map +1 -0
- package/esm/PileupRenderer/index.d.ts +2 -0
- package/esm/PileupRenderer/index.js +12 -0
- package/esm/PileupRenderer/index.js.map +1 -0
- package/esm/PileupRenderer/sortUtil.d.ts +8 -0
- package/esm/PileupRenderer/sortUtil.js +80 -0
- package/esm/PileupRenderer/sortUtil.js.map +1 -0
- package/esm/SNPCoverageAdapter/SNPCoverageAdapter.d.ts +67 -0
- package/esm/SNPCoverageAdapter/SNPCoverageAdapter.js +259 -0
- package/esm/SNPCoverageAdapter/SNPCoverageAdapter.js.map +1 -0
- package/esm/SNPCoverageAdapter/configSchema.d.ts +3 -0
- package/esm/SNPCoverageAdapter/configSchema.js +6 -0
- package/esm/SNPCoverageAdapter/configSchema.js.map +1 -0
- package/esm/SNPCoverageAdapter/index.d.ts +3 -0
- package/esm/SNPCoverageAdapter/index.js +18 -0
- package/esm/SNPCoverageAdapter/index.js.map +1 -0
- package/esm/SNPCoverageRenderer/SNPCoverageRenderer.d.ts +20 -0
- package/esm/SNPCoverageRenderer/SNPCoverageRenderer.js +185 -0
- package/esm/SNPCoverageRenderer/SNPCoverageRenderer.js.map +1 -0
- package/esm/SNPCoverageRenderer/configSchema.d.ts +2 -0
- package/esm/SNPCoverageRenderer/configSchema.js +29 -0
- package/esm/SNPCoverageRenderer/configSchema.js.map +1 -0
- package/esm/SNPCoverageRenderer/index.d.ts +3 -0
- package/esm/SNPCoverageRenderer/index.js +14 -0
- package/esm/SNPCoverageRenderer/index.js.map +1 -0
- package/esm/index.d.ts +10 -0
- package/esm/index.js +91 -0
- package/esm/index.js.map +1 -0
- package/esm/shared.d.ts +25 -0
- package/esm/shared.js +28 -0
- package/esm/shared.js.map +1 -0
- package/esm/util.d.ts +19 -0
- package/esm/util.js +83 -0
- package/esm/util.js.map +1 -0
- package/package.json +19 -11
- package/src/AlignmentsFeatureDetail/AlignmentsFeatureDetail.tsx +16 -6
- package/src/AlignmentsFeatureDetail/__snapshots__/index.test.js.snap +321 -397
- package/src/AlignmentsFeatureDetail/index.ts +7 -17
- package/src/BamAdapter/MismatchParser.ts +1 -0
- package/src/LinearAlignmentsDisplay/components/AlignmentsDisplay.tsx +3 -3
- package/src/LinearPileupDisplay/components/ColorByModifications.tsx +7 -7
- package/src/LinearPileupDisplay/components/ColorByTag.tsx +5 -5
- package/src/LinearPileupDisplay/components/FilterByTag.tsx +5 -5
- package/src/LinearPileupDisplay/components/LinearPileupDisplayBlurb.tsx +1 -1
- package/src/LinearPileupDisplay/components/SetFeatureHeight.tsx +9 -9
- package/src/LinearPileupDisplay/components/SetMaxHeight.tsx +5 -5
- package/src/LinearPileupDisplay/components/SortByTag.tsx +5 -5
- package/src/LinearPileupDisplay/model.ts +90 -32
- package/src/LinearSNPCoverageDisplay/components/Tooltip.tsx +44 -30
- package/src/LinearSNPCoverageDisplay/models/model.ts +25 -25
- package/src/PileupRenderer/PileupRenderer.tsx +399 -198
- package/src/PileupRenderer/components/PileupRendering.tsx +11 -11
- package/src/SNPCoverageAdapter/SNPCoverageAdapter.ts +5 -0
- package/src/SNPCoverageRenderer/SNPCoverageRenderer.ts +7 -5
- package/dist/AlignmentsFeatureDetail/index.test.js +0 -60
- package/dist/BamAdapter/BamAdapter.test.js +0 -177
- package/dist/BamAdapter/MismatchParser.test.js +0 -251
- package/dist/CramAdapter/CramAdapter.test.js +0 -138
- package/dist/LinearAlignmentsDisplay/models/configSchema.test.js +0 -83
- package/dist/LinearPileupDisplay/configSchema.test.js +0 -92
- package/dist/LinearSNPCoverageDisplay/models/configSchema.test.js +0 -62
- package/dist/PileupRenderer/components/PileupRendering.test.js +0 -36
- package/dist/declare.d.js +0 -1
- package/dist/index.test.js +0 -26
|
@@ -1,370 +1,363 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
7
43
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
52
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
53
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
54
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
55
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
56
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
57
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
61
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
62
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
63
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
64
|
+
function step(op) {
|
|
65
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
66
|
+
while (_) try {
|
|
67
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
68
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
+
switch (op[0]) {
|
|
70
|
+
case 0: case 1: t = op; break;
|
|
71
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
72
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
73
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
74
|
+
default:
|
|
75
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
76
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
77
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
78
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
79
|
+
if (t[2]) _.ops.pop();
|
|
80
|
+
_.trys.pop(); continue;
|
|
81
|
+
}
|
|
82
|
+
op = body.call(thisArg, _);
|
|
83
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
84
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
88
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
89
|
+
if (!m) return o;
|
|
90
|
+
var i = m.call(o), r, ar = [], e;
|
|
91
|
+
try {
|
|
92
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
93
|
+
}
|
|
94
|
+
catch (error) { e = { error: error }; }
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
98
|
+
}
|
|
99
|
+
finally { if (e) throw e.error; }
|
|
100
|
+
}
|
|
101
|
+
return ar;
|
|
102
|
+
};
|
|
103
|
+
var __values = (this && this.__values) || function(o) {
|
|
104
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
105
|
+
if (m) return m.call(o);
|
|
106
|
+
if (o && typeof o.length === "number") return {
|
|
107
|
+
next: function () {
|
|
108
|
+
if (o && i >= o.length) o = void 0;
|
|
109
|
+
return { value: o && o[i++], done: !o };
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
113
|
+
};
|
|
114
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
115
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
116
|
+
};
|
|
117
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
118
|
+
var BoxRendererType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType"));
|
|
119
|
+
var ui_1 = require("@jbrowse/core/ui");
|
|
120
|
+
var util_1 = require("@jbrowse/core/util");
|
|
121
|
+
var offscreenCanvasUtils_1 = require("@jbrowse/core/util/offscreenCanvasUtils");
|
|
122
|
+
var dataAdapterCache_1 = require("@jbrowse/core/data_adapters/dataAdapterCache");
|
|
123
|
+
var configuration_1 = require("@jbrowse/core/configuration");
|
|
124
|
+
// locals
|
|
125
|
+
var MismatchParser_1 = require("../BamAdapter/MismatchParser");
|
|
126
|
+
var sortUtil_1 = require("./sortUtil");
|
|
127
|
+
var util_2 = require("../util");
|
|
128
|
+
var PileupLayoutSession_1 = require("./PileupLayoutSession");
|
|
129
|
+
function fillRect(ctx, l, t, w, h, cw, color) {
|
|
130
|
+
if (l + w < 0 || l > cw) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
if (color) {
|
|
135
|
+
ctx.fillStyle = color;
|
|
136
|
+
}
|
|
137
|
+
ctx.fillRect(l, t, w, h);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
68
140
|
function getColorBaseMap(theme) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
var bases = theme.palette.bases;
|
|
143
|
+
return {
|
|
144
|
+
A: bases.A.main,
|
|
145
|
+
C: bases.C.main,
|
|
146
|
+
G: bases.G.main,
|
|
147
|
+
T: bases.T.main,
|
|
148
|
+
deletion: '#808080', // gray
|
|
149
|
+
};
|
|
77
150
|
}
|
|
78
|
-
|
|
79
151
|
function getContrastBaseMap(theme) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
152
|
+
return Object.fromEntries(Object.entries(getColorBaseMap(theme)).map(function (_a) {
|
|
153
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
154
|
+
return [
|
|
155
|
+
key,
|
|
156
|
+
theme.palette.getContrastText(value),
|
|
157
|
+
];
|
|
158
|
+
}));
|
|
87
159
|
}
|
|
88
|
-
|
|
89
160
|
var alignmentColoring = {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
161
|
+
color_fwd_strand_not_proper: '#ECC8C8',
|
|
162
|
+
color_rev_strand_not_proper: '#BEBED8',
|
|
163
|
+
color_fwd_strand: '#EC8B8B',
|
|
164
|
+
color_rev_strand: '#8F8FD8',
|
|
165
|
+
color_fwd_missing_mate: '#D11919',
|
|
166
|
+
color_rev_missing_mate: '#1919D1',
|
|
167
|
+
color_fwd_diff_chr: '#000',
|
|
168
|
+
color_rev_diff_chr: '#969696',
|
|
169
|
+
color_pair_lr: '#c8c8c8',
|
|
170
|
+
color_pair_rr: 'navy',
|
|
171
|
+
color_pair_rl: 'teal',
|
|
172
|
+
color_pair_ll: 'green',
|
|
173
|
+
color_nostrand: '#c8c8c8',
|
|
174
|
+
color_interchrom: 'orange',
|
|
175
|
+
color_longinsert: 'red',
|
|
176
|
+
color_shortinsert: 'pink',
|
|
106
177
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return !['methylation', 'modifications'].includes(type || '');
|
|
178
|
+
function shouldDrawSNPsMuted(type) {
|
|
179
|
+
return ['methylation', 'modifications'].includes(type || '');
|
|
110
180
|
}
|
|
111
|
-
|
|
112
181
|
function shouldDrawIndels(type) {
|
|
113
|
-
|
|
182
|
+
return true;
|
|
114
183
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
function PileupRenderer() {
|
|
122
|
-
var _this;
|
|
123
|
-
|
|
124
|
-
(0, _classCallCheck2.default)(this, PileupRenderer);
|
|
125
|
-
|
|
126
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
127
|
-
args[_key] = arguments[_key];
|
|
184
|
+
var PileupRenderer = /** @class */ (function (_super) {
|
|
185
|
+
__extends(PileupRenderer, _super);
|
|
186
|
+
function PileupRenderer() {
|
|
187
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
188
|
+
_this.supportsSVG = true;
|
|
189
|
+
return _this;
|
|
128
190
|
}
|
|
129
|
-
|
|
130
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
131
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "supportsSVG", true);
|
|
132
|
-
return _this;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
(0, _createClass2.default)(PileupRenderer, [{
|
|
136
|
-
key: "getCharWidthHeight",
|
|
137
|
-
value: // get width and height of chars the height is an approximation: width
|
|
191
|
+
// get width and height of chars the height is an approximation: width
|
|
138
192
|
// letter M is approximately the height
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
var mismatches = feature.get('mismatches');
|
|
162
|
-
var seq = feature.get('seq');
|
|
163
|
-
|
|
164
|
-
if (seq) {
|
|
165
|
-
for (var i = 0; i < mismatches.length; i += 1) {
|
|
166
|
-
var _mismatches$i = mismatches[i],
|
|
167
|
-
type = _mismatches$i.type,
|
|
168
|
-
start = _mismatches$i.start,
|
|
169
|
-
_mismatches$i$cliplen = _mismatches$i.cliplen,
|
|
170
|
-
cliplen = _mismatches$i$cliplen === void 0 ? 0 : _mismatches$i$cliplen;
|
|
171
|
-
|
|
172
|
-
if (type === 'softclip') {
|
|
173
|
-
start === 0 ? expansionBefore = cliplen : expansionAfter = cliplen;
|
|
193
|
+
PileupRenderer.prototype.getCharWidthHeight = function (ctx) {
|
|
194
|
+
var charWidth = (0, util_1.measureText)('A');
|
|
195
|
+
var charHeight = (0, util_1.measureText)('M') - 2;
|
|
196
|
+
return { charWidth: charWidth, charHeight: charHeight };
|
|
197
|
+
};
|
|
198
|
+
PileupRenderer.prototype.layoutFeature = function (_a) {
|
|
199
|
+
var feature = _a.feature, layout = _a.layout, bpPerPx = _a.bpPerPx, region = _a.region, showSoftClip = _a.showSoftClip, heightPx = _a.heightPx, displayMode = _a.displayMode;
|
|
200
|
+
var expansionBefore = 0;
|
|
201
|
+
var expansionAfter = 0;
|
|
202
|
+
// Expand the start and end of feature when softclipping enabled
|
|
203
|
+
if (showSoftClip) {
|
|
204
|
+
var mismatches = feature.get('mismatches');
|
|
205
|
+
var seq = feature.get('seq');
|
|
206
|
+
if (seq) {
|
|
207
|
+
for (var i = 0; i < mismatches.length; i += 1) {
|
|
208
|
+
var _b = mismatches[i], type = _b.type, start = _b.start, _c = _b.cliplen, cliplen = _c === void 0 ? 0 : _c;
|
|
209
|
+
if (type === 'softclip') {
|
|
210
|
+
start === 0
|
|
211
|
+
? (expansionBefore = cliplen)
|
|
212
|
+
: (expansionAfter = cliplen);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
174
215
|
}
|
|
175
|
-
}
|
|
176
216
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return {
|
|
199
|
-
feature: feature,
|
|
200
|
-
leftPx: leftPx,
|
|
201
|
-
rightPx: rightPx,
|
|
202
|
-
topPx: displayMode === 'collapse' ? 0 : topPx,
|
|
203
|
-
heightPx: heightPx
|
|
204
|
-
};
|
|
205
|
-
} // expands region for clipping to use. possible improvement: use average read
|
|
217
|
+
var _d = __read((0, util_1.bpSpanPx)(feature.get('start') - expansionBefore, feature.get('end') + expansionAfter, region, bpPerPx), 2), leftPx = _d[0], rightPx = _d[1];
|
|
218
|
+
if (displayMode === 'compact') {
|
|
219
|
+
heightPx /= 3;
|
|
220
|
+
}
|
|
221
|
+
if (feature.get('refName') !== region.refName) {
|
|
222
|
+
throw new Error("feature ".concat(feature.id(), " is not on the current region's reference sequence ").concat(region.refName));
|
|
223
|
+
}
|
|
224
|
+
var topPx = layout.addRect(feature.id(), feature.get('start') - expansionBefore, feature.get('end') + expansionAfter, heightPx, feature);
|
|
225
|
+
if (topPx === null) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
feature: feature,
|
|
230
|
+
leftPx: leftPx,
|
|
231
|
+
rightPx: rightPx,
|
|
232
|
+
topPx: displayMode === 'collapse' ? 0 : topPx,
|
|
233
|
+
heightPx: heightPx,
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
// expands region for clipping to use. possible improvement: use average read
|
|
206
237
|
// size to set the heuristic maxClippingSize expansion (e.g. short reads
|
|
207
238
|
// don't have to expand a softclipping size a lot, but long reads might)
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (feature.get('multi_segment_next_segment_unmapped')) {
|
|
263
|
-
return strand * flipper === 1 ? 'color_rev_missing_mate' : 'color_fwd_missing_mate';
|
|
239
|
+
PileupRenderer.prototype.getExpandedRegion = function (region, renderArgs) {
|
|
240
|
+
var config = renderArgs.config, showSoftClip = renderArgs.showSoftClip;
|
|
241
|
+
var maxClippingSize = (0, configuration_1.readConfObject)(config, 'maxClippingSize');
|
|
242
|
+
var start = region.start, end = region.end;
|
|
243
|
+
var len = end - start;
|
|
244
|
+
var bpExpansion = Math.max(len, showSoftClip ? Math.round(maxClippingSize) : 0);
|
|
245
|
+
return __assign(__assign({}, region), { start: Math.floor(Math.max(start - bpExpansion, 0)), end: Math.ceil(end + bpExpansion) });
|
|
246
|
+
};
|
|
247
|
+
PileupRenderer.prototype.colorByOrientation = function (feature, config) {
|
|
248
|
+
return alignmentColoring[this.getOrientation(feature, config) || 'color_nostrand'];
|
|
249
|
+
};
|
|
250
|
+
PileupRenderer.prototype.getOrientation = function (feature, config) {
|
|
251
|
+
var orientationType = (0, configuration_1.readConfObject)(config, 'orientationType');
|
|
252
|
+
var type = util_2.orientationTypes[orientationType];
|
|
253
|
+
var orientation = type[feature.get('pair_orientation')];
|
|
254
|
+
var map = {
|
|
255
|
+
LR: 'color_pair_lr',
|
|
256
|
+
RR: 'color_pair_rr',
|
|
257
|
+
RL: 'color_pair_rl',
|
|
258
|
+
LL: 'color_pair_ll',
|
|
259
|
+
};
|
|
260
|
+
return map[orientation];
|
|
261
|
+
};
|
|
262
|
+
PileupRenderer.prototype.colorByInsertSize = function (feature, _config) {
|
|
263
|
+
return feature.get('is_paired') &&
|
|
264
|
+
feature.get('seq_id') !== feature.get('next_seq_id')
|
|
265
|
+
? '#555'
|
|
266
|
+
: "hsl(".concat(Math.abs(feature.get('template_length')) / 10, ",50%,50%)");
|
|
267
|
+
};
|
|
268
|
+
PileupRenderer.prototype.colorByStranded = function (feature, _config) {
|
|
269
|
+
var flags = feature.get('flags');
|
|
270
|
+
var strand = feature.get('strand');
|
|
271
|
+
// is paired
|
|
272
|
+
if (flags & 1) {
|
|
273
|
+
var revflag = flags & 64;
|
|
274
|
+
var flipper = revflag ? -1 : 1;
|
|
275
|
+
// proper pairing
|
|
276
|
+
if (flags & 2) {
|
|
277
|
+
return strand * flipper === 1 ? 'color_rev_strand' : 'color_fwd_strand';
|
|
278
|
+
}
|
|
279
|
+
if (feature.get('multi_segment_next_segment_unmapped')) {
|
|
280
|
+
return strand * flipper === 1
|
|
281
|
+
? 'color_rev_missing_mate'
|
|
282
|
+
: 'color_fwd_missing_mate';
|
|
283
|
+
}
|
|
284
|
+
if (feature.get('seq_id') === feature.get('next_seq_id')) {
|
|
285
|
+
return strand * flipper === 1
|
|
286
|
+
? 'color_rev_strand_not_proper'
|
|
287
|
+
: 'color_fwd_strand_not_proper';
|
|
288
|
+
}
|
|
289
|
+
// should only leave aberrant chr
|
|
290
|
+
return strand === 1 ? 'color_fwd_diff_chr' : 'color_rev_diff_chr';
|
|
264
291
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
soffset += len;
|
|
301
|
-
} else if (op === 'D' || op === 'N') {
|
|
302
|
-
roffset += len;
|
|
303
|
-
} else if (op === 'M' || op === 'X' || op === '=') {
|
|
304
|
-
for (var m = 0; m < len; m++) {
|
|
305
|
-
var letter = seq[soffset + m];
|
|
306
|
-
ctx.fillStyle = colorForBase[letter];
|
|
307
|
-
|
|
308
|
-
var _bpSpanPx3 = (0, _util.bpSpanPx)(start + roffset + m, start + roffset + m + 1, region, bpPerPx),
|
|
309
|
-
_bpSpanPx4 = (0, _slicedToArray2.default)(_bpSpanPx3, 1),
|
|
310
|
-
leftPx = _bpSpanPx4[0];
|
|
311
|
-
|
|
312
|
-
ctx.fillRect(leftPx, topPx, widthPx + 0.5, heightPx);
|
|
313
|
-
|
|
314
|
-
if (widthPx >= charWidth && heightPx >= heightLim) {
|
|
315
|
-
// normal SNP coloring
|
|
316
|
-
ctx.fillStyle = contrastForBase[letter];
|
|
317
|
-
ctx.fillText(letter, leftPx + (widthPx - charWidth) / 2 + 1, topPx + heightPx);
|
|
292
|
+
return strand === 1 ? 'color_fwd_strand' : 'color_rev_strand';
|
|
293
|
+
};
|
|
294
|
+
PileupRenderer.prototype.colorByPerBaseLettering = function (_a) {
|
|
295
|
+
var ctx = _a.ctx, feat = _a.feat, region = _a.region, bpPerPx = _a.bpPerPx, colorForBase = _a.colorForBase, contrastForBase = _a.contrastForBase, charWidth = _a.charWidth, charHeight = _a.charHeight, canvasWidth = _a.canvasWidth;
|
|
296
|
+
var heightLim = charHeight - 2;
|
|
297
|
+
var feature = feat.feature, topPx = feat.topPx, heightPx = feat.heightPx;
|
|
298
|
+
var seq = feature.get('seq');
|
|
299
|
+
var cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
|
|
300
|
+
var w = 1 / bpPerPx;
|
|
301
|
+
var start = feature.get('start');
|
|
302
|
+
var soffset = 0; // sequence offset
|
|
303
|
+
var roffset = 0; // reference offset
|
|
304
|
+
for (var i = 0; i < cigarOps.length; i += 2) {
|
|
305
|
+
var len = +cigarOps[i];
|
|
306
|
+
var op = cigarOps[i + 1];
|
|
307
|
+
if (op === 'S' || op === 'I') {
|
|
308
|
+
soffset += len;
|
|
309
|
+
}
|
|
310
|
+
else if (op === 'D' || op === 'N') {
|
|
311
|
+
roffset += len;
|
|
312
|
+
}
|
|
313
|
+
else if (op === 'M' || op === 'X' || op === '=') {
|
|
314
|
+
for (var m = 0; m < len; m++) {
|
|
315
|
+
var letter = seq[soffset + m];
|
|
316
|
+
var r = start + roffset + m;
|
|
317
|
+
var _b = __read((0, util_1.bpSpanPx)(r, r + 1, region, bpPerPx), 1), leftPx = _b[0];
|
|
318
|
+
fillRect(ctx, leftPx, topPx, w + 0.5, heightPx, canvasWidth, colorForBase[letter]);
|
|
319
|
+
if (w >= charWidth && heightPx >= heightLim) {
|
|
320
|
+
// normal SNP coloring
|
|
321
|
+
ctx.fillStyle = contrastForBase[letter];
|
|
322
|
+
ctx.fillText(letter, leftPx + (w - charWidth) / 2 + 1, topPx + heightPx);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
soffset += len;
|
|
326
|
+
roffset += len;
|
|
318
327
|
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
soffset += len;
|
|
322
|
-
roffset += len;
|
|
323
328
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
var score = scores[soffset + m];
|
|
354
|
-
ctx.fillStyle = "hsl(".concat(score === 255 ? 150 : score * 1.5, ",55%,50%)");
|
|
355
|
-
|
|
356
|
-
var _bpSpanPx5 = (0, _util.bpSpanPx)(start + roffset + m, start + roffset + m + 1, region, bpPerPx),
|
|
357
|
-
_bpSpanPx6 = (0, _slicedToArray2.default)(_bpSpanPx5, 1),
|
|
358
|
-
leftPx = _bpSpanPx6[0];
|
|
359
|
-
|
|
360
|
-
ctx.fillRect(leftPx, topPx, width + 0.5, heightPx);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
soffset += len;
|
|
364
|
-
roffset += len;
|
|
329
|
+
};
|
|
330
|
+
PileupRenderer.prototype.colorByPerBaseQuality = function (_a) {
|
|
331
|
+
var ctx = _a.ctx, feat = _a.feat, region = _a.region, bpPerPx = _a.bpPerPx, canvasWidth = _a.canvasWidth;
|
|
332
|
+
var feature = feat.feature, topPx = feat.topPx, heightPx = feat.heightPx;
|
|
333
|
+
var qual = feature.get('qual') || '';
|
|
334
|
+
var scores = qual.split(' ').map(function (val) { return +val; });
|
|
335
|
+
var cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
|
|
336
|
+
var width = 1 / bpPerPx;
|
|
337
|
+
var start = feature.get('start');
|
|
338
|
+
var soffset = 0; // sequence offset
|
|
339
|
+
var roffset = 0; // reference offset
|
|
340
|
+
for (var i = 0; i < cigarOps.length; i += 2) {
|
|
341
|
+
var len = +cigarOps[i];
|
|
342
|
+
var op = cigarOps[i + 1];
|
|
343
|
+
if (op === 'S' || op === 'I') {
|
|
344
|
+
soffset += len;
|
|
345
|
+
}
|
|
346
|
+
else if (op === 'D' || op === 'N') {
|
|
347
|
+
roffset += len;
|
|
348
|
+
}
|
|
349
|
+
else if (op === 'M' || op === 'X' || op === '=') {
|
|
350
|
+
for (var m = 0; m < len; m++) {
|
|
351
|
+
var score = scores[soffset + m];
|
|
352
|
+
var _b = __read((0, util_1.bpSpanPx)(start + roffset + m, start + roffset + m + 1, region, bpPerPx), 1), leftPx = _b[0];
|
|
353
|
+
fillRect(ctx, leftPx, topPx, width + 0.5, heightPx, canvasWidth, "hsl(".concat(score === 255 ? 150 : score * 1.5, ",55%,50%)"));
|
|
354
|
+
}
|
|
355
|
+
soffset += len;
|
|
356
|
+
roffset += len;
|
|
357
|
+
}
|
|
365
358
|
}
|
|
366
|
-
|
|
367
|
-
|
|
359
|
+
};
|
|
360
|
+
// ML stores probabilities as array of numerics and MP is scaled phred scores
|
|
368
361
|
// https://github.com/samtools/hts-specs/pull/418/files#diff-e765c6479316309f56b636f88189cdde8c40b854c7bdcce9ee7fe87a4e76febcR596
|
|
369
362
|
//
|
|
370
363
|
// if we have ML or Ml, it is an 8bit probability, divide by 255
|
|
@@ -373,811 +366,626 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
|
|
|
373
366
|
// has very high likelihood basecalls at that point, we really only care
|
|
374
367
|
// about low qual calls <20 approx
|
|
375
368
|
//
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
var prob = probabilities[probIndex];
|
|
428
|
-
ctx.fillStyle = prob && prob !== 1 ? base.alpha(prob + 0.1).hsl().string() : col;
|
|
429
|
-
ctx.fillRect(leftPx, topPx, rightPx - leftPx + 0.5, heightPx);
|
|
430
|
-
probIndex++;
|
|
431
|
-
}
|
|
432
|
-
} catch (err) {
|
|
433
|
-
_iterator.e(err);
|
|
434
|
-
} finally {
|
|
435
|
-
_iterator.f();
|
|
369
|
+
PileupRenderer.prototype.colorByModifications = function (_a) {
|
|
370
|
+
var e_1, _b;
|
|
371
|
+
var ctx = _a.ctx, feat = _a.feat, region = _a.region, bpPerPx = _a.bpPerPx, renderArgs = _a.renderArgs, canvasWidth = _a.canvasWidth;
|
|
372
|
+
var feature = feat.feature, topPx = feat.topPx, heightPx = feat.heightPx;
|
|
373
|
+
var Color = renderArgs.Color, _c = renderArgs.modificationTagMap, modificationTagMap = _c === void 0 ? {} : _c;
|
|
374
|
+
var mm = (0, util_2.getTagAlt)(feature, 'MM', 'Mm') || '';
|
|
375
|
+
var ml = (0, util_2.getTagAlt)(feature, 'ML', 'Ml') || [];
|
|
376
|
+
var probabilities = ml
|
|
377
|
+
? (typeof ml === 'string' ? ml.split(',').map(function (e) { return +e; }) : ml).map(function (e) { return e / 255; })
|
|
378
|
+
: (0, util_2.getTagAlt)(feature, 'MP', 'Mp')
|
|
379
|
+
.split('')
|
|
380
|
+
.map(function (s) { return s.charCodeAt(0) - 33; })
|
|
381
|
+
.map(function (elt) { return Math.min(1, elt / 50); });
|
|
382
|
+
var cigar = feature.get('CIGAR');
|
|
383
|
+
var start = feature.get('start');
|
|
384
|
+
var seq = feature.get('seq');
|
|
385
|
+
var strand = feature.get('strand');
|
|
386
|
+
var cigarOps = (0, MismatchParser_1.parseCigar)(cigar);
|
|
387
|
+
var modifications = (0, MismatchParser_1.getModificationPositions)(mm, seq, strand);
|
|
388
|
+
// probIndex applies across multiple modifications e.g.
|
|
389
|
+
var probIndex = 0;
|
|
390
|
+
for (var i = 0; i < modifications.length; i++) {
|
|
391
|
+
var _d = modifications[i], type = _d.type, positions = _d.positions;
|
|
392
|
+
var col = modificationTagMap[type] || 'black';
|
|
393
|
+
// @ts-ignore
|
|
394
|
+
var base = Color(col);
|
|
395
|
+
try {
|
|
396
|
+
for (var _e = (e_1 = void 0, __values((0, MismatchParser_1.getNextRefPos)(cigarOps, positions))), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
397
|
+
var readPos = _f.value;
|
|
398
|
+
var r = start + readPos;
|
|
399
|
+
var _g = __read((0, util_1.bpSpanPx)(r, r + 1, region, bpPerPx), 2), leftPx = _g[0], rightPx = _g[1];
|
|
400
|
+
// give it a little boost of 0.1 to not make them fully
|
|
401
|
+
// invisible to avoid confusion
|
|
402
|
+
var prob = probabilities[probIndex];
|
|
403
|
+
fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, prob && prob !== 1
|
|
404
|
+
? base
|
|
405
|
+
.alpha(prob + 0.1)
|
|
406
|
+
.hsl()
|
|
407
|
+
.string()
|
|
408
|
+
: col);
|
|
409
|
+
probIndex++;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
413
|
+
finally {
|
|
414
|
+
try {
|
|
415
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
416
|
+
}
|
|
417
|
+
finally { if (e_1) throw e_1.error; }
|
|
418
|
+
}
|
|
436
419
|
}
|
|
437
|
-
|
|
438
|
-
|
|
420
|
+
};
|
|
421
|
+
// Color by methylation is slightly modified version of color by
|
|
439
422
|
// modifications that focuses on CpG sites, with non-methylated CpG colored
|
|
440
423
|
// blue
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
var mm = (0, _util2.getTagAlt)(feature, 'MM', 'Mm') || '';
|
|
450
|
-
|
|
451
|
-
if (!regionSequence) {
|
|
452
|
-
throw new Error('region sequence required for methylation');
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
var cigar = feature.get('CIGAR');
|
|
456
|
-
var fstart = feature.get('start');
|
|
457
|
-
var fend = feature.get('end');
|
|
458
|
-
var seq = feature.get('seq');
|
|
459
|
-
var strand = feature.get('strand');
|
|
460
|
-
var cigarOps = (0, _MismatchParser.parseCigar)(cigar);
|
|
461
|
-
var methBins = new Array(region.end - region.start).fill(0);
|
|
462
|
-
var modifications = (0, _MismatchParser.getModificationPositions)(mm, seq, strand);
|
|
463
|
-
|
|
464
|
-
for (var i = 0; i < modifications.length; i++) {
|
|
465
|
-
var _modifications$i2 = modifications[i],
|
|
466
|
-
type = _modifications$i2.type,
|
|
467
|
-
positions = _modifications$i2.positions;
|
|
468
|
-
|
|
469
|
-
if (type === 'm' && positions) {
|
|
470
|
-
var _iterator2 = _createForOfIteratorHelper((0, _MismatchParser.getNextRefPos)(cigarOps, positions)),
|
|
471
|
-
_step2;
|
|
472
|
-
|
|
473
|
-
try {
|
|
474
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
475
|
-
var pos = _step2.value;
|
|
476
|
-
var epos = pos + fstart - region.start;
|
|
477
|
-
|
|
478
|
-
if (epos >= 0 && epos < methBins.length) {
|
|
479
|
-
methBins[epos] = 1;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
} catch (err) {
|
|
483
|
-
_iterator2.e(err);
|
|
484
|
-
} finally {
|
|
485
|
-
_iterator2.f();
|
|
486
|
-
}
|
|
424
|
+
PileupRenderer.prototype.colorByMethylation = function (_a) {
|
|
425
|
+
var e_2, _b;
|
|
426
|
+
var ctx = _a.ctx, feat = _a.feat, region = _a.region, bpPerPx = _a.bpPerPx, renderArgs = _a.renderArgs, canvasWidth = _a.canvasWidth;
|
|
427
|
+
var regionSequence = renderArgs.regionSequence;
|
|
428
|
+
var feature = feat.feature, topPx = feat.topPx, heightPx = feat.heightPx;
|
|
429
|
+
var mm = (0, util_2.getTagAlt)(feature, 'MM', 'Mm') || '';
|
|
430
|
+
if (!regionSequence) {
|
|
431
|
+
throw new Error('region sequence required for methylation');
|
|
487
432
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
var _s = region.start + _i;
|
|
516
|
-
|
|
517
|
-
var _bpSpanPx11 = (0, _util.bpSpanPx)(_s, _s + 1, region, bpPerPx),
|
|
518
|
-
_bpSpanPx12 = (0, _slicedToArray2.default)(_bpSpanPx11, 2),
|
|
519
|
-
_leftPx = _bpSpanPx12[0],
|
|
520
|
-
_rightPx = _bpSpanPx12[1];
|
|
521
|
-
|
|
522
|
-
ctx.fillStyle = methBins[_i] ? 'red' : 'blue';
|
|
523
|
-
ctx.fillRect(_leftPx, topPx, _rightPx - _leftPx + 0.5, heightPx);
|
|
524
|
-
|
|
525
|
-
var _bpSpanPx13 = (0, _util.bpSpanPx)(_s + 1, _s + 2, region, bpPerPx),
|
|
526
|
-
_bpSpanPx14 = (0, _slicedToArray2.default)(_bpSpanPx13, 2),
|
|
527
|
-
leftPx2 = _bpSpanPx14[0],
|
|
528
|
-
rightPx2 = _bpSpanPx14[1];
|
|
529
|
-
|
|
530
|
-
ctx.fillStyle = methBins[_i + 1] ? 'red' : 'blue';
|
|
531
|
-
ctx.fillRect(leftPx2, topPx, rightPx2 - leftPx2 + 0.5, heightPx);
|
|
433
|
+
var cigar = feature.get('CIGAR');
|
|
434
|
+
var fstart = feature.get('start');
|
|
435
|
+
var fend = feature.get('end');
|
|
436
|
+
var seq = feature.get('seq');
|
|
437
|
+
var strand = feature.get('strand');
|
|
438
|
+
var cigarOps = (0, MismatchParser_1.parseCigar)(cigar);
|
|
439
|
+
var methBins = new Array(region.end - region.start).fill(0);
|
|
440
|
+
var modifications = (0, MismatchParser_1.getModificationPositions)(mm, seq, strand);
|
|
441
|
+
for (var i = 0; i < modifications.length; i++) {
|
|
442
|
+
var _c = modifications[i], type = _c.type, positions = _c.positions;
|
|
443
|
+
if (type === 'm' && positions) {
|
|
444
|
+
try {
|
|
445
|
+
for (var _d = (e_2 = void 0, __values((0, MismatchParser_1.getNextRefPos)(cigarOps, positions))), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
446
|
+
var pos = _e.value;
|
|
447
|
+
var epos = pos + fstart - region.start;
|
|
448
|
+
if (epos >= 0 && epos < methBins.length) {
|
|
449
|
+
methBins[epos] = 1;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
454
|
+
finally {
|
|
455
|
+
try {
|
|
456
|
+
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
457
|
+
}
|
|
458
|
+
finally { if (e_2) throw e_2.error; }
|
|
459
|
+
}
|
|
532
460
|
}
|
|
533
|
-
}
|
|
534
461
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
ctx.moveTo(leftPx - 5, topPx + heightPx / 2);
|
|
561
|
-
ctx.lineTo(leftPx, topPx + heightPx);
|
|
562
|
-
ctx.lineTo(rightPx, topPx + heightPx);
|
|
563
|
-
ctx.lineTo(rightPx, topPx);
|
|
564
|
-
ctx.lineTo(leftPx, topPx);
|
|
565
|
-
ctx.closePath();
|
|
566
|
-
ctx.fill();
|
|
567
|
-
} else {
|
|
568
|
-
ctx.beginPath();
|
|
569
|
-
ctx.moveTo(leftPx, topPx);
|
|
570
|
-
ctx.lineTo(leftPx, topPx + heightPx);
|
|
571
|
-
ctx.lineTo(rightPx, topPx + heightPx);
|
|
572
|
-
ctx.lineTo(rightPx + 5, topPx + heightPx / 2);
|
|
573
|
-
ctx.lineTo(rightPx, topPx);
|
|
574
|
-
ctx.closePath();
|
|
575
|
-
ctx.fill();
|
|
462
|
+
for (var j = fstart; j < fend; j++) {
|
|
463
|
+
var i = j - region.start;
|
|
464
|
+
if (i >= 0 && i < methBins.length) {
|
|
465
|
+
var l1 = regionSequence[i].toLowerCase();
|
|
466
|
+
var l2 = regionSequence[i + 1].toLowerCase();
|
|
467
|
+
// if we are zoomed out, display just a block over the cpg
|
|
468
|
+
if (bpPerPx > 2) {
|
|
469
|
+
if (l1 === 'c' && l2 === 'g') {
|
|
470
|
+
var s = region.start + i;
|
|
471
|
+
var _f = __read((0, util_1.bpSpanPx)(s, s + 2, region, bpPerPx), 2), leftPx = _f[0], rightPx = _f[1];
|
|
472
|
+
fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, methBins[i] || methBins[i + 1] ? 'red' : 'blue');
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
// if we are zoomed in, color the c inside the cpg
|
|
476
|
+
else {
|
|
477
|
+
// color
|
|
478
|
+
if (l1 === 'c' && l2 === 'g') {
|
|
479
|
+
var s = region.start + i;
|
|
480
|
+
var _g = __read((0, util_1.bpSpanPx)(s, s + 1, region, bpPerPx), 2), leftPx = _g[0], rightPx = _g[1];
|
|
481
|
+
fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, methBins[i] ? 'red' : 'blue');
|
|
482
|
+
var _h = __read((0, util_1.bpSpanPx)(s + 1, s + 2, region, bpPerPx), 2), leftPx2 = _h[0], rightPx2 = _h[1];
|
|
483
|
+
fillRect(ctx, leftPx2, topPx, rightPx2 - leftPx2 + 0.5, heightPx, canvasWidth, methBins[i + 1] ? 'red' : 'blue');
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
576
487
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
var _ref4 = colorBy || {},
|
|
597
|
-
_ref4$tag = _ref4.tag,
|
|
598
|
-
tag = _ref4$tag === void 0 ? '' : _ref4$tag,
|
|
599
|
-
_ref4$type = _ref4.type,
|
|
600
|
-
colorType = _ref4$type === void 0 ? '' : _ref4$type;
|
|
601
|
-
|
|
602
|
-
var feature = feat.feature;
|
|
603
|
-
var region = regions[0]; // first pass for simple color changes that change the color of the
|
|
604
|
-
// alignment
|
|
605
|
-
|
|
606
|
-
switch (colorType) {
|
|
607
|
-
case 'insertSize':
|
|
608
|
-
ctx.fillStyle = this.colorByInsertSize(feature, config);
|
|
609
|
-
break;
|
|
610
|
-
|
|
611
|
-
case 'strand':
|
|
612
|
-
ctx.fillStyle = feature.get('strand') === -1 ? '#8F8FD8' : '#EC8B8B';
|
|
613
|
-
break;
|
|
614
|
-
|
|
615
|
-
case 'mappingQuality':
|
|
616
|
-
ctx.fillStyle = "hsl(".concat(feature.get('mq'), ",50%,50%)");
|
|
617
|
-
break;
|
|
618
|
-
|
|
619
|
-
case 'pairOrientation':
|
|
620
|
-
ctx.fillStyle = this.colorByOrientation(feature, config);
|
|
621
|
-
break;
|
|
622
|
-
|
|
623
|
-
case 'stranded':
|
|
624
|
-
ctx.fillStyle = alignmentColoring[this.colorByStranded(feature, config)];
|
|
625
|
-
break;
|
|
626
|
-
|
|
627
|
-
case 'xs':
|
|
628
|
-
case 'tag':
|
|
629
|
-
{
|
|
630
|
-
var tags = feature.get('tags');
|
|
631
|
-
var val = tags ? tags[tag] : feature.get(tag); // special for for XS/TS tag
|
|
632
|
-
|
|
633
|
-
if (tag === 'XS' || tag === 'TS') {
|
|
634
|
-
var map = {
|
|
635
|
-
'-': 'color_rev_strand',
|
|
636
|
-
'+': 'color_fwd_strand'
|
|
637
|
-
};
|
|
638
|
-
ctx.fillStyle = alignmentColoring[map[val] || 'color_nostrand'];
|
|
639
|
-
} // lower case 'ts' from minimap2 is flipped from xs
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
if (tag === 'ts') {
|
|
643
|
-
var _map = {
|
|
644
|
-
'-': feature.get('strand') === -1 ? 'color_fwd_strand' : 'color_rev_strand',
|
|
645
|
-
'+': feature.get('strand') === -1 ? 'color_rev_strand' : 'color_fwd_strand'
|
|
646
|
-
};
|
|
647
|
-
ctx.fillStyle = alignmentColoring[_map[val] || 'color_nostrand'];
|
|
648
|
-
} // tag is not one of the autofilled tags, has color-value pairs from
|
|
649
|
-
// fetchValues
|
|
650
|
-
else {
|
|
651
|
-
var foundValue = colorTagMap[val];
|
|
652
|
-
ctx.fillStyle = foundValue || alignmentColoring['color_nostrand'];
|
|
488
|
+
};
|
|
489
|
+
PileupRenderer.prototype.drawRect = function (ctx, feat, props) {
|
|
490
|
+
var regions = props.regions, bpPerPx = props.bpPerPx;
|
|
491
|
+
var heightPx = feat.heightPx, topPx = feat.topPx, feature = feat.feature;
|
|
492
|
+
var _a = __read(regions, 1), region = _a[0];
|
|
493
|
+
var _b = __read((0, util_1.bpSpanPx)(feature.get('start'), feature.get('end'), region, bpPerPx), 2), leftPx = _b[0], rightPx = _b[1];
|
|
494
|
+
var flip = region.reversed ? -1 : 1;
|
|
495
|
+
var strand = feature.get('strand') * flip;
|
|
496
|
+
if (bpPerPx < 10) {
|
|
497
|
+
if (strand === -1) {
|
|
498
|
+
ctx.beginPath();
|
|
499
|
+
ctx.moveTo(leftPx - 5, topPx + heightPx / 2);
|
|
500
|
+
ctx.lineTo(leftPx, topPx + heightPx);
|
|
501
|
+
ctx.lineTo(rightPx, topPx + heightPx);
|
|
502
|
+
ctx.lineTo(rightPx, topPx);
|
|
503
|
+
ctx.lineTo(leftPx, topPx);
|
|
504
|
+
ctx.closePath();
|
|
505
|
+
ctx.fill();
|
|
653
506
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
// this coloring is similar to igv.js, and is helpful to color negative
|
|
664
|
-
// strand reads differently because their c-g will be flipped (e.g. g-c
|
|
665
|
-
// read right to left)
|
|
666
|
-
if (feature.get('flags') & 16) {
|
|
667
|
-
ctx.fillStyle = '#c8dcc8';
|
|
668
|
-
} else {
|
|
669
|
-
ctx.fillStyle = '#c8c8c8';
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
break;
|
|
673
|
-
|
|
674
|
-
case 'normal':
|
|
675
|
-
default:
|
|
676
|
-
if (defaultColor) {
|
|
677
|
-
// avoid a readConfObject call here
|
|
678
|
-
ctx.fillStyle = '#c8c8c8';
|
|
679
|
-
} else {
|
|
680
|
-
ctx.fillStyle = (0, _configuration.readConfObject)(config, 'color', {
|
|
681
|
-
feature: feature
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
break;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
this.drawRect(ctx, feat, props); // second pass for color types that render per-base things that go over the
|
|
689
|
-
// existing drawing
|
|
690
|
-
|
|
691
|
-
switch (colorType) {
|
|
692
|
-
case 'perBaseQuality':
|
|
693
|
-
this.colorByPerBaseQuality(ctx, feat, config, region, bpPerPx);
|
|
694
|
-
break;
|
|
695
|
-
|
|
696
|
-
case 'perBaseLettering':
|
|
697
|
-
this.colorByPerBaseLettering(ctx, feat, config, region, bpPerPx, {
|
|
698
|
-
colorForBase: colorForBase,
|
|
699
|
-
contrastForBase: contrastForBase,
|
|
700
|
-
charWidth: charWidth,
|
|
701
|
-
charHeight: charHeight
|
|
702
|
-
});
|
|
703
|
-
break;
|
|
704
|
-
|
|
705
|
-
case 'modifications':
|
|
706
|
-
this.colorByModifications(ctx, feat, config, region, bpPerPx, props);
|
|
707
|
-
break;
|
|
708
|
-
|
|
709
|
-
case 'methylation':
|
|
710
|
-
this.colorByMethylation(ctx, feat, config, region, bpPerPx, props);
|
|
711
|
-
break;
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}, {
|
|
715
|
-
key: "drawMismatches",
|
|
716
|
-
value: function drawMismatches(ctx, feat, props, opts) {
|
|
717
|
-
var minSubfeatureWidth = opts.minSubfeatureWidth,
|
|
718
|
-
largeInsertionIndicatorScale = opts.largeInsertionIndicatorScale,
|
|
719
|
-
mismatchAlpha = opts.mismatchAlpha,
|
|
720
|
-
_opts$drawSNPs = opts.drawSNPs,
|
|
721
|
-
drawSNPs = _opts$drawSNPs === void 0 ? true : _opts$drawSNPs,
|
|
722
|
-
_opts$drawIndels = opts.drawIndels,
|
|
723
|
-
drawIndels = _opts$drawIndels === void 0 ? true : _opts$drawIndels,
|
|
724
|
-
charWidth = opts.charWidth,
|
|
725
|
-
charHeight = opts.charHeight,
|
|
726
|
-
colorForBase = opts.colorForBase,
|
|
727
|
-
contrastForBase = opts.contrastForBase;
|
|
728
|
-
var bpPerPx = props.bpPerPx,
|
|
729
|
-
regions = props.regions;
|
|
730
|
-
var heightPx = feat.heightPx,
|
|
731
|
-
topPx = feat.topPx,
|
|
732
|
-
feature = feat.feature;
|
|
733
|
-
|
|
734
|
-
var _regions2 = (0, _slicedToArray2.default)(regions, 1),
|
|
735
|
-
region = _regions2[0];
|
|
736
|
-
|
|
737
|
-
var start = feature.get('start');
|
|
738
|
-
var pxPerBp = Math.min(1 / bpPerPx, 2);
|
|
739
|
-
var w = Math.max(minSubfeatureWidth, pxPerBp);
|
|
740
|
-
var mismatches = feature.get('mismatches');
|
|
741
|
-
var heightLim = charHeight - 2; // extraHorizontallyFlippedOffset is used to draw interbase items, which
|
|
742
|
-
// are located to the left when forward and right when reversed
|
|
743
|
-
|
|
744
|
-
var extraHorizontallyFlippedOffset = region.reversed ? 1 / bpPerPx + 1 : -1; // two pass rendering: first pass, draw all the mismatches except wide
|
|
745
|
-
// insertion markers
|
|
746
|
-
|
|
747
|
-
for (var i = 0; i < mismatches.length; i += 1) {
|
|
748
|
-
var mismatch = mismatches[i];
|
|
749
|
-
var mstart = start + mismatch.start;
|
|
750
|
-
var mlen = mismatch.length;
|
|
751
|
-
var mbase = mismatch.base;
|
|
752
|
-
|
|
753
|
-
var _bpSpanPx17 = (0, _util.bpSpanPx)(mstart, mstart + mlen, region, bpPerPx),
|
|
754
|
-
_bpSpanPx18 = (0, _slicedToArray2.default)(_bpSpanPx17, 2),
|
|
755
|
-
leftPx = _bpSpanPx18[0],
|
|
756
|
-
rightPx = _bpSpanPx18[1];
|
|
757
|
-
|
|
758
|
-
var widthPx = Math.max(minSubfeatureWidth, Math.abs(leftPx - rightPx));
|
|
759
|
-
|
|
760
|
-
if (mismatch.type === 'mismatch' && drawSNPs) {
|
|
761
|
-
var baseColor = colorForBase[mismatch.base] || '#888';
|
|
762
|
-
ctx.fillStyle = !mismatchAlpha ? baseColor : mismatch.qual !== undefined ? (0, _color.default)(baseColor).alpha(Math.min(1, mismatch.qual / 50)).hsl().string() : baseColor;
|
|
763
|
-
ctx.fillRect(leftPx, topPx, widthPx, heightPx);
|
|
764
|
-
|
|
765
|
-
if (widthPx >= charWidth && heightPx >= heightLim) {
|
|
766
|
-
// normal SNP coloring
|
|
767
|
-
var contrastColor = contrastForBase[mismatch.base] || 'black';
|
|
768
|
-
ctx.fillStyle = !mismatchAlpha ? contrastColor : mismatch.qual !== undefined ? (0, _color.default)(contrastColor).alpha(Math.min(1, mismatch.qual / 50)).hsl().string() : contrastColor;
|
|
769
|
-
ctx.fillText(mbase, leftPx + (widthPx - charWidth) / 2 + 1, topPx + heightPx);
|
|
770
|
-
}
|
|
771
|
-
} else if (mismatch.type === 'deletion' && drawIndels) {
|
|
772
|
-
var _baseColor = colorForBase.deletion;
|
|
773
|
-
ctx.fillStyle = _baseColor;
|
|
774
|
-
ctx.fillRect(leftPx, topPx, widthPx, heightPx);
|
|
775
|
-
var txt = "".concat(mismatch.length);
|
|
776
|
-
var rwidth = (0, _util.measureText)(txt, 10);
|
|
777
|
-
|
|
778
|
-
if (widthPx >= rwidth && heightPx >= heightLim) {
|
|
779
|
-
ctx.fillStyle = contrastForBase.deletion;
|
|
780
|
-
ctx.fillText(txt, (leftPx + rightPx) / 2 - rwidth / 2, topPx + heightPx);
|
|
781
|
-
}
|
|
782
|
-
} else if (mismatch.type === 'insertion' && drawIndels) {
|
|
783
|
-
ctx.fillStyle = 'purple';
|
|
784
|
-
var pos = leftPx + extraHorizontallyFlippedOffset;
|
|
785
|
-
var len = +mismatch.base || mismatch.length;
|
|
786
|
-
var insW = Math.max(minSubfeatureWidth / 2, Math.min(1.2, 1 / bpPerPx));
|
|
787
|
-
|
|
788
|
-
if (len < 10) {
|
|
789
|
-
ctx.fillRect(pos, topPx, insW, heightPx);
|
|
790
|
-
|
|
791
|
-
if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
|
|
792
|
-
ctx.fillRect(pos - insW, topPx, insW * 3, 1);
|
|
793
|
-
ctx.fillRect(pos - insW, topPx + heightPx - 1, insW * 3, 1);
|
|
794
|
-
ctx.fillText("(".concat(mismatch.base, ")"), pos + 3, topPx + heightPx);
|
|
507
|
+
else {
|
|
508
|
+
ctx.beginPath();
|
|
509
|
+
ctx.moveTo(leftPx, topPx);
|
|
510
|
+
ctx.lineTo(leftPx, topPx + heightPx);
|
|
511
|
+
ctx.lineTo(rightPx, topPx + heightPx);
|
|
512
|
+
ctx.lineTo(rightPx + 5, topPx + heightPx / 2);
|
|
513
|
+
ctx.lineTo(rightPx, topPx);
|
|
514
|
+
ctx.closePath();
|
|
515
|
+
ctx.fill();
|
|
795
516
|
}
|
|
796
|
-
}
|
|
797
|
-
} else if (mismatch.type === 'hardclip' || mismatch.type === 'softclip') {
|
|
798
|
-
ctx.fillStyle = mismatch.type === 'hardclip' ? 'red' : 'blue';
|
|
799
|
-
|
|
800
|
-
var _pos = leftPx + extraHorizontallyFlippedOffset;
|
|
801
|
-
|
|
802
|
-
ctx.fillRect(_pos, topPx, w, heightPx);
|
|
803
|
-
|
|
804
|
-
if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
|
|
805
|
-
ctx.fillRect(_pos - w, topPx, w * 3, 1);
|
|
806
|
-
ctx.fillRect(_pos - w, topPx + heightPx - 1, w * 3, 1);
|
|
807
|
-
ctx.fillText("(".concat(mismatch.base, ")"), _pos + 3, topPx + heightPx);
|
|
808
|
-
}
|
|
809
|
-
} else if (mismatch.type === 'skip') {
|
|
810
|
-
// fix to avoid bad rendering note that this was also related to chrome
|
|
811
|
-
// bug https://bugs.chromium.org/p/chromium/issues/detail?id=1131528
|
|
812
|
-
// also affected firefox ref #1236 #2750
|
|
813
|
-
if (leftPx + widthPx > 0) {
|
|
814
|
-
// make small exons more visible when zoomed far out
|
|
815
|
-
var adjustPx = widthPx - (bpPerPx > 10 ? 1.5 : 0);
|
|
816
|
-
ctx.clearRect(leftPx, topPx, adjustPx, heightPx);
|
|
817
|
-
ctx.fillStyle = '#333';
|
|
818
|
-
ctx.fillRect(Math.max(0, leftPx), topPx + heightPx / 2 - 1, adjustPx + (leftPx < 0 ? leftPx : 0), 2);
|
|
819
|
-
}
|
|
820
517
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
518
|
+
else {
|
|
519
|
+
ctx.fillRect(leftPx, topPx, rightPx - leftPx, heightPx);
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
PileupRenderer.prototype.drawAlignmentRect = function (_a) {
|
|
523
|
+
var ctx = _a.ctx, feat = _a.feat, renderArgs = _a.renderArgs, colorForBase = _a.colorForBase, contrastForBase = _a.contrastForBase, charWidth = _a.charWidth, charHeight = _a.charHeight, defaultColor = _a.defaultColor, canvasWidth = _a.canvasWidth;
|
|
524
|
+
var config = renderArgs.config, bpPerPx = renderArgs.bpPerPx, regions = renderArgs.regions, colorBy = renderArgs.colorBy, _b = renderArgs.colorTagMap, colorTagMap = _b === void 0 ? {} : _b;
|
|
525
|
+
var _c = colorBy || {}, _d = _c.tag, tag = _d === void 0 ? '' : _d, _e = _c.type, colorType = _e === void 0 ? '' : _e;
|
|
526
|
+
var feature = feat.feature;
|
|
527
|
+
var region = regions[0];
|
|
528
|
+
// first pass for simple color changes that change the color of the
|
|
529
|
+
// alignment
|
|
530
|
+
switch (colorType) {
|
|
531
|
+
case 'insertSize':
|
|
532
|
+
ctx.fillStyle = this.colorByInsertSize(feature, config);
|
|
533
|
+
break;
|
|
534
|
+
case 'strand':
|
|
535
|
+
ctx.fillStyle = feature.get('strand') === -1 ? '#8F8FD8' : '#EC8B8B';
|
|
536
|
+
break;
|
|
537
|
+
case 'mappingQuality':
|
|
538
|
+
ctx.fillStyle = "hsl(".concat(feature.get('mq'), ",50%,50%)");
|
|
539
|
+
break;
|
|
540
|
+
case 'pairOrientation':
|
|
541
|
+
ctx.fillStyle = this.colorByOrientation(feature, config);
|
|
542
|
+
break;
|
|
543
|
+
case 'stranded':
|
|
544
|
+
ctx.fillStyle = alignmentColoring[this.colorByStranded(feature, config)];
|
|
545
|
+
break;
|
|
546
|
+
case 'xs':
|
|
547
|
+
case 'tag': {
|
|
548
|
+
var tags = feature.get('tags');
|
|
549
|
+
var val = tags ? tags[tag] : feature.get(tag);
|
|
550
|
+
// special for for XS/TS tag
|
|
551
|
+
if (tag === 'XS' || tag === 'TS') {
|
|
552
|
+
var map = {
|
|
553
|
+
'-': 'color_rev_strand',
|
|
554
|
+
'+': 'color_fwd_strand',
|
|
555
|
+
};
|
|
556
|
+
ctx.fillStyle = alignmentColoring[map[val] || 'color_nostrand'];
|
|
557
|
+
}
|
|
558
|
+
// lower case 'ts' from minimap2 is flipped from xs
|
|
559
|
+
if (tag === 'ts') {
|
|
560
|
+
var map = {
|
|
561
|
+
'-': feature.get('strand') === -1
|
|
562
|
+
? 'color_fwd_strand'
|
|
563
|
+
: 'color_rev_strand',
|
|
564
|
+
'+': feature.get('strand') === -1
|
|
565
|
+
? 'color_rev_strand'
|
|
566
|
+
: 'color_fwd_strand',
|
|
567
|
+
};
|
|
568
|
+
ctx.fillStyle = alignmentColoring[map[val] || 'color_nostrand'];
|
|
569
|
+
}
|
|
570
|
+
// tag is not one of the autofilled tags, has color-value pairs from
|
|
571
|
+
// fetchValues
|
|
572
|
+
else {
|
|
573
|
+
var foundValue = colorTagMap[val];
|
|
574
|
+
ctx.fillStyle = foundValue || alignmentColoring['color_nostrand'];
|
|
575
|
+
}
|
|
576
|
+
break;
|
|
856
577
|
}
|
|
857
|
-
|
|
578
|
+
case 'insertSizeAndPairOrientation':
|
|
579
|
+
break;
|
|
580
|
+
case 'modifications':
|
|
581
|
+
case 'methylation':
|
|
582
|
+
// this coloring is similar to igv.js, and is helpful to color negative
|
|
583
|
+
// strand reads differently because their c-g will be flipped (e.g. g-c
|
|
584
|
+
// read right to left)
|
|
585
|
+
if (feature.get('flags') & 16) {
|
|
586
|
+
ctx.fillStyle = '#c8dcc8';
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
ctx.fillStyle = '#c8c8c8';
|
|
590
|
+
}
|
|
591
|
+
break;
|
|
592
|
+
case 'normal':
|
|
593
|
+
default:
|
|
594
|
+
if (defaultColor) {
|
|
595
|
+
// avoid a readConfObject call here
|
|
596
|
+
ctx.fillStyle = '#c8c8c8';
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
ctx.fillStyle = (0, configuration_1.readConfObject)(config, 'color', { feature: feature });
|
|
600
|
+
}
|
|
601
|
+
break;
|
|
858
602
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
603
|
+
this.drawRect(ctx, feat, renderArgs);
|
|
604
|
+
// second pass for color types that render per-base things that go over the
|
|
605
|
+
// existing drawing
|
|
606
|
+
switch (colorType) {
|
|
607
|
+
case 'perBaseQuality':
|
|
608
|
+
this.colorByPerBaseQuality({
|
|
609
|
+
ctx: ctx,
|
|
610
|
+
feat: feat,
|
|
611
|
+
region: region,
|
|
612
|
+
bpPerPx: bpPerPx,
|
|
613
|
+
canvasWidth: canvasWidth,
|
|
614
|
+
});
|
|
615
|
+
break;
|
|
616
|
+
case 'perBaseLettering':
|
|
617
|
+
this.colorByPerBaseLettering({
|
|
618
|
+
ctx: ctx,
|
|
619
|
+
feat: feat,
|
|
620
|
+
region: region,
|
|
621
|
+
bpPerPx: bpPerPx,
|
|
622
|
+
colorForBase: colorForBase,
|
|
623
|
+
contrastForBase: contrastForBase,
|
|
624
|
+
charWidth: charWidth,
|
|
625
|
+
charHeight: charHeight,
|
|
626
|
+
canvasWidth: canvasWidth,
|
|
627
|
+
});
|
|
628
|
+
break;
|
|
629
|
+
case 'modifications':
|
|
630
|
+
this.colorByModifications({
|
|
631
|
+
ctx: ctx,
|
|
632
|
+
feat: feat,
|
|
633
|
+
region: region,
|
|
634
|
+
bpPerPx: bpPerPx,
|
|
635
|
+
renderArgs: renderArgs,
|
|
636
|
+
canvasWidth: canvasWidth,
|
|
637
|
+
});
|
|
638
|
+
break;
|
|
639
|
+
case 'methylation':
|
|
640
|
+
this.colorByMethylation({
|
|
641
|
+
ctx: ctx,
|
|
642
|
+
feat: feat,
|
|
643
|
+
region: region,
|
|
644
|
+
bpPerPx: bpPerPx,
|
|
645
|
+
renderArgs: renderArgs,
|
|
646
|
+
canvasWidth: canvasWidth,
|
|
647
|
+
});
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
PileupRenderer.prototype.drawMismatches = function (_a) {
|
|
652
|
+
var ctx = _a.ctx, feat = _a.feat, renderArgs = _a.renderArgs, minSubfeatureWidth = _a.minSubfeatureWidth, largeInsertionIndicatorScale = _a.largeInsertionIndicatorScale, mismatchAlpha = _a.mismatchAlpha, charWidth = _a.charWidth, charHeight = _a.charHeight, colorForBase = _a.colorForBase, contrastForBase = _a.contrastForBase, canvasWidth = _a.canvasWidth, drawSNPsMuted = _a.drawSNPsMuted, _b = _a.drawIndels, drawIndels = _b === void 0 ? true : _b;
|
|
653
|
+
var Color = renderArgs.Color, bpPerPx = renderArgs.bpPerPx, regions = renderArgs.regions;
|
|
654
|
+
var heightPx = feat.heightPx, topPx = feat.topPx, feature = feat.feature;
|
|
655
|
+
var _c = __read(regions, 1), region = _c[0];
|
|
656
|
+
var start = feature.get('start');
|
|
657
|
+
var pxPerBp = Math.min(1 / bpPerPx, 2);
|
|
658
|
+
var w = Math.max(minSubfeatureWidth, pxPerBp);
|
|
659
|
+
var mismatches = feature.get('mismatches');
|
|
660
|
+
var heightLim = charHeight - 2;
|
|
661
|
+
// extraHorizontallyFlippedOffset is used to draw interbase items, which
|
|
662
|
+
// are located to the left when forward and right when reversed
|
|
663
|
+
var extraHorizontallyFlippedOffset = region.reversed
|
|
664
|
+
? 1 / bpPerPx + 1
|
|
665
|
+
: -1;
|
|
666
|
+
// two pass rendering: first pass, draw all the mismatches except wide
|
|
667
|
+
// insertion markers
|
|
668
|
+
for (var i = 0; i < mismatches.length; i += 1) {
|
|
669
|
+
var mismatch = mismatches[i];
|
|
670
|
+
var mstart = start + mismatch.start;
|
|
671
|
+
var mlen = mismatch.length;
|
|
672
|
+
var mbase = mismatch.base;
|
|
673
|
+
var _d = __read((0, util_1.bpSpanPx)(mstart, mstart + mlen, region, bpPerPx), 2), leftPx = _d[0], rightPx = _d[1];
|
|
674
|
+
var widthPx = Math.max(minSubfeatureWidth, Math.abs(leftPx - rightPx));
|
|
675
|
+
if (mismatch.type === 'mismatch') {
|
|
676
|
+
if (!drawSNPsMuted) {
|
|
677
|
+
var baseColor = colorForBase[mismatch.base] || '#888';
|
|
678
|
+
fillRect(ctx, leftPx, topPx, widthPx, heightPx, canvasWidth, !mismatchAlpha
|
|
679
|
+
? baseColor
|
|
680
|
+
: mismatch.qual !== undefined
|
|
681
|
+
? // @ts-ignore
|
|
682
|
+
Color(baseColor)
|
|
683
|
+
.alpha(Math.min(1, mismatch.qual / 50))
|
|
684
|
+
.hsl()
|
|
685
|
+
.string()
|
|
686
|
+
: baseColor);
|
|
687
|
+
}
|
|
688
|
+
if (widthPx >= charWidth && heightPx >= heightLim) {
|
|
689
|
+
// normal SNP coloring
|
|
690
|
+
var contrastColor = drawSNPsMuted
|
|
691
|
+
? 'black'
|
|
692
|
+
: contrastForBase[mismatch.base] || 'black';
|
|
693
|
+
ctx.fillStyle = !mismatchAlpha
|
|
694
|
+
? contrastColor
|
|
695
|
+
: mismatch.qual !== undefined
|
|
696
|
+
? // @ts-ignore
|
|
697
|
+
Color(contrastColor)
|
|
698
|
+
.alpha(Math.min(1, mismatch.qual / 50))
|
|
699
|
+
.hsl()
|
|
700
|
+
.string()
|
|
701
|
+
: contrastColor;
|
|
702
|
+
ctx.fillText(mbase, leftPx + (widthPx - charWidth) / 2 + 1, topPx + heightPx);
|
|
703
|
+
}
|
|
904
704
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
705
|
+
else if (mismatch.type === 'deletion' && drawIndels) {
|
|
706
|
+
fillRect(ctx, leftPx, topPx, widthPx, heightPx, canvasWidth, colorForBase.deletion);
|
|
707
|
+
var txt = "".concat(mismatch.length);
|
|
708
|
+
var rwidth = (0, util_1.measureText)(txt, 10);
|
|
709
|
+
if (widthPx >= rwidth && heightPx >= heightLim) {
|
|
710
|
+
ctx.fillStyle = contrastForBase.deletion;
|
|
711
|
+
ctx.fillText(txt, (leftPx + rightPx) / 2 - rwidth / 2, topPx + heightPx);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
else if (mismatch.type === 'insertion' && drawIndels) {
|
|
715
|
+
ctx.fillStyle = 'purple';
|
|
716
|
+
var pos = leftPx + extraHorizontallyFlippedOffset;
|
|
717
|
+
var len = +mismatch.base || mismatch.length;
|
|
718
|
+
var insW = Math.max(minSubfeatureWidth / 2, Math.min(1.2, 1 / bpPerPx));
|
|
719
|
+
if (len < 10) {
|
|
720
|
+
fillRect(ctx, pos, topPx, insW, heightPx, canvasWidth, 'purple');
|
|
721
|
+
if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
|
|
722
|
+
fillRect(ctx, pos - insW, topPx, insW * 3, 1, canvasWidth);
|
|
723
|
+
fillRect(ctx, pos - insW, topPx + heightPx - 1, insW * 3, 1, canvasWidth);
|
|
724
|
+
ctx.fillText("(".concat(mismatch.base, ")"), pos + 3, topPx + heightPx);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
else if (mismatch.type === 'hardclip' || mismatch.type === 'softclip') {
|
|
729
|
+
var pos = leftPx + extraHorizontallyFlippedOffset;
|
|
730
|
+
fillRect(ctx, pos, topPx, w, heightPx, canvasWidth, mismatch.type === 'hardclip' ? 'red' : 'blue');
|
|
731
|
+
if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
|
|
732
|
+
fillRect(ctx, pos - w, topPx, w * 3, 1, canvasWidth);
|
|
733
|
+
fillRect(ctx, pos - w, topPx + heightPx - 1, w * 3, 1, canvasWidth);
|
|
734
|
+
ctx.fillText("(".concat(mismatch.base, ")"), pos + 3, topPx + heightPx);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
else if (mismatch.type === 'skip') {
|
|
738
|
+
// fix to avoid bad rendering note that this was also related to chrome
|
|
739
|
+
// bug https://bugs.chromium.org/p/chromium/issues/detail?id=1131528
|
|
740
|
+
// also affected firefox ref #1236 #2750
|
|
741
|
+
if (leftPx + widthPx > 0) {
|
|
742
|
+
// make small exons more visible when zoomed far out
|
|
743
|
+
var adjustPx = widthPx - (bpPerPx > 10 ? 1.5 : 0);
|
|
744
|
+
ctx.clearRect(leftPx, topPx, adjustPx, heightPx);
|
|
745
|
+
fillRect(ctx, Math.max(0, leftPx), topPx + heightPx / 2 - 1, adjustPx + (leftPx < 0 ? leftPx : 0), 2, canvasWidth, '#333');
|
|
746
|
+
}
|
|
921
747
|
}
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
}, {
|
|
927
|
-
key: "makeImageData",
|
|
928
|
-
value: function makeImageData(ctx, layoutRecords, props) {
|
|
929
|
-
var layout = props.layout,
|
|
930
|
-
config = props.config,
|
|
931
|
-
showSoftClip = props.showSoftClip,
|
|
932
|
-
colorBy = props.colorBy,
|
|
933
|
-
configTheme = props.theme;
|
|
934
|
-
var mismatchAlpha = (0, _configuration.readConfObject)(config, 'mismatchAlpha');
|
|
935
|
-
var minSubfeatureWidth = (0, _configuration.readConfObject)(config, 'minSubfeatureWidth');
|
|
936
|
-
var largeInsertionIndicatorScale = (0, _configuration.readConfObject)(config, 'largeInsertionIndicatorScale');
|
|
937
|
-
var defaultColor = (0, _configuration.readConfObject)(config, 'color') === '#f0f';
|
|
938
|
-
var theme = (0, _ui.createJBrowseTheme)(configTheme);
|
|
939
|
-
var colorForBase = getColorBaseMap(theme);
|
|
940
|
-
var contrastForBase = getContrastBaseMap(theme);
|
|
941
|
-
|
|
942
|
-
if (!layout) {
|
|
943
|
-
throw new Error("layout required");
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
if (!layout.addRect) {
|
|
947
|
-
throw new Error('invalid layout object');
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
ctx.font = 'bold 10px Courier New,monospace';
|
|
951
|
-
|
|
952
|
-
var _this$getCharWidthHei2 = this.getCharWidthHeight(ctx),
|
|
953
|
-
charWidth = _this$getCharWidthHei2.charWidth,
|
|
954
|
-
charHeight = _this$getCharWidthHei2.charHeight;
|
|
955
|
-
|
|
956
|
-
var drawSNPs = shouldDrawSNPs(colorBy === null || colorBy === void 0 ? void 0 : colorBy.type);
|
|
957
|
-
var drawIndels = shouldDrawIndels(colorBy === null || colorBy === void 0 ? void 0 : colorBy.type);
|
|
958
|
-
|
|
959
|
-
for (var i = 0; i < layoutRecords.length; i++) {
|
|
960
|
-
var feat = layoutRecords[i];
|
|
961
|
-
|
|
962
|
-
if (feat === null) {
|
|
963
|
-
continue;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
this.drawAlignmentRect(ctx, feat, _objectSpread(_objectSpread({}, props), {}, {
|
|
967
|
-
defaultColor: defaultColor,
|
|
968
|
-
colorForBase: colorForBase,
|
|
969
|
-
contrastForBase: contrastForBase,
|
|
970
|
-
charWidth: charWidth,
|
|
971
|
-
charHeight: charHeight
|
|
972
|
-
}));
|
|
973
|
-
this.drawMismatches(ctx, feat, props, {
|
|
974
|
-
mismatchAlpha: mismatchAlpha,
|
|
975
|
-
drawSNPs: drawSNPs,
|
|
976
|
-
drawIndels: drawIndels,
|
|
977
|
-
largeInsertionIndicatorScale: largeInsertionIndicatorScale,
|
|
978
|
-
minSubfeatureWidth: minSubfeatureWidth,
|
|
979
|
-
charWidth: charWidth,
|
|
980
|
-
charHeight: charHeight,
|
|
981
|
-
colorForBase: colorForBase,
|
|
982
|
-
contrastForBase: contrastForBase
|
|
983
|
-
});
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
if (showSoftClip) {
|
|
987
|
-
for (var _i3 = 0; _i3 < layoutRecords.length; _i3++) {
|
|
988
|
-
var _feat = layoutRecords[_i3];
|
|
989
|
-
|
|
990
|
-
if (_feat === null) {
|
|
991
|
-
continue;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
this.drawSoftClipping(ctx, _feat, props, config, theme);
|
|
995
748
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
if (!layout.addRect) {
|
|
1021
|
-
throw new Error('invalid layout object');
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
var featureMap = sortedBy !== null && sortedBy !== void 0 && sortedBy.type && region.start === sortedBy.pos ? (0, _sortUtil.sortFeature)(features, sortedBy) : features;
|
|
1025
|
-
var heightPx = (0, _configuration.readConfObject)(config, 'height');
|
|
1026
|
-
var displayMode = (0, _configuration.readConfObject)(config, 'displayMode');
|
|
1027
|
-
return (0, _util.iterMap)(featureMap.values(), function (feature) {
|
|
1028
|
-
return _this2.layoutFeature({
|
|
1029
|
-
feature: feature,
|
|
1030
|
-
layout: layout,
|
|
1031
|
-
bpPerPx: bpPerPx,
|
|
1032
|
-
region: region,
|
|
1033
|
-
showSoftClip: showSoftClip,
|
|
1034
|
-
heightPx: heightPx,
|
|
1035
|
-
displayMode: displayMode
|
|
1036
|
-
});
|
|
1037
|
-
}, featureMap.size);
|
|
1038
|
-
}
|
|
1039
|
-
}, {
|
|
1040
|
-
key: "fetchSequence",
|
|
1041
|
-
value: function () {
|
|
1042
|
-
var _fetchSequence2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(renderProps) {
|
|
1043
|
-
var sessionId, regions, adapterConfig, sequenceAdapter, _yield$getAdapter, dataAdapter, _regions5, region;
|
|
1044
|
-
|
|
1045
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
1046
|
-
while (1) {
|
|
1047
|
-
switch (_context.prev = _context.next) {
|
|
1048
|
-
case 0:
|
|
1049
|
-
sessionId = renderProps.sessionId, regions = renderProps.regions, adapterConfig = renderProps.adapterConfig;
|
|
1050
|
-
sequenceAdapter = adapterConfig.sequenceAdapter;
|
|
1051
|
-
|
|
1052
|
-
if (sequenceAdapter) {
|
|
1053
|
-
_context.next = 4;
|
|
1054
|
-
break;
|
|
749
|
+
// second pass, draw wide insertion markers on top
|
|
750
|
+
if (drawIndels) {
|
|
751
|
+
for (var i = 0; i < mismatches.length; i += 1) {
|
|
752
|
+
var mismatch = mismatches[i];
|
|
753
|
+
var mstart = start + mismatch.start;
|
|
754
|
+
var mlen = mismatch.length;
|
|
755
|
+
var _e = __read((0, util_1.bpSpanPx)(mstart, mstart + mlen, region, bpPerPx), 1), leftPx = _e[0];
|
|
756
|
+
var len = +mismatch.base || mismatch.length;
|
|
757
|
+
var txt = "".concat(len);
|
|
758
|
+
if (mismatch.type === 'insertion' && len >= 10) {
|
|
759
|
+
if (bpPerPx > largeInsertionIndicatorScale) {
|
|
760
|
+
fillRect(ctx, leftPx - 1, topPx, 2, heightPx, canvasWidth, 'purple');
|
|
761
|
+
}
|
|
762
|
+
else if (heightPx > charHeight) {
|
|
763
|
+
var rwidth = (0, util_1.measureText)(txt);
|
|
764
|
+
var padding = 5;
|
|
765
|
+
fillRect(ctx, leftPx - rwidth / 2 - padding, topPx, rwidth + 2 * padding, heightPx, canvasWidth, 'purple');
|
|
766
|
+
ctx.fillStyle = 'white';
|
|
767
|
+
ctx.fillText(txt, leftPx - rwidth / 2, topPx + heightPx);
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
var padding = 2;
|
|
771
|
+
fillRect(ctx, leftPx - padding, topPx, 2 * padding, heightPx, canvasWidth, 'purple');
|
|
772
|
+
}
|
|
1055
773
|
}
|
|
1056
|
-
|
|
1057
|
-
return _context.abrupt("return", undefined);
|
|
1058
|
-
|
|
1059
|
-
case 4:
|
|
1060
|
-
_context.next = 6;
|
|
1061
|
-
return (0, _dataAdapterCache.getAdapter)(this.pluginManager, sessionId, sequenceAdapter);
|
|
1062
|
-
|
|
1063
|
-
case 6:
|
|
1064
|
-
_yield$getAdapter = _context.sent;
|
|
1065
|
-
dataAdapter = _yield$getAdapter.dataAdapter;
|
|
1066
|
-
_regions5 = (0, _slicedToArray2.default)(regions, 1), region = _regions5[0];
|
|
1067
|
-
return _context.abrupt("return", (0, _util2.fetchSequence)(region, dataAdapter));
|
|
1068
|
-
|
|
1069
|
-
case 10:
|
|
1070
|
-
case "end":
|
|
1071
|
-
return _context.stop();
|
|
1072
774
|
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
PileupRenderer.prototype.drawSoftClipping = function (_a) {
|
|
778
|
+
var ctx = _a.ctx, feat = _a.feat, renderArgs = _a.renderArgs, config = _a.config, theme = _a.theme, canvasWidth = _a.canvasWidth;
|
|
779
|
+
var feature = feat.feature, topPx = feat.topPx, heightPx = feat.heightPx;
|
|
780
|
+
var regions = renderArgs.regions, bpPerPx = renderArgs.bpPerPx;
|
|
781
|
+
var _b = __read(regions, 1), region = _b[0];
|
|
782
|
+
var minFeatWidth = (0, configuration_1.readConfObject)(config, 'minSubfeatureWidth');
|
|
783
|
+
var mismatches = feature.get('mismatches');
|
|
784
|
+
var seq = feature.get('seq');
|
|
785
|
+
var _c = this.getCharWidthHeight(ctx), charWidth = _c.charWidth, charHeight = _c.charHeight;
|
|
786
|
+
// @ts-ignore
|
|
787
|
+
var bases = theme.palette.bases;
|
|
788
|
+
var colorForBase = {
|
|
789
|
+
A: bases.A.main,
|
|
790
|
+
C: bases.C.main,
|
|
791
|
+
G: bases.G.main,
|
|
792
|
+
T: bases.T.main,
|
|
793
|
+
deletion: '#808080', // gray
|
|
794
|
+
};
|
|
795
|
+
// Display all bases softclipped off in lightened colors
|
|
796
|
+
if (seq) {
|
|
797
|
+
mismatches
|
|
798
|
+
.filter(function (mismatch) { return mismatch.type === 'softclip'; })
|
|
799
|
+
.forEach(function (mismatch) {
|
|
800
|
+
var softClipLength = mismatch.cliplen || 0;
|
|
801
|
+
var s = feature.get('start');
|
|
802
|
+
var softClipStart = mismatch.start === 0 ? s - softClipLength : s + mismatch.start;
|
|
803
|
+
for (var k = 0; k < softClipLength; k += 1) {
|
|
804
|
+
var base = seq.charAt(k + mismatch.start);
|
|
805
|
+
// If softclip length+start is longer than sequence, no need to
|
|
806
|
+
// continue showing base
|
|
807
|
+
if (!base) {
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
var _a = __read((0, util_1.bpSpanPx)(softClipStart + k, softClipStart + k + 1, region, bpPerPx), 2), softClipLeftPx = _a[0], softClipRightPx = _a[1];
|
|
811
|
+
var softClipWidthPx = Math.max(minFeatWidth, Math.abs(softClipLeftPx - softClipRightPx));
|
|
812
|
+
// Black accounts for IUPAC ambiguity code bases such as N that
|
|
813
|
+
// show in soft clipping
|
|
814
|
+
var baseColor = colorForBase[base] || '#000000';
|
|
815
|
+
ctx.fillStyle = baseColor;
|
|
816
|
+
fillRect(ctx, softClipLeftPx, topPx, softClipWidthPx, heightPx, canvasWidth);
|
|
817
|
+
if (softClipWidthPx >= charWidth && heightPx >= charHeight - 5) {
|
|
818
|
+
ctx.fillStyle = theme.palette.getContrastText(baseColor);
|
|
819
|
+
ctx.fillText(base, softClipLeftPx + (softClipWidthPx - charWidth) / 2 + 1, topPx + heightPx);
|
|
820
|
+
}
|
|
1113
821
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
PileupRenderer.prototype.makeImageData = function (_a) {
|
|
826
|
+
var ctx = _a.ctx, layoutRecords = _a.layoutRecords, canvasWidth = _a.canvasWidth, renderArgs = _a.renderArgs;
|
|
827
|
+
var layout = renderArgs.layout, config = renderArgs.config, showSoftClip = renderArgs.showSoftClip, colorBy = renderArgs.colorBy, configTheme = renderArgs.theme;
|
|
828
|
+
var mismatchAlpha = (0, configuration_1.readConfObject)(config, 'mismatchAlpha');
|
|
829
|
+
var minSubfeatureWidth = (0, configuration_1.readConfObject)(config, 'minSubfeatureWidth');
|
|
830
|
+
var largeInsertionIndicatorScale = (0, configuration_1.readConfObject)(config, 'largeInsertionIndicatorScale');
|
|
831
|
+
var defaultColor = (0, configuration_1.readConfObject)(config, 'color') === '#f0f';
|
|
832
|
+
var theme = (0, ui_1.createJBrowseTheme)(configTheme);
|
|
833
|
+
var colorForBase = getColorBaseMap(theme);
|
|
834
|
+
var contrastForBase = getContrastBaseMap(theme);
|
|
835
|
+
if (!layout) {
|
|
836
|
+
throw new Error("layout required");
|
|
837
|
+
}
|
|
838
|
+
if (!layout.addRect) {
|
|
839
|
+
throw new Error('invalid layout object');
|
|
840
|
+
}
|
|
841
|
+
ctx.font = 'bold 10px Courier New,monospace';
|
|
842
|
+
var _b = this.getCharWidthHeight(ctx), charWidth = _b.charWidth, charHeight = _b.charHeight;
|
|
843
|
+
var drawSNPsMuted = shouldDrawSNPsMuted(colorBy === null || colorBy === void 0 ? void 0 : colorBy.type);
|
|
844
|
+
var drawIndels = shouldDrawIndels(colorBy === null || colorBy === void 0 ? void 0 : colorBy.type);
|
|
845
|
+
for (var i = 0; i < layoutRecords.length; i++) {
|
|
846
|
+
var feat = layoutRecords[i];
|
|
847
|
+
if (feat === null) {
|
|
848
|
+
continue;
|
|
849
|
+
}
|
|
850
|
+
this.drawAlignmentRect({
|
|
851
|
+
ctx: ctx,
|
|
852
|
+
feat: feat,
|
|
853
|
+
renderArgs: renderArgs,
|
|
854
|
+
defaultColor: defaultColor,
|
|
855
|
+
colorForBase: colorForBase,
|
|
856
|
+
contrastForBase: contrastForBase,
|
|
857
|
+
charWidth: charWidth,
|
|
858
|
+
charHeight: charHeight,
|
|
859
|
+
canvasWidth: canvasWidth,
|
|
860
|
+
});
|
|
861
|
+
this.drawMismatches({
|
|
862
|
+
ctx: ctx,
|
|
863
|
+
feat: feat,
|
|
864
|
+
renderArgs: renderArgs,
|
|
865
|
+
mismatchAlpha: mismatchAlpha,
|
|
866
|
+
drawSNPsMuted: drawSNPsMuted,
|
|
867
|
+
drawIndels: drawIndels,
|
|
868
|
+
largeInsertionIndicatorScale: largeInsertionIndicatorScale,
|
|
869
|
+
minSubfeatureWidth: minSubfeatureWidth,
|
|
870
|
+
charWidth: charWidth,
|
|
871
|
+
charHeight: charHeight,
|
|
872
|
+
colorForBase: colorForBase,
|
|
873
|
+
contrastForBase: contrastForBase,
|
|
874
|
+
canvasWidth: canvasWidth,
|
|
875
|
+
});
|
|
876
|
+
if (showSoftClip) {
|
|
877
|
+
this.drawSoftClipping({
|
|
878
|
+
ctx: ctx,
|
|
879
|
+
feat: feat,
|
|
880
|
+
renderArgs: renderArgs,
|
|
881
|
+
config: config,
|
|
882
|
+
theme: theme,
|
|
883
|
+
canvasWidth: canvasWidth,
|
|
1138
884
|
});
|
|
1139
|
-
|
|
1140
|
-
case 20:
|
|
1141
|
-
res = _context2.sent;
|
|
1142
|
-
_context2.next = 23;
|
|
1143
|
-
return (0, _get2.default)((0, _getPrototypeOf2.default)(PileupRenderer.prototype), "render", this).call(this, _objectSpread(_objectSpread(_objectSpread({}, renderProps), res), {}, {
|
|
1144
|
-
features: features,
|
|
1145
|
-
layout: layout,
|
|
1146
|
-
height: height,
|
|
1147
|
-
width: width
|
|
1148
|
-
}));
|
|
1149
|
-
|
|
1150
|
-
case 23:
|
|
1151
|
-
results = _context2.sent;
|
|
1152
|
-
return _context2.abrupt("return", _objectSpread(_objectSpread(_objectSpread({}, results), res), {}, {
|
|
1153
|
-
features: new Map(),
|
|
1154
|
-
layout: layout,
|
|
1155
|
-
height: height,
|
|
1156
|
-
width: width,
|
|
1157
|
-
maxHeightReached: layout.maxHeightReached
|
|
1158
|
-
}));
|
|
1159
|
-
|
|
1160
|
-
case 25:
|
|
1161
|
-
case "end":
|
|
1162
|
-
return _context2.stop();
|
|
1163
885
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
// we perform a full layout before render as a separate method because the
|
|
889
|
+
// layout determines the height of the canvas that we use to render
|
|
890
|
+
PileupRenderer.prototype.layoutFeats = function (props) {
|
|
891
|
+
var _this = this;
|
|
892
|
+
var layout = props.layout, features = props.features, sortedBy = props.sortedBy, config = props.config, bpPerPx = props.bpPerPx, showSoftClip = props.showSoftClip, regions = props.regions;
|
|
893
|
+
var _a = __read(regions, 1), region = _a[0];
|
|
894
|
+
if (!layout) {
|
|
895
|
+
throw new Error("layout required");
|
|
896
|
+
}
|
|
897
|
+
if (!layout.addRect) {
|
|
898
|
+
throw new Error('invalid layout object');
|
|
899
|
+
}
|
|
900
|
+
var featureMap = (sortedBy === null || sortedBy === void 0 ? void 0 : sortedBy.type) && region.start === sortedBy.pos
|
|
901
|
+
? (0, sortUtil_1.sortFeature)(features, sortedBy)
|
|
902
|
+
: features;
|
|
903
|
+
var heightPx = (0, configuration_1.readConfObject)(config, 'height');
|
|
904
|
+
var displayMode = (0, configuration_1.readConfObject)(config, 'displayMode');
|
|
905
|
+
return (0, util_1.iterMap)(featureMap.values(), function (feature) {
|
|
906
|
+
return _this.layoutFeature({
|
|
907
|
+
feature: feature,
|
|
908
|
+
layout: layout,
|
|
909
|
+
bpPerPx: bpPerPx,
|
|
910
|
+
region: region,
|
|
911
|
+
showSoftClip: showSoftClip,
|
|
912
|
+
heightPx: heightPx,
|
|
913
|
+
displayMode: displayMode,
|
|
914
|
+
});
|
|
915
|
+
}, featureMap.size);
|
|
916
|
+
};
|
|
917
|
+
PileupRenderer.prototype.fetchSequence = function (renderProps) {
|
|
918
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
919
|
+
var sessionId, regions, adapterConfig, sequenceAdapter, dataAdapter, _a, region;
|
|
920
|
+
return __generator(this, function (_b) {
|
|
921
|
+
switch (_b.label) {
|
|
922
|
+
case 0:
|
|
923
|
+
sessionId = renderProps.sessionId, regions = renderProps.regions, adapterConfig = renderProps.adapterConfig;
|
|
924
|
+
sequenceAdapter = adapterConfig.sequenceAdapter;
|
|
925
|
+
if (!sequenceAdapter) {
|
|
926
|
+
return [2 /*return*/, undefined];
|
|
927
|
+
}
|
|
928
|
+
return [4 /*yield*/, (0, dataAdapterCache_1.getAdapter)(this.pluginManager, sessionId, sequenceAdapter)];
|
|
929
|
+
case 1:
|
|
930
|
+
dataAdapter = (_b.sent()).dataAdapter;
|
|
931
|
+
_a = __read(regions, 1), region = _a[0];
|
|
932
|
+
return [2 /*return*/, (0, util_2.fetchSequence)(region, dataAdapter)];
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
};
|
|
937
|
+
PileupRenderer.prototype.render = function (renderProps) {
|
|
938
|
+
var _a;
|
|
939
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
940
|
+
var features, layout, regions, bpPerPx, layoutRecords, _b, region, regionSequence, _c, end, start, width, height, Color, res, results;
|
|
941
|
+
var _this = this;
|
|
942
|
+
return __generator(this, function (_d) {
|
|
943
|
+
switch (_d.label) {
|
|
944
|
+
case 0: return [4 /*yield*/, this.getFeatures(renderProps)];
|
|
945
|
+
case 1:
|
|
946
|
+
features = _d.sent();
|
|
947
|
+
layout = this.createLayoutInWorker(renderProps);
|
|
948
|
+
regions = renderProps.regions, bpPerPx = renderProps.bpPerPx;
|
|
949
|
+
layoutRecords = this.layoutFeats(__assign(__assign({}, renderProps), { features: features, layout: layout }));
|
|
950
|
+
_b = __read(regions, 1), region = _b[0];
|
|
951
|
+
if (!(features.size && (0, util_2.shouldFetchReferenceSequence)((_a = renderProps.colorBy) === null || _a === void 0 ? void 0 : _a.type))) return [3 /*break*/, 3];
|
|
952
|
+
return [4 /*yield*/, this.fetchSequence(renderProps)];
|
|
953
|
+
case 2:
|
|
954
|
+
_c = _d.sent();
|
|
955
|
+
return [3 /*break*/, 4];
|
|
956
|
+
case 3:
|
|
957
|
+
_c = undefined;
|
|
958
|
+
_d.label = 4;
|
|
959
|
+
case 4:
|
|
960
|
+
regionSequence = _c;
|
|
961
|
+
end = region.end, start = region.start;
|
|
962
|
+
width = (end - start) / bpPerPx;
|
|
963
|
+
height = Math.max(layout.getTotalHeight(), 1);
|
|
964
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('color')); }).then(function (f) { return f.default; })];
|
|
965
|
+
case 5:
|
|
966
|
+
Color = _d.sent();
|
|
967
|
+
return [4 /*yield*/, (0, offscreenCanvasUtils_1.renderToAbstractCanvas)(width, height, renderProps, function (ctx) {
|
|
968
|
+
return _this.makeImageData({
|
|
969
|
+
ctx: ctx,
|
|
970
|
+
layoutRecords: layoutRecords,
|
|
971
|
+
canvasWidth: width,
|
|
972
|
+
renderArgs: __assign(__assign({}, renderProps), { layout: layout, features: features, regionSequence: regionSequence, Color: Color }),
|
|
973
|
+
});
|
|
974
|
+
})];
|
|
975
|
+
case 6:
|
|
976
|
+
res = _d.sent();
|
|
977
|
+
return [4 /*yield*/, _super.prototype.render.call(this, __assign(__assign(__assign({}, renderProps), res), { features: features, layout: layout, height: height, width: width }))];
|
|
978
|
+
case 7:
|
|
979
|
+
results = _d.sent();
|
|
980
|
+
return [2 /*return*/, __assign(__assign(__assign({}, results), res), { features: new Map(), layout: layout, height: height, width: width, maxHeightReached: layout.maxHeightReached })];
|
|
981
|
+
}
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
PileupRenderer.prototype.createSession = function (args) {
|
|
986
|
+
return new PileupLayoutSession_1.PileupLayoutSession(args);
|
|
987
|
+
};
|
|
988
|
+
return PileupRenderer;
|
|
989
|
+
}(BoxRendererType_1.default));
|
|
990
|
+
exports.default = PileupRenderer;
|
|
991
|
+
//# sourceMappingURL=PileupRenderer.js.map
|