@jbrowse/plugin-alignments 2.1.0 → 2.1.2
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 +61 -90
- package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.js.map +1 -1
- package/dist/AlignmentsFeatureDetail/index.js +14 -16
- package/dist/AlignmentsFeatureDetail/index.js.map +1 -1
- package/dist/AlignmentsTrack/index.js +8 -8
- package/dist/AlignmentsTrack/index.js.map +1 -1
- package/dist/BamAdapter/BamAdapter.js +157 -336
- package/dist/BamAdapter/BamAdapter.js.map +1 -1
- package/dist/BamAdapter/BamSlightlyLazyFeature.js +68 -103
- package/dist/BamAdapter/BamSlightlyLazyFeature.js.map +1 -1
- package/dist/BamAdapter/MismatchParser.js +96 -162
- package/dist/BamAdapter/MismatchParser.js.map +1 -1
- package/dist/BamAdapter/configSchema.js +27 -29
- package/dist/BamAdapter/configSchema.js.map +1 -1
- package/dist/BamAdapter/index.js +9 -11
- package/dist/BamAdapter/index.js.map +1 -1
- package/dist/CramAdapter/CramAdapter.js +193 -351
- package/dist/CramAdapter/CramAdapter.js.map +1 -1
- package/dist/CramAdapter/CramSlightlyLazyFeature.js +119 -154
- package/dist/CramAdapter/CramSlightlyLazyFeature.js.map +1 -1
- package/dist/CramAdapter/CramTestAdapters.js +51 -148
- package/dist/CramAdapter/CramTestAdapters.js.map +1 -1
- package/dist/CramAdapter/configSchema.js +23 -25
- package/dist/CramAdapter/configSchema.js.map +1 -1
- package/dist/CramAdapter/index.js +9 -11
- package/dist/CramAdapter/index.js.map +1 -1
- package/dist/HtsgetBamAdapter/HtsgetBamAdapter.js +25 -87
- package/dist/HtsgetBamAdapter/HtsgetBamAdapter.js.map +1 -1
- package/dist/HtsgetBamAdapter/configSchema.js +16 -18
- package/dist/HtsgetBamAdapter/configSchema.js.map +1 -1
- package/dist/HtsgetBamAdapter/index.js +15 -19
- package/dist/HtsgetBamAdapter/index.js.map +1 -1
- package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js +14 -15
- package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.js.map +1 -1
- package/dist/LinearAlignmentsDisplay/index.js +7 -7
- package/dist/LinearAlignmentsDisplay/index.js.map +1 -1
- package/dist/LinearAlignmentsDisplay/models/configSchema.js +5 -5
- package/dist/LinearAlignmentsDisplay/models/configSchema.js.map +1 -1
- package/dist/LinearAlignmentsDisplay/models/model.js +64 -140
- package/dist/LinearAlignmentsDisplay/models/model.js.map +1 -1
- package/dist/LinearPileupDisplay/components/ColorByModifications.js +24 -53
- package/dist/LinearPileupDisplay/components/ColorByModifications.js.map +1 -1
- package/dist/LinearPileupDisplay/components/ColorByTag.js +14 -30
- package/dist/LinearPileupDisplay/components/ColorByTag.js.map +1 -1
- package/dist/LinearPileupDisplay/components/FilterByTag.js +33 -49
- package/dist/LinearPileupDisplay/components/FilterByTag.js.map +1 -1
- package/dist/LinearPileupDisplay/components/LinearPileupDisplayBlurb.js +7 -7
- package/dist/LinearPileupDisplay/components/LinearPileupDisplayBlurb.js.map +1 -1
- package/dist/LinearPileupDisplay/components/SetFeatureHeight.js +17 -33
- package/dist/LinearPileupDisplay/components/SetFeatureHeight.js.map +1 -1
- package/dist/LinearPileupDisplay/components/SetMaxHeight.js +14 -30
- package/dist/LinearPileupDisplay/components/SetMaxHeight.js.map +1 -1
- package/dist/LinearPileupDisplay/components/SortByTag.js +14 -30
- package/dist/LinearPileupDisplay/components/SortByTag.js.map +1 -1
- package/dist/LinearPileupDisplay/configSchema.js +4 -4
- package/dist/LinearPileupDisplay/configSchema.js.map +1 -1
- package/dist/LinearPileupDisplay/index.js +7 -7
- package/dist/LinearPileupDisplay/index.js.map +1 -1
- package/dist/LinearPileupDisplay/model.d.ts +2 -2
- package/dist/LinearPileupDisplay/model.js +534 -644
- package/dist/LinearPileupDisplay/model.js.map +1 -1
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.d.ts +1 -1
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.js +30 -78
- package/dist/LinearSNPCoverageDisplay/components/Tooltip.js.map +1 -1
- package/dist/LinearSNPCoverageDisplay/index.js +7 -7
- package/dist/LinearSNPCoverageDisplay/index.js.map +1 -1
- package/dist/LinearSNPCoverageDisplay/models/configSchema.js +4 -4
- package/dist/LinearSNPCoverageDisplay/models/configSchema.js.map +1 -1
- package/dist/LinearSNPCoverageDisplay/models/model.d.ts +1 -1
- package/dist/LinearSNPCoverageDisplay/models/model.js +170 -244
- package/dist/LinearSNPCoverageDisplay/models/model.js.map +1 -1
- package/dist/NestedFrequencyTable.js +27 -40
- package/dist/NestedFrequencyTable.js.map +1 -1
- package/dist/PileupRPC/rpcMethods.js +63 -191
- package/dist/PileupRPC/rpcMethods.js.map +1 -1
- package/dist/PileupRenderer/PileupLayoutSession.js +25 -47
- package/dist/PileupRenderer/PileupLayoutSession.js.map +1 -1
- package/dist/PileupRenderer/PileupRenderer.js +395 -529
- package/dist/PileupRenderer/PileupRenderer.js.map +1 -1
- package/dist/PileupRenderer/components/PileupRendering.js +41 -68
- package/dist/PileupRenderer/components/PileupRendering.js.map +1 -1
- package/dist/PileupRenderer/configSchema.js +2 -2
- package/dist/PileupRenderer/configSchema.js.map +1 -1
- package/dist/PileupRenderer/index.js +9 -11
- package/dist/PileupRenderer/index.js.map +1 -1
- package/dist/PileupRenderer/sortUtil.js +36 -40
- package/dist/PileupRenderer/sortUtil.js.map +1 -1
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js +229 -415
- package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js.map +1 -1
- package/dist/SNPCoverageAdapter/configSchema.js +5 -9
- package/dist/SNPCoverageAdapter/configSchema.js.map +1 -1
- package/dist/SNPCoverageAdapter/index.js +17 -21
- package/dist/SNPCoverageAdapter/index.js.map +1 -1
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.js +175 -259
- package/dist/SNPCoverageRenderer/SNPCoverageRenderer.js.map +1 -1
- package/dist/SNPCoverageRenderer/configSchema.js +1 -1
- package/dist/SNPCoverageRenderer/configSchema.js.map +1 -1
- package/dist/SNPCoverageRenderer/index.js +10 -12
- package/dist/SNPCoverageRenderer/index.js.map +1 -1
- package/dist/index.js +40 -58
- package/dist/index.js.map +1 -1
- package/dist/shared.js +23 -78
- package/dist/shared.js.map +1 -1
- package/dist/util.js +13 -66
- package/dist/util.js.map +1 -1
- package/esm/LinearPileupDisplay/model.d.ts +2 -2
- package/esm/LinearSNPCoverageDisplay/models/model.d.ts +1 -1
- package/esm/PileupRenderer/PileupRenderer.js +0 -2
- package/esm/PileupRenderer/PileupRenderer.js.map +1 -1
- package/esm/SNPCoverageRenderer/SNPCoverageRenderer.js +0 -1
- package/esm/SNPCoverageRenderer/SNPCoverageRenderer.js.map +1 -1
- package/package.json +2 -3
- package/src/AlignmentsFeatureDetail/__snapshots__/index.test.js.snap +12 -12
- package/src/PileupRenderer/PileupRenderer.tsx +0 -2
- package/src/SNPCoverageRenderer/SNPCoverageRenderer.ts +0 -1
|
@@ -1,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
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
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
3
|
if (k2 === undefined) k2 = k;
|
|
30
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,84 +22,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
48
22
|
__setModuleDefault(result, mod);
|
|
49
23
|
return result;
|
|
50
24
|
};
|
|
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
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
115
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
116
27
|
};
|
|
117
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
29
|
+
const BoxRendererType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType"));
|
|
30
|
+
const ui_1 = require("@jbrowse/core/ui");
|
|
31
|
+
const util_1 = require("@jbrowse/core/util");
|
|
32
|
+
const offscreenCanvasUtils_1 = require("@jbrowse/core/util/offscreenCanvasUtils");
|
|
33
|
+
const dataAdapterCache_1 = require("@jbrowse/core/data_adapters/dataAdapterCache");
|
|
34
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
124
35
|
// locals
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
36
|
+
const MismatchParser_1 = require("../BamAdapter/MismatchParser");
|
|
37
|
+
const sortUtil_1 = require("./sortUtil");
|
|
38
|
+
const util_2 = require("../util");
|
|
39
|
+
const PileupLayoutSession_1 = require("./PileupLayoutSession");
|
|
129
40
|
function fillRect(ctx, l, t, w, h, cw, color) {
|
|
130
41
|
if (l + w < 0 || l > cw) {
|
|
131
42
|
return;
|
|
@@ -138,8 +49,7 @@ function fillRect(ctx, l, t, w, h, cw, color) {
|
|
|
138
49
|
}
|
|
139
50
|
}
|
|
140
51
|
function getColorBaseMap(theme) {
|
|
141
|
-
|
|
142
|
-
var bases = theme.palette.bases;
|
|
52
|
+
const { bases } = theme.palette;
|
|
143
53
|
return {
|
|
144
54
|
A: bases.A.main,
|
|
145
55
|
C: bases.C.main,
|
|
@@ -149,15 +59,12 @@ function getColorBaseMap(theme) {
|
|
|
149
59
|
};
|
|
150
60
|
}
|
|
151
61
|
function getContrastBaseMap(theme) {
|
|
152
|
-
return Object.fromEntries(Object.entries(getColorBaseMap(theme)).map(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
theme.palette.getContrastText(value),
|
|
157
|
-
];
|
|
158
|
-
}));
|
|
62
|
+
return Object.fromEntries(Object.entries(getColorBaseMap(theme)).map(([key, value]) => [
|
|
63
|
+
key,
|
|
64
|
+
theme.palette.getContrastText(value),
|
|
65
|
+
]));
|
|
159
66
|
}
|
|
160
|
-
|
|
67
|
+
const alignmentColoring = {
|
|
161
68
|
color_fwd_strand_not_proper: '#ECC8C8',
|
|
162
69
|
color_rev_strand_not_proper: '#BEBED8',
|
|
163
70
|
color_fwd_strand: '#EC8B8B',
|
|
@@ -181,31 +88,28 @@ function shouldDrawSNPsMuted(type) {
|
|
|
181
88
|
function shouldDrawIndels(type) {
|
|
182
89
|
return true;
|
|
183
90
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
_this.supportsSVG = true;
|
|
189
|
-
return _this;
|
|
91
|
+
class PileupRenderer extends BoxRendererType_1.default {
|
|
92
|
+
constructor() {
|
|
93
|
+
super(...arguments);
|
|
94
|
+
this.supportsSVG = true;
|
|
190
95
|
}
|
|
191
96
|
// get width and height of chars the height is an approximation: width
|
|
192
97
|
// letter M is approximately the height
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return { charWidth
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
var expansionAfter = 0;
|
|
98
|
+
getCharWidthHeight(ctx) {
|
|
99
|
+
const charWidth = (0, util_1.measureText)('A');
|
|
100
|
+
const charHeight = (0, util_1.measureText)('M') - 2;
|
|
101
|
+
return { charWidth, charHeight };
|
|
102
|
+
}
|
|
103
|
+
layoutFeature({ feature, layout, bpPerPx, region, showSoftClip, heightPx, displayMode, }) {
|
|
104
|
+
let expansionBefore = 0;
|
|
105
|
+
let expansionAfter = 0;
|
|
202
106
|
// Expand the start and end of feature when softclipping enabled
|
|
203
107
|
if (showSoftClip) {
|
|
204
|
-
|
|
205
|
-
|
|
108
|
+
const mismatches = feature.get('mismatches');
|
|
109
|
+
const seq = feature.get('seq');
|
|
206
110
|
if (seq) {
|
|
207
|
-
for (
|
|
208
|
-
|
|
111
|
+
for (let i = 0; i < mismatches.length; i += 1) {
|
|
112
|
+
const { type, start, cliplen = 0 } = mismatches[i];
|
|
209
113
|
if (type === 'softclip') {
|
|
210
114
|
start === 0
|
|
211
115
|
? (expansionBefore = cliplen)
|
|
@@ -214,64 +118,69 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
214
118
|
}
|
|
215
119
|
}
|
|
216
120
|
}
|
|
217
|
-
|
|
121
|
+
const [leftPx, rightPx] = (0, util_1.bpSpanPx)(feature.get('start') - expansionBefore, feature.get('end') + expansionAfter, region, bpPerPx);
|
|
218
122
|
if (displayMode === 'compact') {
|
|
219
123
|
heightPx /= 3;
|
|
220
124
|
}
|
|
221
125
|
if (feature.get('refName') !== region.refName) {
|
|
222
|
-
throw new Error(
|
|
126
|
+
throw new Error(`feature ${feature.id()} is not on the current region's reference sequence ${region.refName}`);
|
|
223
127
|
}
|
|
224
|
-
|
|
128
|
+
const topPx = layout.addRect(feature.id(), feature.get('start') - expansionBefore, feature.get('end') + expansionAfter, heightPx, feature);
|
|
225
129
|
if (topPx === null) {
|
|
226
130
|
return null;
|
|
227
131
|
}
|
|
228
132
|
return {
|
|
229
|
-
feature
|
|
230
|
-
leftPx
|
|
231
|
-
rightPx
|
|
133
|
+
feature,
|
|
134
|
+
leftPx,
|
|
135
|
+
rightPx,
|
|
232
136
|
topPx: displayMode === 'collapse' ? 0 : topPx,
|
|
233
|
-
heightPx
|
|
137
|
+
heightPx,
|
|
234
138
|
};
|
|
235
|
-
}
|
|
139
|
+
}
|
|
236
140
|
// expands region for clipping to use. possible improvement: use average read
|
|
237
141
|
// size to set the heuristic maxClippingSize expansion (e.g. short reads
|
|
238
142
|
// don't have to expand a softclipping size a lot, but long reads might)
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
return
|
|
246
|
-
|
|
247
|
-
|
|
143
|
+
getExpandedRegion(region, renderArgs) {
|
|
144
|
+
const { config, showSoftClip } = renderArgs;
|
|
145
|
+
const maxClippingSize = (0, configuration_1.readConfObject)(config, 'maxClippingSize');
|
|
146
|
+
const { start, end } = region;
|
|
147
|
+
const len = end - start;
|
|
148
|
+
const bpExpansion = Math.max(len, showSoftClip ? Math.round(maxClippingSize) : 0);
|
|
149
|
+
return {
|
|
150
|
+
// xref https://github.com/mobxjs/mobx-state-tree/issues/1524 for Omit
|
|
151
|
+
...region,
|
|
152
|
+
start: Math.floor(Math.max(start - bpExpansion, 0)),
|
|
153
|
+
end: Math.ceil(end + bpExpansion),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
colorByOrientation(feature, config) {
|
|
248
157
|
return alignmentColoring[this.getOrientation(feature, config) || 'color_nostrand'];
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
158
|
+
}
|
|
159
|
+
getOrientation(feature, config) {
|
|
160
|
+
const orientationType = (0, configuration_1.readConfObject)(config, 'orientationType');
|
|
161
|
+
const type = util_2.orientationTypes[orientationType];
|
|
162
|
+
const orientation = type[feature.get('pair_orientation')];
|
|
163
|
+
const map = {
|
|
255
164
|
LR: 'color_pair_lr',
|
|
256
165
|
RR: 'color_pair_rr',
|
|
257
166
|
RL: 'color_pair_rl',
|
|
258
167
|
LL: 'color_pair_ll',
|
|
259
168
|
};
|
|
260
169
|
return map[orientation];
|
|
261
|
-
}
|
|
262
|
-
|
|
170
|
+
}
|
|
171
|
+
colorByInsertSize(feature, _config) {
|
|
263
172
|
return feature.get('is_paired') &&
|
|
264
173
|
feature.get('seq_id') !== feature.get('next_seq_id')
|
|
265
174
|
? '#555'
|
|
266
|
-
:
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
175
|
+
: `hsl(${Math.abs(feature.get('template_length')) / 10},50%,50%)`;
|
|
176
|
+
}
|
|
177
|
+
colorByStranded(feature, _config) {
|
|
178
|
+
const flags = feature.get('flags');
|
|
179
|
+
const strand = feature.get('strand');
|
|
271
180
|
// is paired
|
|
272
181
|
if (flags & 1) {
|
|
273
|
-
|
|
274
|
-
|
|
182
|
+
const revflag = flags & 64;
|
|
183
|
+
const flipper = revflag ? -1 : 1;
|
|
275
184
|
// proper pairing
|
|
276
185
|
if (flags & 2) {
|
|
277
186
|
return strand * flipper === 1 ? 'color_rev_strand' : 'color_fwd_strand';
|
|
@@ -290,20 +199,19 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
290
199
|
return strand === 1 ? 'color_fwd_diff_chr' : 'color_rev_diff_chr';
|
|
291
200
|
}
|
|
292
201
|
return strand === 1 ? 'color_fwd_strand' : 'color_rev_strand';
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
var op = cigarOps[i + 1];
|
|
202
|
+
}
|
|
203
|
+
colorByPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, }) {
|
|
204
|
+
const heightLim = charHeight - 2;
|
|
205
|
+
const { feature, topPx, heightPx } = feat;
|
|
206
|
+
const seq = feature.get('seq');
|
|
207
|
+
const cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
|
|
208
|
+
const w = 1 / bpPerPx;
|
|
209
|
+
const start = feature.get('start');
|
|
210
|
+
let soffset = 0; // sequence offset
|
|
211
|
+
let roffset = 0; // reference offset
|
|
212
|
+
for (let i = 0; i < cigarOps.length; i += 2) {
|
|
213
|
+
const len = +cigarOps[i];
|
|
214
|
+
const op = cigarOps[i + 1];
|
|
307
215
|
if (op === 'S' || op === 'I') {
|
|
308
216
|
soffset += len;
|
|
309
217
|
}
|
|
@@ -311,10 +219,10 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
311
219
|
roffset += len;
|
|
312
220
|
}
|
|
313
221
|
else if (op === 'M' || op === 'X' || op === '=') {
|
|
314
|
-
for (
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
222
|
+
for (let m = 0; m < len; m++) {
|
|
223
|
+
const letter = seq[soffset + m];
|
|
224
|
+
const r = start + roffset + m;
|
|
225
|
+
const [leftPx] = (0, util_1.bpSpanPx)(r, r + 1, region, bpPerPx);
|
|
318
226
|
fillRect(ctx, leftPx, topPx, w + 0.5, heightPx, canvasWidth, colorForBase[letter]);
|
|
319
227
|
if (w >= charWidth && heightPx >= heightLim) {
|
|
320
228
|
// normal SNP coloring
|
|
@@ -326,20 +234,19 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
326
234
|
roffset += len;
|
|
327
235
|
}
|
|
328
236
|
}
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
var op = cigarOps[i + 1];
|
|
237
|
+
}
|
|
238
|
+
colorByPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, }) {
|
|
239
|
+
const { feature, topPx, heightPx } = feat;
|
|
240
|
+
const qual = feature.get('qual') || '';
|
|
241
|
+
const scores = qual.split(' ').map(val => +val);
|
|
242
|
+
const cigarOps = (0, MismatchParser_1.parseCigar)(feature.get('CIGAR'));
|
|
243
|
+
const width = 1 / bpPerPx;
|
|
244
|
+
const start = feature.get('start');
|
|
245
|
+
let soffset = 0; // sequence offset
|
|
246
|
+
let roffset = 0; // reference offset
|
|
247
|
+
for (let i = 0; i < cigarOps.length; i += 2) {
|
|
248
|
+
const len = +cigarOps[i];
|
|
249
|
+
const op = cigarOps[i + 1];
|
|
343
250
|
if (op === 'S' || op === 'I') {
|
|
344
251
|
soffset += len;
|
|
345
252
|
}
|
|
@@ -347,16 +254,16 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
347
254
|
roffset += len;
|
|
348
255
|
}
|
|
349
256
|
else if (op === 'M' || op === 'X' || op === '=') {
|
|
350
|
-
for (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
fillRect(ctx, leftPx, topPx, width + 0.5, heightPx, canvasWidth,
|
|
257
|
+
for (let m = 0; m < len; m++) {
|
|
258
|
+
const score = scores[soffset + m];
|
|
259
|
+
const [leftPx] = (0, util_1.bpSpanPx)(start + roffset + m, start + roffset + m + 1, region, bpPerPx);
|
|
260
|
+
fillRect(ctx, leftPx, topPx, width + 0.5, heightPx, canvasWidth, `hsl(${score === 255 ? 150 : score * 1.5},55%,50%)`);
|
|
354
261
|
}
|
|
355
262
|
soffset += len;
|
|
356
263
|
roffset += len;
|
|
357
264
|
}
|
|
358
265
|
}
|
|
359
|
-
}
|
|
266
|
+
}
|
|
360
267
|
// ML stores probabilities as array of numerics and MP is scaled phred scores
|
|
361
268
|
// https://github.com/samtools/hts-specs/pull/418/files#diff-e765c6479316309f56b636f88189cdde8c40b854c7bdcce9ee7fe87a4e76febcR596
|
|
362
269
|
//
|
|
@@ -366,109 +273,85 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
366
273
|
// has very high likelihood basecalls at that point, we really only care
|
|
367
274
|
// about low qual calls <20 approx
|
|
368
275
|
//
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
var probabilities = ml
|
|
377
|
-
? (typeof ml === 'string' ? ml.split(',').map(function (e) { return +e; }) : ml).map(function (e) { return e / 255; })
|
|
276
|
+
colorByModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, }) {
|
|
277
|
+
const { feature, topPx, heightPx } = feat;
|
|
278
|
+
const { Color, modificationTagMap = {} } = renderArgs;
|
|
279
|
+
const mm = (0, util_2.getTagAlt)(feature, 'MM', 'Mm') || '';
|
|
280
|
+
const ml = (0, util_2.getTagAlt)(feature, 'ML', 'Ml') || [];
|
|
281
|
+
const probabilities = ml
|
|
282
|
+
? (typeof ml === 'string' ? ml.split(',').map(e => +e) : ml).map(e => e / 255)
|
|
378
283
|
: (0, util_2.getTagAlt)(feature, 'MP', 'Mp')
|
|
379
284
|
.split('')
|
|
380
|
-
.map(
|
|
381
|
-
.map(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
285
|
+
.map(s => s.charCodeAt(0) - 33)
|
|
286
|
+
.map(elt => Math.min(1, elt / 50));
|
|
287
|
+
const cigar = feature.get('CIGAR');
|
|
288
|
+
const start = feature.get('start');
|
|
289
|
+
const seq = feature.get('seq');
|
|
290
|
+
const strand = feature.get('strand');
|
|
291
|
+
const cigarOps = (0, MismatchParser_1.parseCigar)(cigar);
|
|
292
|
+
const modifications = (0, MismatchParser_1.getModificationPositions)(mm, seq, strand);
|
|
388
293
|
// probIndex applies across multiple modifications e.g.
|
|
389
|
-
|
|
390
|
-
for (
|
|
391
|
-
|
|
392
|
-
|
|
294
|
+
let probIndex = 0;
|
|
295
|
+
for (let i = 0; i < modifications.length; i++) {
|
|
296
|
+
const { type, positions } = modifications[i];
|
|
297
|
+
const col = modificationTagMap[type] || 'black';
|
|
393
298
|
// @ts-ignore
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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; }
|
|
299
|
+
const base = Color(col);
|
|
300
|
+
for (const readPos of (0, MismatchParser_1.getNextRefPos)(cigarOps, positions)) {
|
|
301
|
+
const r = start + readPos;
|
|
302
|
+
const [leftPx, rightPx] = (0, util_1.bpSpanPx)(r, r + 1, region, bpPerPx);
|
|
303
|
+
// give it a little boost of 0.1 to not make them fully
|
|
304
|
+
// invisible to avoid confusion
|
|
305
|
+
const prob = probabilities[probIndex];
|
|
306
|
+
fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, prob && prob !== 1
|
|
307
|
+
? base
|
|
308
|
+
.alpha(prob + 0.1)
|
|
309
|
+
.hsl()
|
|
310
|
+
.string()
|
|
311
|
+
: col);
|
|
312
|
+
probIndex++;
|
|
418
313
|
}
|
|
419
314
|
}
|
|
420
|
-
}
|
|
315
|
+
}
|
|
421
316
|
// Color by methylation is slightly modified version of color by
|
|
422
317
|
// modifications that focuses on CpG sites, with non-methylated CpG colored
|
|
423
318
|
// blue
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
var feature = feat.feature, topPx = feat.topPx, heightPx = feat.heightPx;
|
|
429
|
-
var mm = (0, util_2.getTagAlt)(feature, 'MM', 'Mm') || '';
|
|
319
|
+
colorByMethylation({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, }) {
|
|
320
|
+
const { regionSequence } = renderArgs;
|
|
321
|
+
const { feature, topPx, heightPx } = feat;
|
|
322
|
+
const mm = (0, util_2.getTagAlt)(feature, 'MM', 'Mm') || '';
|
|
430
323
|
if (!regionSequence) {
|
|
431
324
|
throw new Error('region sequence required for methylation');
|
|
432
325
|
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
for (
|
|
442
|
-
|
|
326
|
+
const cigar = feature.get('CIGAR');
|
|
327
|
+
const fstart = feature.get('start');
|
|
328
|
+
const fend = feature.get('end');
|
|
329
|
+
const seq = feature.get('seq');
|
|
330
|
+
const strand = feature.get('strand');
|
|
331
|
+
const cigarOps = (0, MismatchParser_1.parseCigar)(cigar);
|
|
332
|
+
const methBins = new Array(region.end - region.start).fill(0);
|
|
333
|
+
const modifications = (0, MismatchParser_1.getModificationPositions)(mm, seq, strand);
|
|
334
|
+
for (let i = 0; i < modifications.length; i++) {
|
|
335
|
+
const { type, positions } = modifications[i];
|
|
443
336
|
if (type === 'm' && positions) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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);
|
|
337
|
+
for (const pos of (0, MismatchParser_1.getNextRefPos)(cigarOps, positions)) {
|
|
338
|
+
const epos = pos + fstart - region.start;
|
|
339
|
+
if (epos >= 0 && epos < methBins.length) {
|
|
340
|
+
methBins[epos] = 1;
|
|
457
341
|
}
|
|
458
|
-
finally { if (e_2) throw e_2.error; }
|
|
459
342
|
}
|
|
460
343
|
}
|
|
461
344
|
}
|
|
462
|
-
for (
|
|
463
|
-
|
|
345
|
+
for (let j = fstart; j < fend; j++) {
|
|
346
|
+
const i = j - region.start;
|
|
464
347
|
if (i >= 0 && i < methBins.length) {
|
|
465
|
-
|
|
466
|
-
|
|
348
|
+
const l1 = regionSequence[i].toLowerCase();
|
|
349
|
+
const l2 = regionSequence[i + 1].toLowerCase();
|
|
467
350
|
// if we are zoomed out, display just a block over the cpg
|
|
468
351
|
if (bpPerPx > 2) {
|
|
469
352
|
if (l1 === 'c' && l2 === 'g') {
|
|
470
|
-
|
|
471
|
-
|
|
353
|
+
const s = region.start + i;
|
|
354
|
+
const [leftPx, rightPx] = (0, util_1.bpSpanPx)(s, s + 2, region, bpPerPx);
|
|
472
355
|
fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, methBins[i] || methBins[i + 1] ? 'red' : 'blue');
|
|
473
356
|
}
|
|
474
357
|
}
|
|
@@ -476,23 +359,23 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
476
359
|
else {
|
|
477
360
|
// color
|
|
478
361
|
if (l1 === 'c' && l2 === 'g') {
|
|
479
|
-
|
|
480
|
-
|
|
362
|
+
const s = region.start + i;
|
|
363
|
+
const [leftPx, rightPx] = (0, util_1.bpSpanPx)(s, s + 1, region, bpPerPx);
|
|
481
364
|
fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, methBins[i] ? 'red' : 'blue');
|
|
482
|
-
|
|
365
|
+
const [leftPx2, rightPx2] = (0, util_1.bpSpanPx)(s + 1, s + 2, region, bpPerPx);
|
|
483
366
|
fillRect(ctx, leftPx2, topPx, rightPx2 - leftPx2 + 0.5, heightPx, canvasWidth, methBins[i + 1] ? 'red' : 'blue');
|
|
484
367
|
}
|
|
485
368
|
}
|
|
486
369
|
}
|
|
487
370
|
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
371
|
+
}
|
|
372
|
+
drawRect(ctx, feat, props) {
|
|
373
|
+
const { regions, bpPerPx } = props;
|
|
374
|
+
const { heightPx, topPx, feature } = feat;
|
|
375
|
+
const [region] = regions;
|
|
376
|
+
const [leftPx, rightPx] = (0, util_1.bpSpanPx)(feature.get('start'), feature.get('end'), region, bpPerPx);
|
|
377
|
+
const flip = region.reversed ? -1 : 1;
|
|
378
|
+
const strand = feature.get('strand') * flip;
|
|
496
379
|
if (bpPerPx < 10) {
|
|
497
380
|
if (strand === -1) {
|
|
498
381
|
ctx.beginPath();
|
|
@@ -518,13 +401,12 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
518
401
|
else {
|
|
519
402
|
ctx.fillRect(leftPx, topPx, rightPx - leftPx, heightPx);
|
|
520
403
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
var region = regions[0];
|
|
404
|
+
}
|
|
405
|
+
drawAlignmentRect({ ctx, feat, renderArgs, colorForBase, contrastForBase, charWidth, charHeight, defaultColor, canvasWidth, }) {
|
|
406
|
+
const { config, bpPerPx, regions, colorBy, colorTagMap = {} } = renderArgs;
|
|
407
|
+
const { tag = '', type: colorType = '' } = colorBy || {};
|
|
408
|
+
const { feature } = feat;
|
|
409
|
+
const region = regions[0];
|
|
528
410
|
// first pass for simple color changes that change the color of the
|
|
529
411
|
// alignment
|
|
530
412
|
switch (colorType) {
|
|
@@ -535,7 +417,7 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
535
417
|
ctx.fillStyle = feature.get('strand') === -1 ? '#8F8FD8' : '#EC8B8B';
|
|
536
418
|
break;
|
|
537
419
|
case 'mappingQuality':
|
|
538
|
-
ctx.fillStyle =
|
|
420
|
+
ctx.fillStyle = `hsl(${feature.get('mq')},50%,50%)`;
|
|
539
421
|
break;
|
|
540
422
|
case 'pairOrientation':
|
|
541
423
|
ctx.fillStyle = this.colorByOrientation(feature, config);
|
|
@@ -545,11 +427,11 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
545
427
|
break;
|
|
546
428
|
case 'xs':
|
|
547
429
|
case 'tag': {
|
|
548
|
-
|
|
549
|
-
|
|
430
|
+
const tags = feature.get('tags');
|
|
431
|
+
const val = tags ? tags[tag] : feature.get(tag);
|
|
550
432
|
// special for for XS/TS tag
|
|
551
433
|
if (tag === 'XS' || tag === 'TS') {
|
|
552
|
-
|
|
434
|
+
const map = {
|
|
553
435
|
'-': 'color_rev_strand',
|
|
554
436
|
'+': 'color_fwd_strand',
|
|
555
437
|
};
|
|
@@ -557,7 +439,7 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
557
439
|
}
|
|
558
440
|
// lower case 'ts' from minimap2 is flipped from xs
|
|
559
441
|
if (tag === 'ts') {
|
|
560
|
-
|
|
442
|
+
const map = {
|
|
561
443
|
'-': feature.get('strand') === -1
|
|
562
444
|
? 'color_fwd_strand'
|
|
563
445
|
: 'color_rev_strand',
|
|
@@ -570,7 +452,7 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
570
452
|
// tag is not one of the autofilled tags, has color-value pairs from
|
|
571
453
|
// fetchValues
|
|
572
454
|
else {
|
|
573
|
-
|
|
455
|
+
const foundValue = colorTagMap[val];
|
|
574
456
|
ctx.fillStyle = foundValue || alignmentColoring['color_nostrand'];
|
|
575
457
|
}
|
|
576
458
|
break;
|
|
@@ -596,7 +478,7 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
596
478
|
ctx.fillStyle = '#c8c8c8';
|
|
597
479
|
}
|
|
598
480
|
else {
|
|
599
|
-
ctx.fillStyle = (0, configuration_1.readConfObject)(config, 'color', { feature
|
|
481
|
+
ctx.fillStyle = (0, configuration_1.readConfObject)(config, 'color', { feature });
|
|
600
482
|
}
|
|
601
483
|
break;
|
|
602
484
|
}
|
|
@@ -606,75 +488,74 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
606
488
|
switch (colorType) {
|
|
607
489
|
case 'perBaseQuality':
|
|
608
490
|
this.colorByPerBaseQuality({
|
|
609
|
-
ctx
|
|
610
|
-
feat
|
|
611
|
-
region
|
|
612
|
-
bpPerPx
|
|
613
|
-
canvasWidth
|
|
491
|
+
ctx,
|
|
492
|
+
feat,
|
|
493
|
+
region,
|
|
494
|
+
bpPerPx,
|
|
495
|
+
canvasWidth,
|
|
614
496
|
});
|
|
615
497
|
break;
|
|
616
498
|
case 'perBaseLettering':
|
|
617
499
|
this.colorByPerBaseLettering({
|
|
618
|
-
ctx
|
|
619
|
-
feat
|
|
620
|
-
region
|
|
621
|
-
bpPerPx
|
|
622
|
-
colorForBase
|
|
623
|
-
contrastForBase
|
|
624
|
-
charWidth
|
|
625
|
-
charHeight
|
|
626
|
-
canvasWidth
|
|
500
|
+
ctx,
|
|
501
|
+
feat,
|
|
502
|
+
region,
|
|
503
|
+
bpPerPx,
|
|
504
|
+
colorForBase,
|
|
505
|
+
contrastForBase,
|
|
506
|
+
charWidth,
|
|
507
|
+
charHeight,
|
|
508
|
+
canvasWidth,
|
|
627
509
|
});
|
|
628
510
|
break;
|
|
629
511
|
case 'modifications':
|
|
630
512
|
this.colorByModifications({
|
|
631
|
-
ctx
|
|
632
|
-
feat
|
|
633
|
-
region
|
|
634
|
-
bpPerPx
|
|
635
|
-
renderArgs
|
|
636
|
-
canvasWidth
|
|
513
|
+
ctx,
|
|
514
|
+
feat,
|
|
515
|
+
region,
|
|
516
|
+
bpPerPx,
|
|
517
|
+
renderArgs,
|
|
518
|
+
canvasWidth,
|
|
637
519
|
});
|
|
638
520
|
break;
|
|
639
521
|
case 'methylation':
|
|
640
522
|
this.colorByMethylation({
|
|
641
|
-
ctx
|
|
642
|
-
feat
|
|
643
|
-
region
|
|
644
|
-
bpPerPx
|
|
645
|
-
renderArgs
|
|
646
|
-
canvasWidth
|
|
523
|
+
ctx,
|
|
524
|
+
feat,
|
|
525
|
+
region,
|
|
526
|
+
bpPerPx,
|
|
527
|
+
renderArgs,
|
|
528
|
+
canvasWidth,
|
|
647
529
|
});
|
|
648
530
|
break;
|
|
649
531
|
}
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
var heightLim = charHeight - 2;
|
|
532
|
+
}
|
|
533
|
+
drawMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInsertionIndicatorScale, mismatchAlpha, charWidth, charHeight, colorForBase, contrastForBase, canvasWidth, drawSNPsMuted, drawIndels = true, }) {
|
|
534
|
+
const { Color, bpPerPx, regions } = renderArgs;
|
|
535
|
+
const { heightPx, topPx, feature } = feat;
|
|
536
|
+
const [region] = regions;
|
|
537
|
+
const start = feature.get('start');
|
|
538
|
+
const pxPerBp = Math.min(1 / bpPerPx, 2);
|
|
539
|
+
const w = Math.max(minSubfeatureWidth, pxPerBp);
|
|
540
|
+
const mismatches = feature.get('mismatches');
|
|
541
|
+
const heightLim = charHeight - 2;
|
|
661
542
|
// extraHorizontallyFlippedOffset is used to draw interbase items, which
|
|
662
543
|
// are located to the left when forward and right when reversed
|
|
663
|
-
|
|
544
|
+
const extraHorizontallyFlippedOffset = region.reversed
|
|
664
545
|
? 1 / bpPerPx + 1
|
|
665
546
|
: -1;
|
|
666
547
|
// two pass rendering: first pass, draw all the mismatches except wide
|
|
667
548
|
// insertion markers
|
|
668
|
-
for (
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
549
|
+
for (let i = 0; i < mismatches.length; i += 1) {
|
|
550
|
+
const mismatch = mismatches[i];
|
|
551
|
+
const mstart = start + mismatch.start;
|
|
552
|
+
const mlen = mismatch.length;
|
|
553
|
+
const mbase = mismatch.base;
|
|
554
|
+
const [leftPx, rightPx] = (0, util_1.bpSpanPx)(mstart, mstart + mlen, region, bpPerPx);
|
|
555
|
+
const widthPx = Math.max(minSubfeatureWidth, Math.abs(leftPx - rightPx));
|
|
675
556
|
if (mismatch.type === 'mismatch') {
|
|
676
557
|
if (!drawSNPsMuted) {
|
|
677
|
-
|
|
558
|
+
const baseColor = colorForBase[mismatch.base] || '#888';
|
|
678
559
|
fillRect(ctx, leftPx, topPx, widthPx, heightPx, canvasWidth, !mismatchAlpha
|
|
679
560
|
? baseColor
|
|
680
561
|
: mismatch.qual !== undefined
|
|
@@ -687,7 +568,7 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
687
568
|
}
|
|
688
569
|
if (widthPx >= charWidth && heightPx >= heightLim) {
|
|
689
570
|
// normal SNP coloring
|
|
690
|
-
|
|
571
|
+
const contrastColor = drawSNPsMuted
|
|
691
572
|
? 'black'
|
|
692
573
|
: contrastForBase[mismatch.base] || 'black';
|
|
693
574
|
ctx.fillStyle = !mismatchAlpha
|
|
@@ -704,8 +585,8 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
704
585
|
}
|
|
705
586
|
else if (mismatch.type === 'deletion' && drawIndels) {
|
|
706
587
|
fillRect(ctx, leftPx, topPx, widthPx, heightPx, canvasWidth, colorForBase.deletion);
|
|
707
|
-
|
|
708
|
-
|
|
588
|
+
const txt = `${mismatch.length}`;
|
|
589
|
+
const rwidth = (0, util_1.measureText)(txt, 10);
|
|
709
590
|
if (widthPx >= rwidth && heightPx >= heightLim) {
|
|
710
591
|
ctx.fillStyle = contrastForBase.deletion;
|
|
711
592
|
ctx.fillText(txt, (leftPx + rightPx) / 2 - rwidth / 2, topPx + heightPx);
|
|
@@ -713,25 +594,25 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
713
594
|
}
|
|
714
595
|
else if (mismatch.type === 'insertion' && drawIndels) {
|
|
715
596
|
ctx.fillStyle = 'purple';
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
597
|
+
const pos = leftPx + extraHorizontallyFlippedOffset;
|
|
598
|
+
const len = +mismatch.base || mismatch.length;
|
|
599
|
+
const insW = Math.max(minSubfeatureWidth / 2, Math.min(1.2, 1 / bpPerPx));
|
|
719
600
|
if (len < 10) {
|
|
720
601
|
fillRect(ctx, pos, topPx, insW, heightPx, canvasWidth, 'purple');
|
|
721
602
|
if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
|
|
722
603
|
fillRect(ctx, pos - insW, topPx, insW * 3, 1, canvasWidth);
|
|
723
604
|
fillRect(ctx, pos - insW, topPx + heightPx - 1, insW * 3, 1, canvasWidth);
|
|
724
|
-
ctx.fillText(
|
|
605
|
+
ctx.fillText(`(${mismatch.base})`, pos + 3, topPx + heightPx);
|
|
725
606
|
}
|
|
726
607
|
}
|
|
727
608
|
}
|
|
728
609
|
else if (mismatch.type === 'hardclip' || mismatch.type === 'softclip') {
|
|
729
|
-
|
|
610
|
+
const pos = leftPx + extraHorizontallyFlippedOffset;
|
|
730
611
|
fillRect(ctx, pos, topPx, w, heightPx, canvasWidth, mismatch.type === 'hardclip' ? 'red' : 'blue');
|
|
731
612
|
if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
|
|
732
613
|
fillRect(ctx, pos - w, topPx, w * 3, 1, canvasWidth);
|
|
733
614
|
fillRect(ctx, pos - w, topPx + heightPx - 1, w * 3, 1, canvasWidth);
|
|
734
|
-
ctx.fillText(
|
|
615
|
+
ctx.fillText(`(${mismatch.base})`, pos + 3, topPx + heightPx);
|
|
735
616
|
}
|
|
736
617
|
}
|
|
737
618
|
else if (mismatch.type === 'skip') {
|
|
@@ -740,7 +621,7 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
740
621
|
// also affected firefox ref #1236 #2750
|
|
741
622
|
if (leftPx + widthPx > 0) {
|
|
742
623
|
// make small exons more visible when zoomed far out
|
|
743
|
-
|
|
624
|
+
const adjustPx = widthPx - (bpPerPx > 10 ? 1.5 : 0);
|
|
744
625
|
ctx.clearRect(leftPx, topPx, adjustPx, heightPx);
|
|
745
626
|
fillRect(ctx, Math.max(0, leftPx), topPx + heightPx / 2 - 1, adjustPx + (leftPx < 0 ? leftPx : 0), 2, canvasWidth, '#333');
|
|
746
627
|
}
|
|
@@ -748,44 +629,42 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
748
629
|
}
|
|
749
630
|
// second pass, draw wide insertion markers on top
|
|
750
631
|
if (drawIndels) {
|
|
751
|
-
for (
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
632
|
+
for (let i = 0; i < mismatches.length; i += 1) {
|
|
633
|
+
const mismatch = mismatches[i];
|
|
634
|
+
const mstart = start + mismatch.start;
|
|
635
|
+
const mlen = mismatch.length;
|
|
636
|
+
const [leftPx] = (0, util_1.bpSpanPx)(mstart, mstart + mlen, region, bpPerPx);
|
|
637
|
+
const len = +mismatch.base || mismatch.length;
|
|
638
|
+
const txt = `${len}`;
|
|
758
639
|
if (mismatch.type === 'insertion' && len >= 10) {
|
|
759
640
|
if (bpPerPx > largeInsertionIndicatorScale) {
|
|
760
641
|
fillRect(ctx, leftPx - 1, topPx, 2, heightPx, canvasWidth, 'purple');
|
|
761
642
|
}
|
|
762
643
|
else if (heightPx > charHeight) {
|
|
763
|
-
|
|
764
|
-
|
|
644
|
+
const rwidth = (0, util_1.measureText)(txt);
|
|
645
|
+
const padding = 5;
|
|
765
646
|
fillRect(ctx, leftPx - rwidth / 2 - padding, topPx, rwidth + 2 * padding, heightPx, canvasWidth, 'purple');
|
|
766
647
|
ctx.fillStyle = 'white';
|
|
767
648
|
ctx.fillText(txt, leftPx - rwidth / 2, topPx + heightPx);
|
|
768
649
|
}
|
|
769
650
|
else {
|
|
770
|
-
|
|
651
|
+
const padding = 2;
|
|
771
652
|
fillRect(ctx, leftPx - padding, topPx, 2 * padding, heightPx, canvasWidth, 'purple');
|
|
772
653
|
}
|
|
773
654
|
}
|
|
774
655
|
}
|
|
775
656
|
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
var bases = theme.palette.bases;
|
|
788
|
-
var colorForBase = {
|
|
657
|
+
}
|
|
658
|
+
drawSoftClipping({ ctx, feat, renderArgs, config, theme, canvasWidth, }) {
|
|
659
|
+
const { feature, topPx, heightPx } = feat;
|
|
660
|
+
const { regions, bpPerPx } = renderArgs;
|
|
661
|
+
const [region] = regions;
|
|
662
|
+
const minFeatWidth = (0, configuration_1.readConfObject)(config, 'minSubfeatureWidth');
|
|
663
|
+
const mismatches = feature.get('mismatches');
|
|
664
|
+
const seq = feature.get('seq');
|
|
665
|
+
const { charWidth, charHeight } = this.getCharWidthHeight(ctx);
|
|
666
|
+
const { bases } = theme.palette;
|
|
667
|
+
const colorForBase = {
|
|
789
668
|
A: bases.A.main,
|
|
790
669
|
C: bases.C.main,
|
|
791
670
|
G: bases.G.main,
|
|
@@ -795,23 +674,23 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
795
674
|
// Display all bases softclipped off in lightened colors
|
|
796
675
|
if (seq) {
|
|
797
676
|
mismatches
|
|
798
|
-
.filter(
|
|
799
|
-
.forEach(
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
for (
|
|
804
|
-
|
|
677
|
+
.filter(mismatch => mismatch.type === 'softclip')
|
|
678
|
+
.forEach(mismatch => {
|
|
679
|
+
const softClipLength = mismatch.cliplen || 0;
|
|
680
|
+
const s = feature.get('start');
|
|
681
|
+
const softClipStart = mismatch.start === 0 ? s - softClipLength : s + mismatch.start;
|
|
682
|
+
for (let k = 0; k < softClipLength; k += 1) {
|
|
683
|
+
const base = seq.charAt(k + mismatch.start);
|
|
805
684
|
// If softclip length+start is longer than sequence, no need to
|
|
806
685
|
// continue showing base
|
|
807
686
|
if (!base) {
|
|
808
687
|
return;
|
|
809
688
|
}
|
|
810
|
-
|
|
811
|
-
|
|
689
|
+
const [softClipLeftPx, softClipRightPx] = (0, util_1.bpSpanPx)(softClipStart + k, softClipStart + k + 1, region, bpPerPx);
|
|
690
|
+
const softClipWidthPx = Math.max(minFeatWidth, Math.abs(softClipLeftPx - softClipRightPx));
|
|
812
691
|
// Black accounts for IUPAC ambiguity code bases such as N that
|
|
813
692
|
// show in soft clipping
|
|
814
|
-
|
|
693
|
+
const baseColor = colorForBase[base] || '#000000';
|
|
815
694
|
ctx.fillStyle = baseColor;
|
|
816
695
|
fillRect(ctx, softClipLeftPx, topPx, softClipWidthPx, heightPx, canvasWidth);
|
|
817
696
|
if (softClipWidthPx >= charWidth && heightPx >= charHeight - 5) {
|
|
@@ -821,171 +700,158 @@ var PileupRenderer = /** @class */ (function (_super) {
|
|
|
821
700
|
}
|
|
822
701
|
});
|
|
823
702
|
}
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
var contrastForBase = getContrastBaseMap(theme);
|
|
703
|
+
}
|
|
704
|
+
makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, }) {
|
|
705
|
+
const { layout, config, showSoftClip, colorBy, theme: configTheme, } = renderArgs;
|
|
706
|
+
const mismatchAlpha = (0, configuration_1.readConfObject)(config, 'mismatchAlpha');
|
|
707
|
+
const minSubfeatureWidth = (0, configuration_1.readConfObject)(config, 'minSubfeatureWidth');
|
|
708
|
+
const largeInsertionIndicatorScale = (0, configuration_1.readConfObject)(config, 'largeInsertionIndicatorScale');
|
|
709
|
+
const defaultColor = (0, configuration_1.readConfObject)(config, 'color') === '#f0f';
|
|
710
|
+
const theme = (0, ui_1.createJBrowseTheme)(configTheme);
|
|
711
|
+
const colorForBase = getColorBaseMap(theme);
|
|
712
|
+
const contrastForBase = getContrastBaseMap(theme);
|
|
835
713
|
if (!layout) {
|
|
836
|
-
throw new Error(
|
|
714
|
+
throw new Error(`layout required`);
|
|
837
715
|
}
|
|
838
716
|
if (!layout.addRect) {
|
|
839
717
|
throw new Error('invalid layout object');
|
|
840
718
|
}
|
|
841
719
|
ctx.font = 'bold 10px Courier New,monospace';
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
for (
|
|
846
|
-
|
|
720
|
+
const { charWidth, charHeight } = this.getCharWidthHeight(ctx);
|
|
721
|
+
const drawSNPsMuted = shouldDrawSNPsMuted(colorBy === null || colorBy === void 0 ? void 0 : colorBy.type);
|
|
722
|
+
const drawIndels = shouldDrawIndels(colorBy === null || colorBy === void 0 ? void 0 : colorBy.type);
|
|
723
|
+
for (let i = 0; i < layoutRecords.length; i++) {
|
|
724
|
+
const feat = layoutRecords[i];
|
|
847
725
|
if (feat === null) {
|
|
848
726
|
continue;
|
|
849
727
|
}
|
|
850
728
|
this.drawAlignmentRect({
|
|
851
|
-
ctx
|
|
852
|
-
feat
|
|
853
|
-
renderArgs
|
|
854
|
-
defaultColor
|
|
855
|
-
colorForBase
|
|
856
|
-
contrastForBase
|
|
857
|
-
charWidth
|
|
858
|
-
charHeight
|
|
859
|
-
canvasWidth
|
|
729
|
+
ctx,
|
|
730
|
+
feat,
|
|
731
|
+
renderArgs,
|
|
732
|
+
defaultColor,
|
|
733
|
+
colorForBase,
|
|
734
|
+
contrastForBase,
|
|
735
|
+
charWidth,
|
|
736
|
+
charHeight,
|
|
737
|
+
canvasWidth,
|
|
860
738
|
});
|
|
861
739
|
this.drawMismatches({
|
|
862
|
-
ctx
|
|
863
|
-
feat
|
|
864
|
-
renderArgs
|
|
865
|
-
mismatchAlpha
|
|
866
|
-
drawSNPsMuted
|
|
867
|
-
drawIndels
|
|
868
|
-
largeInsertionIndicatorScale
|
|
869
|
-
minSubfeatureWidth
|
|
870
|
-
charWidth
|
|
871
|
-
charHeight
|
|
872
|
-
colorForBase
|
|
873
|
-
contrastForBase
|
|
874
|
-
canvasWidth
|
|
740
|
+
ctx,
|
|
741
|
+
feat,
|
|
742
|
+
renderArgs,
|
|
743
|
+
mismatchAlpha,
|
|
744
|
+
drawSNPsMuted,
|
|
745
|
+
drawIndels,
|
|
746
|
+
largeInsertionIndicatorScale,
|
|
747
|
+
minSubfeatureWidth,
|
|
748
|
+
charWidth,
|
|
749
|
+
charHeight,
|
|
750
|
+
colorForBase,
|
|
751
|
+
contrastForBase,
|
|
752
|
+
canvasWidth,
|
|
875
753
|
});
|
|
876
754
|
if (showSoftClip) {
|
|
877
755
|
this.drawSoftClipping({
|
|
878
|
-
ctx
|
|
879
|
-
feat
|
|
880
|
-
renderArgs
|
|
881
|
-
config
|
|
882
|
-
theme
|
|
883
|
-
canvasWidth
|
|
756
|
+
ctx,
|
|
757
|
+
feat,
|
|
758
|
+
renderArgs,
|
|
759
|
+
config,
|
|
760
|
+
theme,
|
|
761
|
+
canvasWidth,
|
|
884
762
|
});
|
|
885
763
|
}
|
|
886
764
|
}
|
|
887
|
-
}
|
|
765
|
+
}
|
|
888
766
|
// we perform a full layout before render as a separate method because the
|
|
889
767
|
// layout determines the height of the canvas that we use to render
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
var _a = __read(regions, 1), region = _a[0];
|
|
768
|
+
layoutFeats(props) {
|
|
769
|
+
const { layout, features, sortedBy, config, bpPerPx, showSoftClip, regions, } = props;
|
|
770
|
+
const [region] = regions;
|
|
894
771
|
if (!layout) {
|
|
895
|
-
throw new Error(
|
|
772
|
+
throw new Error(`layout required`);
|
|
896
773
|
}
|
|
897
774
|
if (!layout.addRect) {
|
|
898
775
|
throw new Error('invalid layout object');
|
|
899
776
|
}
|
|
900
|
-
|
|
777
|
+
const featureMap = (sortedBy === null || sortedBy === void 0 ? void 0 : sortedBy.type) && region.start === sortedBy.pos
|
|
901
778
|
? (0, sortUtil_1.sortFeature)(features, sortedBy)
|
|
902
779
|
: features;
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
return (0, util_1.iterMap)(featureMap.values(),
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
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) {
|
|
780
|
+
const heightPx = (0, configuration_1.readConfObject)(config, 'height');
|
|
781
|
+
const displayMode = (0, configuration_1.readConfObject)(config, 'displayMode');
|
|
782
|
+
return (0, util_1.iterMap)(featureMap.values(), feature => this.layoutFeature({
|
|
783
|
+
feature,
|
|
784
|
+
layout,
|
|
785
|
+
bpPerPx,
|
|
786
|
+
region,
|
|
787
|
+
showSoftClip,
|
|
788
|
+
heightPx,
|
|
789
|
+
displayMode,
|
|
790
|
+
}), featureMap.size);
|
|
791
|
+
}
|
|
792
|
+
async fetchSequence(renderProps) {
|
|
793
|
+
const { sessionId, regions, adapterConfig } = renderProps;
|
|
794
|
+
const { sequenceAdapter } = adapterConfig;
|
|
795
|
+
if (!sequenceAdapter) {
|
|
796
|
+
return undefined;
|
|
797
|
+
}
|
|
798
|
+
const { dataAdapter } = await (0, dataAdapterCache_1.getAdapter)(this.pluginManager, sessionId, sequenceAdapter);
|
|
799
|
+
const [region] = regions;
|
|
800
|
+
return (0, util_2.fetchSequence)(region, dataAdapter);
|
|
801
|
+
}
|
|
802
|
+
async render(renderProps) {
|
|
938
803
|
var _a;
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
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
|
-
});
|
|
804
|
+
const features = await this.getFeatures(renderProps);
|
|
805
|
+
const layout = this.createLayoutInWorker(renderProps);
|
|
806
|
+
const { regions, bpPerPx } = renderProps;
|
|
807
|
+
const layoutRecords = this.layoutFeats({
|
|
808
|
+
...renderProps,
|
|
809
|
+
features,
|
|
810
|
+
layout,
|
|
983
811
|
});
|
|
984
|
-
|
|
985
|
-
|
|
812
|
+
const [region] = regions;
|
|
813
|
+
// only need reference sequence if there are features and only for some
|
|
814
|
+
// cases
|
|
815
|
+
const regionSequence = features.size && (0, util_2.shouldFetchReferenceSequence)((_a = renderProps.colorBy) === null || _a === void 0 ? void 0 : _a.type)
|
|
816
|
+
? await this.fetchSequence(renderProps)
|
|
817
|
+
: undefined;
|
|
818
|
+
const { end, start } = region;
|
|
819
|
+
const width = (end - start) / bpPerPx;
|
|
820
|
+
const height = Math.max(layout.getTotalHeight(), 1);
|
|
821
|
+
const Color = await Promise.resolve().then(() => __importStar(require('color'))).then(f => f.default);
|
|
822
|
+
const res = await (0, offscreenCanvasUtils_1.renderToAbstractCanvas)(width, height, renderProps, ctx => this.makeImageData({
|
|
823
|
+
ctx,
|
|
824
|
+
layoutRecords,
|
|
825
|
+
canvasWidth: width,
|
|
826
|
+
renderArgs: {
|
|
827
|
+
...renderProps,
|
|
828
|
+
layout,
|
|
829
|
+
features,
|
|
830
|
+
regionSequence,
|
|
831
|
+
Color,
|
|
832
|
+
},
|
|
833
|
+
}));
|
|
834
|
+
const results = await super.render({
|
|
835
|
+
...renderProps,
|
|
836
|
+
...res,
|
|
837
|
+
features,
|
|
838
|
+
layout,
|
|
839
|
+
height,
|
|
840
|
+
width,
|
|
841
|
+
});
|
|
842
|
+
return {
|
|
843
|
+
...results,
|
|
844
|
+
...res,
|
|
845
|
+
features: new Map(),
|
|
846
|
+
layout,
|
|
847
|
+
height,
|
|
848
|
+
width,
|
|
849
|
+
maxHeightReached: layout.maxHeightReached,
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
createSession(args) {
|
|
986
853
|
return new PileupLayoutSession_1.PileupLayoutSession(args);
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
}(BoxRendererType_1.default));
|
|
854
|
+
}
|
|
855
|
+
}
|
|
990
856
|
exports.default = PileupRenderer;
|
|
991
857
|
//# sourceMappingURL=PileupRenderer.js.map
|