@datagrok/peptides 0.8.7 → 0.8.8
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 +1 -3
- package/setup.cmd +18 -0
- package/src/describe.ts +2 -2
- package/src/monomer-library.ts +1 -2
- package/src/package.ts +24 -2
- package/src/utils/cell-renderer.ts +29 -7
- package/src/utils/chem-palette.ts +10 -4
- package/src/viewers/subst-viewer.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/peptides",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@biowasm/aioli": ">=2.4.0",
|
|
@@ -32,8 +32,6 @@
|
|
|
32
32
|
"webpack-cli": "latest"
|
|
33
33
|
},
|
|
34
34
|
"sources": [
|
|
35
|
-
"files/aligned.csv",
|
|
36
|
-
"files/aligned_2.csv",
|
|
37
35
|
"common/ngl_viewer/ngl.js"
|
|
38
36
|
],
|
|
39
37
|
"scripts": {
|
package/setup.cmd
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
call npm unlink datagrok-api
|
|
2
|
+
call npm unlink @datagrok-libraries/utils
|
|
3
|
+
call npm unlink @datagrok-libraries/ml
|
|
4
|
+
cd ../../js-api
|
|
5
|
+
call npm install
|
|
6
|
+
call npm link
|
|
7
|
+
cd ../libraries/utils
|
|
8
|
+
call npm install
|
|
9
|
+
call npm link
|
|
10
|
+
call npm link datagrok-api
|
|
11
|
+
cd ../../libraries/ml
|
|
12
|
+
call npm install
|
|
13
|
+
call npm link
|
|
14
|
+
call npm link @datagrok-libraries/utils
|
|
15
|
+
cd ../../packages/Peptides
|
|
16
|
+
call npm install
|
|
17
|
+
call npm link datagrok-api @datagrok-libraries/utils @datagrok-libraries/ml
|
|
18
|
+
webpack
|
package/src/describe.ts
CHANGED
|
@@ -356,7 +356,7 @@ function setTooltipFunc(
|
|
|
356
356
|
sarGrid: DG.Grid,
|
|
357
357
|
sarVGrid: DG.Grid,
|
|
358
358
|
) {
|
|
359
|
-
const onCellTooltipFunc = function(cell: DG.GridCell, x: number, y: number) {
|
|
359
|
+
const onCellTooltipFunc = async function(cell: DG.GridCell, x: number, y: number) {
|
|
360
360
|
if (
|
|
361
361
|
!cell.isRowHeader &&
|
|
362
362
|
!cell.isColHeader &&
|
|
@@ -401,7 +401,7 @@ function setTooltipFunc(
|
|
|
401
401
|
const divText = ui.divText('Amino Acids in this group: ' + currentGroup['aminoAcids'].join(', '));
|
|
402
402
|
ui.tooltip.show(ui.divV([ui.h3(currentGroup['description']), divText]), x, y);
|
|
403
403
|
} else
|
|
404
|
-
cp.showTooltip(cell, x, y);
|
|
404
|
+
await cp.showTooltip(cell, x, y);
|
|
405
405
|
}
|
|
406
406
|
return true;
|
|
407
407
|
};
|
package/src/monomer-library.ts
CHANGED
|
@@ -16,7 +16,6 @@ export class MonomerLibrary {
|
|
|
16
16
|
private monomers: string[] = [];
|
|
17
17
|
|
|
18
18
|
constructor(sdf: string) {
|
|
19
|
-
//sdf = sdf.replaceAll('\n\[', '\[');
|
|
20
19
|
const sdfReader = new SDFReader();
|
|
21
20
|
const data = sdfReader.get_colls(sdf);
|
|
22
21
|
this.monomerFields.forEach((f) => {
|
|
@@ -39,7 +38,7 @@ export class MonomerLibrary {
|
|
|
39
38
|
|
|
40
39
|
const name = data.MonomerCode[i] !== '.' ? data.MonomerCode[i] : data.MonomerName[i];
|
|
41
40
|
this.library[name] = entry;
|
|
42
|
-
this.monomers.push(
|
|
41
|
+
this.monomers.push(name);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
package/src/package.ts
CHANGED
|
@@ -232,18 +232,40 @@ export async function peptideSubstitution(table: DG.DataFrame): Promise<DG.Widge
|
|
|
232
232
|
if (!table) {
|
|
233
233
|
return new DG.Widget(ui.label('No difference'));
|
|
234
234
|
}
|
|
235
|
+
const peptideLength = 17;
|
|
235
236
|
let initialCol: DG.Column = table.columns.byName('Initial');
|
|
236
237
|
let substitutedCol: DG.Column = table.columns.byName('Substituted');
|
|
238
|
+
let substCounts = [];
|
|
239
|
+
let cnt = 0;
|
|
237
240
|
|
|
238
241
|
for (let i = 0; i < initialCol.length; ++i) {
|
|
239
|
-
|
|
242
|
+
const initialPeptide: string = initialCol.get(i);
|
|
243
|
+
const substPeptide: string = substitutedCol.get(i);
|
|
244
|
+
const concat = initialPeptide + '#' + substPeptide;
|
|
245
|
+
|
|
240
246
|
initialCol.set(i, concat);
|
|
247
|
+
|
|
248
|
+
const initialAminos = initialPeptide.split('-');
|
|
249
|
+
const substAminos = substPeptide.split('-');
|
|
250
|
+
|
|
251
|
+
for (let j = 0; j < peptideLength; ++j) {
|
|
252
|
+
if (initialAminos[j] != substAminos[j])
|
|
253
|
+
substCounts[cnt++] = j;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const countCol = DG.Column.fromInt32Array('substCounts', substCounts as unknown as Int32Array);
|
|
258
|
+
const df = DG.DataFrame.fromColumns([countCol]);
|
|
259
|
+
const barchart = df.plot.histogram({value: 'substCounts'});
|
|
260
|
+
if (barchart) {
|
|
261
|
+
barchart.root.style.width = '200px';
|
|
262
|
+
barchart.root.style.marginLeft = '30px';
|
|
241
263
|
}
|
|
242
264
|
|
|
243
265
|
initialCol.semType = 'alignedSequenceDifference';
|
|
244
266
|
initialCol.name = 'Substitution';
|
|
245
267
|
table.columns.remove('Substituted');
|
|
246
|
-
return new DG.Widget(ui.
|
|
268
|
+
return new DG.Widget(ui.div([barchart?.root, table.plot.grid().root]));
|
|
247
269
|
}
|
|
248
270
|
|
|
249
271
|
//name: alignedSequenceDifferenceCellRenderer
|
|
@@ -74,12 +74,13 @@ export function measureAAR(s: string): number {
|
|
|
74
74
|
* @param {number} [pivot=0] Pirvot.
|
|
75
75
|
* @param {boolean} [left=false] Is left aligned.
|
|
76
76
|
* @param {boolean} [hideMod=false] Hide amino acid redidue modifications.
|
|
77
|
+
* @param {number} [transparencyRate=0.0] Transparency rate where 1.0 is fully transparent
|
|
77
78
|
* @return {number} x coordinate to start printing at.
|
|
78
79
|
*/
|
|
79
80
|
function printLeftOrCentered(
|
|
80
81
|
x: number, y: number, w: number, h: number,
|
|
81
82
|
g: CanvasRenderingContext2D, s: string, color = ChemPalette.undefinedColor,
|
|
82
|
-
pivot: number = 0, left = false, hideMod = false,
|
|
83
|
+
pivot: number = 0, left = false, hideMod = false, transparencyRate: number = 1.0
|
|
83
84
|
) {
|
|
84
85
|
g.textAlign = 'start';
|
|
85
86
|
let colorPart = pivot == -1 ? s.substring(0) : s.substring(0, pivot);
|
|
@@ -112,6 +113,7 @@ function printLeftOrCentered(
|
|
|
112
113
|
|
|
113
114
|
function draw(dx1: number, dx2: number) {
|
|
114
115
|
g.fillStyle = color;
|
|
116
|
+
g.globalAlpha = transparencyRate;
|
|
115
117
|
g.fillText(
|
|
116
118
|
colorPart,
|
|
117
119
|
x + dx1,
|
|
@@ -230,6 +232,16 @@ export class AlignedSequenceCellRenderer extends DG.GridCellRenderer {
|
|
|
230
232
|
return 'alignedSequence';
|
|
231
233
|
}
|
|
232
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Cell width.
|
|
237
|
+
*
|
|
238
|
+
* @readonly
|
|
239
|
+
* @memberof AlignedSequenceCellRenderer
|
|
240
|
+
*/
|
|
241
|
+
get defaultWidth() {
|
|
242
|
+
return 230;
|
|
243
|
+
}
|
|
244
|
+
|
|
233
245
|
/**
|
|
234
246
|
* Cell renderer function.
|
|
235
247
|
*
|
|
@@ -337,7 +349,17 @@ export function processSequence(subParts: string[]): [string[], boolean] {
|
|
|
337
349
|
* @memberof AlignedSequenceDifferenceCellRenderer
|
|
338
350
|
*/
|
|
339
351
|
get defaultHeight() {
|
|
340
|
-
return
|
|
352
|
+
return 30;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Cell width.
|
|
357
|
+
*
|
|
358
|
+
* @readonly
|
|
359
|
+
* @memberof AlignedSequenceDifferenceCellRenderer
|
|
360
|
+
*/
|
|
361
|
+
get defaultWidth() {
|
|
362
|
+
return 200;
|
|
341
363
|
}
|
|
342
364
|
|
|
343
365
|
/**
|
|
@@ -360,7 +382,7 @@ export function processSequence(subParts: string[]): [string[], boolean] {
|
|
|
360
382
|
const cell = gridCell.cell;
|
|
361
383
|
|
|
362
384
|
w = grid ? Math.min(grid.canvas.width - x, w) : g.canvas.width - x;
|
|
363
|
-
y +=
|
|
385
|
+
y += 2;
|
|
364
386
|
g.save();
|
|
365
387
|
g.beginPath();
|
|
366
388
|
g.rect(x, y, w, h);
|
|
@@ -387,17 +409,17 @@ export function processSequence(subParts: string[]): [string[], boolean] {
|
|
|
387
409
|
[color, pivot] = cp.getColorPivot(amino2);
|
|
388
410
|
|
|
389
411
|
if (amino1 != amino2) {
|
|
390
|
-
const verticalShift =
|
|
412
|
+
const verticalShift = 7;
|
|
391
413
|
|
|
392
414
|
if (amino1 == '')
|
|
393
415
|
amino1 = '-';
|
|
394
416
|
if (amino2 == '')
|
|
395
417
|
amino2 = '-';
|
|
396
418
|
|
|
397
|
-
printLeftOrCentered(x, y - verticalShift, w, h, g, amino1,
|
|
398
|
-
x = printLeftOrCentered(x, y + verticalShift, w, h, g, amino2,
|
|
419
|
+
printLeftOrCentered(x, y - verticalShift, w, h, g, amino1, color, pivot, true);
|
|
420
|
+
x = printLeftOrCentered(x, y + verticalShift, w, h, g, amino2, color, pivot, true);
|
|
399
421
|
} else {
|
|
400
|
-
x = printLeftOrCentered(x, y, w, h, g, amino1, color, pivot, true);
|
|
422
|
+
x = printLeftOrCentered(x, y, w, h, g, amino1, color, pivot, true, false, 0.5);
|
|
401
423
|
}
|
|
402
424
|
});
|
|
403
425
|
g.restore();
|
|
@@ -3,6 +3,8 @@ import * as ui from 'datagrok-api/ui';
|
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
4
|
|
|
5
5
|
import {StringDictionary} from '@datagrok-libraries/utils/src/type-declarations';
|
|
6
|
+
import {_package} from '../package';
|
|
7
|
+
import {MonomerLibrary} from '../monomer-library';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Chem palette class.
|
|
@@ -12,7 +14,8 @@ import {StringDictionary} from '@datagrok-libraries/utils/src/type-declarations'
|
|
|
12
14
|
*/
|
|
13
15
|
export class ChemPalette {
|
|
14
16
|
cp: StringDictionary = {};
|
|
15
|
-
|
|
17
|
+
isInit: boolean = false;
|
|
18
|
+
monomerLib: MonomerLibrary | null = null;
|
|
16
19
|
/**
|
|
17
20
|
* Creates an instance of ChemPalette.
|
|
18
21
|
*
|
|
@@ -32,11 +35,14 @@ export class ChemPalette {
|
|
|
32
35
|
* @param {number} x x coordinate of the mouse pointer.
|
|
33
36
|
* @param {number} y y coordinate of the mouse pointer.
|
|
34
37
|
*/
|
|
35
|
-
showTooltip(cell: DG.GridCell, x: number, y: number) {
|
|
38
|
+
async showTooltip(cell: DG.GridCell, x: number, y: number) {
|
|
39
|
+
if(!this.isInit)
|
|
40
|
+
this.monomerLib = new MonomerLibrary(await _package.files.readAsText(`HELMMonomers_June10.sdf`));
|
|
41
|
+
|
|
36
42
|
const s = cell.cell.value as string;
|
|
37
43
|
let toDisplay = [ui.divText(s)];
|
|
38
44
|
const [, aar] = this.getColorAAPivot(s);
|
|
39
|
-
if (aar
|
|
45
|
+
if (this.monomerLib!.monomerNames.includes(aar)) {
|
|
40
46
|
if (s in ChemPalette.AANames)
|
|
41
47
|
toDisplay = [ui.divText(ChemPalette.AANames[s])];
|
|
42
48
|
|
|
@@ -48,7 +54,7 @@ export class ChemPalette {
|
|
|
48
54
|
autoCropMargin: 0,
|
|
49
55
|
suppressChiralText: true,
|
|
50
56
|
};
|
|
51
|
-
const sketch = grok.chem.svgMol(
|
|
57
|
+
const sketch = grok.chem.svgMol(this.monomerLib!.getMonomerMol(aar), undefined, undefined, options);
|
|
52
58
|
toDisplay.push(sketch);
|
|
53
59
|
}
|
|
54
60
|
ui.tooltip.show(ui.divV(toDisplay), x, y);
|
|
@@ -13,12 +13,14 @@ export class SubstViewer extends DG.JsViewer {
|
|
|
13
13
|
maxSubstitutions: number;
|
|
14
14
|
activityLimit: number;
|
|
15
15
|
activityColumnName: string;
|
|
16
|
+
title: string;
|
|
16
17
|
casesGrid: DG.Grid | null;
|
|
17
18
|
|
|
18
19
|
constructor() {
|
|
19
20
|
super();
|
|
20
21
|
|
|
21
22
|
this.activityColumnName = this.string('activityColumnName');
|
|
23
|
+
this.title = this.string('title', 'Substitution analysis');
|
|
22
24
|
|
|
23
25
|
this.maxSubstitutions = this.int('maxSubstitutions', 1);
|
|
24
26
|
this.activityLimit = this.float('activityLimit', 2);
|
|
@@ -216,7 +218,11 @@ export class SubstViewer extends DG.JsViewer {
|
|
|
216
218
|
|
|
217
219
|
render() {
|
|
218
220
|
$(this.root).empty();
|
|
219
|
-
|
|
221
|
+
const title = ui.h1(this.title, {style: {'align-self': 'center'}});
|
|
222
|
+
const grid = this.viewerGrid!.root;
|
|
223
|
+
title.style.alignContent = 'center';
|
|
224
|
+
grid.style.width = 'auto';
|
|
225
|
+
this.root.appendChild(ui.divV([title, grid]));
|
|
220
226
|
}
|
|
221
227
|
|
|
222
228
|
split(peptideColumn: DG.Column, filter: boolean = true): string[][] {
|