jbrowse-plugin-mafviewer 1.1.4 → 1.2.1
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/BgzipTaffyAdapter/BgzipTaffyAdapter.d.ts +5 -4
- package/dist/BgzipTaffyAdapter/BgzipTaffyAdapter.js +102 -82
- package/dist/BgzipTaffyAdapter/BgzipTaffyAdapter.js.map +1 -1
- package/dist/BgzipTaffyAdapter/util.d.ts +1 -0
- package/dist/BgzipTaffyAdapter/util.js +22 -0
- package/dist/BgzipTaffyAdapter/util.js.map +1 -0
- package/dist/BigMafAdapter/BigMafAdapter.d.ts +3 -2
- package/dist/BigMafAdapter/BigMafAdapter.js +4 -3
- package/dist/BigMafAdapter/BigMafAdapter.js.map +1 -1
- package/dist/LinearMafDisplay/components/ColorLegend.js +1 -1
- package/dist/LinearMafDisplay/components/ColorLegend.js.map +1 -1
- package/dist/LinearMafDisplay/components/ReactComponent.js +1 -1
- package/dist/LinearMafDisplay/components/ReactComponent.js.map +1 -1
- package/dist/LinearMafDisplay/components/SvgWrapper.js +2 -2
- package/dist/LinearMafDisplay/components/SvgWrapper.js.map +1 -1
- package/dist/LinearMafDisplay/components/YScaleBars.js +2 -2
- package/dist/LinearMafDisplay/components/YScaleBars.js.map +1 -1
- package/dist/LinearMafDisplay/renderSvg.d.ts +2 -2
- package/dist/LinearMafDisplay/renderSvg.js +0 -1
- package/dist/LinearMafDisplay/renderSvg.js.map +1 -1
- package/dist/LinearMafDisplay/stateModel.d.ts +19 -17
- package/dist/LinearMafDisplay/stateModel.js +17 -10
- package/dist/LinearMafDisplay/stateModel.js.map +1 -1
- package/dist/LinearMafRenderer/LinearMafRenderer.d.ts +8 -4
- package/dist/LinearMafRenderer/LinearMafRenderer.js +14 -148
- package/dist/LinearMafRenderer/LinearMafRenderer.js.map +1 -1
- package/dist/LinearMafRenderer/configSchema.d.ts +6 -1
- package/dist/LinearMafRenderer/configSchema.js +6 -1
- package/dist/LinearMafRenderer/configSchema.js.map +1 -1
- package/dist/LinearMafRenderer/makeImageData.d.ts +20 -0
- package/dist/LinearMafRenderer/makeImageData.js +144 -0
- package/dist/LinearMafRenderer/makeImageData.js.map +1 -0
- package/dist/LinearMafRenderer/util.d.ts +6 -1
- package/dist/LinearMafRenderer/util.js +17 -0
- package/dist/LinearMafRenderer/util.js.map +1 -1
- package/dist/MafAddTrackWorkflow/AddTrackWorkflow.d.ts +1 -1
- package/dist/MafAddTrackWorkflow/AddTrackWorkflow.js.map +1 -1
- package/dist/MafTabixAdapter/MafTabixAdapter.d.ts +9 -6
- package/dist/MafTabixAdapter/MafTabixAdapter.js +69 -56
- package/dist/MafTabixAdapter/MafTabixAdapter.js.map +1 -1
- package/dist/MafTabixAdapter/configSchema.d.ts +7 -0
- package/dist/MafTabixAdapter/configSchema.js +7 -0
- package/dist/MafTabixAdapter/configSchema.js.map +1 -1
- package/dist/jbrowse-plugin-mafviewer.umd.production.min.js +7 -8
- package/dist/jbrowse-plugin-mafviewer.umd.production.min.js.map +4 -4
- package/package.json +3 -2
- package/src/BgzipTaffyAdapter/BgzipTaffyAdapter.ts +122 -86
- package/src/BgzipTaffyAdapter/util.ts +25 -0
- package/src/BigMafAdapter/BigMafAdapter.ts +10 -4
- package/src/LinearMafDisplay/components/ColorLegend.tsx +1 -2
- package/src/LinearMafDisplay/components/ReactComponent.tsx +1 -1
- package/src/LinearMafDisplay/components/SvgWrapper.tsx +2 -2
- package/src/LinearMafDisplay/components/YScaleBars.tsx +3 -2
- package/src/LinearMafDisplay/renderSvg.tsx +5 -5
- package/src/LinearMafDisplay/stateModel.ts +30 -24
- package/src/LinearMafRenderer/LinearMafRenderer.ts +21 -176
- package/src/LinearMafRenderer/configSchema.ts +6 -1
- package/src/LinearMafRenderer/makeImageData.ts +210 -0
- package/src/LinearMafRenderer/util.ts +29 -1
- package/src/MafAddTrackWorkflow/AddTrackWorkflow.tsx +2 -1
- package/src/MafTabixAdapter/MafTabixAdapter.ts +84 -57
- package/src/MafTabixAdapter/configSchema.ts +7 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ConfigurationReference, getConf
|
|
1
|
+
import { ConfigurationReference, getConf } from '@jbrowse/core/configuration';
|
|
2
2
|
import { getEnv, getSession } from '@jbrowse/core/util';
|
|
3
3
|
import { getRpcSessionId } from '@jbrowse/core/util/tracks';
|
|
4
4
|
import { ascending } from 'd3-array';
|
|
5
5
|
import { cluster, hierarchy } from 'd3-hierarchy';
|
|
6
|
+
import deepEqual from 'fast-deep-equal';
|
|
6
7
|
import { autorun } from 'mobx';
|
|
7
8
|
import { addDisposer, isAlive, types } from 'mobx-state-tree';
|
|
8
9
|
import SetRowHeightDialog from './components/SetRowHeight';
|
|
9
|
-
import { maxLength, setBrLength
|
|
10
|
+
import { maxLength, setBrLength } from './types';
|
|
10
11
|
import { normalize } from '../util';
|
|
11
12
|
/**
|
|
12
13
|
* #stateModel LinearMafDisplay
|
|
@@ -58,11 +59,11 @@ export default function stateModelFactory(configSchema, pluginManager) {
|
|
|
58
59
|
/**
|
|
59
60
|
* #volatile
|
|
60
61
|
*/
|
|
61
|
-
volatileSamples:
|
|
62
|
+
volatileSamples: undefined,
|
|
62
63
|
/**
|
|
63
64
|
* #volatile
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
|
+
volatileTree: undefined,
|
|
66
67
|
}))
|
|
67
68
|
.actions(self => ({
|
|
68
69
|
/**
|
|
@@ -93,8 +94,12 @@ export default function stateModelFactory(configSchema, pluginManager) {
|
|
|
93
94
|
* #action
|
|
94
95
|
*/
|
|
95
96
|
setSamples({ samples, tree }) {
|
|
96
|
-
self.volatileSamples
|
|
97
|
-
|
|
97
|
+
if (!deepEqual(samples, self.volatileSamples)) {
|
|
98
|
+
self.volatileSamples = samples;
|
|
99
|
+
}
|
|
100
|
+
if (!deepEqual(tree, self.volatileTree)) {
|
|
101
|
+
self.volatileTree = tree;
|
|
102
|
+
}
|
|
98
103
|
},
|
|
99
104
|
}))
|
|
100
105
|
.views(self => ({
|
|
@@ -121,8 +126,8 @@ export default function stateModelFactory(configSchema, pluginManager) {
|
|
|
121
126
|
* #getter
|
|
122
127
|
*/
|
|
123
128
|
get root() {
|
|
124
|
-
return self.
|
|
125
|
-
? hierarchy(self.
|
|
129
|
+
return self.volatileTree
|
|
130
|
+
? hierarchy(self.volatileTree, d => d.children)
|
|
126
131
|
// todo: investigate whether needed, typescript says children always true
|
|
127
132
|
.sum(d => (d.children ? 0 : 1))
|
|
128
133
|
.sort((a, b) => ascending(a.data.length || 1, b.data.length || 1))
|
|
@@ -159,7 +164,7 @@ export default function stateModelFactory(configSchema, pluginManager) {
|
|
|
159
164
|
* #getter
|
|
160
165
|
*/
|
|
161
166
|
get totalHeight() {
|
|
162
|
-
return this.samples.length * self.rowHeight;
|
|
167
|
+
return this.samples ? this.samples.length * self.rowHeight : 1;
|
|
163
168
|
},
|
|
164
169
|
/**
|
|
165
170
|
* #getter
|
|
@@ -192,8 +197,10 @@ export default function stateModelFactory(configSchema, pluginManager) {
|
|
|
192
197
|
*/
|
|
193
198
|
renderProps() {
|
|
194
199
|
const { showAllLetters, rendererConfig, samples, rowHeight, rowProportion, mismatchRendering, } = self;
|
|
200
|
+
const s = superRenderProps();
|
|
195
201
|
return {
|
|
196
|
-
...
|
|
202
|
+
...s,
|
|
203
|
+
notReady: !self.volatileSamples || !self.volatileTree || super.notReady,
|
|
197
204
|
config: rendererConfig,
|
|
198
205
|
samples,
|
|
199
206
|
rowHeight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stateModel.js","sourceRoot":"","sources":["../../src/LinearMafDisplay/stateModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stateModel.js","sourceRoot":"","sources":["../../src/LinearMafDisplay/stateModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,UAAU,E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CAAC,IAAI,CAAC,CAAA;oBAEvC,MAAM,OAAO,GAAG,CAAC,MAAM,UAAU,CAAC,IAAI,CACpC,SAAS,EACT,eAAe,EACf;wBACE,SAAS;wBACT,aAAa,EAAE,IAAI,CAAC,aAAa;wBACjC,cAAc,EAAE,CAAC,OAAe,EAAE,EAAE;4BAClC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gCAClB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;4BAC1B,CAAC;wBACH,CAAC;qBACF,CACF,CAAQ,CAAA;oBACT,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;gBAC1B,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACX,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;oBAChB,UAAU,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;gBACzC,CAAC;YACH,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC,CAAC;SACF,OAAO,CAAC,IAAI,CAAC,EAAE;QACd,6DAA6D;QAC7D,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;QAC1C,OAAO;YACL;;eAEG;YACH,KAAK,CAAC,SAAS,CAAC,IAA6B;gBAC3C,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;gBACjD,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAA;YAC9C,CAAC;SACF,CAAA;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FeatureRendererType } from '@jbrowse/core/pluggableElementTypes';
|
|
2
2
|
import { RenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType';
|
|
3
|
-
import {
|
|
3
|
+
import { Region } from '@jbrowse/core/util';
|
|
4
4
|
interface Sample {
|
|
5
5
|
id: string;
|
|
6
6
|
color?: string;
|
|
@@ -11,6 +11,7 @@ interface RenderArgs extends RenderArgsDeserialized {
|
|
|
11
11
|
rowProportion: number;
|
|
12
12
|
showAllLetters: boolean;
|
|
13
13
|
mismatchRendering: boolean;
|
|
14
|
+
statusCallback?: (arg: string) => void;
|
|
14
15
|
}
|
|
15
16
|
export default class LinearMafRenderer extends FeatureRendererType {
|
|
16
17
|
getExpandedRegion(region: Region): {
|
|
@@ -21,23 +22,26 @@ export default class LinearMafRenderer extends FeatureRendererType {
|
|
|
21
22
|
assemblyName: string;
|
|
22
23
|
};
|
|
23
24
|
render(renderProps: RenderArgs): Promise<{
|
|
25
|
+
features: Map<any, any>;
|
|
24
26
|
width: number;
|
|
25
27
|
height: number;
|
|
28
|
+
containsNoTransferables: boolean;
|
|
26
29
|
canvasRecordedData: any;
|
|
27
|
-
features: Map<string, Feature>;
|
|
28
30
|
reactElement?: React.ReactElement;
|
|
29
31
|
html?: string;
|
|
30
32
|
} | {
|
|
33
|
+
features: Map<any, any>;
|
|
31
34
|
width: number;
|
|
32
35
|
height: number;
|
|
36
|
+
containsNoTransferables: boolean;
|
|
33
37
|
reactElement: import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
features: Map<string, Feature>;
|
|
35
38
|
html?: string;
|
|
36
39
|
} | {
|
|
40
|
+
features: Map<any, any>;
|
|
37
41
|
width: number;
|
|
38
42
|
height: number;
|
|
43
|
+
containsNoTransferables: boolean;
|
|
39
44
|
imageData: any;
|
|
40
|
-
features: Map<string, Feature>;
|
|
41
45
|
reactElement?: React.ReactElement;
|
|
42
46
|
html?: string;
|
|
43
47
|
}>;
|
|
@@ -1,144 +1,6 @@
|
|
|
1
1
|
import { FeatureRendererType } from '@jbrowse/core/pluggableElementTypes';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { getColorBaseMap, getContrastBaseMap } from './util';
|
|
5
|
-
function makeImageData({ ctx, renderArgs, }) {
|
|
6
|
-
const { regions, bpPerPx, rowHeight, showAllLetters, theme: configTheme, mismatchRendering, samples, rowProportion, features, } = renderArgs;
|
|
7
|
-
const region = regions[0];
|
|
8
|
-
const h = rowHeight * rowProportion;
|
|
9
|
-
const theme = createJBrowseTheme(configTheme);
|
|
10
|
-
const colorForBase = getColorBaseMap(theme);
|
|
11
|
-
const contrastForBase = getContrastBaseMap(theme);
|
|
12
|
-
const sampleToRowMap = new Map(samples.map((s, i) => [s.id, i]));
|
|
13
|
-
const scale = 1 / bpPerPx;
|
|
14
|
-
const f = 0.4;
|
|
15
|
-
const h2 = rowHeight / 2;
|
|
16
|
-
const hp2 = h / 2;
|
|
17
|
-
const offset = (rowHeight - h) / 2;
|
|
18
|
-
// sample as alignments
|
|
19
|
-
ctx.font = 'bold 10px Courier New,monospace';
|
|
20
|
-
for (const feature of features.values()) {
|
|
21
|
-
const [leftPx] = featureSpanPx(feature, region, bpPerPx);
|
|
22
|
-
const vals = feature.get('alignments');
|
|
23
|
-
const seq = feature.get('seq').toLowerCase();
|
|
24
|
-
for (const [sample, val] of Object.entries(vals)) {
|
|
25
|
-
const origAlignment = val.data;
|
|
26
|
-
const alignment = origAlignment.toLowerCase();
|
|
27
|
-
const row = sampleToRowMap.get(sample);
|
|
28
|
-
if (row === undefined) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const t = rowHeight * row;
|
|
32
|
-
// gaps
|
|
33
|
-
ctx.beginPath();
|
|
34
|
-
ctx.fillStyle = 'black';
|
|
35
|
-
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
36
|
-
if (seq[i] !== '-') {
|
|
37
|
-
if (alignment[i] === '-') {
|
|
38
|
-
const l = leftPx + scale * o;
|
|
39
|
-
ctx.moveTo(l, t + h2);
|
|
40
|
-
ctx.lineTo(l + scale + f, t + h2);
|
|
41
|
-
}
|
|
42
|
-
o++;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
ctx.stroke();
|
|
46
|
-
if (!showAllLetters) {
|
|
47
|
-
// matches
|
|
48
|
-
ctx.beginPath();
|
|
49
|
-
ctx.fillStyle = 'lightgrey';
|
|
50
|
-
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
51
|
-
if (seq[i] !== '-') {
|
|
52
|
-
const c = alignment[i];
|
|
53
|
-
const l = leftPx + scale * o;
|
|
54
|
-
if (seq[i] === c && c !== '-') {
|
|
55
|
-
ctx.rect(l, offset + t, scale + f, h);
|
|
56
|
-
}
|
|
57
|
-
o++;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
ctx.fill();
|
|
61
|
-
}
|
|
62
|
-
// mismatches
|
|
63
|
-
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
64
|
-
const c = alignment[i];
|
|
65
|
-
if (seq[i] !== '-') {
|
|
66
|
-
if (c !== '-') {
|
|
67
|
-
const l = leftPx + scale * o;
|
|
68
|
-
if (seq[i] !== c && c !== ' ') {
|
|
69
|
-
ctx.fillStyle = mismatchRendering
|
|
70
|
-
? // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
71
|
-
(colorForBase[c] ?? 'black')
|
|
72
|
-
: 'orange';
|
|
73
|
-
ctx.fillRect(l, offset + t, scale + f, h);
|
|
74
|
-
}
|
|
75
|
-
else if (showAllLetters) {
|
|
76
|
-
ctx.fillStyle = mismatchRendering
|
|
77
|
-
? // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
78
|
-
(colorForBase[c] ?? 'black')
|
|
79
|
-
: 'lightblue';
|
|
80
|
-
ctx.fillRect(l, offset + t, scale + f, h);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
o++;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// font
|
|
87
|
-
const charSizeW = 10;
|
|
88
|
-
if (scale >= charSizeW) {
|
|
89
|
-
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
90
|
-
if (seq[i] !== '-') {
|
|
91
|
-
const l = leftPx + scale * o;
|
|
92
|
-
const offset = (scale - charSizeW) / 2 + 1;
|
|
93
|
-
const c = alignment[i];
|
|
94
|
-
if ((showAllLetters || seq[i] !== c) && c !== '-') {
|
|
95
|
-
ctx.fillStyle = mismatchRendering
|
|
96
|
-
? (contrastForBase[c] ?? 'white')
|
|
97
|
-
: 'black';
|
|
98
|
-
ctx.fillText(origAlignment[i] || '', l + offset, hp2 + t + 3);
|
|
99
|
-
}
|
|
100
|
-
o++;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// second pass for insertions, has slightly improved look since the
|
|
107
|
-
// insertions are always 'on top' of the other features
|
|
108
|
-
for (const feature of features.values()) {
|
|
109
|
-
const [leftPx] = featureSpanPx(feature, region, bpPerPx);
|
|
110
|
-
const vals = feature.get('alignments');
|
|
111
|
-
const seq = feature.get('seq').toLowerCase();
|
|
112
|
-
for (const [sample, val] of Object.entries(vals)) {
|
|
113
|
-
const origAlignment = val.data;
|
|
114
|
-
const alignment = origAlignment.toLowerCase();
|
|
115
|
-
const row = sampleToRowMap.get(sample);
|
|
116
|
-
if (row === undefined) {
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
const t = rowHeight * row;
|
|
120
|
-
ctx.beginPath();
|
|
121
|
-
ctx.fillStyle = 'purple';
|
|
122
|
-
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
123
|
-
let ins = '';
|
|
124
|
-
while (seq[i] === '-') {
|
|
125
|
-
if (alignment[i] !== '-' && alignment[i] !== ' ') {
|
|
126
|
-
ins += alignment[i];
|
|
127
|
-
}
|
|
128
|
-
i++;
|
|
129
|
-
}
|
|
130
|
-
if (ins.length > 0) {
|
|
131
|
-
const l = leftPx + scale * o - 1;
|
|
132
|
-
ctx.rect(l, offset + t + 1, 1, h - 1);
|
|
133
|
-
ctx.rect(l - 2, offset + t, 5, 1);
|
|
134
|
-
ctx.rect(l - 2, offset + t + h - 1, 5, 1);
|
|
135
|
-
}
|
|
136
|
-
o++;
|
|
137
|
-
}
|
|
138
|
-
ctx.fill();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
2
|
+
import { renderToAbstractCanvas, updateStatus, } from '@jbrowse/core/util';
|
|
3
|
+
import { makeImageData } from './makeImageData';
|
|
142
4
|
export default class LinearMafRenderer extends FeatureRendererType {
|
|
143
5
|
getExpandedRegion(region) {
|
|
144
6
|
const { start, end } = region;
|
|
@@ -151,18 +13,20 @@ export default class LinearMafRenderer extends FeatureRendererType {
|
|
|
151
13
|
};
|
|
152
14
|
}
|
|
153
15
|
async render(renderProps) {
|
|
154
|
-
const { regions, bpPerPx, samples, rowHeight } = renderProps;
|
|
16
|
+
const { statusCallback = () => { }, regions, bpPerPx, samples, rowHeight, } = renderProps;
|
|
155
17
|
const region = regions[0];
|
|
156
18
|
const height = samples.length * (rowHeight + 1) + 100;
|
|
157
19
|
const width = (region.end - region.start) / bpPerPx;
|
|
158
20
|
const features = await this.getFeatures(renderProps);
|
|
159
|
-
const res = await renderToAbstractCanvas(width, height, renderProps, ctx => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
21
|
+
const res = await renderToAbstractCanvas(width, height, renderProps, async (ctx) => {
|
|
22
|
+
await updateStatus('Rendering alignment', statusCallback, () => {
|
|
23
|
+
makeImageData({
|
|
24
|
+
ctx,
|
|
25
|
+
renderArgs: {
|
|
26
|
+
...renderProps,
|
|
27
|
+
features,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
166
30
|
});
|
|
167
31
|
return undefined;
|
|
168
32
|
});
|
|
@@ -175,8 +39,10 @@ export default class LinearMafRenderer extends FeatureRendererType {
|
|
|
175
39
|
return {
|
|
176
40
|
...results,
|
|
177
41
|
...res,
|
|
42
|
+
features: new Map(),
|
|
178
43
|
width,
|
|
179
44
|
height,
|
|
45
|
+
containsNoTransferables: true,
|
|
180
46
|
};
|
|
181
47
|
}
|
|
182
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinearMafRenderer.js","sourceRoot":"","sources":["../../src/LinearMafRenderer/LinearMafRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEzE,OAAO,
|
|
1
|
+
{"version":3,"file":"LinearMafRenderer.js","sourceRoot":"","sources":["../../src/LinearMafRenderer/LinearMafRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AAEzE,OAAO,EAEL,sBAAsB,EACtB,YAAY,GACb,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAe/C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,mBAAmB;IAChE,iBAAiB,CAAC,MAAc;QAC9B,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,CAAA;QAC7B,MAAM,WAAW,GAAG,CAAC,CAAA;QAErB,OAAO;YACL,sEAAsE;YACtE,GAAI,MAAsC;YAC1C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,WAAW,EAAE,CAAC,CAAC,CAAC;YACnD,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,WAAW,CAAC;SAClC,CAAA;IACH,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,WAAuB;QAClC,MAAM,EACJ,cAAc,GAAG,GAAG,EAAE,GAAE,CAAC,EACzB,OAAO,EACP,OAAO,EACP,OAAO,EACP,SAAS,GACV,GAAG,WAAW,CAAA;QACf,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAE,CAAA;QAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAA;QACrD,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAA;QACnD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;QACpD,MAAM,GAAG,GAAG,MAAM,sBAAsB,CACtC,KAAK,EACL,MAAM,EACN,WAAW,EACX,KAAK,EAAC,GAAG,EAAC,EAAE;YACV,MAAM,YAAY,CAAC,qBAAqB,EAAE,cAAc,EAAE,GAAG,EAAE;gBAC7D,aAAa,CAAC;oBACZ,GAAG;oBACH,UAAU,EAAE;wBACV,GAAG,WAAW;wBACd,QAAQ;qBACT;iBACF,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;YACF,OAAO,SAAS,CAAA;QAClB,CAAC,CACF,CAAA;QACD,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC;YACjC,GAAG,WAAW;YACd,GAAG,GAAG;YACN,KAAK;YACL,MAAM;SACP,CAAC,CAAA;QACF,OAAO;YACL,GAAG,OAAO;YACV,GAAG,GAAG;YACN,QAAQ,EAAE,IAAI,GAAG,EAAE;YACnB,KAAK;YACL,MAAM;YACN,uBAAuB,EAAE,IAAI;SAC9B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
declare const configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
1
|
+
declare const configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
2
|
+
baseColor: {
|
|
3
|
+
type: string;
|
|
4
|
+
defaultValue: string;
|
|
5
|
+
};
|
|
6
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
|
|
2
7
|
export default configSchema;
|
|
@@ -3,7 +3,12 @@ import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
|
3
3
|
* #config LinearMafRenderer
|
|
4
4
|
*/
|
|
5
5
|
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
6
|
-
const configSchema = ConfigurationSchema('LinearMafRenderer', {
|
|
6
|
+
const configSchema = ConfigurationSchema('LinearMafRenderer', {
|
|
7
|
+
baseColor: {
|
|
8
|
+
type: 'color',
|
|
9
|
+
defaultValue: 'lightgrey',
|
|
10
|
+
},
|
|
11
|
+
}, {
|
|
7
12
|
/**
|
|
8
13
|
* #baseConfiguration
|
|
9
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/LinearMafRenderer/configSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE;;GAEG;AACH,SAAS,CAAC,KAAI,CAAC,CAAC,wDAAwD;AAExE,MAAM,YAAY,GAAG,mBAAmB,CACtC,mBAAmB,EACnB,EAAE,
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/LinearMafRenderer/configSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE;;GAEG;AACH,SAAS,CAAC,KAAI,CAAC,CAAC,wDAAwD;AAExE,MAAM,YAAY,GAAG,mBAAmB,CACtC,mBAAmB,EACnB;IACE,SAAS,EAAE;QACT,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,WAAW;KAC1B;CACF,EACD;IACE;;OAEG;IACH,eAAe,EAAE,IAAI;CACtB,CACF,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RenderArgsDeserialized } from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType';
|
|
2
|
+
import { Feature } from '@jbrowse/core/util';
|
|
3
|
+
interface Sample {
|
|
4
|
+
id: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
}
|
|
7
|
+
interface RenderArgs extends RenderArgsDeserialized {
|
|
8
|
+
samples: Sample[];
|
|
9
|
+
rowHeight: number;
|
|
10
|
+
rowProportion: number;
|
|
11
|
+
showAllLetters: boolean;
|
|
12
|
+
mismatchRendering: boolean;
|
|
13
|
+
features: Map<string, Feature>;
|
|
14
|
+
statusCallback?: (arg: string) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function makeImageData({ ctx, renderArgs, }: {
|
|
17
|
+
ctx: CanvasRenderingContext2D;
|
|
18
|
+
renderArgs: RenderArgs;
|
|
19
|
+
}): void;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { createJBrowseTheme } from '@jbrowse/core/ui';
|
|
2
|
+
import { featureSpanPx } from '@jbrowse/core/util';
|
|
3
|
+
import { fillRect, getCharWidthHeight, getColorBaseMap, getContrastBaseMap, } from './util';
|
|
4
|
+
export function makeImageData({ ctx, renderArgs, }) {
|
|
5
|
+
const { regions, bpPerPx, rowHeight, showAllLetters, theme: configTheme, mismatchRendering, samples, rowProportion, features, } = renderArgs;
|
|
6
|
+
const region = regions[0];
|
|
7
|
+
const canvasWidth = (region.end - region.start) / bpPerPx;
|
|
8
|
+
const h = rowHeight * rowProportion;
|
|
9
|
+
const theme = createJBrowseTheme(configTheme);
|
|
10
|
+
const colorForBase = getColorBaseMap(theme);
|
|
11
|
+
const contrastForBase = getContrastBaseMap(theme);
|
|
12
|
+
const { charHeight } = getCharWidthHeight();
|
|
13
|
+
const sampleToRowMap = new Map(samples.map((s, i) => [s.id, i]));
|
|
14
|
+
const scale = 1 / bpPerPx;
|
|
15
|
+
const f = 0.4;
|
|
16
|
+
const h2 = rowHeight / 2;
|
|
17
|
+
const hp2 = h / 2;
|
|
18
|
+
const offset = (rowHeight - h) / 2;
|
|
19
|
+
// sample as alignments
|
|
20
|
+
ctx.font = 'bold 10px Courier New,monospace';
|
|
21
|
+
for (const feature of features.values()) {
|
|
22
|
+
const [leftPx] = featureSpanPx(feature, region, bpPerPx);
|
|
23
|
+
const vals = feature.get('alignments');
|
|
24
|
+
const seq = feature.get('seq').toLowerCase();
|
|
25
|
+
const r = Object.entries(vals);
|
|
26
|
+
for (const [sample, val] of r) {
|
|
27
|
+
const origAlignment = val.data;
|
|
28
|
+
const alignment = origAlignment.toLowerCase();
|
|
29
|
+
const row = sampleToRowMap.get(sample);
|
|
30
|
+
if (row === undefined) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const t = rowHeight * row;
|
|
34
|
+
// gaps
|
|
35
|
+
ctx.beginPath();
|
|
36
|
+
ctx.fillStyle = 'black';
|
|
37
|
+
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
38
|
+
if (seq[i] !== '-') {
|
|
39
|
+
if (alignment[i] === '-') {
|
|
40
|
+
const l = leftPx + scale * o;
|
|
41
|
+
ctx.moveTo(l, t + h2);
|
|
42
|
+
ctx.lineTo(l + scale + f, t + h2);
|
|
43
|
+
}
|
|
44
|
+
o++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
ctx.stroke();
|
|
48
|
+
if (!showAllLetters) {
|
|
49
|
+
// matches
|
|
50
|
+
ctx.fillStyle = 'lightgrey';
|
|
51
|
+
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
52
|
+
if (seq[i] !== '-') {
|
|
53
|
+
const c = alignment[i];
|
|
54
|
+
const l = leftPx + scale * o;
|
|
55
|
+
if (seq[i] === c && c !== '-') {
|
|
56
|
+
fillRect(ctx, l, offset + t, scale + f, h, canvasWidth);
|
|
57
|
+
}
|
|
58
|
+
o++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// mismatches
|
|
63
|
+
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
64
|
+
const c = alignment[i];
|
|
65
|
+
if (seq[i] !== '-') {
|
|
66
|
+
if (c !== '-') {
|
|
67
|
+
const l = leftPx + scale * o;
|
|
68
|
+
if (seq[i] !== c && c !== ' ') {
|
|
69
|
+
fillRect(ctx, l, offset + t, scale + f, h, canvasWidth, mismatchRendering
|
|
70
|
+
? // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
71
|
+
(colorForBase[c] ?? 'black')
|
|
72
|
+
: 'orange');
|
|
73
|
+
}
|
|
74
|
+
else if (showAllLetters) {
|
|
75
|
+
fillRect(ctx, l, offset + t, scale + f, h, canvasWidth, mismatchRendering
|
|
76
|
+
? // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
77
|
+
(colorForBase[c] ?? 'black')
|
|
78
|
+
: 'lightblue');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
o++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// font
|
|
85
|
+
const charSizeW = 10;
|
|
86
|
+
if (scale >= charSizeW) {
|
|
87
|
+
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
88
|
+
if (seq[i] !== '-') {
|
|
89
|
+
const l = leftPx + scale * o;
|
|
90
|
+
const offset = (scale - charSizeW) / 2 + 1;
|
|
91
|
+
const c = alignment[i];
|
|
92
|
+
if ((showAllLetters || seq[i] !== c) && c !== '-') {
|
|
93
|
+
ctx.fillStyle = mismatchRendering
|
|
94
|
+
? (contrastForBase[c] ?? 'white')
|
|
95
|
+
: 'black';
|
|
96
|
+
if (rowHeight > charHeight) {
|
|
97
|
+
ctx.fillText(origAlignment[i] || '', l + offset, hp2 + t + 3);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
o++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// second pass for insertions, has slightly improved look since the
|
|
107
|
+
// insertions are always 'on top' of the other features
|
|
108
|
+
for (const feature of features.values()) {
|
|
109
|
+
const [leftPx] = featureSpanPx(feature, region, bpPerPx);
|
|
110
|
+
const vals = feature.get('alignments');
|
|
111
|
+
const seq = feature.get('seq').toLowerCase();
|
|
112
|
+
for (const [sample, val] of Object.entries(vals)) {
|
|
113
|
+
const origAlignment = val.data;
|
|
114
|
+
const alignment = origAlignment.toLowerCase();
|
|
115
|
+
const row = sampleToRowMap.get(sample);
|
|
116
|
+
if (row === undefined) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const t = rowHeight * row;
|
|
120
|
+
ctx.beginPath();
|
|
121
|
+
ctx.fillStyle = 'purple';
|
|
122
|
+
for (let i = 0, o = 0; i < alignment.length; i++) {
|
|
123
|
+
let ins = '';
|
|
124
|
+
while (seq[i] === '-') {
|
|
125
|
+
if (alignment[i] !== '-' && alignment[i] !== ' ') {
|
|
126
|
+
ins += alignment[i];
|
|
127
|
+
}
|
|
128
|
+
i++;
|
|
129
|
+
}
|
|
130
|
+
if (ins.length > 0) {
|
|
131
|
+
const l = leftPx + scale * o - 1;
|
|
132
|
+
ctx.rect(l, offset + t, 1, h);
|
|
133
|
+
if (bpPerPx < 1) {
|
|
134
|
+
ctx.rect(l - 2, offset + t, 5, 1);
|
|
135
|
+
ctx.rect(l - 2, offset + t + h - 1, 5, 1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
o++;
|
|
139
|
+
}
|
|
140
|
+
ctx.fill();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=makeImageData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeImageData.js","sourceRoot":"","sources":["../../src/LinearMafRenderer/makeImageData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAW,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE3D,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,kBAAkB,GACnB,MAAM,QAAQ,CAAA;AAgBf,MAAM,UAAU,aAAa,CAAC,EAC5B,GAAG,EACH,UAAU,GAIX;IACC,MAAM,EACJ,OAAO,EACP,OAAO,EACP,SAAS,EACT,cAAc,EACd,KAAK,EAAE,WAAW,EAClB,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,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;wBACjD,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAA;oBACrB,CAAC;oBACD,CAAC,EAAE,CAAA;gBACL,CAAC;gBACD,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACnB,MAAM,CAAC,GAAG,MAAM,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAA;oBAEhC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;oBAC7B,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;wBAChB,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;wBACjC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;oBAC3C,CAAC;gBACH,CAAC;gBACD,CAAC,EAAE,CAAA;YACL,CAAC;YACD,GAAG,CAAC,IAAI,EAAE,CAAA;QACZ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Theme } from '@mui/material';
|
|
1
|
+
import type { Theme } from '@mui/material';
|
|
2
2
|
export declare function getContrastBaseMap(theme: Theme): {
|
|
3
3
|
[k: string]: string;
|
|
4
4
|
};
|
|
@@ -8,3 +8,8 @@ export declare function getColorBaseMap(theme: Theme): {
|
|
|
8
8
|
g: string;
|
|
9
9
|
t: string;
|
|
10
10
|
};
|
|
11
|
+
export declare function fillRect(ctx: CanvasRenderingContext2D, l: number, t: number, w: number, h: number, cw: number, color?: string): void;
|
|
12
|
+
export declare function getCharWidthHeight(): {
|
|
13
|
+
charWidth: number;
|
|
14
|
+
charHeight: number;
|
|
15
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { measureText } from '@jbrowse/core/util';
|
|
1
2
|
export function getContrastBaseMap(theme) {
|
|
2
3
|
return Object.fromEntries(Object.entries(getColorBaseMap(theme)).map(([key, value]) => [
|
|
3
4
|
key,
|
|
@@ -13,4 +14,20 @@ export function getColorBaseMap(theme) {
|
|
|
13
14
|
t: bases.T.main,
|
|
14
15
|
};
|
|
15
16
|
}
|
|
17
|
+
export function fillRect(ctx, l, t, w, h, cw, color) {
|
|
18
|
+
if (l + w < 0 || l > cw) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (color) {
|
|
22
|
+
ctx.fillStyle = color;
|
|
23
|
+
}
|
|
24
|
+
ctx.fillRect(l, t, w, h);
|
|
25
|
+
}
|
|
26
|
+
// get width and height of chars the height is an approximation: width letter M
|
|
27
|
+
// is approximately the height
|
|
28
|
+
export function getCharWidthHeight() {
|
|
29
|
+
const charWidth = measureText('A');
|
|
30
|
+
const charHeight = measureText('M') - 2;
|
|
31
|
+
return { charWidth, charHeight };
|
|
32
|
+
}
|
|
16
33
|
//# sourceMappingURL=util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/LinearMafRenderer/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/LinearMafRenderer/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD,MAAM,UAAU,kBAAkB,CAAC,KAAY;IAC7C,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QAC3D,GAAG;QACH,KAAK,CAAC,OAAO,CAAC,e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