@datagrok/peptides 0.8.10 → 0.8.12
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/.eslintrc.json +2 -1
- package/dist/package-test.js +22626 -0
- package/dist/package.js +21429 -0
- package/dist/vendors-node_modules_datagrok-libraries_ml_src_workers_dimensionality-reducer_js.js +8840 -0
- package/jest.config.js +33 -0
- package/package.json +70 -62
- package/src/__jest__/remote.test.ts +50 -0
- package/src/__jest__/test-node.ts +96 -0
- package/src/model.ts +849 -442
- package/src/package-test.ts +2 -1
- package/src/package.ts +36 -22
- package/src/peptides.ts +152 -116
- package/src/styles.css +8 -0
- package/src/tests/peptides-tests.ts +7 -7
- package/src/tests/utils.ts +1 -7
- package/src/utils/SAR-multiple-filter.ts +439 -0
- package/src/utils/SAR-multiple-selection.ts +177 -0
- package/src/utils/cell-renderer.ts +38 -37
- package/src/utils/chem-palette.ts +1 -0
- package/src/utils/constants.ts +56 -0
- package/src/utils/filtering-statistics.ts +62 -0
- package/src/utils/multivariate-analysis.ts +5 -3
- package/src/utils/peptide-similarity-space.ts +12 -31
- package/src/utils/types.ts +10 -0
- package/src/viewers/logo-viewer.ts +2 -1
- package/src/viewers/peptide-space-viewer.ts +121 -0
- package/src/viewers/sar-viewer.ts +109 -293
- package/src/viewers/stacked-barchart-viewer.ts +100 -136
- package/src/widgets/analyze-peptides.ts +34 -31
- package/src/widgets/distribution.ts +61 -0
- package/src/widgets/manual-alignment.ts +1 -0
- package/src/widgets/subst-table.ts +30 -20
- package/test-Peptides-414a1874a71a-2f1c6575.html +256 -0
- package/src/viewers/subst-viewer.ts +0 -312
package/src/package-test.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
|
|
3
|
-
import {runTests} from '@datagrok-libraries/utils/src/test';
|
|
3
|
+
import {runTests, tests} from '@datagrok-libraries/utils/src/test';
|
|
4
4
|
|
|
5
5
|
import './tests/peptide-space-test';
|
|
6
6
|
import './tests/peptides-tests';
|
|
7
7
|
import './tests/msa-tests';
|
|
8
8
|
|
|
9
9
|
export const _packageTest = new DG.Package();
|
|
10
|
+
export {tests};
|
|
10
11
|
|
|
11
12
|
//name: test
|
|
12
13
|
//input: string category {optional: true}
|
package/src/package.ts
CHANGED
|
@@ -3,6 +3,8 @@ import * as grok from 'datagrok-api/grok';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
|
|
6
|
+
import * as C from './utils/constants';
|
|
7
|
+
|
|
6
8
|
import {
|
|
7
9
|
AlignedSequenceCellRenderer,
|
|
8
10
|
AlignedSequenceDifferenceCellRenderer,
|
|
@@ -16,10 +18,11 @@ import {PeptideSimilaritySpaceWidget} from './utils/peptide-similarity-space';
|
|
|
16
18
|
import {manualAlignmentWidget} from './widgets/manual-alignment';
|
|
17
19
|
import {SARViewer, SARViewerVertical} from './viewers/sar-viewer';
|
|
18
20
|
import {peptideMoleculeWidget, getMolecule} from './widgets/peptide-molecule';
|
|
19
|
-
import {SubstViewer} from './viewers/subst-viewer';
|
|
20
21
|
import {runKalign, testMSAEnoughMemory} from './utils/multiple-sequence-alignment';
|
|
21
|
-
import {
|
|
22
|
+
import {substitutionsWidget} from './widgets/subst-table';
|
|
22
23
|
import {msaWidget} from './widgets/multiple-sequence-alignment';
|
|
24
|
+
import {getDistributionWidget} from './widgets/distribution';
|
|
25
|
+
import {PeptideSpaceViewer} from './viewers/peptide-space-viewer';
|
|
23
26
|
|
|
24
27
|
export const _package = new DG.Package();
|
|
25
28
|
let currentGrid: DG.Grid;
|
|
@@ -32,7 +35,6 @@ async function main(chosenFile: string) {
|
|
|
32
35
|
const path = _package.webRoot + 'files/' + chosenFile;
|
|
33
36
|
const peptides = (await grok.data.loadTable(path));
|
|
34
37
|
peptides.name = 'Peptides';
|
|
35
|
-
peptides.setTag('dataType', 'peptides');
|
|
36
38
|
const view = grok.shell.addTableView(peptides);
|
|
37
39
|
currentGrid = view.grid;
|
|
38
40
|
view.name = 'PeptidesView';
|
|
@@ -92,8 +94,8 @@ export async function peptidesPanel(col: DG.Column): Promise<DG.Widget> {
|
|
|
92
94
|
return new DG.Widget(ui.divText('Analysis is not applicable'));
|
|
93
95
|
|
|
94
96
|
[currentView, currentGrid, currentTable, alignedSequenceColumn] =
|
|
95
|
-
|
|
96
|
-
return
|
|
97
|
+
getOrDefine(undefined, undefined, col.dataFrame, col);
|
|
98
|
+
return analyzePeptidesWidget(currentTable, alignedSequenceColumn);
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
//name: peptide-sar-viewer
|
|
@@ -112,12 +114,12 @@ export function sarVertical(): SARViewerVertical {
|
|
|
112
114
|
return new SARViewerVertical();
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
//name:
|
|
116
|
-
//description:
|
|
117
|
+
//name: peptide-space-viewer
|
|
118
|
+
//description: Peptide Space Viewer
|
|
117
119
|
//tags: viewer
|
|
118
120
|
//output: viewer result
|
|
119
|
-
export function
|
|
120
|
-
return new
|
|
121
|
+
export function peptideSpace(): PeptideSpaceViewer {
|
|
122
|
+
return new PeptideSpaceViewer();
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
//name: StackedBarchart Widget
|
|
@@ -135,7 +137,7 @@ export async function stackedBarchartWidget(col: DG.Column): Promise<DG.Widget>
|
|
|
135
137
|
//input: string peptide {semType: alignedSequence}
|
|
136
138
|
//output: widget result
|
|
137
139
|
export async function peptideMolecule(peptide: string): Promise<DG.Widget> {
|
|
138
|
-
return
|
|
140
|
+
return peptideMoleculeWidget(peptide);
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
//name: Peptide Molecule
|
|
@@ -144,9 +146,9 @@ export async function peptideMolecule(peptide: string): Promise<DG.Widget> {
|
|
|
144
146
|
//output: widget result
|
|
145
147
|
export async function peptideMolecule2(aar: string): Promise<DG.Widget> {
|
|
146
148
|
[currentView, currentGrid, currentTable, alignedSequenceColumn] =
|
|
147
|
-
|
|
149
|
+
getOrDefine();
|
|
148
150
|
const peptide = alignedSequenceColumn.get(currentTable.currentRowIdx);
|
|
149
|
-
return
|
|
151
|
+
return peptideMolecule(peptide);
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
//name: StackedBarChartAA
|
|
@@ -185,7 +187,7 @@ export function logov() {
|
|
|
185
187
|
//output: widget result
|
|
186
188
|
export function manualAlignment(monomer: string) {
|
|
187
189
|
[currentView, currentGrid, currentTable, alignedSequenceColumn] =
|
|
188
|
-
|
|
190
|
+
getOrDefine();
|
|
189
191
|
//TODO: recalculate Molfile and Molecule panels on sequence update
|
|
190
192
|
return manualAlignmentWidget(alignedSequenceColumn, currentTable);
|
|
191
193
|
}
|
|
@@ -196,9 +198,9 @@ export function manualAlignment(monomer: string) {
|
|
|
196
198
|
//output: widget result
|
|
197
199
|
export async function peptideSpacePanel(col: DG.Column): Promise<DG.Widget> {
|
|
198
200
|
[currentView, currentGrid, currentTable, alignedSequenceColumn] =
|
|
199
|
-
|
|
201
|
+
getOrDefine(undefined, undefined, col.dataFrame, col);
|
|
200
202
|
const widget = new PeptideSimilaritySpaceWidget(col, currentView);
|
|
201
|
-
return
|
|
203
|
+
return widget.draw();
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
//name: Molfile
|
|
@@ -207,7 +209,7 @@ export async function peptideSpacePanel(col: DG.Column): Promise<DG.Widget> {
|
|
|
207
209
|
//output: widget result
|
|
208
210
|
export async function peptideMolfile(peptide: string): Promise<DG.Widget> {
|
|
209
211
|
const smiles = getMolecule(peptide);
|
|
210
|
-
return
|
|
212
|
+
return grok.functions.call('Chem:molfile', {'smiles': smiles});
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
//name: Molfile
|
|
@@ -216,9 +218,9 @@ export async function peptideMolfile(peptide: string): Promise<DG.Widget> {
|
|
|
216
218
|
//output: widget result
|
|
217
219
|
export async function peptideMolfile2(aar: string): Promise<DG.Widget> {
|
|
218
220
|
[currentView, currentGrid, currentTable, alignedSequenceColumn] =
|
|
219
|
-
|
|
221
|
+
getOrDefine();
|
|
220
222
|
const peptide = alignedSequenceColumn.get(currentTable.currentRowIdx);
|
|
221
|
-
return
|
|
223
|
+
return peptideMolfile(peptide);
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
//name: Multiple sequence alignment
|
|
@@ -226,7 +228,7 @@ export async function peptideMolfile2(aar: string): Promise<DG.Widget> {
|
|
|
226
228
|
//input: column col {semType: alignedSequence}
|
|
227
229
|
//output: dataframe result
|
|
228
230
|
export async function multipleSequenceAlignment(col: DG.Column): Promise<DG.DataFrame> {
|
|
229
|
-
return
|
|
231
|
+
return msaWidget(col);
|
|
230
232
|
}
|
|
231
233
|
|
|
232
234
|
//name: Multiple sequence alignment for any column
|
|
@@ -253,7 +255,19 @@ export async function runTestMSAEnoughMemory(table: DG.DataFrame, col: DG.Column
|
|
|
253
255
|
//input: dataframe table {semType: Substitution}
|
|
254
256
|
//output: widget result
|
|
255
257
|
export async function peptideSubstitution(table: DG.DataFrame): Promise<DG.Widget> {
|
|
256
|
-
|
|
258
|
+
if (!table.temp[C.PEPTIDES_ANALYSIS])
|
|
259
|
+
return new DG.Widget(ui.divText('This widget is only applicable for peptides analysis'));
|
|
260
|
+
return substitutionsWidget(table);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//name: Distribution
|
|
264
|
+
//tags: panel, widgets
|
|
265
|
+
//input: dataframe table {semType: viewerTable}
|
|
266
|
+
//output: widget result
|
|
267
|
+
export function peptideDistribution(table: DG.DataFrame): DG.Widget {
|
|
268
|
+
if (!table.temp[C.PEPTIDES_ANALYSIS])
|
|
269
|
+
return new DG.Widget(ui.divText('This widget is only applicable for peptides analysis'));
|
|
270
|
+
return getDistributionWidget(table);
|
|
257
271
|
}
|
|
258
272
|
|
|
259
273
|
//name: alignedSequenceDifferenceCellRenderer
|
|
@@ -264,13 +278,13 @@ export function alignedSequenceDifferenceCellRenderer() {
|
|
|
264
278
|
return new AlignedSequenceDifferenceCellRenderer();
|
|
265
279
|
}
|
|
266
280
|
|
|
267
|
-
function
|
|
281
|
+
function getOrDefine(
|
|
268
282
|
view?: DG.TableView, grid?: DG.Grid, dataframe?: DG.DataFrame, column?: DG.Column | null,
|
|
269
283
|
): [DG.TableView, DG.Grid, DG.DataFrame, DG.Column] {
|
|
270
284
|
view ??= (grok.shell.v as DG.TableView);
|
|
271
285
|
grid ??= view.grid;
|
|
272
286
|
dataframe ??= grok.shell.t;
|
|
273
|
-
column ??= (dataframe.columns as DG.ColumnList).bySemType(
|
|
287
|
+
column ??= (dataframe.columns as DG.ColumnList).bySemType(C.SEM_TYPES.ALIGNED_SEQUENCE);
|
|
274
288
|
if (column === null)
|
|
275
289
|
throw new Error('Table does not contain aligned sequence columns');
|
|
276
290
|
|
package/src/peptides.ts
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as grok from 'datagrok-api/grok';
|
|
2
2
|
import * as DG from 'datagrok-api/dg';
|
|
3
|
-
import {createPeptideSimilaritySpaceViewer} from './utils/peptide-similarity-space';
|
|
4
3
|
import {PeptidesModel} from './model';
|
|
5
|
-
import {StringDictionary} from '@datagrok-libraries/utils/src/type-declarations';
|
|
6
4
|
import {SARViewer, SARViewerVertical} from './viewers/sar-viewer';
|
|
7
|
-
import {SubstViewer} from './viewers/subst-viewer';
|
|
8
5
|
import {ChemPalette} from './utils/chem-palette';
|
|
9
6
|
import {Observable} from 'rxjs';
|
|
10
7
|
import {MonomerLibrary} from './monomer-library';
|
|
11
8
|
import {_package} from './package';
|
|
12
9
|
import {setAARRenderer} from './utils/cell-renderer';
|
|
10
|
+
import * as C from './utils/constants';
|
|
11
|
+
import {PeptideSpaceViewer} from './viewers/peptide-space-viewer';
|
|
12
|
+
import { FilteringStatistics } from './utils/filtering-statistics';
|
|
13
13
|
|
|
14
|
-
type viewerTypes = SARViewer | SARViewerVertical
|
|
14
|
+
type viewerTypes = SARViewer | SARViewerVertical;
|
|
15
15
|
export class PeptidesController {
|
|
16
16
|
private static _controllerName: string = 'peptidesController';
|
|
17
17
|
private helpUrl = '/help/domains/bio/peptides.md';
|
|
18
18
|
|
|
19
19
|
private _model: PeptidesModel;
|
|
20
|
+
sarViewer!: SARViewer;
|
|
21
|
+
sarViewerVertical!: SARViewerVertical;
|
|
22
|
+
isInitialized = false;
|
|
20
23
|
|
|
21
24
|
private constructor(dataFrame: DG.DataFrame) {
|
|
22
25
|
this._model = PeptidesModel.getInstance(dataFrame);
|
|
23
|
-
// this.getOrInitModel(this._dataFrame);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
static async getInstance(dataFrame: DG.DataFrame): Promise<PeptidesController> {
|
|
@@ -32,58 +34,57 @@ export class PeptidesController {
|
|
|
32
34
|
return dataFrame.temp[PeptidesController.controllerName];
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
static get controllerName() {
|
|
36
|
-
return PeptidesController._controllerName;
|
|
37
|
-
}
|
|
37
|
+
static get controllerName() {return PeptidesController._controllerName;}
|
|
38
38
|
|
|
39
|
-
get dataFrame() {
|
|
40
|
-
return this._model.dataFrame;
|
|
41
|
-
}
|
|
39
|
+
get dataFrame() {return this._model.dataFrame;}
|
|
42
40
|
|
|
43
|
-
static setAARRenderer(col: DG.Column, grid: DG.Grid
|
|
44
|
-
return setAARRenderer(col, grid
|
|
41
|
+
static setAARRenderer(col: DG.Column, grid: DG.Grid) {
|
|
42
|
+
return setAARRenderer(col, grid);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
get onStatsDataFrameChanged(): Observable<DG.DataFrame> {
|
|
48
|
-
return this._model.onStatsDataFrameChanged;
|
|
49
|
-
}
|
|
45
|
+
get onStatsDataFrameChanged(): Observable<DG.DataFrame> {return this._model.onStatsDataFrameChanged;}
|
|
50
46
|
|
|
51
|
-
get onSARGridChanged(): Observable<DG.Grid> {
|
|
52
|
-
return this._model.onSARGridChanged;
|
|
53
|
-
}
|
|
47
|
+
get onSARGridChanged(): Observable<DG.Grid> {return this._model.onSARGridChanged;}
|
|
54
48
|
|
|
55
|
-
get onSARVGridChanged(): Observable<DG.Grid> {
|
|
56
|
-
return this._model.onSARVGridChanged;
|
|
57
|
-
}
|
|
49
|
+
get onSARVGridChanged(): Observable<DG.Grid> {return this._model.onSARVGridChanged;}
|
|
58
50
|
|
|
59
|
-
get onGroupMappingChanged(): Observable<StringDictionary> {
|
|
60
|
-
return this._model.onGroupMappingChanged;
|
|
61
|
-
}
|
|
51
|
+
// get onGroupMappingChanged(): Observable<StringDictionary> {return this._model.onGroupMappingChanged;}
|
|
62
52
|
|
|
63
|
-
get
|
|
64
|
-
return this._model.onSubstFlagChanged;
|
|
65
|
-
}
|
|
53
|
+
get onSubstTableChanged(): Observable<DG.DataFrame> {return this._model.onSubstTableChanged;}
|
|
66
54
|
|
|
67
|
-
async updateDefault() {
|
|
68
|
-
|
|
69
|
-
}
|
|
55
|
+
async updateDefault() {await this._model.updateDefault();}
|
|
56
|
+
|
|
57
|
+
get sarGrid() {return this._model._sarGrid;}
|
|
58
|
+
|
|
59
|
+
get sarVGrid() {return this._model._sarVGrid;}
|
|
60
|
+
|
|
61
|
+
get sourceGrid() {return this._model._sourceGrid!; }
|
|
70
62
|
|
|
71
63
|
async updateData(
|
|
72
|
-
|
|
73
|
-
|
|
64
|
+
activityScaling?: string, sourceGrid?: DG.Grid, twoColorMode?: boolean, activityLimit?: number,
|
|
65
|
+
maxSubstitutions?: number, isSubstitutionOn?: boolean, filterMode?: boolean,
|
|
74
66
|
) {
|
|
67
|
+
filterMode ??= false;
|
|
75
68
|
await this._model.updateData(
|
|
76
|
-
|
|
69
|
+
activityScaling, sourceGrid, twoColorMode, activityLimit, maxSubstitutions, isSubstitutionOn, filterMode);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getSubstitutions() {
|
|
73
|
+
return this._model.getSubstitutionTable();
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
static async scaleActivity(
|
|
80
|
-
activityScaling: string,
|
|
77
|
+
activityScaling: string, df: DG.DataFrame, originalActivityName?: string, cloneBitset = false,
|
|
81
78
|
): Promise<[DG.DataFrame, string]> {
|
|
82
79
|
// const df = sourceGrid.dataFrame!;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
let currentActivityColName = originalActivityName ?? C.COLUMNS_NAMES.ACTIVITY;
|
|
81
|
+
const flag = (df.columns as DG.ColumnList).names().includes(currentActivityColName) &&
|
|
82
|
+
currentActivityColName === originalActivityName;
|
|
83
|
+
currentActivityColName = flag ? currentActivityColName : C.COLUMNS_NAMES.ACTIVITY;
|
|
84
|
+
const tempDf = df.clone(cloneBitset ? df.filter : null, [currentActivityColName]);
|
|
85
|
+
|
|
86
|
+
let formula = '${' + currentActivityColName + '}';
|
|
87
|
+
let newColName = 'activity'; //originalActivityName ?? df.temp[C.COLUMNS_NAMES.ACTIVITY] ?? currentActivityColName;
|
|
87
88
|
switch (activityScaling) {
|
|
88
89
|
case 'none':
|
|
89
90
|
break;
|
|
@@ -99,11 +100,16 @@ export class PeptidesController {
|
|
|
99
100
|
throw new Error(`ScalingError: method \`${activityScaling}\` is not available.`);
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
await (tempDf.columns as DG.ColumnList).addNewCalculated(
|
|
103
|
+
await (tempDf.columns as DG.ColumnList).addNewCalculated(C.COLUMNS_NAMES.ACTIVITY_SCALED, formula);
|
|
104
|
+
df.tags['scaling'] = activityScaling;
|
|
103
105
|
|
|
104
106
|
return [tempDf, newColName];
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
get originalActivityColumnName(): string {return this.dataFrame.temp[C.COLUMNS_NAMES.ACTIVITY];}
|
|
110
|
+
|
|
111
|
+
get substTooltipData() {return this._model.substTooltipData;}
|
|
112
|
+
|
|
107
113
|
static splitAlignedPeptides(peptideColumn: DG.Column, filter: boolean = true): [DG.DataFrame, number[]] {
|
|
108
114
|
const splitPeptidesArray: string[][] = [];
|
|
109
115
|
let currentSplitPeptide: string[];
|
|
@@ -145,8 +151,8 @@ export class PeptidesController {
|
|
|
145
151
|
|
|
146
152
|
//create column names list
|
|
147
153
|
const columnNames = Array.from({length: modeMonomerCount}, (_, index) => `${index + 1 < 10 ? 0 : ''}${index + 1 }`);
|
|
148
|
-
columnNames.splice(0, 0, '
|
|
149
|
-
columnNames.push('
|
|
154
|
+
columnNames.splice(0, 0, 'Nterminal');
|
|
155
|
+
columnNames.push('Cterminal');
|
|
150
156
|
|
|
151
157
|
// filter out the columns with the same values
|
|
152
158
|
if (filter) {
|
|
@@ -167,23 +173,91 @@ export class PeptidesController {
|
|
|
167
173
|
];
|
|
168
174
|
}
|
|
169
175
|
|
|
170
|
-
static get chemPalette() {
|
|
171
|
-
|
|
176
|
+
static get chemPalette() { return ChemPalette; }
|
|
177
|
+
|
|
178
|
+
assertVar(variable: string, init = false): boolean {
|
|
179
|
+
//@ts-ignore
|
|
180
|
+
let foundVariable: any = this[variable];
|
|
181
|
+
if (!foundVariable && init) {
|
|
182
|
+
//@ts-ignore
|
|
183
|
+
this[variable] = foundVariable = this.dataFrame.temp[variable];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const assertionResult = foundVariable ? true : false
|
|
187
|
+
if (init && !assertionResult)
|
|
188
|
+
throw new Error(`Variable assertion error: variable '${variable}' is not found in dataFrame`);
|
|
189
|
+
|
|
190
|
+
return assertionResult;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
assertVariables(variables: string[], init = false) {
|
|
194
|
+
let result = true;
|
|
195
|
+
for (const variable of variables)
|
|
196
|
+
result &&= this.assertVar(variable, init);
|
|
197
|
+
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
syncProperties(isSourceSAR = true) {
|
|
202
|
+
this.assertVariables(['sarViewer', 'sarViewerVertical'], true);
|
|
203
|
+
const sourceViewer = isSourceSAR ? this.sarViewer : this.sarViewerVertical;
|
|
204
|
+
const targetViewer = isSourceSAR ? this.sarViewerVertical : this.sarViewer;
|
|
205
|
+
const properties = sourceViewer.props.getProperties();
|
|
206
|
+
for (const property of properties)
|
|
207
|
+
targetViewer.props.set(property.name, property.get(sourceViewer));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
modifyOrCreateSplitCol(aar: string, position: string, notify: boolean = true) {
|
|
211
|
+
this._model.modifyOrCreateSplitCol(aar, position);
|
|
212
|
+
if (notify)
|
|
213
|
+
this._model.fireBitsetChanged();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
setSARGridCellAt(aar: string, position: string) {
|
|
217
|
+
const sarDf = this.sarGrid.dataFrame;
|
|
218
|
+
const aarCol = sarDf.getCol(C.COLUMNS_NAMES.AMINO_ACID_RESIDUE);
|
|
219
|
+
const aarColLen = aarCol.length;
|
|
220
|
+
let index = -1;
|
|
221
|
+
for (let i = 0; i < aarColLen; i++) {
|
|
222
|
+
if (aarCol.get(i) === aar) {
|
|
223
|
+
index = i;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
position = position === C.CATEGORIES.ALL ? C.COLUMNS_NAMES.AMINO_ACID_RESIDUE : position;
|
|
228
|
+
sarDf.currentCell = sarDf.cell(index, position);
|
|
172
229
|
}
|
|
173
230
|
|
|
174
231
|
/**
|
|
175
232
|
* Class initializer
|
|
176
233
|
*
|
|
177
|
-
* @param {DG.Grid}
|
|
178
|
-
* @param {DG.TableView}
|
|
234
|
+
* @param {DG.Grid} sourceGrid Working talbe grid.
|
|
235
|
+
* @param {DG.TableView} currentView Working view.
|
|
179
236
|
* @param {DG.DataFrame} currentDf Working table.
|
|
180
237
|
* @param {StringDictionary} options SAR viewer options
|
|
181
238
|
* @param {DG.Column} col Aligned sequences column.
|
|
182
239
|
* @memberof Peptides
|
|
183
240
|
*/
|
|
184
|
-
async init(
|
|
185
|
-
|
|
186
|
-
|
|
241
|
+
async init(table: DG.DataFrame) {
|
|
242
|
+
if (this.isInitialized)
|
|
243
|
+
return;
|
|
244
|
+
this.isInitialized = true;
|
|
245
|
+
//calculate initial stats
|
|
246
|
+
const stats = new FilteringStatistics();
|
|
247
|
+
const activityScaledCol = table.getCol(C.COLUMNS_NAMES.ACTIVITY_SCALED);
|
|
248
|
+
stats.setData(activityScaledCol.getRawData() as Float32Array);
|
|
249
|
+
stats.setMask(table.selection);
|
|
250
|
+
table.temp[C.STATS] = stats;
|
|
251
|
+
|
|
252
|
+
//set up views
|
|
253
|
+
let currentView = grok.shell.v as DG.TableView ;
|
|
254
|
+
if (currentView.dataFrame.tags['isPeptidesAnalysis'] !== 'true')
|
|
255
|
+
currentView = grok.shell.addTableView(table);
|
|
256
|
+
const sourceGrid = currentView.grid;
|
|
257
|
+
sourceGrid.col(C.COLUMNS_NAMES.ACTIVITY_SCALED)!.name = table.temp[C.COLUMNS_NAMES.ACTIVITY_SCALED];
|
|
258
|
+
sourceGrid.columns.setOrder([table.temp[C.COLUMNS_NAMES.ACTIVITY_SCALED]]);
|
|
259
|
+
|
|
260
|
+
this.dataFrame.temp[C.EMBEDDING_STATUS] = false;
|
|
187
261
|
function adjustCellSize(grid: DG.Grid) {
|
|
188
262
|
const colNum = grid.columns.length;
|
|
189
263
|
for (let i = 0; i < colNum; ++i) {
|
|
@@ -193,83 +267,45 @@ export class PeptidesController {
|
|
|
193
267
|
grid.props.rowHeight = 20;
|
|
194
268
|
}
|
|
195
269
|
|
|
196
|
-
for (let i = 0; i <
|
|
197
|
-
const aarCol =
|
|
198
|
-
if (aarCol &&
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
//@ts-ignore
|
|
203
|
-
tableGrid.columns.byIndex(i)?.visible = false;
|
|
204
|
-
}
|
|
270
|
+
for (let i = 0; i < sourceGrid.columns.length; i++) {
|
|
271
|
+
const aarCol = sourceGrid.columns.byIndex(i);
|
|
272
|
+
if (aarCol && aarCol.name && aarCol.column?.semType !== C.SEM_TYPES.AMINO_ACIDS &&
|
|
273
|
+
aarCol.name !== this.dataFrame.temp[C.COLUMNS_NAMES.ACTIVITY_SCALED]
|
|
274
|
+
)
|
|
275
|
+
sourceGrid.columns.byIndex(i)!.visible = false;
|
|
205
276
|
}
|
|
206
277
|
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const sarViewer = await this.dataFrame.plot.fromType('peptide-sar-viewer', options) as SARViewer;
|
|
211
|
-
sarViewer.helpUrl = this.helpUrl;
|
|
212
|
-
|
|
213
|
-
const sarViewerVertical = await this.dataFrame.plot.fromType('peptide-sar-viewer-vertical') as SARViewerVertical;
|
|
214
|
-
sarViewerVertical.helpUrl = this.helpUrl;
|
|
215
|
-
|
|
216
|
-
const sarViewersGroup: viewerTypes[] = [sarViewer, sarViewerVertical];
|
|
217
|
-
|
|
218
|
-
const peptideSpaceViewer = await createPeptideSimilaritySpaceViewer(
|
|
219
|
-
this.dataFrame, col, 't-SNE', 'Levenshtein', 100, view, `${options['activityColumnName']}Scaled`);
|
|
220
|
-
dockManager.dock(peptideSpaceViewer, DG.DOCK_TYPE.RIGHT, null, 'Peptide Space viewer');
|
|
278
|
+
const options = {scaling: table.tags['scaling']};
|
|
279
|
+
await this.updateData(table.tags['scaling'], sourceGrid, false, 1, 2, false, false);
|
|
221
280
|
|
|
222
|
-
|
|
281
|
+
const dockManager = currentView.dockManager;
|
|
223
282
|
|
|
224
|
-
|
|
225
|
-
'
|
|
226
|
-
|
|
283
|
+
this.dataFrame.temp['sarViewer'] = this.sarViewer =
|
|
284
|
+
await this.dataFrame.plot.fromType('peptide-sar-viewer', options) as SARViewer;
|
|
285
|
+
this.sarViewer.helpUrl = this.helpUrl;
|
|
227
286
|
|
|
228
|
-
|
|
229
|
-
|
|
287
|
+
this.dataFrame.temp['sarViewerVertical'] = this.sarViewerVertical =
|
|
288
|
+
await this.dataFrame.plot.fromType('peptide-sar-viewer-vertical', options) as SARViewerVertical;
|
|
289
|
+
this.sarViewerVertical.helpUrl = this.helpUrl;
|
|
230
290
|
|
|
231
|
-
const
|
|
232
|
-
const viewers = [];
|
|
233
|
-
for (const viewer of view.viewers) {
|
|
234
|
-
if (viewer.type !== DG.VIEWER.GRID)
|
|
235
|
-
viewers.push(viewer);
|
|
236
|
-
}
|
|
237
|
-
viewers.forEach((v) => v.close());
|
|
238
|
-
|
|
239
|
-
const cols = (this.dataFrame.columns as DG.ColumnList);
|
|
240
|
-
for (const colName of cols.names()) {
|
|
241
|
-
if (!originalDfColumns.includes(colName))
|
|
242
|
-
cols.remove(colName);
|
|
243
|
-
}
|
|
291
|
+
const sarViewersGroup: viewerTypes[] = [this.sarViewer, this.sarViewerVertical];
|
|
244
292
|
|
|
245
|
-
|
|
246
|
-
|
|
293
|
+
const peptideSpaceViewerOptions = {method: 't-SNE', measure: 'Levenshtein', cyclesCount: 100};
|
|
294
|
+
const peptideSpaceViewer =
|
|
295
|
+
await this.dataFrame.plot.fromType('peptide-space-viewer', peptideSpaceViewerOptions) as PeptideSpaceViewer;
|
|
296
|
+
dockManager.dock(peptideSpaceViewer, DG.DOCK_TYPE.RIGHT, null, 'Peptide Space Viewer');
|
|
247
297
|
|
|
248
|
-
|
|
249
|
-
tableGrid.columns.setVisible(originalDfColumns);
|
|
250
|
-
tableGrid.props.allowEdit = true;
|
|
251
|
-
tableGrid.temp['containsBarchart'] = false;
|
|
252
|
-
this.dataFrame.name = originalDfName;
|
|
298
|
+
dockViewers(sarViewersGroup, DG.DOCK_TYPE.RIGHT, dockManager, DG.DOCK_TYPE.DOWN);
|
|
253
299
|
|
|
254
|
-
|
|
255
|
-
|
|
300
|
+
sourceGrid.props.allowEdit = false;
|
|
301
|
+
adjustCellSize(sourceGrid);
|
|
256
302
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
nodeList?.forEach((node) => {
|
|
261
|
-
view.dockManager.close(node);
|
|
262
|
-
node.container.destroy();
|
|
263
|
-
});
|
|
264
|
-
const getCurrentViewerGroup = () => isSA ? substViewersGroup : sarViewersGroup;
|
|
265
|
-
getCurrentViewerGroup().forEach((v) => v.removeFromView());
|
|
266
|
-
isSA = !isSA;
|
|
267
|
-
nodeList = dockViewers(getCurrentViewerGroup(), DG.DOCK_TYPE.LEFT, dockManager, DG.DOCK_TYPE.DOWN);
|
|
268
|
-
}, 'Toggle viewer group');
|
|
269
|
-
|
|
270
|
-
const ribbonPanels = view.getRibbonPanels();
|
|
271
|
-
view.setRibbonPanels([[hideIcon, switchViewers]]);
|
|
303
|
+
// this._model._sarGrid.invalidate();
|
|
304
|
+
// this._model._sarVGrid.invalidate();
|
|
305
|
+
this._model.invalidateGrids();
|
|
272
306
|
}
|
|
307
|
+
|
|
308
|
+
invalidateSourceGrid() { this.sourceGrid.invalidate(); }
|
|
273
309
|
}
|
|
274
310
|
|
|
275
311
|
function dockViewers(
|
package/src/styles.css
CHANGED
|
@@ -11,9 +11,9 @@ import {_packageTest} from '../package-test';
|
|
|
11
11
|
category('peptides', async () => {
|
|
12
12
|
let peptidesDf: DG.DataFrame;
|
|
13
13
|
let options: StringDictionary;
|
|
14
|
-
let peptidesGrid: DG.Grid;
|
|
14
|
+
// let peptidesGrid: DG.Grid;
|
|
15
15
|
let asCol: DG.Column;
|
|
16
|
-
let pepView: DG.TableView;
|
|
16
|
+
// let pepView: DG.TableView;
|
|
17
17
|
|
|
18
18
|
before(async () => {
|
|
19
19
|
peptidesDf = DG.DataFrame.fromCsv(await _packageTest.files.readAsText('aligned.csv'));
|
|
@@ -22,8 +22,8 @@ category('peptides', async () => {
|
|
|
22
22
|
scaling: '-lg',
|
|
23
23
|
};
|
|
24
24
|
asCol = peptidesDf.getCol('AlignedSequence');
|
|
25
|
-
pepView = grok.shell.addTableView(peptidesDf);
|
|
26
|
-
peptidesGrid = pepView.grid;
|
|
25
|
+
// pepView = grok.shell.addTableView(peptidesDf);
|
|
26
|
+
// peptidesGrid = pepView.grid;
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test('utils.split-sequence', async () => {
|
|
@@ -38,11 +38,11 @@ category('peptides', async () => {
|
|
|
38
38
|
|
|
39
39
|
test('Peptides-controller', async () => {
|
|
40
40
|
const peptides = await PeptidesController.getInstance(peptidesDf);
|
|
41
|
-
peptides.init(
|
|
41
|
+
peptides.init(peptidesDf); //, peptidesDf.columns.names());
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
test('widgets.analyze-peptides', async () => {
|
|
45
|
-
await analyzePeptidesWidget(
|
|
45
|
+
await analyzePeptidesWidget(peptidesDf, asCol);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
test('widgets.manual-alignment', async () => {
|
|
@@ -54,7 +54,7 @@ category('peptides', async () => {
|
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
after(async () => {
|
|
57
|
-
pepView.close();
|
|
57
|
+
// pepView.close();
|
|
58
58
|
grok.shell.closeTable(peptidesDf);
|
|
59
59
|
});
|
|
60
60
|
});
|
package/src/tests/utils.ts
CHANGED
|
@@ -86,13 +86,7 @@ export async function _testPeptideSimilaritySpaceViewer(
|
|
|
86
86
|
|
|
87
87
|
try {
|
|
88
88
|
viewer = await createPeptideSimilaritySpaceViewer(
|
|
89
|
-
table,
|
|
90
|
-
alignedSequencesColumn,
|
|
91
|
-
method,
|
|
92
|
-
measure,
|
|
93
|
-
cyclesCount,
|
|
94
|
-
null,
|
|
95
|
-
);
|
|
89
|
+
table, method, measure, cyclesCount, undefined, alignedSequencesColumn);
|
|
96
90
|
df = viewer.dataFrame!;
|
|
97
91
|
} catch (error) {
|
|
98
92
|
noException = false;
|