@datagrok/helm 2.0.4 → 2.0.6

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
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@datagrok/helm",
3
3
  "friendlyName": "Helm",
4
- "version": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "author": {
6
6
  "name": "Oleksandra Serhiienko",
7
7
  "email": "oserhiienko@datagrok.ai"
8
8
  },
9
9
  "description": "",
10
10
  "dependencies": {
11
- "datagrok-api": "^1.6.0",
11
+ "@datagrok-libraries/utils": "^1.11.1",
12
+ "@datagrok-libraries/bio": "^5.5.0",
12
13
  "cash-dom": "^8.1.1",
14
+ "datagrok-api": "^1.7.2",
13
15
  "dayjs": "^1.10.6",
14
- "@datagrok-libraries/utils": "^1.6.2",
15
- "@datagrok-libraries/bio": "^5.1.0"
16
+ "rxjs": "^6.5.5"
16
17
  },
17
18
  "sources": [
18
19
  "css/helm.css",
@@ -0,0 +1,45 @@
1
+ import * as grok from 'datagrok-api/grok';
2
+ import * as ui from 'datagrok-api/ui';
3
+ import * as DG from 'datagrok-api/dg';
4
+
5
+ export class HelmWebEditor {
6
+ editorView: any;
7
+ webEditor: any;
8
+ host: any;
9
+ editor: any;
10
+ w = 200;
11
+ h = 100;
12
+ constructor() {
13
+ this.editorView = ui.div();
14
+ org.helm.webeditor.MolViewer.molscale = 0.8;
15
+ this.webEditor = new scil.helm.App(this.editorView, {
16
+ showabout: false,
17
+ mexfontsize: '90%',
18
+ mexrnapinontab: true,
19
+ topmargin: 20,
20
+ mexmonomerstab: true,
21
+ sequenceviewonly: false,
22
+ mexfavoritefirst: true,
23
+ mexfilter: true
24
+ });
25
+ const sizes = this.webEditor.calculateSizes();
26
+ this.webEditor.canvas.resize(sizes.rightwidth - 100, sizes.topheight - 210);
27
+ let s = {width: sizes.rightwidth - 100 + 'px', height: sizes.bottomheight + 'px'};
28
+ //@ts-ignore
29
+ scil.apply(this.webEditor.sequence.style, s);
30
+ //@ts-ignore
31
+ scil.apply(this.webEditor.notation.style, s);
32
+ s = {width: sizes.rightwidth + 'px', height: (sizes.bottomheight + this.webEditor.toolbarheight) + 'px'};
33
+ //@ts-ignore
34
+ scil.apply(this.webEditor.properties.parent.style, s);
35
+ this.webEditor.structureview.resize(sizes.rightwidth, sizes.bottomheight + this.webEditor.toolbarheight);
36
+ this.webEditor.mex.resize(sizes.topheight - 80);
37
+ this.host = ui.div([], {style: {width: `${this.w}px`, height: `${this.h}px`}});
38
+ this.editor = new JSDraw2.Editor(this.host, {width: this.w, height: this.h, viewonly: true});
39
+ }
40
+
41
+ resizeEditor(w: number, h: number) {
42
+ this.editor.setSize(w, h);
43
+ }
44
+ }
45
+
@@ -1,6 +1,6 @@
1
1
  import * as DG from 'datagrok-api/dg';
2
2
  import * as grok from 'datagrok-api/grok';
3
- import {runTests, tests} from '@datagrok-libraries/utils/src/test';
3
+ import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test';
4
4
  import './tests/helm-tests.ts';
5
5
 
6
6
  export const _package = new DG.Package();
@@ -10,8 +10,9 @@ export {tests};
10
10
  //name: test
11
11
  //input: string category {optional: true}
12
12
  //input: string test {optional: true}
13
+ //input: object testContext {optional: true}
13
14
  //output: dataframe result
14
- export async function test(category: string, test: string): Promise<DG.DataFrame> {
15
- const data = await runTests({category, test});
15
+ export async function test(category: string, test: string, testContext: TestContext): Promise<DG.DataFrame> {
16
+ const data = await runTests({category, test, testContext});
16
17
  return DG.DataFrame.fromObjects(data)!;
17
18
  }
package/src/package.ts CHANGED
@@ -6,14 +6,14 @@ import * as bio from '@datagrok-libraries/bio';
6
6
 
7
7
  import {createJsonMonomerLibFromSdf} from './utils';
8
8
  import {MONOMER_MANAGER_MAP, RGROUPS, RGROUP_CAP_GROUP_NAME, RGROUP_LABEL, SMILES} from './constants';
9
- import {delay} from '@datagrok-libraries/utils/src/test';
9
+ import {HelmWebEditor} from './helm-web-editor';
10
+ import {Observable, Subject} from 'rxjs';
10
11
 
11
12
  export const _package = new DG.Package();
12
13
 
13
14
  const STORAGE_NAME = 'Libraries';
14
15
  const LIB_PATH = 'libraries/';
15
16
 
16
-
17
17
  //tags: init
18
18
  export async function initHelm(): Promise<void> {
19
19
  return new Promise(async (resolve, reject) => {
@@ -23,11 +23,11 @@ export async function initHelm(): Promise<void> {
23
23
  });
24
24
  }
25
25
 
26
+
26
27
  async function loadLibraries() {
27
28
  let uploadedLibraries: string[] = Object.values(await grok.dapi.userDataStorage.get(STORAGE_NAME, true));
28
- for (let i = 0; i < uploadedLibraries.length; ++i) {
29
- await monomerManager(await grok.dapi.userDataStorage.getValue(STORAGE_NAME, uploadedLibraries[i], true));
30
- }
29
+ for (let i = 0; i < uploadedLibraries.length; ++i)
30
+ await monomerManager(uploadedLibraries[i]);
31
31
  }
32
32
 
33
33
  //name: helmCellRenderer
@@ -283,6 +283,12 @@ export async function monomerManager(value: string) {
283
283
  }
284
284
  org.helm.webeditor.Monomers.addOneMonomer(m);
285
285
  });
286
+
287
+ // Now after updating org.helm.webeditor.Monomers we update MonomerLib window singleton (fires onChanged event)
288
+ (getMonomerLibObj() as MonomerLib).update(getAllLibsData());
289
+ //grok.events.fireCustomEvent('monomersLibChanged', null);
290
+
291
+ // Obsolete
286
292
  let grid: DG.Grid = grok.shell.tv.grid;
287
293
  grid.invalidate();
288
294
  }
@@ -442,6 +448,54 @@ export function findMonomers(helmString: string) {
442
448
  return new Set(split_string.filter(val => !monomer_names.includes(val)));
443
449
  }
444
450
 
451
+
452
+ class MonomerLib implements bio.IMonomerLib {
453
+ private _monomers: { [type: string]: { [name: string]: bio.Monomer } };
454
+ private _onChanged = new Subject<any>();
455
+
456
+ get(monomerType: string, monomerName: string): bio.Monomer | null {
457
+ if (monomerType in this._monomers && monomerName in this._monomers[monomerType])
458
+ return this._monomers[monomerType][monomerName];
459
+ else
460
+ return null;
461
+ }
462
+
463
+ get onChanged(): Observable<any> {
464
+ return this._onChanged;
465
+ }
466
+
467
+ public update(monomers: { [type: string]: { [name: string]: bio.Monomer } }): void {
468
+ this._monomers = monomers;
469
+ this._onChanged.next();
470
+ }
471
+ }
472
+
473
+ function getAllLibsData(): { [type: string]: { [name: string]: bio.Monomer } } {
474
+ //@ts-ignore
475
+ const types = Object.keys(org.helm.webeditor.monomerTypeList());
476
+ //const monomers: any = [];
477
+ const monomers: { [type: string]: { [name: string]: bio.Monomer } } = {};
478
+ for (let i = 0; i < types.length; i++) {
479
+ monomers[types[i]] = new scil.helm.Monomers.getMonomerSet(types[i]);
480
+ //@ts-ignore
481
+ //monomers.push(new scil.helm.Monomers.getMonomerSet(types[i]));
482
+ }
483
+
484
+ return monomers;
485
+ }
486
+
487
+ //name: getMonomerLibObj
488
+ //description: Get object of IMonomerLib interface (singleton)
489
+ //output: object result
490
+ export function getMonomerLibObj(): bio.IMonomerLib {
491
+ if (!('monomerLib' in window)) {
492
+ window['monomerLib'] = new MonomerLib();
493
+ window['monomerLib'].update(getAllLibsData()); // TODO: refactor
494
+ }
495
+
496
+ return window['monomerLib'];
497
+ }
498
+
445
499
  //name: getMolfiles
446
500
  //input: column col {semType: Macromolecule}
447
501
  //output: column res
@@ -584,5 +638,13 @@ class HelmCellRenderer extends DG.GridCellRenderer {
584
638
  //input: string type
585
639
  //output: string monomerSetJSON
586
640
  export function getMonomerLib(type: string): string {
641
+ // TODO: deprecate
587
642
  return JSON.stringify(scil.helm.Monomers.getMonomerSet(type));
588
643
  }
644
+
645
+
646
+ //name: helmWebEditor
647
+ //output: object
648
+ export function helmWebEditor(): HelmWebEditor {
649
+ return new HelmWebEditor();
650
+ }
@@ -1,4 +1,4 @@
1
- <html><head><meta charset="utf-8"/><title>Helm Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit 481b4bd5.</title><style type="text/css">html,
1
+ <html><head><meta charset="utf-8"/><title>Helm Test Report. Datagrok version datagrok/datagrok:latest SHA=49ff04f38f57. Commit 48c80158.</title><style type="text/css">html,
2
2
  body {
3
3
  font-family: Arial, Helvetica, sans-serif;
4
4
  font-size: 1rem;
@@ -229,7 +229,7 @@ header {
229
229
  font-size: 1rem;
230
230
  padding: 0 0.5rem;
231
231
  }
232
- </style></head><body><div id="jesthtml-content"><header><h1 id="title">Helm Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit 481b4bd5.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-10-14 10:03:25</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed">1 passed</div><div class="summary-failed summary-empty">0 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">1 passed</div><div class="summary-failed summary-empty">0 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/Helm/src/__jest__/remote.test.ts</div><div class="suite-time warn">20.521s</div></div><div class="suite-tests"><div class="test-result passed"><div class="test-info"><div class="test-suitename"> </div><div class="test-title">TEST</div><div class="test-status">passed</div><div class="test-duration">5.136s</div></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/Helm/src/__jest__/test-node.ts:61:11)
232
+ </style></head><body><div id="jesthtml-content"><header><h1 id="title">Helm Test Report. Datagrok version datagrok/datagrok:latest SHA=49ff04f38f57. Commit 48c80158.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-10-25 11:59:02</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed">1 passed</div><div class="summary-failed summary-empty">0 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">1 passed</div><div class="summary-failed summary-empty">0 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/Helm/src/__jest__/remote.test.ts</div><div class="suite-time warn">14.844s</div></div><div class="suite-tests"><div class="test-result passed"><div class="test-info"><div class="test-suitename"> </div><div class="test-title">TEST</div><div class="test-status">passed</div><div class="test-duration">5.034s</div></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/Helm/src/__jest__/test-node.ts:61:11)
233
233
  at Generator.next (&lt;anonymous&gt;)
234
234
  at fulfilled (/home/runner/work/public/public/packages/Helm/src/__jest__/test-node.ts:28:58)
235
235
  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/Helm/src/__jest__/remote.test.ts:40:11
@@ -242,8 +242,7 @@ header {
242
242
  at new Promise (&lt;anonymous&gt;)</pre><pre class="suite-consolelog-item-message">Testing Helm package</pre></div><div class="suite-consolelog-item"><pre class="suite-consolelog-item-origin"> at /home/runner/work/public/public/packages/Helm/src/__jest__/remote.test.ts:66:11
243
243
  at Generator.next (&lt;anonymous&gt;)
244
244
  at fulfilled (/home/runner/work/public/public/packages/Helm/src/__jest__/remote.test.ts:31:58)
245
- at runMicrotasks (&lt;anonymous&gt;)
246
- at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Test result : Success : 90 : Helm.Helm.manageFiles : OK
247
- Test result : Success : 1897 : Helm.Helm.monomerManager : OK
248
- Test result : Success : 1 : Helm.Helm.parseHelm : OK
245
+ at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Test result : Success : 48 : Helm.Helm.manageFiles : OK
246
+ Test result : Success : 839 : Helm.Helm.monomerManager : OK
247
+ Test result : Success : 2 : Helm.Helm.parseHelm : OK
249
248
  </pre></div></div></div></div></body></html>