@datagrok/bio 2.0.9 → 2.0.11
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/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.11",
|
|
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",
|
|
@@ -80,7 +80,7 @@ category('renderers', () => {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async function _rendererMacromoleculeSeparator() {
|
|
83
|
-
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/
|
|
83
|
+
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/data/sample_SEPARATOR_PT.csv');
|
|
84
84
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
85
85
|
|
|
86
86
|
const seqCol = df.getCol('sequence');
|
|
@@ -159,7 +159,7 @@ category('renderers', () => {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
async function _testAfterConvert() {
|
|
162
|
-
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/
|
|
162
|
+
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/data/sample_FASTA_PT.csv');
|
|
163
163
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
164
164
|
|
|
165
165
|
const srcCol: DG.Column = df.col('sequence')!;
|
|
@@ -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([
|
package/src/utils/utils.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '../const';
|
|
8
8
|
import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
9
9
|
|
|
10
|
-
export const HELM_CORE_LIB_FILENAME = '/
|
|
10
|
+
export const HELM_CORE_LIB_FILENAME = '/data/HELMCoreLibrary.json';
|
|
11
11
|
export const HELM_CORE_LIB_MONOMER_SYMBOL = 'symbol';
|
|
12
12
|
export const HELM_CORE_LIB_MOLFILE = 'molfile';
|
|
13
13
|
export const HELM_CORE_FIELDS = ['symbol', 'molfile', 'rgroups', 'name'];
|