@datagrok/bio 2.0.9 → 2.0.10
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/package-test.js +35 -3
- package/dist/package.js +35 -3
- package/package.json +1 -1
- package/src/utils/cell-renderer.ts +27 -1
- package/src/utils/sequence-activity-cliffs.ts +17 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "Leonid Stolbov",
|
|
6
6
|
"email": "lstolbov@datagrok.ai"
|
|
7
7
|
},
|
|
8
|
-
"version": "2.0.
|
|
8
|
+
"version": "2.0.10",
|
|
9
9
|
"description": "Bio is a [package](https://datagrok.ai/help/develop/develop#packages) for the [Datagrok](https://datagrok.ai) platform",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -274,7 +274,8 @@ export function drawMoleculeDifferenceOnCanvas(
|
|
|
274
274
|
s: string,
|
|
275
275
|
units: string,
|
|
276
276
|
separator: string,
|
|
277
|
-
fullStringLength?: boolean
|
|
277
|
+
fullStringLength?: boolean,
|
|
278
|
+
molDifferences?:{[key: number]: HTMLCanvasElement}) {
|
|
278
279
|
|
|
279
280
|
//TODO: can this be replaced/merged with splitSequence?
|
|
280
281
|
const [s1, s2] = s.split('#');
|
|
@@ -314,9 +315,34 @@ export function drawMoleculeDifferenceOnCanvas(
|
|
|
314
315
|
const subX0 = printLeftOrCentered(updatedX, updatedY - vShift, w, h, g, amino1, color1, 0, true);
|
|
315
316
|
const subX1 = printLeftOrCentered(updatedX, updatedY + vShift, w, h, g, amino2, color2, 0, true);
|
|
316
317
|
updatedX = Math.max(subX1, subX0);
|
|
318
|
+
if (molDifferences) {
|
|
319
|
+
molDifferences[i] = createDifferenceCanvas(amino1, amino2, color1, color2, updatedY, vShift, h);
|
|
320
|
+
}
|
|
317
321
|
} else
|
|
318
322
|
updatedX = printLeftOrCentered(updatedX, updatedY, w, h, g, amino1, color1, 0, true, 0.5);
|
|
319
323
|
updatedX += 4;
|
|
320
324
|
}
|
|
321
325
|
g.restore();
|
|
322
326
|
}
|
|
327
|
+
|
|
328
|
+
function createDifferenceCanvas(
|
|
329
|
+
amino1: string,
|
|
330
|
+
amino2: string,
|
|
331
|
+
color1: string,
|
|
332
|
+
color2: string,
|
|
333
|
+
y: number,
|
|
334
|
+
shift: number,
|
|
335
|
+
h: number): HTMLCanvasElement {
|
|
336
|
+
const canvas = document.createElement('canvas');
|
|
337
|
+
const context = canvas.getContext('2d')!;
|
|
338
|
+
const width1 = context.measureText(processSequence([amino1]).join('')).width;
|
|
339
|
+
const width2 = context.measureText(processSequence([amino2]).join('')).width;
|
|
340
|
+
const width = Math.max(width1, width2);
|
|
341
|
+
canvas.height = h;
|
|
342
|
+
canvas.width = width + 20;
|
|
343
|
+
context.font = '12px monospace';
|
|
344
|
+
context.textBaseline = 'top';
|
|
345
|
+
printLeftOrCentered(0, y - shift, width, h, context, amino1, color1, 0, true);
|
|
346
|
+
printLeftOrCentered(0, y + shift, width, h, context, amino2, color2, 0, true);
|
|
347
|
+
return canvas;
|
|
348
|
+
}
|
|
@@ -88,8 +88,24 @@ export function createPropPanelElement(params: ITooltipAndPanelParams): HTMLDivE
|
|
|
88
88
|
canvas.height = 30;
|
|
89
89
|
const units = params.seqCol.getTag(DG.TAGS.UNITS);
|
|
90
90
|
const separator = params.seqCol.getTag(TAGS.SEPARATOR);
|
|
91
|
-
|
|
91
|
+
const molDifferences: {[key: number]: HTMLCanvasElement} = {};
|
|
92
|
+
drawMoleculeDifferenceOnCanvas(context!, 0, 0, 0, 30, sequencesArray.join('#'), units, separator, true, molDifferences);
|
|
92
93
|
propPanel.append(ui.div(canvas, { style: { width: '300px', overflow: 'scroll' } }));
|
|
94
|
+
|
|
95
|
+
if (Object.keys(molDifferences).length > 0) {
|
|
96
|
+
const diffsPanel = ui.divV([]);
|
|
97
|
+
diffsPanel.append(ui.divH([
|
|
98
|
+
ui.divText('Pos', { style: { fontWeight: 'bold', width: '30px' } }),
|
|
99
|
+
ui.divText('Difference', { style: { fontWeight: 'bold' } })
|
|
100
|
+
]))
|
|
101
|
+
for (let key of Object.keys(molDifferences)) {
|
|
102
|
+
diffsPanel.append(ui.divH([
|
|
103
|
+
ui.divText(key, { style: { width: '30px' } }),
|
|
104
|
+
molDifferences[key as any]
|
|
105
|
+
]));
|
|
106
|
+
}
|
|
107
|
+
propPanel.append(diffsPanel);
|
|
108
|
+
}
|
|
93
109
|
|
|
94
110
|
function addFiledToPropPanel(name: string, value: number) {
|
|
95
111
|
propPanel.append(ui.divH([
|