@datagrok/bio 1.8.2 → 1.9.0

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "Leonid Stolbov",
6
6
  "email": "lstolbov@datagrok.ai"
7
7
  },
8
- "version": "1.8.2",
8
+ "version": "1.9.0",
9
9
  "description": "Bio is a [package](https://datagrok.ai/help/develop/develop#packages) for the [Datagrok](https://datagrok.ai) platform",
10
10
  "repository": {
11
11
  "type": "git",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@biowasm/aioli": ">=2.4.0",
17
- "@datagrok-libraries/bio": "^3.1.0",
18
- "@datagrok-libraries/ml": "^3.1.0",
17
+ "@datagrok-libraries/bio": "^3.1.1",
18
+ "@datagrok-libraries/ml": "^4.0.0",
19
19
  "@datagrok-libraries/utils": "^1.6.2",
20
20
  "cash-dom": "latest",
21
21
  "datagrok-api": "^1.5.5",
package/src/package.ts CHANGED
@@ -15,7 +15,7 @@ import {Aminoacids} from '@datagrok-libraries/bio/src/aminoacids';
15
15
  import {getEmbeddingColsNames, sequenceSpace} from './utils/sequence-space';
16
16
  import {AvailableMetrics} from '@datagrok-libraries/ml/src/typed-metrics';
17
17
  import {getActivityCliffs} from '@datagrok-libraries/ml/src/viewers/activity-cliffs';
18
- import {sequenceGetSimilarities, drawTooltip} from './utils/sequence-activity-cliffs';
18
+ import {drawSequences, sequenceGetSimilarities} from './utils/sequence-activity-cliffs';
19
19
  import {createJsonMonomerLibFromSdf, encodeMonomers, getMolfilesFromSeq, HELM_CORE_LIB_FILENAME} from './utils/utils';
20
20
  import {getMacroMol} from './utils/atomic-works';
21
21
  import {MacromoleculeSequenceCellRenderer} from './utils/cell-renderer';
@@ -142,7 +142,7 @@ export async function activityCliffs(df: DG.DataFrame, macroMolecule: DG.Column,
142
142
  tags,
143
143
  sequenceSpace,
144
144
  sequenceGetSimilarities,
145
- drawTooltip,
145
+ drawSequences,
146
146
  (options as any)[methodName]);
147
147
  return sp;
148
148
  }
@@ -6,9 +6,9 @@ import {UnknownSeqPalette, UnknownSeqPalettes} from '@datagrok-libraries/bio/src
6
6
  import {SplitterFunc, WebLogo} from '@datagrok-libraries/bio/src/viewers/web-logo';
7
7
  import {SeqPalette} from '@datagrok-libraries/bio/src/seq-palettes';
8
8
  import * as ui from 'datagrok-api/ui';
9
+ import {printLeftOrCentered} from '@datagrok-libraries/bio/src/utils/cell-renderer';
9
10
 
10
11
  const undefinedColor = 'rgb(100,100,100)';
11
- const grayColor = '#808080';
12
12
 
13
13
  function getPalleteByType(paletteType: string): SeqPalette {
14
14
  switch (paletteType) {
@@ -44,81 +44,6 @@ export function processSequence(subParts: string[]): [string[], boolean] {
44
44
  }
45
45
 
46
46
 
47
- /**
48
- * A function that prints a string aligned to left or centered.
49
- *
50
- * @param {number} x x coordinate.
51
- * @param {number} y y coordinate.
52
- * @param {number} w Width.
53
- * @param {number} h Height.
54
- * @param {CanvasRenderingContext2D} g Canvas rendering context.
55
- * @param {string} s String to print.
56
- * @param {string} [color=undefinedColor] String color.
57
- * @param {number} [pivot=0] Pirvot.
58
- * @param {boolean} [left=false] Is left aligned.
59
- * @param {number} [transparencyRate=0.0] Transparency rate where 1.0 is fully transparent
60
- * @param {string} [separator=''] Is separator for sequence.
61
- * @param {boolean} [last=false] Is checker if element last or not.
62
- * @return {number} x coordinate to start printing at.
63
- */
64
- export function printLeftOrCentered(
65
- x: number, y: number, w: number, h: number,
66
- g: CanvasRenderingContext2D, s: string, color = undefinedColor,
67
- pivot: number = 0, left = false, transparencyRate: number = 1.0,
68
- separator: string = '', last: boolean = false, drawStyle: string = 'classic', maxWord: any = {}, maxWordIdx: number = 0, gridCell: any = {}): number {
69
- g.textAlign = 'start';
70
- const colorPart = s.substring(0);
71
- let grayPart = last ? '' : separator;
72
- if (drawStyle === 'msa') {
73
- grayPart = '';
74
- }
75
-
76
- let textSize: any = g.measureText(colorPart + grayPart);
77
- const indent = 5;
78
-
79
- let maxColorTextSize = g.measureText(colorPart).width;
80
- let colorTextSize = g.measureText(colorPart).width;
81
- const dy = (textSize.fontBoundingBoxAscent + textSize.fontBoundingBoxDescent) / 2;
82
- textSize = textSize.width;
83
- if (drawStyle === 'msa') {
84
- maxColorTextSize = maxWord[maxWordIdx];
85
- textSize = maxWord[maxWordIdx];
86
- if (maxColorTextSize > maxWord) {
87
- maxWord[maxWordIdx] = maxColorTextSize;
88
- gridCell.cell.column.temp = maxWord;
89
- }
90
- if (maxWordIdx > (maxWord['bio-maxIndex'] ?? 0)) {
91
- maxWord['bio-maxIndex'] = maxWordIdx;
92
- gridCell.cell.column.temp = maxWord;
93
- }
94
- }
95
-
96
- function draw(dx1: number, dx2: number): void {
97
- g.fillStyle = color;
98
- g.globalAlpha = transparencyRate;
99
- if (drawStyle === 'classic') {
100
- g.fillText(colorPart, x + dx1, y + dy);
101
- g.fillStyle = grayColor;
102
- g.fillText(grayPart, x + dx2, y + dy);
103
- }
104
- if (drawStyle === 'msa') {
105
- g.fillStyle = color;
106
- g.fillText(colorPart, x + dx1 + ((maxWord[maxWordIdx] - colorTextSize) / 2), y + dy);
107
- }
108
- }
109
-
110
- if (left || textSize > w) {
111
- draw(indent, indent + maxColorTextSize);
112
- return x + maxColorTextSize + g.measureText(grayPart).width;
113
-
114
- } else {
115
- const dx = (w - textSize) / 2;
116
- draw(dx, dx + maxColorTextSize);
117
- return x + dx + maxColorTextSize;
118
- }
119
- }
120
-
121
-
122
47
  export class MacromoleculeSequenceCellRenderer extends DG.GridCellRenderer {
123
48
  get name(): string { return 'sequence'; }
124
49
 
@@ -344,9 +269,8 @@ export class MacromoleculeDifferenceCellRenderer extends DG.GridCellRenderer {
344
269
  // 28 is the height of the two substitutions on top of each other + space
345
270
  const updatedY = Math.max(y, y + (h - 28) / 2);
346
271
 
347
- let palette: SeqPalette = UnknownSeqPalettes.Color;
348
- if (units != 'HELM')
349
- palette = getPalleteByType(units.substring(units.length - 2));
272
+ let palette: SeqPalette = units == 'HELM' ? UnknownSeqPalettes.Color :
273
+ getPalleteByType(gridCell.tableColumn!.tags[C.TAGS.ALPHABET]);
350
274
 
351
275
  const vShift = 7;
352
276
  for (let i = 0; i < subParts1.length; i++) {
@@ -1,4 +1,4 @@
1
- import {IDrawTooltipParams} from '@datagrok-libraries/ml/src/viewers/activity-cliffs';
1
+ import {ITooltipAndPanelParams} from '@datagrok-libraries/ml/src/viewers/activity-cliffs';
2
2
  import * as DG from 'datagrok-api/dg';
3
3
  import * as ui from 'datagrok-api/ui';
4
4
  import {getSimilarityFromDistance} from '@datagrok-libraries/utils/src/similarity-metrics';
@@ -12,25 +12,9 @@ export async function sequenceGetSimilarities(col: DG.Column, seq: string): Prom
12
12
  return DG.Column.fromList(DG.COLUMN_TYPE.FLOAT, 'distances', distances);
13
13
  }
14
14
 
15
- export function drawTooltip(params: IDrawTooltipParams) {
16
- params.tooltips[params.line.id] = ui.divH([]);
17
- const columnNames = ui.divV([
18
- ui.divText('sequense'),
19
- ui.divText(params.activity.name),
20
- ]);
21
- columnNames.style.fontWeight = 'bold';
22
- columnNames.style.display = 'flex';
23
- columnNames.style.justifyContent = 'space-between';
24
- params.tooltips[params.line.id].append(columnNames);
25
- params.line.mols.forEach((mol: number) => {
26
- const seq = ui.divText(params.df.get(params.seqCol.name, mol));
27
- const activity = ui.divText(params.df.get(params.activity.name, mol).toFixed(2));
28
- activity.style.display = 'flex';
29
- activity.style.justifyContent = 'left';
30
- activity.style.paddingLeft = '30px';
31
- params.tooltips[params.line.id].append(ui.divV([
32
- seq,
33
- activity,
34
- ], {style: {paddingLeft: '5px'}}));
15
+ export function drawSequences(params: ITooltipAndPanelParams) {
16
+ params.line.mols.forEach((mol: number, index: number) => {
17
+ ui.empty(params.hosts[index]);
18
+ params.hosts[index].append(ui.divText(params.seqCol.get(mol)));
35
19
  });
36
20
  }
@@ -0,0 +1,245 @@
1
+ <html><head><meta charset="utf-8"/><title>Bio Test Report. Datagrok version datagrok/datagrok:latest SHA=d4ef1f35c295. Commit 90ae719f.</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">Bio Test Report. Datagrok version datagrok/datagrok:latest SHA=d4ef1f35c295. Commit 90ae719f.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-08-29 04:53:14</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/Bio/src/__jest__/remote.test.ts</div><div class="suite-time warn">1813.741s</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">0.001s</div></div><div class="failureMessages"> <pre class="failureMsg">TimeoutError: waiting for selector `.grok-preloader` failed: timeout 1800000ms exceeded
233
+ at new WaitTask (/home/runner/work/public/public/packages/Bio/node_modules/puppeteer/src/common/DOMWorld.ts:813:28)
234
+ at DOMWorld.waitForSelectorInPage (/home/runner/work/public/public/packages/Bio/node_modules/puppeteer/src/common/DOMWorld.ts:656:22)
235
+ at Object.internalHandler.waitFor (/home/runner/work/public/public/packages/Bio/node_modules/puppeteer/src/common/QueryHandler.ts:78:19)
236
+ at DOMWorld.waitForSelector (/home/runner/work/public/public/packages/Bio/node_modules/puppeteer/src/common/DOMWorld.ts:511:25)
237
+ at Frame.waitForSelector (/home/runner/work/public/public/packages/Bio/node_modules/puppeteer/src/common/FrameManager.ts:1290:47)
238
+ at Page.waitForSelector (/home/runner/work/public/public/packages/Bio/node_modules/puppeteer/src/common/Page.ts:3222:29)
239
+ at Object.&lt;anonymous&gt; (/home/runner/work/public/public/packages/Bio/src/__jest__/test-node.ts:79:16)
240
+ at Generator.next (&lt;anonymous&gt;)
241
+ at fulfilled (/home/runner/work/public/public/packages/Bio/src/__jest__/test-node.ts:28:58)
242
+ 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/Bio/src/__jest__/test-node.ts:63:11)
243
+ at Generator.next (&lt;anonymous&gt;)
244
+ at fulfilled (/home/runner/work/public/public/packages/Bio/src/__jest__/test-node.ts:28:58)
245
+ 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></div></div></body></html>