@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
|
@@ -7,7 +7,7 @@ import {IHelmHelper, getHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-
|
|
|
7
7
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
8
8
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
9
9
|
import {
|
|
10
|
-
getUserLibSettings, setUserLibSettings
|
|
10
|
+
getUserLibSettings, setUserLibSettings
|
|
11
11
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
12
12
|
|
|
13
13
|
import {initHelmMainPackage} from './utils';
|
|
@@ -22,9 +22,8 @@ category('helm-web-editor', async () => {
|
|
|
22
22
|
await initHelmMainPackage();
|
|
23
23
|
monomerLibHelper = await getMonomerLibHelper();
|
|
24
24
|
userLibSettings = await getUserLibSettings();
|
|
25
|
-
|
|
26
|
-
await monomerLibHelper.
|
|
27
|
-
await monomerLibHelper.loadMonomerLib(true);
|
|
25
|
+
|
|
26
|
+
await monomerLibHelper.loadMonomerLibForTests();
|
|
28
27
|
|
|
29
28
|
hh = await getHelmHelper();
|
|
30
29
|
});
|
|
@@ -4,11 +4,11 @@ import * as DG from 'datagrok-api/dg';
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
import {after, before, category, delay, expect, test, expectArray, timeout} from '@datagrok-libraries/utils/src/test';
|
|
7
|
-
import {HelmType,
|
|
7
|
+
import {HelmType, IHelmEditorOptions, Mol, OrgType} from '@datagrok-libraries/bio/src/helm/types';
|
|
8
8
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
9
9
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
10
10
|
import {
|
|
11
|
-
getUserLibSettings, setUserLibSettings
|
|
11
|
+
getUserLibSettings, setUserLibSettings
|
|
12
12
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
13
13
|
|
|
14
14
|
import {JSDraw2Module} from '../types';
|
|
@@ -54,9 +54,7 @@ category('parseHelm', () => {
|
|
|
54
54
|
'get user lib settings for backup');
|
|
55
55
|
|
|
56
56
|
// parseHelm is dependent on monomers RGroups available, test requires default monomer library
|
|
57
|
-
await
|
|
58
|
-
await libHelper.awaitLoaded();
|
|
59
|
-
await libHelper.loadMonomerLib(true);
|
|
57
|
+
await libHelper.loadMonomerLibForTests();
|
|
60
58
|
});
|
|
61
59
|
|
|
62
60
|
after(async () => {
|
|
@@ -81,7 +79,7 @@ function _testParseHelmWithEditor(src: string, tgt: TestTgtType): void {
|
|
|
81
79
|
const io = org.helm.webeditor.IO;
|
|
82
80
|
|
|
83
81
|
const editorHost = ui.div();
|
|
84
|
-
const editor = new JSDraw2.Editor<HelmType,
|
|
82
|
+
const editor = new JSDraw2.Editor<HelmType, IHelmEditorOptions>(editorHost, {viewonly: true});
|
|
85
83
|
|
|
86
84
|
const plugin = new org.helm.webeditor.Plugin(editor);
|
|
87
85
|
const origin = new JSDraw2.Point(0, 0);
|
|
@@ -95,7 +93,7 @@ function _testParseHelmWithEditor(src: string, tgt: TestTgtType): void {
|
|
|
95
93
|
function _testParseHelmWithoutDOM(src: string, tgt: TestTgtType): void {
|
|
96
94
|
const io = org.helm.webeditor.IO;
|
|
97
95
|
|
|
98
|
-
const molHandler = new JSDraw2.MolHandler<HelmType>();
|
|
96
|
+
const molHandler = new JSDraw2.MolHandler<HelmType, IHelmEditorOptions>();
|
|
99
97
|
|
|
100
98
|
const plugin = new org.helm.webeditor.Plugin(molHandler);
|
|
101
99
|
const origin = new JSDraw2.Point(0, 0);
|
|
@@ -4,12 +4,12 @@ import * as grok from 'datagrok-api/grok';
|
|
|
4
4
|
|
|
5
5
|
import {after, before, category, expect, expectObject, test, timeout} from '@datagrok-libraries/utils/src/test';
|
|
6
6
|
import {ALPHABET, NOTATION, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
7
|
-
import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
|
|
8
7
|
import {
|
|
9
|
-
getUserLibSettings, setUserLibSettings
|
|
8
|
+
getUserLibSettings, setUserLibSettings
|
|
10
9
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
11
10
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
12
11
|
import {generateLongSequence} from '@datagrok-libraries/bio/src/utils/generator';
|
|
12
|
+
import {getSeqHelper, ISeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
13
13
|
|
|
14
14
|
import {initHelmMainPackage} from './utils';
|
|
15
15
|
import {getPropertiesDict, SeqPropertiesError} from '../widgets/properties-widget';
|
|
@@ -72,20 +72,19 @@ const TestsData: {
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
category('properties-widget', () => {
|
|
75
|
+
let seqHelper: ISeqHelper;
|
|
75
76
|
let monomerLibHelper: IMonomerLibHelper;
|
|
76
77
|
/** Backup actual user's monomer libraries settings */
|
|
77
78
|
let userLibSettings: any = null;
|
|
78
79
|
|
|
79
80
|
before(async () => {
|
|
80
81
|
await initHelmMainPackage();
|
|
82
|
+
seqHelper = await getSeqHelper();
|
|
81
83
|
|
|
82
84
|
monomerLibHelper = await getMonomerLibHelper();
|
|
83
85
|
userLibSettings = getUserLibSettings();
|
|
84
86
|
|
|
85
|
-
await
|
|
86
|
-
await timeout(async () => { await monomerLibHelper.awaitLoaded(); },
|
|
87
|
-
5000, 'MonomerLibHelper.awaitLoaded() timeout');
|
|
88
|
-
await monomerLibHelper.loadMonomerLib(true); // load default libraries
|
|
87
|
+
await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
|
|
89
88
|
});
|
|
90
89
|
|
|
91
90
|
after(async () => {
|
|
@@ -104,7 +103,7 @@ category('properties-widget', () => {
|
|
|
104
103
|
const df = DG.DataFrame.fromColumns(colList);
|
|
105
104
|
const col = df.getCol('MSA');
|
|
106
105
|
|
|
107
|
-
const sh =
|
|
106
|
+
const sh = seqHelper.getSeqHandler(col);
|
|
108
107
|
let errCatched = true;
|
|
109
108
|
try {
|
|
110
109
|
const _actPropDict = getPropertiesDict(col.get(0), sh);
|
|
@@ -114,17 +113,17 @@ category('properties-widget', () => {
|
|
|
114
113
|
}
|
|
115
114
|
expect(errCatched, true);
|
|
116
115
|
});
|
|
117
|
-
});
|
|
118
116
|
|
|
119
|
-
function testPropertiesDict(
|
|
120
|
-
|
|
121
|
-
) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
117
|
+
function testPropertiesDict(
|
|
118
|
+
seq: string, units: NOTATION, separator: string | undefined, alphabet: ALPHABET | undefined, expPropDict: {}
|
|
119
|
+
) {
|
|
120
|
+
const col = DG.Column.fromStrings('seq', [seq]) as DG.Column<string>;
|
|
121
|
+
col.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
122
|
+
col.meta.units = units;
|
|
123
|
+
if (separator) col.setTag(bioTAGS.separator, separator);
|
|
124
|
+
if (alphabet) col.setTag(bioTAGS.alphabet, alphabet);
|
|
125
|
+
const sh = seqHelper.getSeqHandler(col);
|
|
126
|
+
const actPropDict = getPropertiesDict(seq, sh);
|
|
127
|
+
expectObject(actPropDict, expPropDict);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
@@ -12,7 +12,7 @@ import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
|
12
12
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
13
13
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
14
14
|
import {
|
|
15
|
-
getUserLibSettings, setUserLibSettings
|
|
15
|
+
getUserLibSettings, setUserLibSettings
|
|
16
16
|
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
17
17
|
|
|
18
18
|
import {awaitGrid, initHelmMainPackage} from './utils';
|
|
@@ -32,8 +32,7 @@ category('renderers', () => {
|
|
|
32
32
|
userLibSettings = await getUserLibSettings();
|
|
33
33
|
|
|
34
34
|
// Test 'helm' requires default monomer library loaded
|
|
35
|
-
await
|
|
36
|
-
await monomerLibHelper.loadMonomerLib(true); // load default libraries
|
|
35
|
+
await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
after(async () => {
|
package/src/utils/get-hovered.ts
CHANGED
|
@@ -85,9 +85,8 @@ export function getHoveredMonomerFallback(
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export function getSeqMonomerFromHelmAtom(atom: HelmAtom): ISeqMonomer {
|
|
88
|
-
const polymerType = helmTypeToPolymerType(atom.bio!.type);
|
|
89
88
|
const canonicalSymbol = atom.elem === GapOriginals[NOTATION.HELM] ? GAP_SYMBOL : atom.elem;
|
|
90
|
-
return {position: parseInt(atom.bio!.continuousId as string) - 1, symbol:
|
|
89
|
+
return {position: parseInt(atom.bio!.continuousId as string) - 1, symbol: canonicalSymbol, biotype: atom.bio!.type};
|
|
91
90
|
}
|
|
92
91
|
|
|
93
92
|
/** Linear
|
|
@@ -8,22 +8,24 @@ import {HelmType, ISeqMonomer, Mol} from '@datagrok-libraries/bio/src/helm/types
|
|
|
8
8
|
import {
|
|
9
9
|
CellRendererBackAsyncBase, RenderServiceBase
|
|
10
10
|
} from '@datagrok-libraries/bio/src/utils/cell-renderer-async-base';
|
|
11
|
-
import {HelmAux, HelmProps} from '@datagrok-libraries/bio/src/viewers/helm-service';
|
|
12
|
-
import {_getHelmService} from '../package-utils';
|
|
11
|
+
import {HelmAux, HelmProps, HelmServiceBase} from '@datagrok-libraries/bio/src/viewers/helm-service';
|
|
13
12
|
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
14
13
|
import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';
|
|
15
14
|
import {getGridCellColTemp} from '@datagrok-libraries/bio/src/utils/cell-renderer-back-base';
|
|
16
|
-
import {
|
|
15
|
+
import {getMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
16
|
+
import {IMonomerLibBase} from '@datagrok-libraries/bio/src/types/index';
|
|
17
17
|
import {execMonomerHoverLinks} from '@datagrok-libraries/bio/src/monomer-works/monomer-hover';
|
|
18
|
+
import {MmcrTemps} from '@datagrok-libraries/bio/src/utils/cell-renderer-consts';
|
|
18
19
|
|
|
19
20
|
import {getHoveredMonomerFromEditorMol, getSeqMonomerFromHelmAtom} from './get-hovered';
|
|
20
21
|
|
|
21
|
-
import {_package} from '../package';
|
|
22
|
+
import {_package, getHelmService} from '../package';
|
|
22
23
|
|
|
23
24
|
export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProps, HelmAux> {
|
|
24
25
|
private _auxList: (HelmAux | null)[];
|
|
25
26
|
|
|
26
|
-
private
|
|
27
|
+
private sysMonomerLib: IMonomerLibBase | null = null;
|
|
28
|
+
private helmRenderService: HelmServiceBase | null = null;
|
|
27
29
|
|
|
28
30
|
// eslint-disable-next-line max-len
|
|
29
31
|
private readonly uuid: string = wu.repeat(1).map(() => Math.floor((Math.random() * 36)).toString(36)).take(4).toArray().join('');
|
|
@@ -35,23 +37,48 @@ export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProp
|
|
|
35
37
|
super(gridCol, tableCol, _package.logger, true);
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
public async init(): Promise<void> {
|
|
41
|
+
await Promise.all([
|
|
42
|
+
(async () => {
|
|
43
|
+
const libHelper = await getMonomerLibHelper();
|
|
44
|
+
this.sysMonomerLib = libHelper.getMonomerLib();
|
|
45
|
+
})(),
|
|
46
|
+
(async () => {
|
|
47
|
+
this.helmRenderService = await getHelmService();
|
|
48
|
+
})(),
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
this.subs.push(this.sysMonomerLib!.onChanged.subscribe(() => {
|
|
52
|
+
this.dirty = true;
|
|
53
|
+
this.invalidateGrid();
|
|
54
|
+
}));
|
|
55
|
+
|
|
56
|
+
this.dirty = true;
|
|
57
|
+
this.invalidateGrid();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
protected getMonomerLib(): IMonomerLibBase {
|
|
61
|
+
return this.tableCol.temp[MmcrTemps.overriddenLibrary] ?? this.sysMonomerLib;
|
|
62
|
+
}
|
|
63
|
+
|
|
38
64
|
protected override reset(): void {
|
|
39
65
|
const logPrefix = `${this.toLog()}.reset()`;
|
|
40
66
|
this.logger.debug(`${logPrefix}, start`);
|
|
41
67
|
super.reset();
|
|
42
68
|
this._auxList = new Array<HelmAux | null>(this.tableCol.length).fill(null);
|
|
43
|
-
|
|
69
|
+
this.invalidateGrid();
|
|
44
70
|
this.logger.debug(`${logPrefix}, end`);
|
|
45
71
|
}
|
|
46
72
|
|
|
47
|
-
protected override getRenderService(): RenderServiceBase<HelmProps, HelmAux> {
|
|
48
|
-
return
|
|
73
|
+
protected override getRenderService(): RenderServiceBase<HelmProps, HelmAux> | null {
|
|
74
|
+
return this.helmRenderService;
|
|
49
75
|
}
|
|
50
76
|
|
|
51
77
|
protected override getRenderTaskProps(
|
|
52
78
|
gridCell: DG.GridCell, backColor: number, width: number, height: number,
|
|
53
79
|
): HelmProps {
|
|
54
|
-
|
|
80
|
+
const monomerLib = this.getMonomerLib();
|
|
81
|
+
return new HelmProps(gridCell.cell.value, monomerLib, backColor, width, height);
|
|
55
82
|
}
|
|
56
83
|
|
|
57
84
|
protected override storeAux(gridCell: DG.GridCell, aux: HelmAux): void {
|
|
@@ -133,7 +160,7 @@ export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProp
|
|
|
133
160
|
let seqMonomer: ISeqMonomer | null = null;
|
|
134
161
|
if (hoveredAtom) {
|
|
135
162
|
seqMonomer = getSeqMonomerFromHelmAtom(hoveredAtom);
|
|
136
|
-
const monomerLib = _package.monomerLib;
|
|
163
|
+
const monomerLib = this.tableCol.temp[MmcrTemps.overriddenLibrary] ?? _package.monomerLib;
|
|
137
164
|
const tooltipEl = monomerLib ? monomerLib.getTooltip(seqMonomer.biotype, seqMonomer.symbol) :
|
|
138
165
|
ui.divText('Monomer library is not available');
|
|
139
166
|
ui.tooltip.show(tooltipEl, e.x + 16, e.y + 16);
|
|
@@ -149,30 +176,23 @@ export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProp
|
|
|
149
176
|
execMonomerHoverLinks(gridCell, null);
|
|
150
177
|
}
|
|
151
178
|
|
|
152
|
-
public override render(g: CanvasRenderingContext2D,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (this.monomerLib)
|
|
158
|
-
this.subs.push(this.monomerLib.onChanged.subscribe(this.monomerLibOnChanged.bind(this)));
|
|
159
|
-
}
|
|
160
|
-
super.render(g, x, y, w, h, gridCell, cellStyle);
|
|
161
|
-
}
|
|
179
|
+
// public override render(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number,
|
|
180
|
+
// gridCell: DG.GridCell, cellStyle: DG.GridCellStyle
|
|
181
|
+
// ) {
|
|
182
|
+
// super.render(g, x, y, w, h, gridCell, cellStyle);
|
|
183
|
+
// }
|
|
162
184
|
|
|
163
185
|
// -- Handle events --
|
|
164
186
|
|
|
165
|
-
private monomerLibOnChanged(_value: any): void {
|
|
166
|
-
this.dirty = true;
|
|
167
|
-
this.invalidateGrid();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
187
|
static getOrCreate(gridCell: DG.GridCell): HelmGridCellRendererBack {
|
|
171
188
|
const [gridCol, tableCol, temp] =
|
|
172
189
|
getGridCellColTemp<string, HelmGridCellRendererBack>(gridCell);
|
|
173
190
|
|
|
174
191
|
let res: HelmGridCellRendererBack = temp.rendererBack;
|
|
175
|
-
if (!res)
|
|
192
|
+
if (!res) {
|
|
193
|
+
res = temp.rendererBack = new HelmGridCellRendererBack(gridCol, tableCol);
|
|
194
|
+
res.init().then(() => {});
|
|
195
|
+
}
|
|
176
196
|
return res;
|
|
177
197
|
}
|
|
178
198
|
}
|
|
@@ -4,8 +4,9 @@ import * as DG from 'datagrok-api/dg';
|
|
|
4
4
|
|
|
5
5
|
import $ from 'cash-dom';
|
|
6
6
|
import {Subject, Unsubscribable} from 'rxjs';
|
|
7
|
+
import {LRUCache} from 'lru-cache';
|
|
7
8
|
|
|
8
|
-
import {HelmEditor, HelmType,
|
|
9
|
+
import {HelmEditor, HelmType, IHelmEditorOptions} from '@datagrok-libraries/bio/src/helm/types';
|
|
9
10
|
import {RenderTask} from '@datagrok-libraries/bio/src/utils/cell-renderer-async-base';
|
|
10
11
|
import {HelmAux, HelmProps, HelmServiceBase} from '@datagrok-libraries/bio/src/viewers/helm-service';
|
|
11
12
|
import {svgToImage} from '@datagrok-libraries/utils/src/svg';
|
|
@@ -19,7 +20,9 @@ declare const JSDraw2: JSDraw2Module;
|
|
|
19
20
|
export class HelmService extends HelmServiceBase {
|
|
20
21
|
private readonly hostDiv: HTMLDivElement;
|
|
21
22
|
|
|
22
|
-
private
|
|
23
|
+
private readonly editorLruCache: LRUCache<string, HelmEditor>;
|
|
24
|
+
|
|
25
|
+
// private editor!: HelmEditor;
|
|
23
26
|
private image: HTMLImageElement | null = null;
|
|
24
27
|
|
|
25
28
|
constructor() {
|
|
@@ -34,27 +37,43 @@ export class HelmService extends HelmServiceBase {
|
|
|
34
37
|
this.hostDiv.style.height = '0px';
|
|
35
38
|
this.hostDiv.style.visibility = 'hidden';
|
|
36
39
|
document.body.appendChild(this.hostDiv);
|
|
40
|
+
|
|
41
|
+
this.editorLruCache = new LRUCache<string, HelmEditor>({max: 20});
|
|
37
42
|
}
|
|
38
43
|
|
|
39
44
|
protected override toLog(): string {
|
|
40
45
|
return `Helm: ${super.toLog()}`;
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
private getEditor(props: HelmProps): HelmEditor {
|
|
49
|
+
const editorKey = props.monomerLib.source;
|
|
50
|
+
|
|
51
|
+
let resEditor: HelmEditor | undefined = this.editorLruCache.get(editorKey);
|
|
52
|
+
if (!resEditor) {
|
|
53
|
+
const getMonomerFuncs = _package.helmHelper.buildMonomersFuncsFromLib(props.monomerLib);
|
|
54
|
+
resEditor = new JSDraw2.Editor<HelmType, IHelmEditorOptions>(this.hostDiv, {
|
|
55
|
+
width: props.width, height: props.height, skin: 'w8', viewonly: true,
|
|
56
|
+
drawOptions: {getMonomer: getMonomerFuncs.getMonomer},
|
|
57
|
+
});
|
|
58
|
+
this.editorLruCache.set(editorKey, resEditor);
|
|
59
|
+
}
|
|
60
|
+
return resEditor;
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
protected override async requestRender(
|
|
44
64
|
key: keyof any | undefined, task: RenderTask<HelmProps, HelmAux>, renderHandler: (aux: HelmAux) => void
|
|
45
65
|
): Promise<[Unsubscribable, number, () => void]> {
|
|
46
66
|
const logPrefix = `${this.toLog()}.requestRender()`;
|
|
47
67
|
this.logger.debug(`${logPrefix}, start, ` + `key: ${key?.toString()}`);
|
|
48
68
|
const emptyCanvasHash: number = 0;
|
|
69
|
+
const monomerLib = task.props.monomerLib;
|
|
70
|
+
|
|
71
|
+
const editor = this.getEditor(task.props);
|
|
49
72
|
|
|
50
|
-
if (!this.editor) {
|
|
51
|
-
this.editor = new JSDraw2.Editor<HelmType, IHelmDrawOptions>(this.hostDiv,
|
|
52
|
-
{width: task.props.width, height: task.props.height, skin: 'w8', viewonly: true});
|
|
53
|
-
}
|
|
54
73
|
const lST = window.performance.now();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
74
|
+
editor.options.width = task.props.width;
|
|
75
|
+
editor.options.height = task.props.height;
|
|
76
|
+
editor.resize(task.props.width, task.props.height);
|
|
58
77
|
const helmStr = task.props.helm;
|
|
59
78
|
if (helmStr) {
|
|
60
79
|
// getMonomerOverrideAndLogAlert(
|
|
@@ -65,14 +84,14 @@ export class HelmService extends HelmServiceBase {
|
|
|
65
84
|
// this.editor.setData(helmStr, 'helm');
|
|
66
85
|
// }, this.logger);
|
|
67
86
|
this.logger.debug(`${logPrefix}, editor.setData( '${helmStr}' )`);
|
|
68
|
-
|
|
87
|
+
editor.setData(helmStr, 'helm');
|
|
69
88
|
}
|
|
70
89
|
if (!helmStr)
|
|
71
|
-
|
|
90
|
+
editor.reset();
|
|
72
91
|
|
|
73
|
-
const bBox = (
|
|
92
|
+
const bBox = (editor.div.children[0] as SVGSVGElement).getBBox();
|
|
74
93
|
const aux: HelmAux = {
|
|
75
|
-
mol:
|
|
94
|
+
mol: editor.m.clone(false),
|
|
76
95
|
bBox: new DG.Rect(bBox.x, bBox.y, bBox.width + 2, bBox.height + 2) /* adjust for clipping right/bottom */,
|
|
77
96
|
cBox: new DG.Rect(0, 0, task.props.width, task.props.height),
|
|
78
97
|
};
|
|
@@ -7,7 +7,7 @@ import {fromEvent, Observable, Unsubscribable} from 'rxjs';
|
|
|
7
7
|
|
|
8
8
|
import {IMonomerLibBase} from '@datagrok-libraries/bio/src/types/index';
|
|
9
9
|
import {HelmInputBase, IHelmHelper, IHelmInputInitOptions} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
10
|
-
import {HelmAtom, HelmMol, HelmString, IHelmWebEditor} from '@datagrok-libraries/bio/src/helm/types';
|
|
10
|
+
import {HelmAtom, HelmMol, HelmString, IHelmEditorOptions, IHelmWebEditor} from '@datagrok-libraries/bio/src/helm/types';
|
|
11
11
|
|
|
12
12
|
import {defaultErrorHandler} from '../utils/err-info';
|
|
13
13
|
import {getHoveredMonomerFromEditorMol, getSeqMonomerFromHelmAtom} from '../utils/get-hovered';
|
|
@@ -86,7 +86,7 @@ export class HelmInput extends HelmInputBase {
|
|
|
86
86
|
style: {width: '100%', height: '100%', overflow: 'hidden'},
|
|
87
87
|
});
|
|
88
88
|
this.viewer = this.helmHelper.createHelmWebEditor(this.viewerHost, {
|
|
89
|
-
monomerNumbering: MonomerNumberingTypes.continuous
|
|
89
|
+
drawOptions: {monomerNumbering: MonomerNumberingTypes.continuous},
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
this.editHintDiv = ui.divH([
|
|
@@ -4,12 +4,14 @@ import * as DG from 'datagrok-api/dg';
|
|
|
4
4
|
|
|
5
5
|
import $ from 'cash-dom';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {ISeqHandler} from '@datagrok-libraries/bio/src/utils/macromolecule/seq-handler';
|
|
8
8
|
import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
9
9
|
|
|
10
10
|
import {JSDraw2Module} from '../types';
|
|
11
11
|
import {removeGapsFromHelm} from '../utils';
|
|
12
12
|
|
|
13
|
+
import {_package} from '../package';
|
|
14
|
+
|
|
13
15
|
declare const JSDraw2: JSDraw2Module;
|
|
14
16
|
|
|
15
17
|
export class SeqPropertiesError extends Error {
|
|
@@ -18,7 +20,7 @@ export class SeqPropertiesError extends Error {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
export function getPropertiesDict(seq: string, sh:
|
|
23
|
+
export function getPropertiesDict(seq: string, sh: ISeqHandler): {} {
|
|
22
24
|
const host = ui.div([], {style: {width: '0', height: '0'}});
|
|
23
25
|
document.documentElement.appendChild(host);
|
|
24
26
|
try {
|
|
@@ -48,7 +50,7 @@ export function getPropertiesDict(seq: string, sh: SeqHandler): {} {
|
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
export function getPropertiesWidget(value: DG.SemanticValue<string>): DG.Widget {
|
|
51
|
-
const sh =
|
|
53
|
+
const sh = _package.seqHelper.getSeqHandler(value.cell.column as DG.Column<string>);
|
|
52
54
|
try {
|
|
53
55
|
const propDict = getPropertiesDict(value.value, sh);
|
|
54
56
|
return new DG.Widget(
|