@datagrok/peptides 1.3.2 → 1.3.4
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 +1394 -206
- package/dist/package.js +1360 -187
- package/package.json +3 -3
- package/setup-unlink-clean.cmd +19 -0
- package/setup.cmd +15 -18
- package/src/model.ts +17 -22
- package/src/package-test.ts +4 -3
- package/src/tests/core.ts +8 -10
- package/src/utils/cell-renderer.ts +3 -4
- package/src/utils/misc.ts +10 -26
- package/src/widgets/manual-alignment.ts +2 -3
- package/src/widgets/peptides.ts +31 -55
- package/{test-Peptides-916a90d7d48b-ea373bf5.html → test-Peptides-916a90d7d48b-d2f9014f.html} +28 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/peptides",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Volodymyr Dyma",
|
|
6
6
|
"email": "vdyma@datagrok.ai"
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/Peptides"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@datagrok-libraries/bio": "^5.
|
|
15
|
+
"@datagrok-libraries/bio": "^5.1.0",
|
|
16
16
|
"@datagrok-libraries/ml": "^2.0.1",
|
|
17
17
|
"@datagrok-libraries/statistics": "^0.1.6",
|
|
18
|
-
"@datagrok-libraries/utils": "^1.
|
|
18
|
+
"@datagrok-libraries/utils": "^1.11.1",
|
|
19
19
|
"cash-dom": "latest",
|
|
20
20
|
"datagrok-api": "^1.6.0",
|
|
21
21
|
"file-loader": "^6.2.0",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
set package_dir=%cd%
|
|
2
|
+
|
|
3
|
+
set dirs=^
|
|
4
|
+
\..\..\js-api\ ^
|
|
5
|
+
\..\..\libraries\utils\ ^
|
|
6
|
+
\..\..\libraries\ml\ ^
|
|
7
|
+
\..\..\libraries\bio\ ^
|
|
8
|
+
\
|
|
9
|
+
|
|
10
|
+
call npm uninstall -g ^
|
|
11
|
+
datagrok-api ^
|
|
12
|
+
@datagrok-libraries/utils ^
|
|
13
|
+
@datagrok-libraries/ml ^
|
|
14
|
+
@datagrok-libraries/bio ^
|
|
15
|
+
|
|
16
|
+
for %%p in (%dirs%) do cd %package_dir%\%%p & rmdir /s /q node_modules
|
|
17
|
+
for %%p in (%dirs%) do cd %package_dir%\%%p & rmdir /s /q dist
|
|
18
|
+
|
|
19
|
+
for %%p in (%dirs%) do cd %package_dir%\%%p & del "package-lock.json"
|
package/setup.cmd
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
call
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
call npm install
|
|
13
|
-
call npm link
|
|
14
|
-
call npm link
|
|
15
|
-
cd
|
|
16
|
-
call npm install
|
|
17
|
-
call npm link datagrok-api @datagrok-libraries/utils @datagrok-libraries/ml
|
|
18
|
-
webpack
|
|
1
|
+
call setup-unlink-clean.cmd
|
|
2
|
+
|
|
3
|
+
set package_dir=%cd%
|
|
4
|
+
|
|
5
|
+
set dirs=^
|
|
6
|
+
\..\..\js-api\ ^
|
|
7
|
+
\..\..\libraries\utils\ ^
|
|
8
|
+
\..\..\libraries\ml\ ^
|
|
9
|
+
\..\..\libraries\bio\ ^
|
|
10
|
+
\
|
|
11
|
+
|
|
12
|
+
for %%p in (%dirs%) do cd %package_dir%\%%p & call npm install
|
|
13
|
+
for %%p in (%dirs%) do cd %package_dir%\%%p & call npm link
|
|
14
|
+
for %%p in (%dirs%) do cd %package_dir%\%%p & call npm run link-all
|
|
15
|
+
for %%p in (%dirs%) do cd %package_dir%\%%p & call npm run build
|
package/src/model.ts
CHANGED
|
@@ -36,9 +36,9 @@ export class PeptidesModel {
|
|
|
36
36
|
edf: DG.DataFrame | null = null;
|
|
37
37
|
monomerPositionStatsDf!: DG.DataFrame;
|
|
38
38
|
clusterStatsDf!: DG.DataFrame;
|
|
39
|
-
_mutationCliffsSelection
|
|
40
|
-
_invariantMapSelection
|
|
41
|
-
_logoSummarySelection
|
|
39
|
+
_mutationCliffsSelection!: type.PositionToAARList;
|
|
40
|
+
_invariantMapSelection!: type.PositionToAARList;
|
|
41
|
+
_logoSummarySelection!: number[];
|
|
42
42
|
substitutionsInfo: type.SubstitutionsInfo = new Map();
|
|
43
43
|
isInitialized = false;
|
|
44
44
|
currentView!: DG.TableView;
|
|
@@ -375,14 +375,15 @@ export class PeptidesModel {
|
|
|
375
375
|
joinDataFrames(positionColumns: string[], splitSeqDf: DG.DataFrame, alphabet: string): void {
|
|
376
376
|
// append splitSeqDf columns to source table and make sure columns are not added more than once
|
|
377
377
|
const name = this.df.name;
|
|
378
|
+
const cols = this.df.columns;
|
|
378
379
|
for (const colName of positionColumns) {
|
|
379
380
|
const col = this.df.col(colName);
|
|
380
381
|
const newCol = splitSeqDf.getCol(colName);
|
|
381
382
|
if (col === null)
|
|
382
|
-
|
|
383
|
+
cols.add(newCol);
|
|
383
384
|
else {
|
|
384
|
-
|
|
385
|
-
|
|
385
|
+
cols.remove(colName);
|
|
386
|
+
cols.add(newCol);
|
|
386
387
|
}
|
|
387
388
|
CR.setAARRenderer(newCol, alphabet, this.sourceGrid);
|
|
388
389
|
}
|
|
@@ -409,21 +410,15 @@ export class PeptidesModel {
|
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
createScaledCol(activityScaling: string, splitSeqDf: DG.DataFrame): void {
|
|
412
|
-
const
|
|
413
|
-
scaleActivity(activityScaling, this.df.getCol(C.COLUMNS_NAMES.ACTIVITY));
|
|
413
|
+
const scaledCol = scaleActivity(activityScaling, this.df.getCol(C.COLUMNS_NAMES.ACTIVITY));
|
|
414
414
|
//TODO: make another func
|
|
415
|
-
const scaledCol = scaledDf.getCol(C.COLUMNS_NAMES.ACTIVITY_SCALED);
|
|
416
|
-
scaledCol.semType = C.SEM_TYPES.ACTIVITY_SCALED;
|
|
417
415
|
splitSeqDf.columns.add(scaledCol);
|
|
418
|
-
|
|
419
|
-
this.df.columns.replace(oldScaledCol, scaledCol);
|
|
416
|
+
this.df.columns.replace(C.COLUMNS_NAMES.ACTIVITY_SCALED, scaledCol);
|
|
420
417
|
const gridCol = this.sourceGrid.col(C.COLUMNS_NAMES.ACTIVITY_SCALED);
|
|
421
|
-
if (gridCol
|
|
422
|
-
gridCol.name =
|
|
423
|
-
this.df.tags[C.COLUMNS_NAMES.ACTIVITY_SCALED] = newColName;
|
|
424
|
-
}
|
|
418
|
+
if (gridCol)
|
|
419
|
+
gridCol.name = scaledCol.getTag('gridName');
|
|
425
420
|
|
|
426
|
-
this.sourceGrid.columns.setOrder([
|
|
421
|
+
this.sourceGrid.columns.setOrder([scaledCol.getTag('gridName')]);
|
|
427
422
|
}
|
|
428
423
|
|
|
429
424
|
calculateMonomerPositionStatistics(matrixDf: DG.DataFrame): DG.DataFrame {
|
|
@@ -964,10 +959,10 @@ export class PeptidesModel {
|
|
|
964
959
|
const getBitAt = (i: number): boolean => {
|
|
965
960
|
for (const position of positionList) {
|
|
966
961
|
const positionCol: DG.Column<string> = this.df.getCol(position);
|
|
967
|
-
if (this.
|
|
962
|
+
if (this.mutationCliffsSelection[position].includes(positionCol.get(i)!))
|
|
968
963
|
return true;
|
|
969
964
|
}
|
|
970
|
-
if (this.
|
|
965
|
+
if (this.logoSummarySelection.includes(clusterCol?.get(i)!))
|
|
971
966
|
return true;
|
|
972
967
|
return false;
|
|
973
968
|
};
|
|
@@ -982,7 +977,7 @@ export class PeptidesModel {
|
|
|
982
977
|
filter.init((i) => {
|
|
983
978
|
let result = true;
|
|
984
979
|
for (const position of positionList) {
|
|
985
|
-
const aarList = this.
|
|
980
|
+
const aarList = this.invariantMapSelection[position];
|
|
986
981
|
result &&= aarList.length == 0 || aarList.includes(this.df.get(position, i));
|
|
987
982
|
}
|
|
988
983
|
return result;
|
|
@@ -1077,9 +1072,9 @@ export class PeptidesModel {
|
|
|
1077
1072
|
|
|
1078
1073
|
this.df.tags[C.PEPTIDES_ANALYSIS] = 'true';
|
|
1079
1074
|
const scaledGridCol = this.sourceGrid.col(C.COLUMNS_NAMES.ACTIVITY_SCALED)!;
|
|
1080
|
-
scaledGridCol.name =
|
|
1075
|
+
scaledGridCol.name = scaledGridCol.column!.getTag('gridName');
|
|
1081
1076
|
scaledGridCol.format = '#.000';
|
|
1082
|
-
this.sourceGrid.columns.setOrder([
|
|
1077
|
+
this.sourceGrid.columns.setOrder([scaledGridCol.name]);
|
|
1083
1078
|
this.sourceGrid.props.allowColSelection = false;
|
|
1084
1079
|
|
|
1085
1080
|
this.df.temp[C.EMBEDDING_STATUS] = false;
|
package/src/package-test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
|
-
import {runTests, tests} from '@datagrok-libraries/utils/src/test';
|
|
2
|
+
import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test';
|
|
3
3
|
|
|
4
4
|
import './tests/core';
|
|
5
5
|
import './tests/peptide-space-test';
|
|
@@ -10,8 +10,9 @@ export {tests};
|
|
|
10
10
|
//name: test
|
|
11
11
|
//input: string category {optional: true}
|
|
12
12
|
//input: string test {optional: true}
|
|
13
|
+
//input: object testContext {optional: true}
|
|
13
14
|
//output: dataframe result
|
|
14
|
-
export async function test(category: string, test: string): Promise<DG.DataFrame> {
|
|
15
|
-
const data = await runTests({category, test
|
|
15
|
+
export async function test(category: string, test: string, testContext: TestContext): Promise<DG.DataFrame> {
|
|
16
|
+
const data = await runTests({category, test, testContext});
|
|
16
17
|
return DG.DataFrame.fromObjects(data)!;
|
|
17
18
|
}
|
package/src/tests/core.ts
CHANGED
|
@@ -13,14 +13,14 @@ category('Core', () => {
|
|
|
13
13
|
let simpleTable: DG.DataFrame;
|
|
14
14
|
let simpleActivityCol: DG.Column<number>;
|
|
15
15
|
let simpleAlignedSeqCol: DG.Column<string>;
|
|
16
|
-
let
|
|
16
|
+
let simpleScaledCol: DG.Column<number>;
|
|
17
17
|
let scalingFormula: (x: number) => number;
|
|
18
18
|
let simpleScaledColName: string;
|
|
19
19
|
|
|
20
20
|
let complexTable: DG.DataFrame;
|
|
21
21
|
let complexActivityCol: DG.Column<number>;
|
|
22
22
|
let complexAlignedSeqCol: DG.Column<string>;
|
|
23
|
-
let
|
|
23
|
+
let complexScaledCol: DG.Column<number>;
|
|
24
24
|
let complexScaledColName: string;
|
|
25
25
|
const alignedSequenceCol = 'AlignedSequence';
|
|
26
26
|
|
|
@@ -35,10 +35,9 @@ category('Core', () => {
|
|
|
35
35
|
simpleAlignedSeqCol.tags[C.TAGS.ALPHABET] = 'PT';
|
|
36
36
|
simpleAlignedSeqCol.tags[DG.TAGS.UNITS] = 'fasta';
|
|
37
37
|
simpleAlignedSeqCol.tags['aligned'] = 'SEQ.MSA';
|
|
38
|
-
|
|
38
|
+
simpleScaledCol = scaleActivity('-lg', simpleActivityCol);
|
|
39
39
|
|
|
40
|
-
model = await startAnalysis(
|
|
41
|
-
simpleActivityCol, simpleAlignedSeqCol, null, simpleTable, scalingFormula, simpleScaledColName, '-lg', []);
|
|
40
|
+
model = await startAnalysis(simpleActivityCol, simpleAlignedSeqCol, null, simpleTable, simpleScaledCol, '-lg');
|
|
42
41
|
expect(model instanceof PeptidesModel, true);
|
|
43
42
|
|
|
44
43
|
if (model != null) {
|
|
@@ -57,10 +56,10 @@ category('Core', () => {
|
|
|
57
56
|
complexAlignedSeqCol.tags[DG.TAGS.UNITS] = 'separator';
|
|
58
57
|
complexAlignedSeqCol.tags['aligned'] = 'SEQ.MSA';
|
|
59
58
|
complexAlignedSeqCol.tags[C.TAGS.SEPARATOR] = '/';
|
|
60
|
-
|
|
59
|
+
complexScaledCol = scaleActivity('-lg', complexActivityCol);
|
|
61
60
|
|
|
62
61
|
model = await startAnalysis(
|
|
63
|
-
complexActivityCol, complexAlignedSeqCol, null, complexTable,
|
|
62
|
+
complexActivityCol, complexAlignedSeqCol, null, complexTable, complexScaledCol, '-lg');
|
|
64
63
|
expect(model instanceof PeptidesModel, true);
|
|
65
64
|
|
|
66
65
|
if (model != null) {
|
|
@@ -78,10 +77,9 @@ category('Core', () => {
|
|
|
78
77
|
simpleAlignedSeqCol.tags[C.TAGS.ALPHABET] = 'PT';
|
|
79
78
|
simpleAlignedSeqCol.tags[DG.TAGS.UNITS] = 'fasta';
|
|
80
79
|
simpleAlignedSeqCol.tags['aligned'] = 'SEQ.MSA';
|
|
81
|
-
|
|
80
|
+
simpleScaledCol = scaleActivity('-lg', simpleActivityCol);
|
|
82
81
|
|
|
83
|
-
model = await startAnalysis(
|
|
84
|
-
simpleActivityCol, simpleAlignedSeqCol, null, simpleTable, scalingFormula, simpleScaledColName, '-lg', []);
|
|
82
|
+
model = await startAnalysis(simpleActivityCol, simpleAlignedSeqCol, null, simpleTable, simpleScaledCol, '-lg');
|
|
85
83
|
let v = grok.shell.getTableView('Peptides analysis');
|
|
86
84
|
const d = v.dataFrame;
|
|
87
85
|
const layout = v.saveLayout();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {SeqPaletteBase} from '@datagrok-libraries/bio/src/seq-palettes';
|
|
2
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
import * as bio from '@datagrok-libraries/bio';
|
|
3
3
|
|
|
4
4
|
import * as C from './constants';
|
|
5
|
-
import {getPalleteByType} from './misc';
|
|
6
5
|
import * as types from './types';
|
|
7
6
|
|
|
8
7
|
function renderCellSelection(canvasContext: CanvasRenderingContext2D, bound: DG.Rect): void {
|
|
@@ -104,7 +103,7 @@ export function renderLogoSummaryCell(canvasContext: CanvasRenderingContext2D, c
|
|
|
104
103
|
export function renderBarchart(ctx: CanvasRenderingContext2D, col: DG.Column, monomerColStats: types.MonomerColStats,
|
|
105
104
|
bounds: DG.Rect, max: number): types.BarCoordinates {
|
|
106
105
|
let sum = col.length - (monomerColStats['-']?.count ?? 0);
|
|
107
|
-
const colorPalette =
|
|
106
|
+
const colorPalette = bio.getPaletteByType(col.tags[C.TAGS.ALPHABET]);
|
|
108
107
|
const name = col.name;
|
|
109
108
|
const colNameSize = ctx.measureText(name);
|
|
110
109
|
const margin = 0.2;
|
|
@@ -144,7 +143,7 @@ export function renderBarchart(ctx: CanvasRenderingContext2D, col: DG.Column, mo
|
|
|
144
143
|
ctx.fillStyle = color;
|
|
145
144
|
|
|
146
145
|
if (textSize.width <= subBarHeight) {
|
|
147
|
-
if (color != SeqPaletteBase.undefinedColor)
|
|
146
|
+
if (color != bio.SeqPaletteBase.undefinedColor)
|
|
148
147
|
ctx.fillRect(xStart, yStart, barWidth, subBarHeight);
|
|
149
148
|
else {
|
|
150
149
|
ctx.strokeRect(xStart + 0.5, yStart, barWidth - 1, subBarHeight);
|
package/src/utils/misc.ts
CHANGED
|
@@ -7,20 +7,6 @@ import {NucleotidesPalettes} from '@datagrok-libraries/bio/src/nucleotides';
|
|
|
7
7
|
import {UnknownSeqPalettes} from '@datagrok-libraries/bio/src/unknown';
|
|
8
8
|
import {SeqPalette} from '@datagrok-libraries/bio/src/seq-palettes';
|
|
9
9
|
|
|
10
|
-
export function getPalleteByType(paletteType: string): SeqPalette {
|
|
11
|
-
switch (paletteType) {
|
|
12
|
-
case 'PT':
|
|
13
|
-
return AminoacidsPalettes.GrokGroups;
|
|
14
|
-
case 'NT':
|
|
15
|
-
case 'DNA':
|
|
16
|
-
case 'RNA':
|
|
17
|
-
return NucleotidesPalettes.Chromatogram;
|
|
18
|
-
// other
|
|
19
|
-
default:
|
|
20
|
-
return UnknownSeqPalettes.Color;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
10
|
export function getTypedArrayConstructor(
|
|
25
11
|
maxNum: number): Uint8ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor {
|
|
26
12
|
return maxNum < 256 ? Uint8Array :
|
|
@@ -32,13 +18,10 @@ export function getSeparator(col: DG.Column<string>): string {
|
|
|
32
18
|
return col.getTag(C.TAGS.SEPARATOR) ?? '';
|
|
33
19
|
}
|
|
34
20
|
|
|
35
|
-
export function scaleActivity(
|
|
36
|
-
): [DG.DataFrame, (x: number) => number, string] {
|
|
37
|
-
const tempDf = DG.DataFrame.create(activityCol.length);
|
|
38
|
-
|
|
21
|
+
export function scaleActivity(scaling: string, activityCol: DG.Column<number>): DG.Column<number> {
|
|
39
22
|
let formula = (x: number): number => x;
|
|
40
23
|
let newColName = 'activity';
|
|
41
|
-
switch (
|
|
24
|
+
switch (scaling) {
|
|
42
25
|
case 'none':
|
|
43
26
|
break;
|
|
44
27
|
case 'lg':
|
|
@@ -50,15 +33,16 @@ export function scaleActivity(activityScaling: string, activityCol: DG.Column<nu
|
|
|
50
33
|
newColName = `-Log10(${newColName})`;
|
|
51
34
|
break;
|
|
52
35
|
default:
|
|
53
|
-
throw new Error(`ScalingError: method \`${
|
|
36
|
+
throw new Error(`ScalingError: method \`${scaling}\` is not available.`);
|
|
54
37
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
38
|
+
const scaledCol = DG.Column.float(C.COLUMNS_NAMES.ACTIVITY_SCALED, activityCol.length).init((i) => {
|
|
39
|
+
const val = activityCol.get(i);
|
|
40
|
+
return val ? formula(val) : val;
|
|
41
|
+
});
|
|
42
|
+
scaledCol.semType = C.SEM_TYPES.ACTIVITY_SCALED;
|
|
43
|
+
scaledCol.setTag('gridName', newColName);
|
|
60
44
|
|
|
61
|
-
return
|
|
45
|
+
return scaledCol;
|
|
62
46
|
}
|
|
63
47
|
|
|
64
48
|
export function calculateBarsData(columns: DG.Column<string>[], selection: DG.BitSet): type.MonomerDfStats {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as ui from 'datagrok-api/ui';
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
|
-
|
|
5
|
-
import {splitAlignedSequences} from '@datagrok-libraries/bio/src/utils/splitter';
|
|
4
|
+
import * as bio from '@datagrok-libraries/bio';
|
|
6
5
|
|
|
7
6
|
import $ from 'cash-dom';
|
|
8
7
|
import '../styles.css';
|
|
@@ -20,7 +19,7 @@ export function manualAlignmentWidget(alignedSequenceCol: DG.Column<string>, cur
|
|
|
20
19
|
const applyChangesBtn = ui.button('Apply', async () => {
|
|
21
20
|
const newSequence = sequenceInput.value;
|
|
22
21
|
const affectedRowIndex = currentDf.currentRowIdx;
|
|
23
|
-
const splitSequence = splitAlignedSequences(DG.Column.fromStrings('splitSequence', [newSequence]));
|
|
22
|
+
const splitSequence = bio.splitAlignedSequences(DG.Column.fromStrings('splitSequence', [newSequence]));
|
|
24
23
|
|
|
25
24
|
alignedSequenceCol.set(affectedRowIndex, newSequence);
|
|
26
25
|
for (const part of splitSequence.columns) {
|
package/src/widgets/peptides.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as grok from 'datagrok-api/grok';
|
|
2
2
|
import * as ui from 'datagrok-api/ui';
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
|
-
|
|
5
|
-
import {WebLogo} from '@datagrok-libraries/bio/src/viewers/web-logo';
|
|
4
|
+
import * as bio from '@datagrok-libraries/bio';
|
|
6
5
|
|
|
7
6
|
import '../styles.css';
|
|
8
7
|
import * as C from '../utils/constants';
|
|
@@ -27,32 +26,18 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
|
|
|
27
26
|
if (funcs.length == 0)
|
|
28
27
|
return new DG.Widget(ui.label('Helm package is missing or out of date. Please install the latest version.'));
|
|
29
28
|
|
|
30
|
-
let
|
|
31
|
-
let scaledDf: DG.DataFrame;
|
|
32
|
-
let newScaledColName: string;
|
|
33
|
-
let scalingFormula: (x: number) => number;
|
|
34
|
-
|
|
35
|
-
for (const column of df.columns.numerical)
|
|
36
|
-
tempCol = column.type === DG.TYPE.FLOAT ? column : null;
|
|
29
|
+
let scaledCol: DG.Column<number>;
|
|
37
30
|
|
|
38
|
-
const defaultActivityColumn: DG.Column<number> | null =
|
|
31
|
+
const defaultActivityColumn: DG.Column<number> | null =
|
|
32
|
+
df.col('activity') || df.col('IC50') || DG.Utils.firstOrNull(df.columns.numerical);;
|
|
39
33
|
const histogramHost = ui.div([], {id: 'pep-hist-host'});
|
|
40
34
|
|
|
41
|
-
const indexes: number[] = [];
|
|
42
|
-
const f = df.filter;
|
|
43
|
-
df.onFilterChanged.subscribe(() => {
|
|
44
|
-
for (let i = 0; i < f.length; ++i) {
|
|
45
|
-
if (f.get(i))
|
|
46
|
-
indexes.push(i);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
35
|
const activityScalingMethod = ui.choiceInput(
|
|
50
36
|
'Scaling', 'none', ['none', 'lg', '-lg'],
|
|
51
37
|
async (currentMethod: string): Promise<void> => {
|
|
52
|
-
|
|
53
|
-
scaleActivity(currentMethod, activityColumnChoice.value!, indexes.length !== 0 ? indexes : undefined);
|
|
38
|
+
scaledCol = scaleActivity(currentMethod, activityColumnChoice.value!);
|
|
54
39
|
|
|
55
|
-
const hist =
|
|
40
|
+
const hist = DG.DataFrame.fromColumns([scaledCol]).plot.histogram({
|
|
56
41
|
filteringEnabled: false,
|
|
57
42
|
valueColumnName: C.COLUMNS_NAMES.ACTIVITY_SCALED,
|
|
58
43
|
legendVisibility: 'Never',
|
|
@@ -66,9 +51,9 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
|
|
|
66
51
|
});
|
|
67
52
|
activityScalingMethod.setTooltip('Function to apply for each value in activity column');
|
|
68
53
|
|
|
69
|
-
const activityScalingMethodState = (
|
|
54
|
+
const activityScalingMethodState = (): void => {
|
|
70
55
|
activityScalingMethod.enabled = (activityColumnChoice.value ?? false) &&
|
|
71
|
-
DG.Stats.fromColumn(activityColumnChoice.value
|
|
56
|
+
DG.Stats.fromColumn(activityColumnChoice.value!).min > 0;
|
|
72
57
|
activityScalingMethod.fireChanged();
|
|
73
58
|
};
|
|
74
59
|
const activityColumnChoice = ui.columnInput('Activity', df, defaultActivityColumn, activityScalingMethodState);
|
|
@@ -78,13 +63,18 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
|
|
|
78
63
|
|
|
79
64
|
const inputsList = [activityColumnChoice, activityScalingMethod, clustersColumnChoice];
|
|
80
65
|
|
|
66
|
+
const bitsetChanged = df.filter.onChanged.subscribe(() => {
|
|
67
|
+
activityScalingMethodState();
|
|
68
|
+
})
|
|
69
|
+
|
|
81
70
|
const startBtn = ui.button('Launch SAR', async () => {
|
|
82
|
-
await startAnalysis(activityColumnChoice.value
|
|
83
|
-
|
|
71
|
+
await startAnalysis(activityColumnChoice.value!, col, clustersColumnChoice.value, df, scaledCol,
|
|
72
|
+
activityScalingMethod.value ?? 'none');
|
|
73
|
+
bitsetChanged.unsubscribe();
|
|
84
74
|
});
|
|
85
75
|
startBtn.style.alignSelf = 'center';
|
|
86
76
|
|
|
87
|
-
const viewer = await df.plot.fromType('WebLogo') as WebLogo;
|
|
77
|
+
const viewer = await df.plot.fromType('WebLogo') as bio.WebLogo;
|
|
88
78
|
viewer.root.style.setProperty('height', '130px');
|
|
89
79
|
const logoHost = ui.div();
|
|
90
80
|
$(logoHost).empty().append(viewer.root);
|
|
@@ -100,43 +90,30 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
|
|
|
100
90
|
);
|
|
101
91
|
}
|
|
102
92
|
|
|
103
|
-
export async function startAnalysis(activityColumn: DG.Column<number
|
|
104
|
-
clustersColumn: DG.Column | null, currentDf: DG.DataFrame,
|
|
105
|
-
|
|
93
|
+
export async function startAnalysis(activityColumn: DG.Column<number>, peptidesCol: DG.Column<string>,
|
|
94
|
+
clustersColumn: DG.Column | null, currentDf: DG.DataFrame, scaledCol: DG.Column<number>, scaling: string,
|
|
95
|
+
): Promise<PeptidesModel | null> {
|
|
106
96
|
const progress = DG.TaskBarProgressIndicator.create('Loading SAR...');
|
|
107
97
|
let model = null;
|
|
108
|
-
if (activityColumn
|
|
109
|
-
const f = currentDf.filter;
|
|
98
|
+
if (activityColumn.type === DG.TYPE.FLOAT || activityColumn.type === DG.TYPE.INT) {
|
|
110
99
|
//prepare new DF
|
|
111
|
-
const newDf = DG.DataFrame.create(
|
|
112
|
-
const
|
|
113
|
-
let activityCol: DG.Column<number> | null = null;
|
|
100
|
+
const newDf = DG.DataFrame.create(currentDf.rowCount);
|
|
101
|
+
const newDfCols = newDf.columns;
|
|
114
102
|
for (const col of currentDf.columns.toList()) {
|
|
115
|
-
|
|
116
|
-
if (col === activityColumn)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
virtualCol = newDf.columns.addNewVirtual(
|
|
122
|
-
C.COLUMNS_NAMES.MACROMOLECULE, (i) => peptidesCol.get(getIndex(i)!), DG.TYPE.STRING);
|
|
123
|
-
} else
|
|
124
|
-
virtualCol = newDf.columns.addNewVirtual(col.name, (i) => col.get(getIndex(i)!), col.type as DG.TYPE);
|
|
125
|
-
virtualCol.setTag(C.TAGS.VISIBLE, '0');
|
|
103
|
+
const currentCol = newDfCols.add(col);
|
|
104
|
+
if (col === activityColumn)
|
|
105
|
+
currentCol.name = C.COLUMNS_NAMES.ACTIVITY;
|
|
106
|
+
else if (col === peptidesCol)
|
|
107
|
+
currentCol.name = C.COLUMNS_NAMES.MACROMOLECULE;
|
|
108
|
+
col.setTag(C.TAGS.VISIBLE, '0');
|
|
126
109
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const val = activityCol!.get(getIndex(i)!);
|
|
130
|
-
return val ? scaleNum(val) : val;
|
|
131
|
-
}, DG.TYPE.FLOAT);
|
|
132
|
-
activityScaledCol.semType = C.SEM_TYPES.ACTIVITY_SCALED;
|
|
110
|
+
activityColumn.semType = C.SEM_TYPES.ACTIVITY;
|
|
111
|
+
newDfCols.add(scaledCol);
|
|
133
112
|
newDf.name = 'Peptides analysis';
|
|
134
|
-
newDf.tags[C.COLUMNS_NAMES.ACTIVITY_SCALED] = newScaledColName;
|
|
135
113
|
if (clustersColumn) {
|
|
136
114
|
newDf.getCol(clustersColumn.name).name = C.COLUMNS_NAMES.CLUSTERS;
|
|
137
115
|
newDf.tags[C.TAGS.CLUSTERS] = C.COLUMNS_NAMES.CLUSTERS;
|
|
138
116
|
}
|
|
139
|
-
// newDf.tags[C.PEPTIDES_ANALYSIS] = 'true';
|
|
140
117
|
newDf.tags['scaling'] = scaling;
|
|
141
118
|
|
|
142
119
|
let monomerType = 'HELM_AA';
|
|
@@ -149,10 +126,9 @@ export async function startAnalysis(activityColumn: DG.Column<number> | null, pe
|
|
|
149
126
|
}
|
|
150
127
|
|
|
151
128
|
newDf.setTag('monomerType', monomerType);
|
|
152
|
-
|
|
153
129
|
model = await PeptidesModel.getInstance(newDf);
|
|
154
130
|
} else
|
|
155
|
-
grok.shell.error('The activity column must be of
|
|
131
|
+
grok.shell.error('The activity column must be of numeric type!');
|
|
156
132
|
progress.close();
|
|
157
133
|
return model;
|
|
158
134
|
}
|
package/{test-Peptides-916a90d7d48b-ea373bf5.html → test-Peptides-916a90d7d48b-d2f9014f.html}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<html><head><meta charset="utf-8"/><title>Peptides Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit
|
|
1
|
+
<html><head><meta charset="utf-8"/><title>Peptides Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit d2f9014f.</title><style type="text/css">html,
|
|
2
2
|
body {
|
|
3
3
|
font-family: Arial, Helvetica, sans-serif;
|
|
4
4
|
font-size: 1rem;
|
|
@@ -229,9 +229,9 @@ header {
|
|
|
229
229
|
font-size: 1rem;
|
|
230
230
|
padding: 0 0.5rem;
|
|
231
231
|
}
|
|
232
|
-
</style></head><body><div id="jesthtml-content"><header><h1 id="title">Peptides Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit
|
|
233
|
-
Test result : Failed :
|
|
234
|
-
Test result : Failed :
|
|
232
|
+
</style></head><body><div id="jesthtml-content"><header><h1 id="title">Peptides Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit d2f9014f.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-10-18 15:00:21</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed summary-empty">0 passed</div><div class="summary-failed">1 failed</div><div class="summary-pending summary-empty">0 pending</div></div><div id="test-summary"><div class="summary-total">Tests (1)</div><div class="summary-passed summary-empty">0 passed</div><div class="summary-failed">1 failed</div><div class="summary-pending summary-empty">0 pending</div></div></div></div><div id="suite-1" class="suite-container"><div class="suite-info"><div class="suite-path">/home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts</div><div class="suite-time warn">96.772s</div></div><div class="suite-tests"><div class="test-result failed"><div class="test-info"><div class="test-suitename"> </div><div class="test-title">TEST</div><div class="test-status">failed</div><div class="test-duration">78.593s</div></div><div class="failureMessages"> <pre class="failureMsg">Error: Test result : Failed : 459 : Peptides.Core.Start analysis: simple : Unable to get project asset "getMonomerLib"
|
|
233
|
+
Test result : Failed : 247 : Peptides.Core.Start analysis: сomplex : Unable to get project asset "getMonomerLib"
|
|
234
|
+
Test result : Failed : 532 : Peptides.Core.Save and load project : Unable to get project asset "getMonomerLib"
|
|
235
235
|
|
|
236
236
|
at /home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:68:20
|
|
237
237
|
at Generator.next (<anonymous>)
|
|
@@ -249,28 +249,28 @@ Test result : Failed : 431 : Peptides.Core.Save and load project : Unable to get
|
|
|
249
249
|
at new Promise (<anonymous>)</pre><pre class="suite-consolelog-item-message">Testing Peptides package</pre></div><div class="suite-consolelog-item"><pre class="suite-consolelog-item-origin"> at /home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:66:11
|
|
250
250
|
at Generator.next (<anonymous>)
|
|
251
251
|
at fulfilled (/home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:31:58)
|
|
252
|
-
at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Test result : Success :
|
|
253
|
-
Test result : Success :
|
|
254
|
-
Test result : Success :
|
|
255
|
-
Test result : Success :
|
|
256
|
-
Test result : Success :
|
|
257
|
-
Test result : Success :
|
|
258
|
-
Test result : Success :
|
|
259
|
-
Test result : Success :
|
|
260
|
-
Test result : Success :
|
|
261
|
-
Test result : Success :
|
|
262
|
-
Test result : Success :
|
|
263
|
-
Test result : Success :
|
|
264
|
-
Test result : Success :
|
|
265
|
-
Test result : Success :
|
|
266
|
-
Test result : Success :
|
|
267
|
-
Test result : Success :
|
|
268
|
-
Test result : Success :
|
|
269
|
-
Test result : Success :
|
|
270
|
-
Test result : Success :
|
|
271
|
-
Test result : Success :
|
|
272
|
-
Test result : Success :
|
|
273
|
-
Test result : Success :
|
|
274
|
-
Test result : Success :
|
|
275
|
-
Test result : Success :
|
|
252
|
+
at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Test result : Success : 1 : Peptides.Peptide space.test_table.is_not_empty : OK
|
|
253
|
+
Test result : Success : 5431 : Peptides.Peptide space.PeptideSimilaritySpaceWidget.is_drawing : OK
|
|
254
|
+
Test result : Success : 3 : Peptides.Peptide space.test_deminsionality_reducer : OK
|
|
255
|
+
Test result : Success : 0 : Peptides.Peptide space.test_peptide_similarity_space_viewer : OK
|
|
256
|
+
Test result : Success : 4271 : Peptides.Peptide space.peptide_space.DimensinalityReducer.UMAP.Levenshtein.is_numeric : OK
|
|
257
|
+
Test result : Success : 3805 : Peptides.Peptide space.peptide_space.DimensinalityReducer.UMAP.Jaro-Winkler.is_numeric : OK
|
|
258
|
+
Test result : Success : 3355 : Peptides.Peptide space.peptide_space.DimensinalityReducer.t-SNE.Levenshtein.is_numeric : OK
|
|
259
|
+
Test result : Success : 3861 : Peptides.Peptide space.peptide_space.DimensinalityReducer.t-SNE.Jaro-Winkler.is_numeric : OK
|
|
260
|
+
Test result : Success : 202 : Peptides.Peptide space.peptide_space.DimensinalityReducer.SPE.Levenshtein.is_numeric : OK
|
|
261
|
+
Test result : Success : 687 : Peptides.Peptide space.peptide_space.DimensinalityReducer.SPE.Jaro-Winkler.is_numeric : OK
|
|
262
|
+
Test result : Success : 337 : Peptides.Peptide space.peptide_space.DimensinalityReducer.pSPE.Levenshtein.is_numeric : OK
|
|
263
|
+
Test result : Success : 639 : Peptides.Peptide space.peptide_space.DimensinalityReducer.pSPE.Jaro-Winkler.is_numeric : OK
|
|
264
|
+
Test result : Success : 7964 : Peptides.Peptide space.peptide_space.DimensinalityReducer.OriginalSPE.Levenshtein.is_numeric : OK
|
|
265
|
+
Test result : Success : 8785 : Peptides.Peptide space.peptide_space.DimensinalityReducer.OriginalSPE.Jaro-Winkler.is_numeric : OK
|
|
266
|
+
Test result : Success : 2114 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.UMAP.Levenshtein.is_proper : OK
|
|
267
|
+
Test result : Success : 3464 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.UMAP.Jaro-Winkler.is_proper : OK
|
|
268
|
+
Test result : Success : 3603 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.t-SNE.Levenshtein.is_proper : OK
|
|
269
|
+
Test result : Success : 4096 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.t-SNE.Jaro-Winkler.is_proper : OK
|
|
270
|
+
Test result : Success : 234 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.SPE.Levenshtein.is_proper : OK
|
|
271
|
+
Test result : Success : 733 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.SPE.Jaro-Winkler.is_proper : OK
|
|
272
|
+
Test result : Success : 349 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.pSPE.Levenshtein.is_proper : OK
|
|
273
|
+
Test result : Success : 679 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.pSPE.Jaro-Winkler.is_proper : OK
|
|
274
|
+
Test result : Success : 8408 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.OriginalSPE.Levenshtein.is_proper : OK
|
|
275
|
+
Test result : Success : 8267 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.OriginalSPE.Jaro-Winkler.is_proper : OK
|
|
276
276
|
</pre></div></div></div></div></body></html>
|