@datagrok/peptides 1.0.1 → 1.0.2
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 +8275 -3759
- package/dist/package.js +19735 -14773
- package/dist/vendors-node_modules_datagrok-libraries_ml_src_workers_dimensionality-reducer_js.js +306 -215
- package/files/aligned.csv +648 -648
- package/files/aligned_2.csv +541 -10275
- package/files/aligned_3.csv +335 -0
- package/helm/JSDraw/Pistoia.HELM.js +27 -0
- package/package.json +17 -12
- package/src/__jest__/remote.test.ts +31 -13
- package/src/model.ts +321 -342
- package/src/package-test.ts +0 -1
- package/src/package.ts +13 -109
- package/src/tests/core.ts +48 -16
- package/src/tests/utils.ts +0 -11
- package/src/utils/cell-renderer.ts +92 -275
- package/src/utils/constants.ts +5 -4
- package/src/utils/misc.ts +103 -16
- package/src/utils/multiple-sequence-alignment.ts +1 -1
- package/src/utils/peptide-similarity-space.ts +1 -1
- package/src/utils/types.ts +7 -5
- package/src/viewers/peptide-space-viewer.ts +3 -3
- package/src/viewers/sar-viewer.ts +34 -23
- package/src/widgets/analyze-peptides.ts +23 -17
- package/src/widgets/distribution.ts +0 -1
- package/src/widgets/manual-alignment.ts +4 -4
- package/src/widgets/subst-table.ts +5 -2
- package/{test-Peptides-34f75e5127b8-4210edfc.html → test-Peptides-4f0c8bae6479-74cbfe68.html} +8 -8
- package/detectors.js +0 -9
- package/src/monomer-library.ts +0 -193
- package/src/tests/msa-tests.ts +0 -27
- package/src/utils/chem-palette.ts +0 -280
- package/src/viewers/stacked-barchart-viewer.ts +0 -321
- package/src/widgets/multiple-sequence-alignment.ts +0 -9
- package/src/widgets/peptide-molecule.ts +0 -82
package/src/package-test.ts
CHANGED
package/src/package.ts
CHANGED
|
@@ -5,21 +5,13 @@ import * as DG from 'datagrok-api/dg';
|
|
|
5
5
|
|
|
6
6
|
import * as C from './utils/constants';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
AlignedSequenceCellRenderer,
|
|
10
|
-
AlignedSequenceDifferenceCellRenderer,
|
|
11
|
-
AminoAcidsCellRenderer,
|
|
12
|
-
} from './utils/cell-renderer';
|
|
13
|
-
import {StackedBarChart} from './viewers/stacked-barchart-viewer';
|
|
14
|
-
|
|
15
8
|
import {analyzePeptidesWidget} from './widgets/analyze-peptides';
|
|
16
9
|
import {PeptideSimilaritySpaceWidget} from './utils/peptide-similarity-space';
|
|
17
10
|
import {manualAlignmentWidget} from './widgets/manual-alignment';
|
|
18
11
|
import {SARViewer, SARViewerVertical} from './viewers/sar-viewer';
|
|
19
|
-
|
|
20
|
-
import {runKalign, testMSAEnoughMemory} from './utils/multiple-sequence-alignment';
|
|
21
|
-
import {msaWidget} from './widgets/multiple-sequence-alignment';
|
|
12
|
+
|
|
22
13
|
import {PeptideSpaceViewer} from './viewers/peptide-space-viewer';
|
|
14
|
+
import {getSeparator} from './utils/misc';
|
|
23
15
|
|
|
24
16
|
export const _package = new DG.Package();
|
|
25
17
|
let currentTable: DG.DataFrame;
|
|
@@ -74,19 +66,16 @@ export async function Peptides(): Promise<void> {
|
|
|
74
66
|
ui.divH([
|
|
75
67
|
ui.button('Simple demo', () => main('aligned.csv'), ''),
|
|
76
68
|
ui.button('Complex demo', () => main('aligned_2.csv'), ''),
|
|
77
|
-
|
|
69
|
+
ui.button('HELM demo', () => main('aligned_3.csv'), ''),
|
|
78
70
|
]),
|
|
79
71
|
]);
|
|
80
72
|
}
|
|
81
73
|
|
|
82
74
|
//name: Peptides
|
|
83
75
|
//tags: panel, widgets
|
|
84
|
-
//input: column col {semType:
|
|
76
|
+
//input: column col {semType: Macromolecule}
|
|
85
77
|
//output: widget result
|
|
86
78
|
export async function peptidesPanel(col: DG.Column): Promise<DG.Widget> {
|
|
87
|
-
if (!(col.temp['isAnalysisApplicable'] ?? true))
|
|
88
|
-
return new DG.Widget(ui.divText('Analysis is not applicable'));
|
|
89
|
-
|
|
90
79
|
[currentTable, alignedSequenceColumn] = getOrDefine(col.dataFrame, col);
|
|
91
80
|
return analyzePeptidesWidget(currentTable, alignedSequenceColumn);
|
|
92
81
|
}
|
|
@@ -115,61 +104,9 @@ export function peptideSpace(): PeptideSpaceViewer {
|
|
|
115
104
|
return new PeptideSpaceViewer();
|
|
116
105
|
}
|
|
117
106
|
|
|
118
|
-
//name: StackedBarchart Widget
|
|
119
|
-
//tags: panel, widgets
|
|
120
|
-
//input: column col {semType: aminoAcids}
|
|
121
|
-
//output: widget result
|
|
122
|
-
export async function stackedBarchartWidget(col: DG.Column): Promise<DG.Widget> {
|
|
123
|
-
const viewer = await col.dataFrame.plot.fromType('StackedBarChartAA');
|
|
124
|
-
const panel = ui.divH([viewer.root]);
|
|
125
|
-
return new DG.Widget(panel);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//name: Peptide Molecule
|
|
129
|
-
//tags: panel, widgets
|
|
130
|
-
//input: string peptide {semType: alignedSequence}
|
|
131
|
-
//output: widget result
|
|
132
|
-
export async function peptideMolecule(peptide: string): Promise<DG.Widget> {
|
|
133
|
-
[currentTable, alignedSequenceColumn] = getOrDefine();
|
|
134
|
-
return peptideMoleculeWidget(peptide, currentTable);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
//name: Peptide Molecule
|
|
138
|
-
//tags: panel, widgets
|
|
139
|
-
//input: string _aar {semType: aminoAcids}
|
|
140
|
-
//output: widget result
|
|
141
|
-
export async function peptideMolecule2(_aar: string): Promise<DG.Widget> {
|
|
142
|
-
[currentTable, alignedSequenceColumn] = getOrDefine();
|
|
143
|
-
const peptide = alignedSequenceColumn.get(currentTable.currentRowIdx);
|
|
144
|
-
return peptideMolecule(peptide);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//name: StackedBarChartAA
|
|
148
|
-
//tags: viewer
|
|
149
|
-
//output: viewer result
|
|
150
|
-
export function stackedBarChart(): DG.JsViewer {
|
|
151
|
-
return new StackedBarChart();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
//name: alignedSequenceCellRenderer
|
|
155
|
-
//tags: cellRenderer
|
|
156
|
-
//meta.cellType: alignedSequence
|
|
157
|
-
//output: grid_cell_renderer result
|
|
158
|
-
export function alignedSequenceCellRenderer(): AlignedSequenceCellRenderer {
|
|
159
|
-
return new AlignedSequenceCellRenderer();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
//name: aminoAcidsCellRenderer
|
|
163
|
-
//tags: cellRenderer
|
|
164
|
-
//meta.cellType: aminoAcids
|
|
165
|
-
//output: grid_cell_renderer result
|
|
166
|
-
export function aminoAcidsCellRenderer(): AminoAcidsCellRenderer {
|
|
167
|
-
return new AminoAcidsCellRenderer();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
107
|
//name: Manual Alignment
|
|
171
108
|
//tags: panel, widgets
|
|
172
|
-
//input: string _monomer {semType:
|
|
109
|
+
//input: string _monomer {semType: Monomer}
|
|
173
110
|
//output: widget result
|
|
174
111
|
export function manualAlignment(_monomer: string): DG.Widget {
|
|
175
112
|
[currentTable, alignedSequenceColumn] = getOrDefine();
|
|
@@ -179,7 +116,7 @@ export function manualAlignment(_monomer: string): DG.Widget {
|
|
|
179
116
|
|
|
180
117
|
//name: Peptide Space
|
|
181
118
|
//tags: panel, widgets
|
|
182
|
-
//input: column col {semType:
|
|
119
|
+
//input: column col {semType: Macromolecule}
|
|
183
120
|
//output: widget result
|
|
184
121
|
export async function peptideSpacePanel(col: DG.Column): Promise<DG.Widget> {
|
|
185
122
|
[currentTable, alignedSequenceColumn] = getOrDefine(col.dataFrame, col);
|
|
@@ -187,56 +124,31 @@ export async function peptideSpacePanel(col: DG.Column): Promise<DG.Widget> {
|
|
|
187
124
|
return widget.draw();
|
|
188
125
|
}
|
|
189
126
|
|
|
127
|
+
/*
|
|
190
128
|
//name: Molfile
|
|
191
129
|
//tags: panel, widgets
|
|
192
|
-
//input: string peptide {
|
|
130
|
+
//input: string peptide {semType: Macromolecule}
|
|
193
131
|
//output: widget result
|
|
194
132
|
export async function peptideMolfile(peptide: string): Promise<DG.Widget> {
|
|
195
133
|
[currentTable, alignedSequenceColumn] = getOrDefine();
|
|
196
|
-
const smiles = getMolecule(peptide, alignedSequenceColumn
|
|
134
|
+
const smiles = getMolecule(peptide, getSeparator(alignedSequenceColumn));
|
|
197
135
|
return grok.functions.call('Chem:molfile', {'smiles': smiles}) as Promise<DG.Widget>;
|
|
198
136
|
}
|
|
199
137
|
|
|
200
138
|
//name: Molfile
|
|
201
139
|
//tags: panel, widgets
|
|
202
|
-
//input: string _aar {
|
|
140
|
+
//input: string _aar {semType: Monomer}
|
|
203
141
|
//output: widget result
|
|
204
142
|
export async function peptideMolfile2(_aar: string): Promise<DG.Widget> {
|
|
205
143
|
[currentTable, alignedSequenceColumn] = getOrDefine();
|
|
206
144
|
const peptide = alignedSequenceColumn.get(currentTable.currentRowIdx);
|
|
207
145
|
return peptideMolfile(peptide);
|
|
208
146
|
}
|
|
209
|
-
|
|
210
|
-
//name: Multiple sequence alignment
|
|
211
|
-
//tags: panel
|
|
212
|
-
//input: column col {semType: alignedSequence}
|
|
213
|
-
//output: dataframe result
|
|
214
|
-
export async function multipleSequenceAlignment(col: DG.Column): Promise<DG.DataFrame> {
|
|
215
|
-
return msaWidget(col);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
//name: Multiple sequence alignment for any column
|
|
219
|
-
//input: dataframe table
|
|
220
|
-
//input: column col
|
|
221
|
-
//output: dataframe result
|
|
222
|
-
export async function multipleSequenceAlignmentAny(table: DG.DataFrame, col: DG.Column): Promise<DG.DataFrame> {
|
|
223
|
-
const msaCol = await runKalign(col, false);
|
|
224
|
-
table.columns.add(msaCol);
|
|
225
|
-
return table;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
//name: Test multiple sequence alignment for any column
|
|
229
|
-
//input: dataframe _table
|
|
230
|
-
//input: column col
|
|
231
|
-
//output: column result
|
|
232
|
-
export async function runTestMSAEnoughMemory(_table: DG.DataFrame, col: DG.Column<string>): Promise<DG.Column<string>> {
|
|
233
|
-
await testMSAEnoughMemory(col);
|
|
234
|
-
return col;
|
|
235
|
-
}
|
|
147
|
+
*/
|
|
236
148
|
|
|
237
149
|
//name: Get Peptides Structure
|
|
238
150
|
//tags: panel, widgets
|
|
239
|
-
//input: column col {semType:
|
|
151
|
+
//input: column col {semType: Macromolecule}
|
|
240
152
|
//output: widget result
|
|
241
153
|
export function getPeptidesStructure(col: DG.Column): DG.Widget {
|
|
242
154
|
const getButtonTooltip = 'Retrieves peptides structure from customer database by special id column';
|
|
@@ -256,17 +168,9 @@ export function getPeptidesStructure(col: DG.Column): DG.Widget {
|
|
|
256
168
|
return new DG.Widget(getButton);
|
|
257
169
|
}
|
|
258
170
|
|
|
259
|
-
//name: alignedSequenceDifferenceCellRenderer
|
|
260
|
-
//tags: cellRenderer
|
|
261
|
-
//meta.cellType: alignedSequenceDifference
|
|
262
|
-
//output: grid_cell_renderer result
|
|
263
|
-
export function alignedSequenceDifferenceCellRenderer(): AlignedSequenceDifferenceCellRenderer {
|
|
264
|
-
return new AlignedSequenceDifferenceCellRenderer();
|
|
265
|
-
}
|
|
266
|
-
|
|
267
171
|
function getOrDefine(dataframe?: DG.DataFrame, column?: DG.Column | null): [DG.DataFrame, DG.Column] {
|
|
268
172
|
dataframe ??= grok.shell.t;
|
|
269
|
-
column ??= dataframe.columns.bySemType(C.SEM_TYPES.
|
|
173
|
+
column ??= dataframe.columns.bySemType(C.SEM_TYPES.MACROMOLECULE);
|
|
270
174
|
if (column === null)
|
|
271
175
|
throw new Error('Table does not contain aligned sequence columns');
|
|
272
176
|
|
package/src/tests/core.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as grok from 'datagrok-api/grok';
|
|
2
2
|
import * as DG from 'datagrok-api/dg';
|
|
3
3
|
|
|
4
|
-
import {category, test, expect} from '@datagrok-libraries/utils/src/test';
|
|
4
|
+
import {category, test, expect, delay} from '@datagrok-libraries/utils/src/test';
|
|
5
5
|
|
|
6
6
|
import {_package} from '../package-test';
|
|
7
7
|
import {startAnalysis} from '../widgets/analyze-peptides';
|
|
8
8
|
import {PeptidesModel} from '../model';
|
|
9
9
|
import * as C from '../utils/constants';
|
|
10
|
+
import {scaleActivity} from '../utils/misc';
|
|
10
11
|
|
|
11
12
|
category('Core', () => {
|
|
12
13
|
let simpleTable: DG.DataFrame;
|
|
@@ -20,7 +21,7 @@ category('Core', () => {
|
|
|
20
21
|
let complexAlignedSeqCol: DG.Column<string>;
|
|
21
22
|
let complexScaledDf: DG.DataFrame;
|
|
22
23
|
let complexScaledColName: string;
|
|
23
|
-
const
|
|
24
|
+
const alignedSequenceCol = 'AlignedSequence';
|
|
24
25
|
|
|
25
26
|
let model: PeptidesModel | null = null;
|
|
26
27
|
|
|
@@ -28,10 +29,9 @@ category('Core', () => {
|
|
|
28
29
|
const simpleActivityColName = 'IC50';
|
|
29
30
|
simpleTable = DG.DataFrame.fromCsv(await _package.files.readAsText('aligned.csv'));
|
|
30
31
|
simpleActivityCol = simpleTable.getCol(simpleActivityColName);
|
|
31
|
-
simpleAlignedSeqCol = simpleTable.getCol(
|
|
32
|
-
simpleAlignedSeqCol.semType = C.SEM_TYPES.
|
|
33
|
-
[simpleScaledDf, simpleScaledColName] =
|
|
34
|
-
await PeptidesModel.scaleActivity('-lg', simpleTable, simpleActivityColName, true);
|
|
32
|
+
simpleAlignedSeqCol = simpleTable.getCol(alignedSequenceCol);
|
|
33
|
+
simpleAlignedSeqCol.semType = C.SEM_TYPES.MACROMOLECULE;
|
|
34
|
+
[simpleScaledDf, simpleScaledColName] = scaleActivity('-lg', simpleTable, simpleActivityColName, true);
|
|
35
35
|
|
|
36
36
|
model = await startAnalysis(
|
|
37
37
|
simpleActivityCol, simpleAlignedSeqCol, simpleTable, simpleScaledDf, simpleScaledColName, _package);
|
|
@@ -39,21 +39,17 @@ category('Core', () => {
|
|
|
39
39
|
|
|
40
40
|
if (model != null) {
|
|
41
41
|
model.currentSelection = {'11': ['D']};
|
|
42
|
-
grok.shell.closeTable(model.
|
|
42
|
+
grok.shell.closeTable(model.df);
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
test('Start analysis: сomplex', async () => {
|
|
47
|
-
const
|
|
48
|
-
const complexActivityColName = 'Value';
|
|
47
|
+
const complexActivityColName = 'Activity';
|
|
49
48
|
complexTable = DG.DataFrame.fromCsv(await _package.files.readAsText('aligned_2.csv'));
|
|
50
|
-
const measuredCol: DG.Column<string> = complexTable.getCol('Measured');
|
|
51
|
-
complexTable.filter.init((idx) => measuredCol.get(idx) == measureCategory);
|
|
52
49
|
complexActivityCol = complexTable.getCol(complexActivityColName);
|
|
53
|
-
complexAlignedSeqCol = complexTable.getCol(
|
|
54
|
-
complexAlignedSeqCol.semType = C.SEM_TYPES.
|
|
55
|
-
[complexScaledDf, complexScaledColName] =
|
|
56
|
-
await PeptidesModel.scaleActivity('-lg', complexTable, complexActivityColName, true);
|
|
50
|
+
complexAlignedSeqCol = complexTable.getCol('MSA');
|
|
51
|
+
complexAlignedSeqCol.semType = C.SEM_TYPES.MACROMOLECULE;
|
|
52
|
+
[complexScaledDf, complexScaledColName] = scaleActivity('-lg', complexTable, complexActivityColName, true);
|
|
57
53
|
|
|
58
54
|
model = await startAnalysis(
|
|
59
55
|
complexActivityCol, complexAlignedSeqCol, complexTable, complexScaledDf, complexScaledColName, _package);
|
|
@@ -61,7 +57,43 @@ category('Core', () => {
|
|
|
61
57
|
|
|
62
58
|
if (model != null) {
|
|
63
59
|
model.currentSelection = {'13': ['-']};
|
|
64
|
-
grok.shell.closeTable(model.
|
|
60
|
+
grok.shell.closeTable(model.df);
|
|
65
61
|
}
|
|
66
62
|
});
|
|
63
|
+
|
|
64
|
+
test('Save and load project', async () => {
|
|
65
|
+
const simpleActivityColName = 'IC50';
|
|
66
|
+
simpleTable = DG.DataFrame.fromCsv(await _package.files.readAsText('aligned.csv'));
|
|
67
|
+
simpleActivityCol = simpleTable.getCol(simpleActivityColName);
|
|
68
|
+
simpleAlignedSeqCol = simpleTable.getCol(alignedSequenceCol);
|
|
69
|
+
simpleAlignedSeqCol.semType = C.SEM_TYPES.MACROMOLECULE;
|
|
70
|
+
[simpleScaledDf, simpleScaledColName] = scaleActivity('-lg', simpleTable, simpleActivityColName, true);
|
|
71
|
+
|
|
72
|
+
model = await startAnalysis(
|
|
73
|
+
simpleActivityCol, simpleAlignedSeqCol, simpleTable, simpleScaledDf, simpleScaledColName, _package);
|
|
74
|
+
let v = grok.shell.getTableView('Peptides analysis');
|
|
75
|
+
const d = v.dataFrame;
|
|
76
|
+
const layout = v.saveLayout();
|
|
77
|
+
const tableInfo = d.getTableInfo();
|
|
78
|
+
|
|
79
|
+
const project = DG.Project.create();
|
|
80
|
+
project.name = 'Peptides project unique test';
|
|
81
|
+
project.addChild(tableInfo);
|
|
82
|
+
project.addChild(layout);
|
|
83
|
+
const sl = await grok.dapi.layouts.save(layout);
|
|
84
|
+
await grok.dapi.tables.uploadDataFrame(d);
|
|
85
|
+
const sti = await grok.dapi.tables.save(tableInfo);
|
|
86
|
+
const sp = await grok.dapi.projects.save(project);
|
|
87
|
+
|
|
88
|
+
grok.shell.closeTable(d);
|
|
89
|
+
await delay(500);
|
|
90
|
+
|
|
91
|
+
await grok.dapi.projects.open('Peptides project unique test');
|
|
92
|
+
v = grok.shell.getTableView('Peptides analysis');
|
|
93
|
+
grok.shell.closeTable(v.dataFrame);
|
|
94
|
+
|
|
95
|
+
await grok.dapi.layouts.delete(sl);
|
|
96
|
+
await grok.dapi.tables.delete(sti);
|
|
97
|
+
await grok.dapi.projects.delete(sp);
|
|
98
|
+
});
|
|
67
99
|
});
|
package/src/tests/utils.ts
CHANGED
|
@@ -78,14 +78,3 @@ export async function _testPeptideSimilaritySpaceViewer(table: DG.DataFrame, ali
|
|
|
78
78
|
for (const ax of axes)
|
|
79
79
|
expect(ax.every((v) => v !== null && v !== NaN), true);
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Tests if MSA works and returns consistent result.
|
|
84
|
-
*
|
|
85
|
-
* @export
|
|
86
|
-
* @param {DG.Column} col Aligned sequences column.
|
|
87
|
-
*/
|
|
88
|
-
export async function _testMSAIsCorrect(col: DG.Column): Promise<void> {
|
|
89
|
-
const msaCol = await runKalign(col, true);
|
|
90
|
-
expect(msaCol.toList().every((v, i) => v == col.get(i)), true);
|
|
91
|
-
}
|