@datagrok/peptides 0.8.5 → 0.8.9
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 +12 -2
- package/files/aligned.csv +648 -3
- package/files/aligned_2.csv +10275 -3
- package/package.json +12 -14
- package/setup.cmd +18 -0
- package/setup.sh +15 -0
- package/src/describe.ts +131 -136
- package/src/model.ts +98 -76
- package/src/monomer-library.ts +184 -0
- package/src/package-test.ts +4 -3
- package/src/package.ts +76 -23
- package/src/peptides.ts +223 -108
- package/src/tests/msa-tests.ts +27 -0
- package/src/tests/peptide-space-test.ts +46 -9
- package/src/tests/peptides-tests.ts +58 -21
- package/src/tests/test-data.ts +649 -0
- package/src/tests/utils.ts +56 -16
- package/src/utils/cell-renderer.ts +211 -58
- package/src/utils/chem-palette.ts +86 -45
- package/src/utils/molecular-measure.ts +3 -4
- package/src/utils/multiple-sequence-alignment.ts +3 -4
- package/src/utils/peptide-similarity-space.ts +44 -37
- package/src/utils/split-aligned.ts +58 -58
- package/src/viewers/logo-viewer.ts +14 -15
- package/src/viewers/sar-viewer.ts +101 -124
- package/src/viewers/stacked-barchart-viewer.ts +360 -365
- package/src/viewers/subst-viewer.ts +115 -71
- package/src/widgets/analyze-peptides.ts +31 -31
- package/src/widgets/manual-alignment.ts +12 -7
- package/src/widgets/multiple-sequence-alignment.ts +9 -0
- package/src/widgets/peptide-molecule.ts +9 -8
- package/src/widgets/subst-table.ts +65 -0
- package/src/workers/dimensionality-reducer.ts +2 -1
- package/tsconfig.json +1 -1
package/src/peptides.ts
CHANGED
|
@@ -1,21 +1,165 @@
|
|
|
1
1
|
import * as ui from 'datagrok-api/ui';
|
|
2
2
|
import * as DG from 'datagrok-api/dg';
|
|
3
3
|
import {createPeptideSimilaritySpaceViewer} from './utils/peptide-similarity-space';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
import {PeptidesModel} from './model';
|
|
5
|
+
import {StringDictionary} from '@datagrok-libraries/utils/src/type-declarations';
|
|
6
|
+
import {SARViewer, SARViewerVertical} from './viewers/sar-viewer';
|
|
7
|
+
import {SubstViewer} from './viewers/subst-viewer';
|
|
8
|
+
import {ChemPalette} from './utils/chem-palette';
|
|
9
|
+
import {Observable} from 'rxjs';
|
|
10
|
+
|
|
11
|
+
type viewerTypes = SARViewer | SARViewerVertical | SubstViewer;
|
|
12
|
+
export class PeptidesController {
|
|
13
|
+
private static _controllerName: string = 'peptidesController';
|
|
14
|
+
private helpUrl = '/help/domains/bio/peptides.md';
|
|
15
|
+
private _dataFrame: DG.DataFrame;
|
|
16
|
+
private _model: PeptidesModel;
|
|
17
|
+
|
|
18
|
+
private constructor(dataFrame: DG.DataFrame) {
|
|
19
|
+
this._dataFrame = dataFrame;
|
|
20
|
+
this._model = PeptidesModel.getOrInit(this._dataFrame);
|
|
21
|
+
// this.getOrInitModel(this._dataFrame);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static getInstance(dataFrame: DG.DataFrame): PeptidesController {
|
|
25
|
+
dataFrame.temp[PeptidesController.controllerName] ??= new PeptidesController(dataFrame);
|
|
26
|
+
return dataFrame.temp[PeptidesController.controllerName];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static get controllerName() {
|
|
30
|
+
return PeptidesController._controllerName;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// getOrInitModel(): PeptidesModel {
|
|
34
|
+
// this._model ??= PeptidesModel.getOrInit(this._dataFrame);
|
|
35
|
+
// return this._model;
|
|
36
|
+
// }
|
|
37
|
+
|
|
38
|
+
get onStatsDataFrameChanged(): Observable<DG.DataFrame> {
|
|
39
|
+
return this._model.onStatsDataFrameChanged;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get onSARGridChanged(): Observable<DG.Grid> {
|
|
43
|
+
return this._model.onSARGridChanged;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get onSARVGridChanged(): Observable<DG.Grid> {
|
|
47
|
+
return this._model.onSARVGridChanged;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get onGroupMappingChanged(): Observable<StringDictionary> {
|
|
51
|
+
return this._model.onGroupMappingChanged;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get onSubstFlagChanged(): Observable<boolean> {
|
|
55
|
+
return this._model.onSubstFlagChanged;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async updateDefault() {
|
|
59
|
+
await this._model.updateDefault();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async updateData(
|
|
63
|
+
dataFrame: DG.DataFrame | null, activityCol: string | null, activityScaling: string | null,
|
|
64
|
+
sourceGrid: DG.Grid | null, twoColorMode: boolean | null, initialBitset: DG.BitSet | null,
|
|
65
|
+
grouping: boolean | null) {
|
|
66
|
+
await this._model.updateData(
|
|
67
|
+
dataFrame, activityCol, activityScaling, sourceGrid, twoColorMode, initialBitset, grouping);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async scaleActivity(
|
|
71
|
+
activityScaling: string, activityColumn: string, activityColumnScaled: string, df: DG.DataFrame,
|
|
72
|
+
): Promise<[DG.DataFrame, string]> {
|
|
73
|
+
// const df = sourceGrid.dataFrame!;
|
|
74
|
+
const tempDf = df.clone(null, [activityColumn]);
|
|
75
|
+
|
|
76
|
+
let formula = '${' + activityColumn + '}';
|
|
77
|
+
let newColName = activityColumn;
|
|
78
|
+
switch (activityScaling) {
|
|
79
|
+
case 'none':
|
|
80
|
+
break;
|
|
81
|
+
case 'lg':
|
|
82
|
+
formula = `Log10(${formula})`;
|
|
83
|
+
newColName = `Log10(${newColName})`;
|
|
84
|
+
break;
|
|
85
|
+
case '-lg':
|
|
86
|
+
formula = `-1*Log10(${formula})`;
|
|
87
|
+
newColName = `-Log10(${newColName})`;
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
throw new Error(`ScalingError: method \`${activityScaling}\` is not available.`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await (tempDf.columns as DG.ColumnList).addNewCalculated(activityColumnScaled, formula);
|
|
94
|
+
|
|
95
|
+
return [tempDf, newColName];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static splitAlignedPeptides(peptideColumn: DG.Column, filter: boolean = true): [DG.DataFrame, number[]] {
|
|
99
|
+
const splitPeptidesArray: string[][] = [];
|
|
100
|
+
let currentSplitPeptide: string[];
|
|
101
|
+
let modeMonomerCount = 0;
|
|
102
|
+
let currentLength;
|
|
103
|
+
const colLength = peptideColumn.length;
|
|
104
|
+
|
|
105
|
+
// splitting data
|
|
106
|
+
const monomerLengths: {[index: string]: number} = {};
|
|
107
|
+
for (let i = 0; i < colLength; i++) {
|
|
108
|
+
currentSplitPeptide = peptideColumn.get(i).split('-').map((value: string) => value ? value : '-');
|
|
109
|
+
splitPeptidesArray.push(currentSplitPeptide);
|
|
110
|
+
currentLength = currentSplitPeptide.length;
|
|
111
|
+
monomerLengths[currentLength + ''] =
|
|
112
|
+
monomerLengths[currentLength + ''] ? monomerLengths[currentLength + ''] + 1 : 1;
|
|
113
|
+
}
|
|
114
|
+
//@ts-ignore: what I do here is converting string to number the most effective way I could find. parseInt is slow
|
|
115
|
+
modeMonomerCount = 1 * Object.keys(monomerLengths).reduce((a, b) => monomerLengths[a] > monomerLengths[b] ? a : b);
|
|
116
|
+
|
|
117
|
+
// making sure all of the sequences are of the same size
|
|
118
|
+
// and marking invalid sequences
|
|
119
|
+
let nTerminal: string;
|
|
120
|
+
const invalidIndexes: number[] = [];
|
|
121
|
+
let splitColumns: string[][] = Array.from({length: modeMonomerCount}, (_) => []);
|
|
122
|
+
modeMonomerCount--; // minus N-terminal
|
|
123
|
+
for (let i = 0; i < colLength; i++) {
|
|
124
|
+
currentSplitPeptide = splitPeptidesArray[i];
|
|
125
|
+
nTerminal = currentSplitPeptide.pop()!; // it is guaranteed that there will be at least one element
|
|
126
|
+
currentLength = currentSplitPeptide.length;
|
|
127
|
+
if (currentLength !== modeMonomerCount)
|
|
128
|
+
invalidIndexes.push(i);
|
|
129
|
+
|
|
130
|
+
for (let j = 0; j < modeMonomerCount; j++)
|
|
131
|
+
splitColumns[j].push(j < currentLength ? currentSplitPeptide[j] : '-');
|
|
132
|
+
|
|
133
|
+
splitColumns[modeMonomerCount].push(nTerminal);
|
|
134
|
+
}
|
|
135
|
+
modeMonomerCount--; // minus C-terminal
|
|
136
|
+
|
|
137
|
+
//create column names list
|
|
138
|
+
const columnNames = Array.from({length: modeMonomerCount}, (_, index) => `${index + 1 < 10 ? 0 : ''}${index + 1 }`);
|
|
139
|
+
columnNames.splice(0, 0, 'N-terminal');
|
|
140
|
+
columnNames.push('C-terminal');
|
|
141
|
+
|
|
142
|
+
// filter out the columns with the same values
|
|
143
|
+
if (filter) {
|
|
144
|
+
splitColumns = splitColumns.filter((positionArray, index) => {
|
|
145
|
+
const isRetained = new Set(positionArray).size > 1;
|
|
146
|
+
if (!isRetained)
|
|
147
|
+
columnNames.splice(index, 1);
|
|
148
|
+
|
|
149
|
+
return isRetained;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return [
|
|
154
|
+
DG.DataFrame.fromColumns(splitColumns.map((positionArray, index) => {
|
|
155
|
+
return DG.Column.fromList('string', columnNames[index], positionArray);
|
|
156
|
+
})),
|
|
157
|
+
invalidIndexes,
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static getChemPalette() {
|
|
162
|
+
return ChemPalette;
|
|
19
163
|
}
|
|
20
164
|
|
|
21
165
|
/**
|
|
@@ -24,18 +168,22 @@ export class Peptides {
|
|
|
24
168
|
* @param {DG.Grid} tableGrid Working talbe grid.
|
|
25
169
|
* @param {DG.TableView} view Working view.
|
|
26
170
|
* @param {DG.DataFrame} currentDf Working table.
|
|
27
|
-
* @param {
|
|
171
|
+
* @param {StringDictionary} options SAR viewer options
|
|
28
172
|
* @param {DG.Column} col Aligned sequences column.
|
|
29
|
-
* @param {string} activityColumnChoice Activity column name.
|
|
30
173
|
* @memberof Peptides
|
|
31
174
|
*/
|
|
32
175
|
async init(
|
|
33
|
-
tableGrid: DG.Grid,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
176
|
+
tableGrid: DG.Grid, view: DG.TableView, options: StringDictionary, col: DG.Column,
|
|
177
|
+
originalDfColumns: string[]) {
|
|
178
|
+
function adjustCellSize(grid: DG.Grid) {
|
|
179
|
+
const colNum = grid.columns.length;
|
|
180
|
+
for (let i = 0; i < colNum; ++i) {
|
|
181
|
+
const iCol = grid.columns.byIndex(i)!;
|
|
182
|
+
iCol.width = isNaN(parseInt(iCol.name)) ? 50 : 40;
|
|
183
|
+
}
|
|
184
|
+
grid.props.rowHeight = 20;
|
|
185
|
+
}
|
|
186
|
+
|
|
39
187
|
for (let i = 0; i < tableGrid.columns.length; i++) {
|
|
40
188
|
const aarCol = tableGrid.columns.byIndex(i);
|
|
41
189
|
if (aarCol &&
|
|
@@ -47,120 +195,87 @@ export class Peptides {
|
|
|
47
195
|
}
|
|
48
196
|
}
|
|
49
197
|
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const originalDfName = currentDf.name;
|
|
53
|
-
|
|
54
|
-
// const substViewer = view.addViewer(
|
|
55
|
-
// 'substitution-analysis-viewer', {'activityColumnName': options['activityColumnName']},
|
|
56
|
-
// );
|
|
57
|
-
// const substNode = view.dockManager.dock(substViewer, DG.DOCK_TYPE.RIGHT, null, 'Substitution Analysis');
|
|
198
|
+
const originalDfName = this._dataFrame.name;
|
|
199
|
+
const dockManager = view.dockManager;
|
|
58
200
|
|
|
59
|
-
|
|
60
|
-
|
|
201
|
+
const sarViewer = await this._dataFrame.plot.fromType('peptide-sar-viewer', options) as SARViewer;
|
|
202
|
+
sarViewer.helpUrl = this.helpUrl;
|
|
61
203
|
|
|
62
|
-
const
|
|
63
|
-
|
|
204
|
+
const sarViewerVertical = await this._dataFrame.plot.fromType('peptide-sar-viewer-vertical') as SARViewerVertical;
|
|
205
|
+
sarViewerVertical.helpUrl = this.helpUrl;
|
|
64
206
|
|
|
65
|
-
const
|
|
66
|
-
const sarVNode = view.dockManager.dock(sarViewerVertical, DG.DOCK_TYPE.RIGHT, sarNode, 'SAR Vertical Viewer');
|
|
207
|
+
const sarViewersGroup: viewerTypes[] = [sarViewer, sarViewerVertical];
|
|
67
208
|
|
|
68
209
|
const peptideSpaceViewer = await createPeptideSimilaritySpaceViewer(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
`${options['
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const layout2 = view.saveLayout();
|
|
80
|
-
|
|
81
|
-
const nodeList = [sarNode, sarVNode, psNode];
|
|
82
|
-
|
|
83
|
-
const StackedBarchartProm = currentDf.plot.fromType('StackedBarChartAA');
|
|
84
|
-
addViewerToHeader(tableGrid, StackedBarchartProm);
|
|
210
|
+
this._dataFrame, col, 't-SNE', 'Levenshtein', 100, view, `${options['activityColumnName']}Scaled`);
|
|
211
|
+
dockManager.dock(peptideSpaceViewer, DG.DOCK_TYPE.RIGHT, null, 'Peptide Space viewer');
|
|
212
|
+
|
|
213
|
+
let nodeList = dockViewers(sarViewersGroup, DG.DOCK_TYPE.RIGHT, dockManager, DG.DOCK_TYPE.DOWN);
|
|
214
|
+
|
|
215
|
+
const substViewer = await this._dataFrame.plot.fromType(
|
|
216
|
+
'substitution-analysis-viewer', {'activityColumnName': `${options['activityColumnName']}Scaled`}) as SubstViewer;
|
|
217
|
+
const substViewersGroup = [substViewer];
|
|
218
|
+
|
|
85
219
|
tableGrid.props.allowEdit = false;
|
|
220
|
+
adjustCellSize(tableGrid);
|
|
86
221
|
|
|
87
|
-
const hideIcon = ui.iconFA('window-close', () => {
|
|
222
|
+
const hideIcon = ui.iconFA('window-close', () => {
|
|
88
223
|
const viewers = [];
|
|
89
224
|
for (const viewer of view.viewers) {
|
|
90
|
-
if (viewer.type !== DG.VIEWER.GRID)
|
|
225
|
+
if (viewer.type !== DG.VIEWER.GRID)
|
|
91
226
|
viewers.push(viewer);
|
|
92
|
-
}
|
|
93
227
|
}
|
|
94
228
|
viewers.forEach((v) => v.close());
|
|
95
229
|
|
|
96
|
-
const cols = (
|
|
230
|
+
const cols = (this._dataFrame.columns as DG.ColumnList);
|
|
97
231
|
for (const colName of cols.names()) {
|
|
98
|
-
if (!originalDfColumns.includes(colName))
|
|
232
|
+
if (!originalDfColumns.includes(colName))
|
|
99
233
|
cols.remove(colName);
|
|
100
|
-
}
|
|
101
234
|
}
|
|
102
235
|
|
|
103
|
-
|
|
104
|
-
|
|
236
|
+
this._dataFrame.selection.setAll(false);
|
|
237
|
+
this._dataFrame.filter.setAll(true);
|
|
105
238
|
|
|
106
239
|
tableGrid.setOptions({'colHeaderHeight': 20});
|
|
107
240
|
tableGrid.columns.setVisible(originalDfColumns);
|
|
108
241
|
tableGrid.props.allowEdit = true;
|
|
109
|
-
|
|
242
|
+
this._dataFrame.name = originalDfName;
|
|
110
243
|
|
|
111
244
|
view.setRibbonPanels(ribbonPanels);
|
|
112
245
|
}, 'Close viewers and restore dataframe');
|
|
113
246
|
|
|
114
247
|
let isSA = false;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// $(switchViewers).removeClass('fa-toggle-on');
|
|
124
|
-
// $(switchViewers).addClass('fa-toggle-off');
|
|
125
|
-
// }
|
|
126
|
-
// isSA = !isSA;
|
|
127
|
-
// });
|
|
128
|
-
const switchViewers = ui.iconFA('toggle-on', async () => {
|
|
129
|
-
currentDf.filter.copyFrom(initialFiter);
|
|
130
|
-
currentDf.selection.setAll(false);
|
|
131
|
-
nodeList.forEach((node) => view.dockManager.close(node));
|
|
132
|
-
nodeList.length = 0;
|
|
133
|
-
if (isSA) {
|
|
134
|
-
const sarViewer = view.addViewer('peptide-sar-viewer', options);
|
|
135
|
-
const sarNode = view.dockManager.dock(sarViewer, DG.DOCK_TYPE.DOWN, null, 'SAR Viewer');
|
|
136
|
-
|
|
137
|
-
const sarViewerVertical = view.addViewer('peptide-sar-viewer-vertical');
|
|
138
|
-
const sarVNode = view.dockManager.dock(sarViewerVertical, DG.DOCK_TYPE.RIGHT, sarNode, 'SAR Vertical Viewer');
|
|
139
|
-
|
|
140
|
-
const peptideSpaceViewer = await createPeptideSimilaritySpaceViewer(
|
|
141
|
-
currentDf, col, 't-SNE', 'Levenshtein', 100, view, `${options['activityColumnChoice']}Scaled`);
|
|
142
|
-
const psNode = view.dockManager.dock(
|
|
143
|
-
peptideSpaceViewer, DG.DOCK_TYPE.LEFT, sarNode, 'Peptide Space Viewer', 0.3);
|
|
144
|
-
|
|
145
|
-
nodeList.push(sarNode);
|
|
146
|
-
nodeList.push(sarVNode);
|
|
147
|
-
nodeList.push(psNode);
|
|
148
|
-
|
|
149
|
-
$(switchViewers).removeClass('fa-toggle-off');
|
|
150
|
-
$(switchViewers).addClass('fa-toggle-on');
|
|
151
|
-
} else {
|
|
152
|
-
const substViewer = view.addViewer(
|
|
153
|
-
'substitution-analysis-viewer', {'activityColumnName': options['activityColumnName']},
|
|
154
|
-
);
|
|
155
|
-
nodeList.push(view.dockManager.dock(substViewer, DG.DOCK_TYPE.RIGHT, null, 'Substitution Analysis'));
|
|
156
|
-
$(switchViewers).removeClass('fa-toggle-on');
|
|
157
|
-
$(switchViewers).addClass('fa-toggle-off');
|
|
158
|
-
}
|
|
248
|
+
const switchViewers = ui.iconFA('toggle-on', () => {
|
|
249
|
+
$(switchViewers).toggleClass('fa-toggle-off').toggleClass('fa-toggle-on');
|
|
250
|
+
nodeList?.forEach((node) => {
|
|
251
|
+
view.dockManager.close(node);
|
|
252
|
+
node.container.destroy();
|
|
253
|
+
});
|
|
254
|
+
const getCurrentViewerGroup = () => isSA ? substViewersGroup : sarViewersGroup;
|
|
255
|
+
getCurrentViewerGroup().forEach((v) => v.removeFromView());
|
|
159
256
|
isSA = !isSA;
|
|
160
|
-
|
|
257
|
+
nodeList = dockViewers(getCurrentViewerGroup(), DG.DOCK_TYPE.LEFT, dockManager, DG.DOCK_TYPE.DOWN);
|
|
258
|
+
}, 'Toggle viewer group');
|
|
161
259
|
|
|
162
260
|
const ribbonPanels = view.getRibbonPanels();
|
|
163
261
|
view.setRibbonPanels([[hideIcon, switchViewers]]);
|
|
164
|
-
// view.setRibbonPanels([[hideIcon]]);
|
|
165
262
|
}
|
|
166
263
|
}
|
|
264
|
+
|
|
265
|
+
function dockViewers(
|
|
266
|
+
viewerList: viewerTypes[], attachDirection: DG.DockType, dockManager: DG.DockManager,
|
|
267
|
+
initialAttachDirection?: DG.DockType): DG.DockNode[] | null {
|
|
268
|
+
const viewerListLength = viewerList.length;
|
|
269
|
+
if (viewerListLength === 0)
|
|
270
|
+
return null;
|
|
271
|
+
|
|
272
|
+
let currentViewer = viewerList[0];
|
|
273
|
+
const nodeList = [dockManager.dock(currentViewer, initialAttachDirection, null, currentViewer.name ?? '')];
|
|
274
|
+
const ratio = 1 / viewerListLength;
|
|
275
|
+
|
|
276
|
+
for (let i = 1; i < viewerListLength; i++) {
|
|
277
|
+
currentViewer = viewerList[i];
|
|
278
|
+
nodeList.push(dockManager.dock(currentViewer, attachDirection, nodeList[i - 1], currentViewer.name ?? '', ratio));
|
|
279
|
+
}
|
|
280
|
+
return nodeList;
|
|
281
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {category, test} from '@datagrok-libraries/utils/src/test';
|
|
2
|
+
import {
|
|
3
|
+
_testMSAIsCorrect,
|
|
4
|
+
_testTableIsNotEmpty,
|
|
5
|
+
} from './utils';
|
|
6
|
+
import {aligned1} from './test-data';
|
|
7
|
+
|
|
8
|
+
import * as DG from 'datagrok-api/dg';
|
|
9
|
+
//import * as grok from 'datagrok-api/grok';
|
|
10
|
+
|
|
11
|
+
export const _package = new DG.Package();
|
|
12
|
+
|
|
13
|
+
let table: DG.DataFrame;
|
|
14
|
+
|
|
15
|
+
category('peptides', async () => {
|
|
16
|
+
//table = await grok.data.files.openTable('Demo:Files/bio/peptides.csv');
|
|
17
|
+
table = DG.DataFrame.fromCsv(aligned1);
|
|
18
|
+
const alignedSequencesColumn = table.getCol('AlignedSequence');
|
|
19
|
+
|
|
20
|
+
test('MSA.test_table.is_not_empty', async () => {
|
|
21
|
+
_testTableIsNotEmpty(table);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('MSA.is_correct', async () => {
|
|
25
|
+
_testMSAIsCorrect(alignedSequencesColumn);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -1,21 +1,53 @@
|
|
|
1
|
-
import {category, test} from '@datagrok-libraries/utils/src/test';
|
|
1
|
+
import {/*before, after, */category, test} from '@datagrok-libraries/utils/src/test';
|
|
2
2
|
import {
|
|
3
3
|
_testViewerIsDrawing,
|
|
4
4
|
_testDimensionalityReducer,
|
|
5
5
|
_testPeptideSimilaritySpaceViewer,
|
|
6
|
+
_testTableIsNotEmpty,
|
|
6
7
|
} from './utils';
|
|
7
8
|
import {DimensionalityReducer} from '@datagrok-libraries/ml/src/reduce-dimensionality';
|
|
8
9
|
import {cleanAlignedSequencesColumn} from '../utils/peptide-similarity-space';
|
|
10
|
+
import {aligned1} from './test-data';
|
|
9
11
|
|
|
10
12
|
import * as DG from 'datagrok-api/dg';
|
|
11
13
|
import * as grok from 'datagrok-api/grok';
|
|
14
|
+
import {StringMetrics} from '@datagrok-libraries/ml/src/typed-metrics';
|
|
12
15
|
|
|
16
|
+
export const _package = new DG.Package();
|
|
17
|
+
|
|
18
|
+
let table: DG.DataFrame;
|
|
19
|
+
let view: DG.TableView;
|
|
20
|
+
|
|
21
|
+
//const table = await grok.data.loadTable(`${_package.webRoot}files/aligned.csv`);
|
|
22
|
+
//'/home/www/data/dev/packages/data/peptides/aligned.csv');
|
|
23
|
+
//console.log(table);
|
|
24
|
+
//const table = await grok.data.files.openTable('Demo:Files/bio/peptides.csv');
|
|
13
25
|
|
|
14
26
|
category('peptides', async () => {
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
/*before(async () => {
|
|
28
|
+
console.log(['before']);
|
|
29
|
+
// const text = await _package.files.readAsText('aligned.csv');
|
|
30
|
+
// console.log([text]);
|
|
31
|
+
// table = DG.DataFrame.fromCsv(text);
|
|
32
|
+
|
|
33
|
+
// const path = `${_package.webRoot}files/aligned.csv`;
|
|
34
|
+
// console.log([path]);
|
|
35
|
+
// table = await grok.data.loadTable(path);
|
|
36
|
+
// console.log([table]);
|
|
37
|
+
|
|
38
|
+
table = await grok.data.files.openTable('Demo:Files/bio/peptides.csv');
|
|
39
|
+
view = grok.shell.addTableView(table);
|
|
40
|
+
});*/
|
|
17
41
|
|
|
18
|
-
|
|
42
|
+
//table = await grok.data.files.openTable('Demo:Files/bio/peptides.csv');
|
|
43
|
+
table = DG.DataFrame.fromCsv(aligned1);
|
|
44
|
+
view = grok.shell.addTableView(table);
|
|
45
|
+
|
|
46
|
+
test('peptide_space.test_table.is_not_empty', async () => {
|
|
47
|
+
_testTableIsNotEmpty(table);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('peptide_space.PeptideSimilaritySpaceWidget.is_drawing', async () => {
|
|
19
51
|
await _testViewerIsDrawing(table, view);
|
|
20
52
|
});
|
|
21
53
|
|
|
@@ -23,18 +55,23 @@ category('peptides', async () => {
|
|
|
23
55
|
const columnData = cleanAlignedSequencesColumn(alignedSequencesColumn);
|
|
24
56
|
|
|
25
57
|
for (const method of DimensionalityReducer.availableMethods) {
|
|
26
|
-
for (const measure of DimensionalityReducer.
|
|
27
|
-
test(`DimensinalityReducer.${method}.${measure}.is_numeric`, async () => {
|
|
28
|
-
await _testDimensionalityReducer(columnData, method, measure);
|
|
58
|
+
for (const measure of DimensionalityReducer.availableMetricsByType('String')) {
|
|
59
|
+
test(`peptide_space.DimensinalityReducer.${method}.${measure}.is_numeric`, async () => {
|
|
60
|
+
await _testDimensionalityReducer(columnData, method as StringMetrics, measure);
|
|
29
61
|
});
|
|
30
62
|
}
|
|
31
63
|
}
|
|
32
64
|
|
|
33
65
|
for (const method of DimensionalityReducer.availableMethods) {
|
|
34
|
-
for (const measure of DimensionalityReducer.
|
|
35
|
-
test(`
|
|
66
|
+
for (const measure of DimensionalityReducer.availableMetricsByType('String')) {
|
|
67
|
+
test(`peptide_space.PeptideSimilaritySpaceViewer.${method}.${measure}.is_proper`, async () => {
|
|
36
68
|
await _testPeptideSimilaritySpaceViewer(table, alignedSequencesColumn, method, measure, 100);//, view);
|
|
37
69
|
});
|
|
38
70
|
}
|
|
39
71
|
}
|
|
72
|
+
|
|
73
|
+
/*after(async () => {
|
|
74
|
+
view.close();
|
|
75
|
+
grok.shell.closeTable(table!);
|
|
76
|
+
});*/
|
|
40
77
|
});
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import {after, before, category,
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import {after, before, category, test} from '@datagrok-libraries/utils/src/test';
|
|
2
|
+
import {StringDictionary} from '@datagrok-libraries/utils/src/type-declarations';
|
|
3
|
+
// import {splitAlignedPeptides} from '../utils/split-aligned';
|
|
4
|
+
import * as DG from 'datagrok-api/dg';
|
|
5
|
+
import * as grok from 'datagrok-api/grok';
|
|
6
|
+
import {PeptidesController} from '../peptides';
|
|
7
|
+
import {describe} from '../describe';
|
|
8
|
+
import {analyzePeptidesWidget} from '../widgets/analyze-peptides';
|
|
9
|
+
import {manualAlignmentWidget} from '../widgets/manual-alignment';
|
|
10
|
+
import {peptideMoleculeWidget} from '../widgets/peptide-molecule';
|
|
11
|
+
import * as P from '../package';
|
|
12
|
+
|
|
13
|
+
// let _package = new DG.Package();
|
|
13
14
|
|
|
14
15
|
category('peptides', async () => {
|
|
15
16
|
let peptidesDf: DG.DataFrame;
|
|
16
|
-
let options:
|
|
17
|
+
let options: StringDictionary;
|
|
17
18
|
let peptidesGrid: DG.Grid;
|
|
18
19
|
let asCol: DG.Column;
|
|
19
20
|
let pepView: DG.TableView;
|
|
20
21
|
|
|
21
22
|
before(async () => {
|
|
22
|
-
// peptidesDf = DG.DataFrame.fromCsv(await _package.files.readAsText('aligned.csv'));
|
|
23
|
+
// peptidesDf = DG.DataFrame.fromCsv(await P._package.files.readAsText('aligned.csv'));
|
|
23
24
|
const csv = `ID,AlignedSequence,IC50
|
|
24
25
|
1,NH2--A-Q-T-T-Y-K-N-Y-R-R-N-L-L--COOH,4.6411368455908086e-4
|
|
25
26
|
2,NH2-M-A-N-T-T-Y-K-N-Y-R-N-N-L-L--COOH,0.003327324930165897
|
|
@@ -45,24 +46,28 @@ category('peptides', async () => {
|
|
|
45
46
|
'activityColumnName': 'IC50',
|
|
46
47
|
'scaling': '-lg',
|
|
47
48
|
};
|
|
48
|
-
peptidesGrid = peptidesDf.plot.grid();
|
|
49
49
|
asCol = peptidesDf.getCol('AlignedSequence');
|
|
50
50
|
pepView = grok.shell.addTableView(peptidesDf);
|
|
51
|
+
peptidesGrid = pepView.grid;
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
test('utils.split-sequence', async () => {
|
|
54
|
-
splitAlignedPeptides(peptidesDf.getCol('AlignedSequence'));
|
|
55
|
+
PeptidesController.splitAlignedPeptides(peptidesDf.getCol('AlignedSequence'));
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
test('describe', async () => {
|
|
58
59
|
await describe(
|
|
59
|
-
peptidesDf, options['activityColumnName'], options['scaling'],
|
|
60
|
+
peptidesDf, options['activityColumnName'], options['scaling'], peptidesGrid, true,
|
|
60
61
|
DG.BitSet.create(peptidesDf.rowCount, (i) => i % 2 === 0), true);
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
test('Peptides-
|
|
64
|
-
const peptides =
|
|
65
|
-
peptides.init(peptidesGrid, pepView,
|
|
64
|
+
test('Peptides-controller', async () => {
|
|
65
|
+
const peptides = PeptidesController.getInstance(peptidesDf);
|
|
66
|
+
peptides.init(peptidesGrid, pepView, options, asCol, peptidesDf.columns.names());
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('panel.peptides', async () => {
|
|
70
|
+
await P.peptidesPanel(asCol);
|
|
66
71
|
});
|
|
67
72
|
|
|
68
73
|
test('widgets.analyze-peptides', async () => {
|
|
@@ -77,8 +82,40 @@ category('peptides', async () => {
|
|
|
77
82
|
await peptideMoleculeWidget('NH2--A-N-T-T-Y-K-N-Y-R-S-N-L-L--COOH');
|
|
78
83
|
});
|
|
79
84
|
|
|
85
|
+
test('widgets.molfile', async () => {
|
|
86
|
+
await P.peptideMolfile2('');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('renderers.aligned-sequence-cell', async () => {
|
|
90
|
+
P.alignedSequenceCellRenderer();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('renderers.amino-acids-cell', async () => {
|
|
94
|
+
P.aminoAcidsCellRenderer();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('viewers.logo-viewer', async () => {
|
|
98
|
+
P.logov();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test('viewers.sar-viewer', async () => {
|
|
102
|
+
P.sar();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('viewers.sar-vertical-viewer', async () => {
|
|
106
|
+
P.sarVertical();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('viewers.stacked-barchart-viewer', async () => {
|
|
110
|
+
P.stackedBarChart();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('viewers.subst-viewer', async () => {
|
|
114
|
+
P.subst();
|
|
115
|
+
});
|
|
116
|
+
|
|
80
117
|
after(async () => {
|
|
81
118
|
pepView.close();
|
|
82
119
|
grok.shell.closeTable(peptidesDf);
|
|
83
|
-
})
|
|
120
|
+
});
|
|
84
121
|
});
|