@datagrok/helm 2.5.2 → 2.5.4
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 +27 -6
- package/CHANGELOG.md +17 -0
- package/dist/455.js.map +1 -1
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +15 -13
- package/src/helm-helper.ts +9 -8
- package/src/helm-web-editor.ts +8 -7
- package/src/package-test.ts +1 -1
- package/src/package-utils.ts +41 -18
- package/src/package.ts +15 -13
- package/src/tests/findMonomers-tests.ts +2 -3
- package/src/tests/get-molfiles-tests.ts +3 -3
- package/src/tests/get-monomer-tests.ts +12 -24
- package/src/tests/helm-helper-tests.ts +9 -16
- package/src/tests/helm-input-tests.ts +2 -4
- package/src/tests/helm-service-tests.ts +4 -7
- package/src/tests/helm-web-editor-tests.ts +3 -4
- package/src/tests/parse-helm-tests.ts +5 -7
- package/src/tests/properties-widget-tests.ts +19 -20
- package/src/tests/renderers-tests.ts +2 -3
- package/src/utils/get-hovered.ts +1 -2
- package/src/utils/helm-grid-cell-renderer.ts +46 -26
- package/src/utils/helm-service.ts +32 -13
- package/src/widgets/helm-input.ts +2 -2
- package/src/widgets/properties-widget.ts +5 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/helm",
|
|
3
3
|
"friendlyName": "Helm",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.4",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Aleksandr Tanas",
|
|
7
7
|
"email": "atanas@datagrok.ai"
|
|
@@ -16,33 +16,35 @@
|
|
|
16
16
|
"css/helm.css"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@datagrok-libraries/bio": "^5.
|
|
19
|
+
"@datagrok-libraries/bio": "^5.45.0",
|
|
20
20
|
"@datagrok-libraries/chem-meta": "^1.2.7",
|
|
21
|
-
"@datagrok-libraries/utils": "^4.3.
|
|
21
|
+
"@datagrok-libraries/utils": "^4.3.6",
|
|
22
22
|
"cash-dom": "^8.1.1",
|
|
23
23
|
"datagrok-api": "^1.21.1",
|
|
24
24
|
"dayjs": "^1.10.6",
|
|
25
|
+
"lru-cache": "^10.4.3",
|
|
25
26
|
"rxjs": "^6.5.5",
|
|
26
27
|
"wu": "latest"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@datagrok-libraries/helm-web-editor": "^1.1.
|
|
30
|
-
"@datagrok-libraries/js-draw-lite": "^0.0.
|
|
31
|
-
"@datagrok/bio": "^2.
|
|
32
|
-
"@datagrok/chem": "^1.12.
|
|
30
|
+
"@datagrok-libraries/helm-web-editor": "^1.1.12",
|
|
31
|
+
"@datagrok-libraries/js-draw-lite": "^0.0.9",
|
|
32
|
+
"@datagrok/bio": "^2.16.0",
|
|
33
|
+
"@datagrok/chem": "^1.12.3",
|
|
33
34
|
"@types/node": "17.0.45",
|
|
34
35
|
"@types/webpack-env": "^1.18.5",
|
|
35
36
|
"@types/wu": "latest",
|
|
36
37
|
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
37
38
|
"@typescript-eslint/parser": "^7.16.0",
|
|
38
39
|
"datagrok-tools": "latest",
|
|
39
|
-
"eslint": "
|
|
40
|
-
"eslint-config-google": "
|
|
41
|
-
"eslint-plugin-
|
|
40
|
+
"eslint": "latest",
|
|
41
|
+
"eslint-config-google": "latest",
|
|
42
|
+
"eslint-plugin-deprecation": "latest",
|
|
43
|
+
"eslint-plugin-rxjs": "latest",
|
|
42
44
|
"path": "^0.12.7",
|
|
43
|
-
"source-map-loader": "
|
|
44
|
-
"ts-loader": "
|
|
45
|
-
"typescript": "
|
|
45
|
+
"source-map-loader": "latest",
|
|
46
|
+
"ts-loader": "latest",
|
|
47
|
+
"typescript": "latest",
|
|
46
48
|
"webpack": "^5.76.3",
|
|
47
49
|
"webpack-cli": "^4.9.1"
|
|
48
50
|
},
|
package/src/helm-helper.ts
CHANGED
|
@@ -4,12 +4,13 @@ import * as DG from 'datagrok-api/dg';
|
|
|
4
4
|
|
|
5
5
|
import $ from 'cash-dom';
|
|
6
6
|
|
|
7
|
+
/* eslint-disable max-len */
|
|
7
8
|
import {
|
|
8
9
|
App, Point, HelmAtom, HelmBond, HelmMol, HelmType, GetMonomerFunc, GetMonomerResType,
|
|
9
10
|
MonomerExplorer, TabDescType, MonomersFuncs, MonomerSetType, ISeqMonomer, PolymerType, MonomerType,
|
|
10
|
-
DojoType, JSDraw2ModuleType,
|
|
11
|
+
DojoType, JSDraw2ModuleType, IHelmEditorOptions, IHelmDrawOptions
|
|
11
12
|
} from '@datagrok-libraries/bio/src/helm/types';
|
|
12
|
-
import {HelmTypes, MonomerTypes, PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
|
|
13
|
+
import {HelmTabKeys, HelmTypes, MonomerTypes, PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
|
|
13
14
|
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
14
15
|
import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';
|
|
15
16
|
import {
|
|
@@ -17,13 +18,13 @@ import {
|
|
|
17
18
|
} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
18
19
|
import {IHelmWebEditor} from '@datagrok-libraries/bio/src/helm/types';
|
|
19
20
|
import {IMonomerLib, IMonomerLibBase, IMonomerLinkData, IMonomerSetPlaceholder} from '@datagrok-libraries/bio/src/types/index';
|
|
20
|
-
import {HelmTabKeys, IHelmDrawOptions} from '@datagrok-libraries/helm-web-editor/src/types/org-helm';
|
|
21
21
|
import {GAP_SYMBOL, GapOriginals, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule/consts';
|
|
22
22
|
|
|
23
23
|
import {HelmWebEditor} from './helm-web-editor';
|
|
24
24
|
import {OrgHelmModule, ScilModule} from './types';
|
|
25
25
|
import {HelmInput} from './widgets/helm-input';
|
|
26
26
|
import {getHoveredMonomerFromEditorMol} from './utils/get-hovered';
|
|
27
|
+
/* eslint-enable max-len */
|
|
27
28
|
|
|
28
29
|
import {_package} from './package';
|
|
29
30
|
|
|
@@ -47,7 +48,7 @@ export class HelmHelper implements IHelmHelper {
|
|
|
47
48
|
|
|
48
49
|
createHelmInput(name?: string, options?: IHelmInputInitOptions): HelmInputBase {
|
|
49
50
|
try {
|
|
50
|
-
const monomerLib: IMonomerLibBase = _package.
|
|
51
|
+
const monomerLib: IMonomerLibBase = _package._libHelper!.getMonomerLib();
|
|
51
52
|
return HelmInput.create(this, monomerLib, name, options);
|
|
52
53
|
} catch (err: any) {
|
|
53
54
|
const [errMsg, errStack] = errInfo(err);
|
|
@@ -56,8 +57,8 @@ export class HelmHelper implements IHelmHelper {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
createHelmWebEditor(host?: HTMLDivElement,
|
|
60
|
-
return new HelmWebEditor(host,
|
|
60
|
+
createHelmWebEditor(host?: HTMLDivElement, options?: Partial<IHelmEditorOptions>): IHelmWebEditor {
|
|
61
|
+
return new HelmWebEditor(host, options);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
createWebEditorApp(host: HTMLDivElement, helm: string): App {
|
|
@@ -146,7 +147,7 @@ export class HelmHelper implements IHelmHelper {
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
public onShowTabPlaceholdersSets(mex: MonomerExplorer, div: HTMLDivElement): void {
|
|
149
|
-
const monomerSets = _package.
|
|
150
|
+
const monomerSets = _package._libHelper!.getMonomerSets();
|
|
150
151
|
|
|
151
152
|
const phSet: { [polymerType: string]: { [helmType: string]: IMonomerSetPlaceholder[] } } = {};
|
|
152
153
|
for (const ph of monomerSets.placeholders) {
|
|
@@ -340,7 +341,7 @@ export class HelmHelper implements IHelmHelper {
|
|
|
340
341
|
}
|
|
341
342
|
|
|
342
343
|
public parse(helm: string, origin?: Point): HelmMol {
|
|
343
|
-
const molHandler = new JSDraw2.MolHandler<HelmType>();
|
|
344
|
+
const molHandler = new JSDraw2.MolHandler<HelmType, IHelmEditorOptions>();
|
|
344
345
|
const plugin = new org.helm.webeditor.Plugin(molHandler);
|
|
345
346
|
org.helm.webeditor.IO.parseHelm(plugin, helm, origin ?? new JSDraw2.Point(0, 0));
|
|
346
347
|
return plugin.jsd.m;
|
package/src/helm-web-editor.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {Unsubscribable} from 'rxjs';
|
|
|
6
6
|
|
|
7
7
|
import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';
|
|
8
8
|
import {
|
|
9
|
-
App, Editor, HelmType, IHelmWebEditor, HelmEditor,
|
|
9
|
+
App, Editor, HelmType, IHelmWebEditor, HelmEditor, IHelmEditorOptions
|
|
10
10
|
} from '@datagrok-libraries/bio/src/helm/types';
|
|
11
11
|
|
|
12
12
|
import {JSDraw2Module, OrgHelmModule, ScilModule} from './types';
|
|
@@ -27,16 +27,17 @@ export class HelmWebEditor implements IHelmWebEditor {
|
|
|
27
27
|
|
|
28
28
|
constructor(
|
|
29
29
|
host?: HTMLDivElement,
|
|
30
|
-
|
|
30
|
+
options?: Partial<IHelmEditorOptions>,
|
|
31
31
|
private logger: ILogger = _package.logger
|
|
32
32
|
) {
|
|
33
33
|
this.host = host ?? ui.div([], {style: {width: `${this.w}px`, height: `${this.h}px`}});
|
|
34
34
|
|
|
35
|
-
const styleBackup = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const styleBackup = {
|
|
36
|
+
width: this.host.style.width, height: this.host.style.height,
|
|
37
|
+
overflow: this.host.style.overflow
|
|
38
|
+
};
|
|
39
|
+
this.editor = new JSDraw2.Editor(this.host,
|
|
40
|
+
Object.assign({width: this.w, height: this.h, viewonly: true}, options));
|
|
40
41
|
this.host.style.width = styleBackup.width;
|
|
41
42
|
this.host.style.height = styleBackup.height;
|
|
42
43
|
this.host.style.overflow = styleBackup.overflow;
|
package/src/package-test.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as grok from 'datagrok-api/grok';
|
|
|
5
5
|
// import {JSDraw2ModuleType} from '@datagrok/js-draw-lite/src/types/jsdraw2';
|
|
6
6
|
// import {HelmType, OrgHelmModuleType} from '@datagrok/helm-web-editor/src/types/org-helm';
|
|
7
7
|
|
|
8
|
-
import {runTests, tests, TestContext, initAutoTests as initTests
|
|
8
|
+
import {runTests, tests, TestContext, initAutoTests as initTests} from '@datagrok-libraries/utils/src/test';
|
|
9
9
|
|
|
10
10
|
import './tests/_first-tests';
|
|
11
11
|
import './tests/helm-tests';
|
package/src/package-utils.ts
CHANGED
|
@@ -13,9 +13,10 @@ import {
|
|
|
13
13
|
import {HelmServiceBase} from '@datagrok-libraries/bio/src/viewers/helm-service';
|
|
14
14
|
import {IMonomerLib} from '@datagrok-libraries/bio/src/types';
|
|
15
15
|
import {LoggerWrapper} from '@datagrok-libraries/bio/src/utils/logger';
|
|
16
|
+
import {IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
16
17
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
18
|
+
import {ISeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
17
19
|
|
|
18
|
-
import {HelmHelper} from './helm-helper';
|
|
19
20
|
import {HelmService} from './utils/helm-service';
|
|
20
21
|
import {OrgHelmModule, ScilModule} from './types';
|
|
21
22
|
import {rewriteLibraries} from './utils/get-monomer';
|
|
@@ -38,14 +39,15 @@ type DojoConfigWindowType = {
|
|
|
38
39
|
},
|
|
39
40
|
};
|
|
40
41
|
type HelmWindowType = {
|
|
41
|
-
$
|
|
42
|
+
$helmServicePromise?: Promise<HelmServiceBase>,
|
|
42
43
|
require: any,
|
|
43
44
|
};
|
|
44
45
|
declare const window: Window & DojoConfigWindowType & DojoWindowType & HweWindow & HelmWindowType;
|
|
45
46
|
|
|
46
|
-
export function _getHelmService(): HelmServiceBase {
|
|
47
|
-
let res = window.$
|
|
48
|
-
if (!res)
|
|
47
|
+
export async function _getHelmService(): Promise<HelmServiceBase> {
|
|
48
|
+
let res = window.$helmServicePromise;
|
|
49
|
+
if (!res)
|
|
50
|
+
res = window.$helmServicePromise = Promise.resolve(new HelmService());
|
|
49
51
|
return res;
|
|
50
52
|
}
|
|
51
53
|
|
|
@@ -57,7 +59,8 @@ export async function initHelmLoadAndPatchDojo(): Promise<void> {
|
|
|
57
59
|
try {
|
|
58
60
|
const requireBackup = window.require;
|
|
59
61
|
|
|
60
|
-
// dojo.window','dojo.io.script','dojo.io.iframe','dojo.dom',
|
|
62
|
+
// 'dojo.window','dojo.io.script','dojo.io.iframe','dojo.dom',
|
|
63
|
+
// 'dojox.gfx','dojox.gfx.svg','dojox.gfx.shape','dojox.charting'
|
|
61
64
|
const dojoTargetList: { name: string, checker: () => boolean }[] = [
|
|
62
65
|
{name: 'dojo.window', checker: () => !!(window.dojo?.window)},
|
|
63
66
|
{name: 'dojo.ready', checker: () => !!(window.dojo?.ready)},
|
|
@@ -120,14 +123,16 @@ export async function initHelmLoadAndPatchDojo(): Promise<void> {
|
|
|
120
123
|
const cmp = dojoRequire == requireBackup;
|
|
121
124
|
try {
|
|
122
125
|
await new Promise<void>((resolve, reject) => {
|
|
123
|
-
|
|
126
|
+
/* eslint-disable indent */
|
|
127
|
+
dojoRequire([
|
|
128
|
+
'dojo/window', 'dojo/dom', 'dojo/io/script', 'dojo/io/iframe',
|
|
124
129
|
'dojox/gfx', 'dojox/gfx/svg', 'dojox/gfx/shape',
|
|
125
130
|
'dojox/storage/Provider', 'dojox/storage/LocalStorageProvider',
|
|
126
131
|
'dijit/_base', 'dijit/Tooltip', 'dijit/form/_FormValueWidget',
|
|
127
132
|
'dijit/form/DropDownButton', 'dijit/layout/AccordionContainer', 'dijit/form/ComboButton',
|
|
128
|
-
'dijit/layout/StackController', 'dijit/layout/StackContainer',
|
|
129
|
-
],
|
|
133
|
+
'dijit/layout/StackController', 'dijit/layout/StackContainer',],
|
|
130
134
|
(...args: any[]) => { resolve(); });
|
|
135
|
+
/* eslint-enable indent */
|
|
131
136
|
});
|
|
132
137
|
} finally {
|
|
133
138
|
// TODO: Check interference with NGL
|
|
@@ -142,7 +147,8 @@ export async function initHelmLoadAndPatchDojo(): Promise<void> {
|
|
|
142
147
|
const dojoProgress = dojoTargetList.length - dojoNotReadyList.length;
|
|
143
148
|
pi.update(Math.round(100 * dojoProgress / dojoTargetList.length),
|
|
144
149
|
`Loading Helm Web Editor ${dojoProgress}/${dojoTargetList.length}`);
|
|
145
|
-
_package.logger.debug(`${logPrefix}, dojo loading ...
|
|
150
|
+
_package.logger.debug(`${logPrefix}, dojo loading ... ` +
|
|
151
|
+
`${dojoNotReadyList.map((m) => `'${m}'`).join(',')} ...`);
|
|
146
152
|
await delay(100);
|
|
147
153
|
}
|
|
148
154
|
_package.logger.debug(`${logPrefix}, dojo ready all modules`);
|
|
@@ -199,15 +205,27 @@ export const helmJsonReplacer = (key: string, value: any): any => {
|
|
|
199
205
|
|
|
200
206
|
export class HelmPackage extends DG.Package {
|
|
201
207
|
public alertOriginal: ((s: string) => void) | null = null;
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
|
|
209
|
+
private _seqHelper: ISeqHelper;
|
|
210
|
+
public get seqHelper(): ISeqHelper {
|
|
211
|
+
if (!this._seqHelper)
|
|
212
|
+
throw new Error('Package Helm .seqHelper is not initialized');
|
|
213
|
+
return this._seqHelper;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private _helmHelper: IHelmHelper;
|
|
217
|
+
public get helmHelper(): IHelmHelper {
|
|
218
|
+
if (!this._helmHelper)
|
|
219
|
+
throw new Error('Package Helm .helmHelper is not initialized');
|
|
220
|
+
return this._helmHelper;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
public _libHelper!: IMonomerLibHelper;
|
|
204
224
|
|
|
205
225
|
constructor(opts: { debug: boolean } = {debug: false}) {
|
|
206
226
|
super();
|
|
207
227
|
// @ts-ignore
|
|
208
228
|
super._logger = new LoggerWrapper(super.logger, opts.debug);
|
|
209
|
-
|
|
210
|
-
this.helmHelper = new HelmHelper(this.logger);
|
|
211
229
|
}
|
|
212
230
|
|
|
213
231
|
// -- Init --
|
|
@@ -299,16 +317,20 @@ export class HelmPackage extends DG.Package {
|
|
|
299
317
|
// -- MonomerLib --
|
|
300
318
|
|
|
301
319
|
public get monomerLib(): IMonomerLib {
|
|
302
|
-
if (!this.
|
|
320
|
+
if (!this._libHelper)
|
|
303
321
|
throw new Error(`Helm: _package.libHelper is not initialized yet`);
|
|
304
|
-
return this.
|
|
322
|
+
return this._libHelper.getMonomerLib();
|
|
305
323
|
}
|
|
306
324
|
|
|
307
325
|
private _monomerLibSub?: Unsubscribable;
|
|
308
326
|
|
|
327
|
+
private _initialized: boolean = false;
|
|
328
|
+
|
|
309
329
|
/** Requires both Bio & HELMWebEditor initialized */
|
|
310
|
-
|
|
311
|
-
this.
|
|
330
|
+
completeInit(seqHelper: ISeqHelper, helmHelper: IHelmHelper, libHelper: IMonomerLibHelper): void {
|
|
331
|
+
this._seqHelper = seqHelper;
|
|
332
|
+
this._helmHelper = helmHelper;
|
|
333
|
+
this._libHelper = libHelper;
|
|
312
334
|
|
|
313
335
|
const lib = this.monomerLib;
|
|
314
336
|
rewriteLibraries(lib); // initHelm()
|
|
@@ -316,6 +338,7 @@ export class HelmPackage extends DG.Package {
|
|
|
316
338
|
.subscribe(this.monomerLibOnChangedHandler.bind(this));
|
|
317
339
|
|
|
318
340
|
this.initHelmPatchPistoia();
|
|
341
|
+
this._initialized = true;
|
|
319
342
|
}
|
|
320
343
|
|
|
321
344
|
monomerLibOnChangedHandler(): void {
|
package/src/package.ts
CHANGED
|
@@ -8,15 +8,16 @@ import $ from 'cash-dom';
|
|
|
8
8
|
import {testEvent} from '@datagrok-libraries/utils/src/test';
|
|
9
9
|
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
10
10
|
import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
11
|
-
import {
|
|
12
|
-
import {App,
|
|
11
|
+
import {getSeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
12
|
+
import {App, HweWindow} from '@datagrok-libraries/bio/src/helm/types';
|
|
13
13
|
import {HelmInputBase, IHelmHelper, IHelmInputInitOptions} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
14
14
|
import {HelmServiceBase} from '@datagrok-libraries/bio/src/viewers/helm-service';
|
|
15
15
|
import {getMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
16
16
|
|
|
17
17
|
import {getPropertiesWidget} from './widgets/properties-widget';
|
|
18
18
|
import {HelmGridCellRenderer, HelmGridCellRendererBack} from './utils/helm-grid-cell-renderer';
|
|
19
|
-
import {_getHelmService, HelmPackage
|
|
19
|
+
import {_getHelmService, HelmPackage} from './package-utils';
|
|
20
|
+
import {HelmHelper} from './helm-helper';
|
|
20
21
|
|
|
21
22
|
// Do not import anything than types from @datagrok/helm-web-editor/src/types
|
|
22
23
|
import type {JSDraw2Module, OrgHelmModule, ScilModule} from './types';
|
|
@@ -40,10 +41,9 @@ let initHelmPromise: Promise<void> | null = null;
|
|
|
40
41
|
|
|
41
42
|
//tags: init
|
|
42
43
|
export async function initHelm(): Promise<void> {
|
|
43
|
-
if (initHelmPromise === null)
|
|
44
|
+
if (initHelmPromise === null)
|
|
44
45
|
initHelmPromise = initHelmInt();
|
|
45
|
-
|
|
46
|
-
await initHelmPromise;
|
|
46
|
+
return initHelmPromise;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function initHelmInt(): Promise<void> {
|
|
@@ -51,13 +51,15 @@ async function initHelmInt(): Promise<void> {
|
|
|
51
51
|
_package.logger.debug(`${logPrefix}, start`);
|
|
52
52
|
|
|
53
53
|
try {
|
|
54
|
-
const
|
|
54
|
+
const helmHelper: IHelmHelper = new HelmHelper(_package.logger);
|
|
55
|
+
const [_, seqHelper, libHelper] = await Promise.all([
|
|
55
56
|
_package.initHELMWebEditor(),
|
|
57
|
+
getSeqHelper(),
|
|
56
58
|
getMonomerLibHelper(),
|
|
57
59
|
]);
|
|
58
60
|
|
|
59
61
|
_package.logger.debug(`${logPrefix}, lib loaded`);
|
|
60
|
-
_package.
|
|
62
|
+
_package.completeInit(seqHelper, helmHelper, libHelper);
|
|
61
63
|
} catch (err: any) {
|
|
62
64
|
const [errMsg, errStack] = errInfo(err);
|
|
63
65
|
// const errMsg: string = err instanceof Error ? err.message : !!err ? err.toString() : 'Exception \'undefined\'';
|
|
@@ -72,8 +74,9 @@ async function initHelmInt(): Promise<void> {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
//name: getHelmService
|
|
77
|
+
//description: Helm renderer service
|
|
75
78
|
//output: object result
|
|
76
|
-
export function getHelmService(): HelmServiceBase {
|
|
79
|
+
export async function getHelmService(): Promise<HelmServiceBase> {
|
|
77
80
|
return _getHelmService();
|
|
78
81
|
}
|
|
79
82
|
|
|
@@ -108,7 +111,7 @@ export function editMoleculeCell(cell: DG.GridCell): void {
|
|
|
108
111
|
export function openEditor(mol: string): void {
|
|
109
112
|
const df = grok.shell.tv.grid.dataFrame;
|
|
110
113
|
const col = df.columns.bySemType('Macromolecule')! as DG.Column<string>;
|
|
111
|
-
const colSh =
|
|
114
|
+
const colSh = _package.seqHelper.getSeqHandler(col);
|
|
112
115
|
const colUnits = col.meta.units;
|
|
113
116
|
if (df.currentRowIdx === -1)
|
|
114
117
|
return;
|
|
@@ -133,7 +136,7 @@ function openWebEditor(cell: DG.GridCell, value?: string, units?: string) {
|
|
|
133
136
|
// const df = grok.shell.tv.grid.dataFrame;
|
|
134
137
|
// const col = df.columns.bySemType('Macromolecule')!
|
|
135
138
|
const col = cell.cell.column as DG.Column<string>;
|
|
136
|
-
const sh =
|
|
139
|
+
const sh = _package.seqHelper.getSeqHandler(col);
|
|
137
140
|
const app: App =
|
|
138
141
|
_package.helmHelper.createWebEditorApp(view, !!cell && units === undefined ? cell.cell.value : value!);
|
|
139
142
|
const dlg = ui.dialog({showHeader: false, showFooter: true});
|
|
@@ -184,7 +187,7 @@ export function helmInput(name: string, options: IHelmInputInitOptions): HelmInp
|
|
|
184
187
|
|
|
185
188
|
//name: getHelmHelper
|
|
186
189
|
//output: object result
|
|
187
|
-
export
|
|
190
|
+
export function getHelmHelper(): IHelmHelper {
|
|
188
191
|
return _package.helmHelper;
|
|
189
192
|
}
|
|
190
193
|
|
|
@@ -224,7 +227,6 @@ export async function measureCellRenderer(): Promise<void> {
|
|
|
224
227
|
// -- Test apps --
|
|
225
228
|
|
|
226
229
|
//name: Highlight Monomers
|
|
227
|
-
//tags: app
|
|
228
230
|
//output: view result
|
|
229
231
|
export async function highlightMonomers(): Promise<void> {
|
|
230
232
|
const pi = DG.TaskBarProgressIndicator.create('Test app highlight monomers');
|
|
@@ -6,7 +6,7 @@ import {after, before, category, delay, expect, expectObject, test} from '@datag
|
|
|
6
6
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
7
7
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
8
8
|
import {
|
|
9
|
-
getUserLibSettings, setUserLibSettings,
|
|
9
|
+
getUserLibSettings, setUserLibSettings,
|
|
10
10
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
11
11
|
|
|
12
12
|
import {findMonomers, parseHelm} from '../utils';
|
|
@@ -25,8 +25,7 @@ category('findMonomers', () => {
|
|
|
25
25
|
userLibSettings = await getUserLibSettings();
|
|
26
26
|
|
|
27
27
|
// Tests 'findMonomers' requires default monomer library loaded
|
|
28
|
-
await
|
|
29
|
-
await monomerLibHelper.loadMonomerLib(true); // load default libraries for tests
|
|
28
|
+
await monomerLibHelper.loadMonomerLibForTests(); // load default libraries for tests
|
|
30
29
|
});
|
|
31
30
|
|
|
32
31
|
after(async () => {
|
|
@@ -5,7 +5,7 @@ import * as DG from 'datagrok-api/dg';
|
|
|
5
5
|
import {after, before, category, delay, expect, test, expectArray, testEvent} from '@datagrok-libraries/utils/src/test';
|
|
6
6
|
import {getHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
7
7
|
import {
|
|
8
|
-
getUserLibSettings, setUserLibSettings,
|
|
8
|
+
getUserLibSettings, setUserLibSettings,
|
|
9
9
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
10
10
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
11
11
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
@@ -24,8 +24,8 @@ category('getMolfiles', () => {
|
|
|
24
24
|
await initHelmMainPackage();
|
|
25
25
|
monomerLibHelper = await getMonomerLibHelper();
|
|
26
26
|
userLibSettings = await getUserLibSettings();
|
|
27
|
-
|
|
28
|
-
await monomerLibHelper.
|
|
27
|
+
|
|
28
|
+
await monomerLibHelper.loadMonomerLibForTests();
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
after(async () => {
|
|
@@ -15,9 +15,9 @@ import {IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
|
15
15
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
16
16
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
17
17
|
import {
|
|
18
|
-
getUserLibSettings, setUserLibSettings,
|
|
18
|
+
getUserLibSettings, setUserLibSettings,
|
|
19
19
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
20
|
-
import {
|
|
20
|
+
import {expectMonomerLib} from '@datagrok-libraries/bio/src/tests/monomer-lib-tests';
|
|
21
21
|
|
|
22
22
|
import {rewriteLibraries} from '../utils/get-monomer';
|
|
23
23
|
import {JSDraw2Module, OrgHelmModule} from '../types';
|
|
@@ -25,6 +25,7 @@ import {JSDraw2Module, OrgHelmModule} from '../types';
|
|
|
25
25
|
import {initHelmMainPackage} from './utils';
|
|
26
26
|
|
|
27
27
|
import {_package} from '../package-test';
|
|
28
|
+
import {PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
|
|
28
29
|
|
|
29
30
|
declare const org: OrgHelmModule;
|
|
30
31
|
declare const JSDraw2: JSDraw2Module;
|
|
@@ -79,9 +80,7 @@ category('getMonomer', ()=>{
|
|
|
79
80
|
[monomerLibHelper, helmHelper, userLibSettings] = await Promise.all(
|
|
80
81
|
[getMonomerLibHelper(), getHelmHelper(), getUserLibSettings()]);
|
|
81
82
|
|
|
82
|
-
await
|
|
83
|
-
await monomerLibHelper.awaitLoaded();
|
|
84
|
-
await monomerLibHelper.loadMonomerLib(true); // load default libraries for tests
|
|
83
|
+
await monomerLibHelper.loadMonomerLibForTests(); // load default libraries for tests
|
|
85
84
|
});
|
|
86
85
|
|
|
87
86
|
after(async ()=>{
|
|
@@ -93,22 +92,14 @@ category('getMonomer', ()=>{
|
|
|
93
92
|
const monomerLib = monomerLibHelper.getMonomerLib();
|
|
94
93
|
rewriteLibraries(monomerLib);
|
|
95
94
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(helmHelper != null, true);
|
|
100
|
-
const getMonomerFunc: GetMonomerFunc = helmHelper.originalMonomersFuncs!.getMonomer!;
|
|
95
|
+
const helmHelper: IHelmHelper = await getHelmHelper();
|
|
96
|
+
expect(helmHelper != null, true);
|
|
97
|
+
const getMonomerFunc: GetMonomerFunc = helmHelper.originalMonomersFuncs!.getMonomer!;
|
|
101
98
|
|
|
102
|
-
|
|
103
|
-
// } finally {
|
|
104
|
-
// helmHelper.overrideMonomersFuncs(overriddenMonomersFuncs);
|
|
105
|
-
// }
|
|
99
|
+
return _testAll('original', getMonomerFunc);
|
|
106
100
|
}, {isAggregated: true});
|
|
107
101
|
|
|
108
102
|
test('monomerLib', async () =>{
|
|
109
|
-
const monomerLib = monomerLibHelper.getMonomerLib();
|
|
110
|
-
expectMonomerLib(monomerLib);
|
|
111
|
-
|
|
112
103
|
const getMonomerFunc = org.helm.webeditor.Monomers.getMonomer;
|
|
113
104
|
return _testAll('monomerLib', getMonomerFunc);
|
|
114
105
|
}, {isAggregated: true});
|
|
@@ -138,8 +129,6 @@ category('getMonomer', ()=>{
|
|
|
138
129
|
resDf.set('res', resI, '');
|
|
139
130
|
resDf.set('tgt', resI, '');
|
|
140
131
|
try {
|
|
141
|
-
const monomerLib = monomerLibHelper.getMonomerLib();
|
|
142
|
-
expectMonomerLib(monomerLib);
|
|
143
132
|
resDf.set('success', resI, true);
|
|
144
133
|
} catch (err) {
|
|
145
134
|
const [errMsg, errStack] = errInfo(err);
|
|
@@ -172,16 +161,15 @@ category('getMonomer', ()=>{
|
|
|
172
161
|
}
|
|
173
162
|
|
|
174
163
|
test('missing', async ()=> {
|
|
164
|
+
const monomerLib = monomerLibHelper.getMonomerLib();
|
|
175
165
|
/* Tests getMonomer function adding missing monomers. */
|
|
176
166
|
const helmStr = 'PEPTIDE1{[mis1].R.[mis2].T.C.F}$$$$;';
|
|
177
167
|
|
|
178
|
-
|
|
168
|
+
const libSummary = monomerLib.getSummaryObj();
|
|
179
169
|
const editor = new JSDraw2.Editor(ui.div(), {viewonly: true});
|
|
180
170
|
editor.setHelm(helmStr);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
withMissing['PEPTIDE'] += 2;
|
|
184
|
-
expectMonomerLib(monomerLibHelper.getMonomerLib(), withMissing);
|
|
171
|
+
libSummary[PolymerTypes.PEPTIDE] += 2;
|
|
172
|
+
expectMonomerLib(monomerLib, libSummary);
|
|
185
173
|
});
|
|
186
174
|
});
|
|
187
175
|
|
|
@@ -2,14 +2,16 @@ import * as grok from 'datagrok-api/grok';
|
|
|
2
2
|
import * as ui from 'datagrok-api/ui';
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
4
|
|
|
5
|
+
/* eslint-disable max-len */
|
|
5
6
|
import {after, before, category, delay, expect, expectArray, test, testEvent} from '@datagrok-libraries/utils/src/test';
|
|
6
|
-
import {HelmNotSupportedError, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
7
|
+
import {HelmNotSupportedError, HelmNotSupportedErrorType, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
7
8
|
import {getHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
9
|
+
/* eslint-enable max-len */
|
|
8
10
|
|
|
9
11
|
import {_package} from '../package-test';
|
|
10
12
|
|
|
11
13
|
type TestSrcType = { helm: string };
|
|
12
|
-
type TestTgtType = { helm: string | null, map: [number, number][] };
|
|
14
|
+
type TestTgtType = { helm: string | null, map: [number, number][], errType?: string };
|
|
13
15
|
|
|
14
16
|
category('HelmHelper: removeGaps', () => {
|
|
15
17
|
let helmHelper: IHelmHelper;
|
|
@@ -63,13 +65,13 @@ category('HelmHelper: removeGaps', () => {
|
|
|
63
65
|
},
|
|
64
66
|
'single-cycle-gap-at-connection': {
|
|
65
67
|
src: {helm: 'PEPTIDE1{[meY].*.C.R.N.P.C.T}$PEPTIDE1,PEPTIDE1,2:R3-7:R3$$$V2.0'},
|
|
66
|
-
tgt: {helm: null, map: []}
|
|
68
|
+
tgt: {helm: null, map: [], errType: HelmNotSupportedErrorType}
|
|
67
69
|
}
|
|
68
70
|
};
|
|
69
71
|
|
|
70
72
|
for (const [testName, testData] of Object.entries(tests)) {
|
|
71
73
|
test(`${testName}`, async () => {
|
|
72
|
-
let resErr:
|
|
74
|
+
let resErr: HelmNotSupportedError | null = null;
|
|
73
75
|
try {
|
|
74
76
|
const res = helmHelper.removeGaps(testData.src.helm);
|
|
75
77
|
expect(res.resHelm, testData.tgt.helm);
|
|
@@ -78,17 +80,8 @@ category('HelmHelper: removeGaps', () => {
|
|
|
78
80
|
resErr = err;
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
if (testData.tgt.
|
|
82
|
-
expect(resErr
|
|
83
|
-
|
|
84
|
-
const errCtorName = resErr.constructor.name;
|
|
85
|
-
const isErrorCtor = errCtorName === 'HelmNotSupportedError';
|
|
86
|
-
_package.logger.debug(`Check error object. ` +
|
|
87
|
-
`isErrorInstance: ${isErrorInstance}, isErrorCtor: ${isErrorCtor}, errCtorName: ${errCtorName}`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
expect((resErr instanceof HelmNotSupportedError) || resErr?.constructor.name === 'HelmNotSupportedError',
|
|
91
|
-
testData.tgt.helm === null, 'HelmNotSupportedError thrown expected');
|
|
92
|
-
}, testData.tgt.helm == null ? {skipReason: 'GitHub CI does not support testing exceptions'} : undefined);
|
|
83
|
+
if (testData.tgt.errType)
|
|
84
|
+
expect(resErr?.type, testData.tgt.errType, 'HelmNotSupportedError thrown expected');
|
|
85
|
+
});
|
|
93
86
|
}
|
|
94
87
|
});
|
|
@@ -8,7 +8,7 @@ import {after, before, category, delay, expect, test, testEvent} from '@datagrok
|
|
|
8
8
|
import {IHelmHelper, getHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
9
9
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
10
10
|
import {
|
|
11
|
-
getUserLibSettings, setUserLibSettings,
|
|
11
|
+
getUserLibSettings, setUserLibSettings,
|
|
12
12
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
13
13
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
14
14
|
|
|
@@ -28,9 +28,7 @@ category('HelmInput', () => {
|
|
|
28
28
|
userLibSettings = await getUserLibSettings();
|
|
29
29
|
|
|
30
30
|
// Test 'helm' requires default monomer library loaded
|
|
31
|
-
await
|
|
32
|
-
await monomerLibHelper.awaitLoaded();
|
|
33
|
-
await monomerLibHelper.loadMonomerLib(true); // load default libraries
|
|
31
|
+
await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
|
|
34
32
|
});
|
|
35
33
|
|
|
36
34
|
after(async () => {
|
|
@@ -16,7 +16,7 @@ import {RenderTask} from '@datagrok-libraries/bio/src/utils/cell-renderer-async-
|
|
|
16
16
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
17
17
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
18
18
|
import {
|
|
19
|
-
getUserLibSettings, setUserLibSettings,
|
|
19
|
+
getUserLibSettings, setUserLibSettings,
|
|
20
20
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
21
21
|
|
|
22
22
|
import {initHelmMainPackage} from './utils';
|
|
@@ -38,11 +38,7 @@ category('HelmService', () => {
|
|
|
38
38
|
monomerLibHelper = await getMonomerLibHelper();
|
|
39
39
|
userLibSettings = await getUserLibSettings();
|
|
40
40
|
|
|
41
|
-
await
|
|
42
|
-
// Test 'helm' requires default monomer library loaded
|
|
43
|
-
await setUserLibSettingsForTests();
|
|
44
|
-
await monomerLibHelper.loadMonomerLib(true); // load default libraries
|
|
45
|
-
const libSummary = monomerLibHelper.getMonomerLib().getSummaryObj();
|
|
41
|
+
await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
|
|
46
42
|
|
|
47
43
|
helmSvc = await getHelmService();
|
|
48
44
|
await helmSvc.reset();
|
|
@@ -68,6 +64,7 @@ category('HelmService', () => {
|
|
|
68
64
|
const logPrefix: string = `Helm: tests: HelmService: helm`;
|
|
69
65
|
_package.logger.debug(`${logPrefix}, start`);
|
|
70
66
|
const helmStr: string = 'PEPTIDE1{I.H.A.N.T.Thr_PO3H2.Aca.D-Tyr_Et}$$$$';
|
|
67
|
+
const monomerLib = monomerLibHelper.getMonomerLib();
|
|
71
68
|
let consumerId: number | null = null;
|
|
72
69
|
let taskAux: HelmAux | null = null;
|
|
73
70
|
const event = new Subject<void>();
|
|
@@ -78,7 +75,7 @@ category('HelmService', () => {
|
|
|
78
75
|
const task: RenderTask<HelmProps, HelmAux> = {
|
|
79
76
|
name: 'test1',
|
|
80
77
|
props: {
|
|
81
|
-
helm: helmStr,
|
|
78
|
+
helm: helmStr, monomerLib: monomerLib,
|
|
82
79
|
backColor: DG.Color.fromHtml('#FFFFFF'),
|
|
83
80
|
width: 300, height: 100,
|
|
84
81
|
},
|