@datagrok/peptides 1.3.3 → 1.3.5

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.
@@ -26,32 +26,18 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
26
26
  if (funcs.length == 0)
27
27
  return new DG.Widget(ui.label('Helm package is missing or out of date. Please install the latest version.'));
28
28
 
29
- let tempCol = null;
30
- let scaledDf: DG.DataFrame;
31
- let newScaledColName: string;
32
- let scalingFormula: (x: number) => number;
29
+ let scaledCol: DG.Column<number>;
33
30
 
34
- for (const column of df.columns.numerical)
35
- tempCol = column.type === DG.TYPE.FLOAT ? column : null;
36
-
37
- const defaultActivityColumn: DG.Column<number> | null = df.col('activity') || df.col('IC50') || tempCol;
31
+ const defaultActivityColumn: DG.Column<number> | null =
32
+ df.col('activity') || df.col('IC50') || DG.Utils.firstOrNull(df.columns.numerical);;
38
33
  const histogramHost = ui.div([], {id: 'pep-hist-host'});
39
34
 
40
- const indexes: number[] = [];
41
- const f = df.filter;
42
- df.onFilterChanged.subscribe(() => {
43
- for (let i = 0; i < f.length; ++i) {
44
- if (f.get(i))
45
- indexes.push(i);
46
- }
47
- });
48
35
  const activityScalingMethod = ui.choiceInput(
49
36
  'Scaling', 'none', ['none', 'lg', '-lg'],
50
37
  async (currentMethod: string): Promise<void> => {
51
- [scaledDf, scalingFormula, newScaledColName] =
52
- scaleActivity(currentMethod, activityColumnChoice.value!, indexes.length !== 0 ? indexes : undefined);
38
+ scaledCol = scaleActivity(currentMethod, activityColumnChoice.value!);
53
39
 
54
- const hist = scaledDf.plot.histogram({
40
+ const hist = DG.DataFrame.fromColumns([scaledCol]).plot.histogram({
55
41
  filteringEnabled: false,
56
42
  valueColumnName: C.COLUMNS_NAMES.ACTIVITY_SCALED,
57
43
  legendVisibility: 'Never',
@@ -65,9 +51,9 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
65
51
  });
66
52
  activityScalingMethod.setTooltip('Function to apply for each value in activity column');
67
53
 
68
- const activityScalingMethodState = (_: any): void => {
54
+ const activityScalingMethodState = (): void => {
69
55
  activityScalingMethod.enabled = (activityColumnChoice.value ?? false) &&
70
- DG.Stats.fromColumn(activityColumnChoice.value!, df.filter).min > 0;
56
+ DG.Stats.fromColumn(activityColumnChoice.value!).min > 0;
71
57
  activityScalingMethod.fireChanged();
72
58
  };
73
59
  const activityColumnChoice = ui.columnInput('Activity', df, defaultActivityColumn, activityScalingMethodState);
@@ -77,13 +63,18 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
77
63
 
78
64
  const inputsList = [activityColumnChoice, activityScalingMethod, clustersColumnChoice];
79
65
 
66
+ const bitsetChanged = df.filter.onChanged.subscribe(() => {
67
+ activityScalingMethodState();
68
+ })
69
+
80
70
  const startBtn = ui.button('Launch SAR', async () => {
81
- await startAnalysis(activityColumnChoice.value, col, clustersColumnChoice.value, df, scalingFormula,
82
- newScaledColName, activityScalingMethod.value ?? 'none', indexes);
71
+ await startAnalysis(activityColumnChoice.value!, col, clustersColumnChoice.value, df, scaledCol,
72
+ activityScalingMethod.value ?? 'none');
73
+ bitsetChanged.unsubscribe();
83
74
  });
84
75
  startBtn.style.alignSelf = 'center';
85
76
 
86
- const viewer = await df.plot.fromType('WebLogo') as bio.WebLogo;
77
+ const viewer = await df.plot.fromType('WebLogo') as bio.WebLogoViewer;
87
78
  viewer.root.style.setProperty('height', '130px');
88
79
  const logoHost = ui.div();
89
80
  $(logoHost).empty().append(viewer.root);
@@ -99,43 +90,30 @@ export async function analyzePeptidesWidget(df: DG.DataFrame, col: DG.Column): P
99
90
  );
100
91
  }
101
92
 
102
- export async function startAnalysis(activityColumn: DG.Column<number> | null, peptidesCol: DG.Column<string>,
103
- clustersColumn: DG.Column | null, currentDf: DG.DataFrame, scaleNum: (x: number) => number, newScaledColName: string,
104
- scaling: string, indexes: number[]): Promise<PeptidesModel | null> {
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> {
105
96
  const progress = DG.TaskBarProgressIndicator.create('Loading SAR...');
106
97
  let model = null;
107
- if (activityColumn?.type === DG.TYPE.FLOAT) {
108
- const f = currentDf.filter;
98
+ if (activityColumn.type === DG.TYPE.FLOAT || activityColumn.type === DG.TYPE.INT) {
109
99
  //prepare new DF
110
- const newDf = DG.DataFrame.create(f.trueCount);
111
- const getIndex = indexes.length !== 0 ? (i: number): number => indexes[i] : (i: number): number => i;
112
- let activityCol: DG.Column<number> | null = null;
100
+ const newDf = DG.DataFrame.create(currentDf.rowCount);
101
+ const newDfCols = newDf.columns;
113
102
  for (const col of currentDf.columns.toList()) {
114
- let virtualCol: DG.Column<any>;
115
- if (col === activityColumn) {
116
- virtualCol = newDf.columns.addNewVirtual(
117
- C.COLUMNS_NAMES.ACTIVITY, (i) => activityColumn.get(getIndex(i)!), DG.TYPE.FLOAT);
118
- activityCol = virtualCol;
119
- } else if (col === peptidesCol) {
120
- virtualCol = newDf.columns.addNewVirtual(
121
- C.COLUMNS_NAMES.MACROMOLECULE, (i) => peptidesCol.get(getIndex(i)!), DG.TYPE.STRING);
122
- } else
123
- virtualCol = newDf.columns.addNewVirtual(col.name, (i) => col.get(getIndex(i)!), col.type as DG.TYPE);
124
- 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');
125
109
  }
126
- activityCol!.semType = C.SEM_TYPES.ACTIVITY;
127
- const activityScaledCol = newDf.columns.addNewVirtual(C.COLUMNS_NAMES.ACTIVITY_SCALED, (i) => {
128
- const val = activityCol!.get(getIndex(i)!);
129
- return val ? scaleNum(val) : val;
130
- }, DG.TYPE.FLOAT);
131
- activityScaledCol.semType = C.SEM_TYPES.ACTIVITY_SCALED;
110
+ activityColumn.semType = C.SEM_TYPES.ACTIVITY;
111
+ newDfCols.add(scaledCol);
132
112
  newDf.name = 'Peptides analysis';
133
- newDf.tags[C.COLUMNS_NAMES.ACTIVITY_SCALED] = newScaledColName;
134
113
  if (clustersColumn) {
135
114
  newDf.getCol(clustersColumn.name).name = C.COLUMNS_NAMES.CLUSTERS;
136
115
  newDf.tags[C.TAGS.CLUSTERS] = C.COLUMNS_NAMES.CLUSTERS;
137
116
  }
138
- // newDf.tags[C.PEPTIDES_ANALYSIS] = 'true';
139
117
  newDf.tags['scaling'] = scaling;
140
118
 
141
119
  let monomerType = 'HELM_AA';
@@ -148,10 +126,9 @@ export async function startAnalysis(activityColumn: DG.Column<number> | null, pe
148
126
  }
149
127
 
150
128
  newDf.setTag('monomerType', monomerType);
151
-
152
129
  model = await PeptidesModel.getInstance(newDf);
153
130
  } else
154
- grok.shell.error('The activity column must be of floating point number type!');
131
+ grok.shell.error('The activity column must be of numeric type!');
155
132
  progress.close();
156
133
  return model;
157
134
  }
@@ -1,276 +0,0 @@
1
- <html><head><meta charset="utf-8"/><title>Peptides Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit 44350c85.</title><style type="text/css">html,
2
- body {
3
- font-family: Arial, Helvetica, sans-serif;
4
- font-size: 1rem;
5
- margin: 0;
6
- padding: 0;
7
- color: #333;
8
- }
9
- body {
10
- padding: 2rem 1rem;
11
- font-size: 0.85rem;
12
- }
13
- #jesthtml-content {
14
- margin: 0 auto;
15
- max-width: 70rem;
16
- }
17
- header {
18
- display: flex;
19
- align-items: center;
20
- }
21
- #title {
22
- margin: 0;
23
- flex-grow: 1;
24
- }
25
- #logo {
26
- height: 4rem;
27
- }
28
- #timestamp {
29
- color: #777;
30
- margin-top: 0.5rem;
31
- }
32
-
33
- /** SUMMARY */
34
- #summary {
35
- color: #333;
36
- margin: 2rem 0;
37
- display: flex;
38
- font-family: monospace;
39
- font-size: 1rem;
40
- }
41
- #summary > div {
42
- margin-right: 2rem;
43
- background: #eee;
44
- padding: 1rem;
45
- min-width: 15rem;
46
- }
47
- #summary > div:last-child {
48
- margin-right: 0;
49
- }
50
- @media only screen and (max-width: 720px) {
51
- #summary {
52
- flex-direction: column;
53
- }
54
- #summary > div {
55
- margin-right: 0;
56
- margin-top: 2rem;
57
- }
58
- #summary > div:first-child {
59
- margin-top: 0;
60
- }
61
- }
62
-
63
- .summary-total {
64
- font-weight: bold;
65
- margin-bottom: 0.5rem;
66
- }
67
- .summary-passed {
68
- color: #4f8a10;
69
- border-left: 0.4rem solid #4f8a10;
70
- padding-left: 0.5rem;
71
- }
72
- .summary-failed,
73
- .summary-obsolete-snapshots {
74
- color: #d8000c;
75
- border-left: 0.4rem solid #d8000c;
76
- padding-left: 0.5rem;
77
- }
78
- .summary-pending {
79
- color: #9f6000;
80
- border-left: 0.4rem solid #9f6000;
81
- padding-left: 0.5rem;
82
- }
83
- .summary-empty {
84
- color: #999;
85
- border-left: 0.4rem solid #999;
86
- }
87
-
88
- .test-result {
89
- padding: 1rem;
90
- margin-bottom: 0.25rem;
91
- }
92
- .test-result:last-child {
93
- border: 0;
94
- }
95
- .test-result.passed {
96
- background-color: #dff2bf;
97
- color: #4f8a10;
98
- }
99
- .test-result.failed {
100
- background-color: #ffbaba;
101
- color: #d8000c;
102
- }
103
- .test-result.pending {
104
- background-color: #ffdf61;
105
- color: #9f6000;
106
- }
107
-
108
- .test-info {
109
- display: flex;
110
- justify-content: space-between;
111
- }
112
- .test-suitename {
113
- width: 20%;
114
- text-align: left;
115
- font-weight: bold;
116
- word-break: break-word;
117
- }
118
- .test-title {
119
- width: 40%;
120
- text-align: left;
121
- font-style: italic;
122
- }
123
- .test-status {
124
- width: 20%;
125
- text-align: right;
126
- }
127
- .test-duration {
128
- width: 10%;
129
- text-align: right;
130
- font-size: 0.75rem;
131
- }
132
-
133
- .failureMessages {
134
- padding: 0 1rem;
135
- margin-top: 1rem;
136
- border-top: 1px dashed #d8000c;
137
- }
138
- .failureMessages.suiteFailure {
139
- border-top: none;
140
- }
141
- .failureMsg {
142
- white-space: pre-wrap;
143
- white-space: -moz-pre-wrap;
144
- white-space: -pre-wrap;
145
- white-space: -o-pre-wrap;
146
- word-wrap: break-word;
147
- }
148
-
149
- .suite-container {
150
- margin-bottom: 2rem;
151
- }
152
- .suite-info {
153
- padding: 1rem;
154
- background-color: #eee;
155
- color: #777;
156
- display: flex;
157
- align-items: center;
158
- margin-bottom: 0.25rem;
159
- }
160
- .suite-info .suite-path {
161
- word-break: break-all;
162
- flex-grow: 1;
163
- font-family: monospace;
164
- font-size: 1rem;
165
- }
166
- .suite-info .suite-time {
167
- margin-left: 0.5rem;
168
- padding: 0.2rem 0.3rem;
169
- font-size: 0.75rem;
170
- }
171
- .suite-info .suite-time.warn {
172
- background-color: #d8000c;
173
- color: #fff;
174
- }
175
-
176
- /* CONSOLE LOGS */
177
- .suite-consolelog {
178
- margin-bottom: 0.25rem;
179
- padding: 1rem;
180
- background-color: #efefef;
181
- }
182
- .suite-consolelog-header {
183
- font-weight: bold;
184
- }
185
- .suite-consolelog-item {
186
- padding: 0.5rem;
187
- }
188
- .suite-consolelog-item pre {
189
- margin: 0.5rem 0;
190
- white-space: pre-wrap;
191
- white-space: -moz-pre-wrap;
192
- white-space: -pre-wrap;
193
- white-space: -o-pre-wrap;
194
- word-wrap: break-word;
195
- }
196
- .suite-consolelog-item-origin {
197
- color: #777;
198
- font-weight: bold;
199
- }
200
- .suite-consolelog-item-message {
201
- color: #000;
202
- font-size: 1rem;
203
- padding: 0 0.5rem;
204
- }
205
-
206
- /* OBSOLETE SNAPSHOTS */
207
- .suite-obsolete-snapshots {
208
- margin-bottom: 0.25rem;
209
- padding: 1rem;
210
- background-color: #ffbaba;
211
- color: #d8000c;
212
- }
213
- .suite-obsolete-snapshots-header {
214
- font-weight: bold;
215
- }
216
- .suite-obsolete-snapshots-item {
217
- padding: 0.5rem;
218
- }
219
- .suite-obsolete-snapshots-item pre {
220
- margin: 0.5rem 0;
221
- white-space: pre-wrap;
222
- white-space: -moz-pre-wrap;
223
- white-space: -pre-wrap;
224
- white-space: -o-pre-wrap;
225
- word-wrap: break-word;
226
- }
227
- .suite-obsolete-snapshots-item-message {
228
- color: #000;
229
- font-size: 1rem;
230
- padding: 0 0.5rem;
231
- }
232
- </style></head><body><div id="jesthtml-content"><header><h1 id="title">Peptides Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit 44350c85.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-10-14 10:11:35</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.64s</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">76.108s</div></div><div class="failureMessages"> <pre class="failureMsg">Error: Test result : Failed : 610 : Peptides.Core.Start analysis: simple : Unable to get project asset "getMonomerLib"
233
- Test result : Failed : 372 : Peptides.Core.Start analysis: сomplex : Unable to get project asset "getMonomerLib"
234
- Test result : Failed : 382 : Peptides.Core.Save and load project : Unable to get project asset "getMonomerLib"
235
-
236
- at /home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:68:20
237
- at Generator.next (&lt;anonymous&gt;)
238
- at fulfilled (/home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:31:58)
239
- at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre></div></div></div><div class="suite-consolelog"><div class="suite-consolelog-header">Console Log</div><div class="suite-consolelog-item"><pre class="suite-consolelog-item-origin"> at Object.&lt;anonymous&gt; (/home/runner/work/public/public/packages/Peptides/src/__jest__/test-node.ts:62:11)
240
- at Generator.next (&lt;anonymous&gt;)
241
- at fulfilled (/home/runner/work/public/public/packages/Peptides/src/__jest__/test-node.ts:28:58)
242
- at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Using web root: http://localhost:8080</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:40:11
243
- at Generator.next (&lt;anonymous&gt;)
244
- at /home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:34:71
245
- at new Promise (&lt;anonymous&gt;)
246
- at Object.&lt;anonymous&gt;.__awaiter (/home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:30:12)
247
- at Object.&lt;anonymous&gt; (/home/runner/work/public/public/packages/Peptides/src/__jest__/remote.test.ts:38:23)
248
- at Promise.then.completed (/home/runner/work/public/public/packages/Peptides/node_modules/jest-circus/build/utils.js:391:28)
249
- at new Promise (&lt;anonymous&gt;)</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
- at Generator.next (&lt;anonymous&gt;)
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 : 0 : Peptides.Peptide space.test_table.is_not_empty : OK
253
- Test result : Success : 6368 : Peptides.Peptide space.PeptideSimilaritySpaceWidget.is_drawing : OK
254
- Test result : Success : 2 : Peptides.Peptide space.test_deminsionality_reducer : OK
255
- Test result : Success : 1 : Peptides.Peptide space.test_peptide_similarity_space_viewer : OK
256
- Test result : Success : 2945 : Peptides.Peptide space.peptide_space.DimensinalityReducer.UMAP.Levenshtein.is_numeric : OK
257
- Test result : Success : 3009 : Peptides.Peptide space.peptide_space.DimensinalityReducer.UMAP.Jaro-Winkler.is_numeric : OK
258
- Test result : Success : 3394 : Peptides.Peptide space.peptide_space.DimensinalityReducer.t-SNE.Levenshtein.is_numeric : OK
259
- Test result : Success : 3685 : Peptides.Peptide space.peptide_space.DimensinalityReducer.t-SNE.Jaro-Winkler.is_numeric : OK
260
- Test result : Success : 205 : Peptides.Peptide space.peptide_space.DimensinalityReducer.SPE.Levenshtein.is_numeric : OK
261
- Test result : Success : 629 : Peptides.Peptide space.peptide_space.DimensinalityReducer.SPE.Jaro-Winkler.is_numeric : OK
262
- Test result : Success : 174 : Peptides.Peptide space.peptide_space.DimensinalityReducer.pSPE.Levenshtein.is_numeric : OK
263
- Test result : Success : 731 : Peptides.Peptide space.peptide_space.DimensinalityReducer.pSPE.Jaro-Winkler.is_numeric : OK
264
- Test result : Success : 7686 : Peptides.Peptide space.peptide_space.DimensinalityReducer.OriginalSPE.Levenshtein.is_numeric : OK
265
- Test result : Success : 9316 : Peptides.Peptide space.peptide_space.DimensinalityReducer.OriginalSPE.Jaro-Winkler.is_numeric : OK
266
- Test result : Success : 1837 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.UMAP.Levenshtein.is_proper : OK
267
- Test result : Success : 2670 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.UMAP.Jaro-Winkler.is_proper : OK
268
- Test result : Success : 3278 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.t-SNE.Levenshtein.is_proper : OK
269
- Test result : Success : 4073 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.t-SNE.Jaro-Winkler.is_proper : OK
270
- Test result : Success : 244 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.SPE.Levenshtein.is_proper : OK
271
- Test result : Success : 666 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.SPE.Jaro-Winkler.is_proper : OK
272
- Test result : Success : 578 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.pSPE.Levenshtein.is_proper : OK
273
- Test result : Success : 612 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.pSPE.Jaro-Winkler.is_proper : OK
274
- Test result : Success : 9654 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.OriginalSPE.Levenshtein.is_proper : OK
275
- Test result : Success : 9749 : Peptides.Peptide space.peptide_space.PeptideSimilaritySpaceViewer.OriginalSPE.Jaro-Winkler.is_proper : OK
276
- </pre></div></div></div></div></body></html>