@datagrok/helm 2.5.7 → 2.5.9

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@datagrok/helm",
3
3
  "friendlyName": "Helm",
4
- "version": "2.5.7",
4
+ "version": "2.5.9",
5
5
  "author": {
6
6
  "name": "Aleksandr Tanas",
7
7
  "email": "atanas@datagrok.ai"
@@ -16,9 +16,9 @@
16
16
  "css/helm.css"
17
17
  ],
18
18
  "dependencies": {
19
- "@datagrok-libraries/bio": "^5.45.5",
19
+ "@datagrok-libraries/bio": "^5.45.7",
20
20
  "@datagrok-libraries/chem-meta": "^1.2.7",
21
- "@datagrok-libraries/utils": "^4.3.6",
21
+ "@datagrok-libraries/utils": "^4.3.7",
22
22
  "cash-dom": "^8.1.1",
23
23
  "datagrok-api": "^1.21.1",
24
24
  "dayjs": "^1.10.6",
@@ -27,9 +27,9 @@
27
27
  "wu": "^2.1.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@datagrok-libraries/helm-web-editor": "^1.1.12",
31
- "@datagrok-libraries/js-draw-lite": "^0.0.9",
32
- "@datagrok/bio": "^2.16.6",
30
+ "@datagrok-libraries/helm-web-editor": "^1.1.13",
31
+ "@datagrok-libraries/js-draw-lite": "^0.0.10",
32
+ "@datagrok/bio": "^2.16.8",
33
33
  "@datagrok/chem": "^1.12.3",
34
34
  "@types/node": "17.0.45",
35
35
  "@types/webpack-env": "^1.18.5",
@@ -6,9 +6,9 @@ import $ from 'cash-dom';
6
6
 
7
7
  /* eslint-disable max-len */
8
8
  import {
9
- App, Point, HelmAtom, HelmBond, HelmMol, HelmType, GetMonomerFunc, GetMonomerResType,
9
+ App, Point, HelmType, IHelmBio, HelmAtom, HelmBond, HelmMol, GetMonomerFunc, GetMonomerResType,
10
10
  MonomerExplorer, TabDescType, MonomersFuncs, MonomerSetType, ISeqMonomer, PolymerType, MonomerType,
11
- DojoType, JSDraw2ModuleType, IHelmEditorOptions, IHelmDrawOptions
11
+ DojoType, JSDraw2ModuleType, IHelmEditorOptions, IHelmDrawOptions,
12
12
  } from '@datagrok-libraries/bio/src/helm/types';
13
13
  import {HelmTabKeys, HelmTypes, MonomerTypes, PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
14
14
  import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
@@ -344,7 +344,7 @@ export class HelmHelper implements IHelmHelper {
344
344
  }
345
345
 
346
346
  public parse(helm: string, origin?: Point): HelmMol {
347
- const molHandler = new JSDraw2.MolHandler<HelmType, IHelmEditorOptions>();
347
+ const molHandler = new JSDraw2.MolHandler<HelmType, IHelmBio, IHelmEditorOptions>();
348
348
  const plugin = new org.helm.webeditor.Plugin(molHandler);
349
349
  org.helm.webeditor.IO.parseHelm(plugin, helm, origin ?? new JSDraw2.Point(0, 0));
350
350
  return plugin.jsd.m;
@@ -401,7 +401,7 @@ export class HelmHelper implements IHelmHelper {
401
401
 
402
402
  for (let aI: number = 0; aI < mol.atoms.length; ++aI) {
403
403
  const a: HelmAtom = mol.atoms[aI];
404
- monomerMap.set(parseInt(a.bio!.continuousId as string) - 1, aI);
404
+ monomerMap.set(a.bio!.continuousId - 1, aI);
405
405
  }
406
406
 
407
407
  const resHelm = org.helm.webeditor.IO.getHelm(mol)!;
@@ -207,7 +207,7 @@ export const helmJsonReplacer = (key: string, value: any): any => {
207
207
  export class HelmPackage extends DG.Package {
208
208
  public alertOriginal: ((s: string) => void) | null = null;
209
209
 
210
- private _helmHelper: IHelmHelper;
210
+ private _helmHelper?: IHelmHelper;
211
211
  public get helmHelper(): IHelmHelper {
212
212
  if (!this._helmHelper)
213
213
  throw new Error('Package Helm .helmHelper is not initialized');
@@ -215,7 +215,7 @@ export class HelmPackage extends DG.Package {
215
215
  };
216
216
 
217
217
  public get seqHelper(): ISeqHelper {
218
- return this._helmHelper.seqHelper;
218
+ return this.helmHelper!.seqHelper;
219
219
  }
220
220
 
221
221
  public _libHelper!: IMonomerLibHelper;
package/src/package.ts CHANGED
@@ -18,6 +18,7 @@ import {getPropertiesWidget} from './widgets/properties-widget';
18
18
  import {HelmGridCellRenderer, HelmGridCellRendererBack} from './utils/helm-grid-cell-renderer';
19
19
  import {_getHelmService, HelmPackage} from './package-utils';
20
20
  import {HelmHelper} from './helm-helper';
21
+ import {getRdKitModule} from '@datagrok-libraries/bio/src/chem/rdkit-module';
21
22
 
22
23
  // Do not import anything than types from @datagrok/helm-web-editor/src/types
23
24
  import type {JSDraw2Module, OrgHelmModule, ScilModule} from './types';
@@ -51,11 +52,11 @@ async function initHelmInt(): Promise<void> {
51
52
  _package.logger.debug(`${logPrefix}, start`);
52
53
 
53
54
  try {
54
- const [_, seqHelper, libHelper] = await Promise.all([
55
- _package.initHELMWebEditor(),
56
- getSeqHelper(),
57
- getMonomerLibHelper(),
58
- ]);
55
+ // order of things is very important
56
+ await getRdKitModule();
57
+ const seqHelper = await getSeqHelper();
58
+ const libHelper = await getMonomerLibHelper();
59
+ await _package.initHELMWebEditor();
59
60
  const helmHelper: IHelmHelper = new HelmHelper(seqHelper, _package.logger);
60
61
  _package.completeInit(helmHelper, libHelper);
61
62
  } catch (err: any) {
@@ -9,7 +9,7 @@ import {
9
9
  } from '@datagrok-libraries/utils/src/test';
10
10
  import {getHelmHelper, getMonomerHandleArgs} from '@datagrok-libraries/bio/src/helm/helm-helper';
11
11
  import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
12
- import {Atom, HelmType, IJsAtom, GetMonomerFunc} from '@datagrok-libraries/bio/src/helm/types';
12
+ import {Atom, HelmType, IJsAtom, GetMonomerFunc, HelmAtom} from '@datagrok-libraries/bio/src/helm/types';
13
13
  import {MonomerLibSummaryType} from '@datagrok-libraries/bio/src/types';
14
14
  import {IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
15
15
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
@@ -138,7 +138,7 @@ category('getMonomer', ()=>{
138
138
  }
139
139
 
140
140
  for (const [[testName, testData], testI] of wu.enumerate(Object.entries(tests))) {
141
- const a: Atom<HelmType> | HelmType = getAtomFromJson(testData.args.a);
141
+ const a: HelmAtom | HelmType = getAtomFromJson(testData.args.a);
142
142
  const [biotype, elem] = getMonomerHandleArgs(a, testData.args.name);
143
143
  const tgt = testData.tgt;
144
144
 
@@ -173,8 +173,8 @@ category('getMonomer', ()=>{
173
173
  });
174
174
  });
175
175
 
176
- function getAtomFromJson(argA: IJsAtom<HelmType> | HelmType): Atom<HelmType> | HelmType {
177
- let res: Atom<HelmType> | HelmType;
176
+ function getAtomFromJson(argA: IJsAtom<HelmType> | HelmType): HelmAtom | HelmType {
177
+ let res: HelmAtom | HelmType;
178
178
  const a = argA as IJsAtom<HelmType>;
179
179
  if (a.T === 'ATOM')
180
180
  res = new JSDraw2.Atom(a.p, a.elem, a.bio);
@@ -4,7 +4,7 @@ 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, IHelmEditorOptions, Mol, OrgType} from '@datagrok-libraries/bio/src/helm/types';
7
+ import {HelmMol, HelmType, IHelmBio, 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 {
@@ -104,13 +104,13 @@ function _testParseHelmWithEditor(src: string, tgt: TestTgtType): void {
104
104
  const io = org.helm.webeditor.IO;
105
105
 
106
106
  const editorHost = ui.div();
107
- const editor = new JSDraw2.Editor<HelmType, IHelmEditorOptions>(editorHost, {viewonly: true});
107
+ const editor = new JSDraw2.Editor<HelmType, IHelmBio, IHelmEditorOptions>(editorHost, {viewonly: true});
108
108
 
109
109
  const plugin = new org.helm.webeditor.Plugin(editor);
110
110
  const origin = new JSDraw2.Point(0, 0);
111
111
  io.parseHelm(plugin, src, origin, undefined);
112
112
 
113
- const m: Mol<HelmType> = plugin.jsd.m;
113
+ const m: HelmMol = plugin.jsd.m;
114
114
  expect(m.atoms.length, tgt.atomCount);
115
115
  expect(m.bonds.length, tgt.bondCount);
116
116
  }
@@ -132,13 +132,13 @@ function _testParseHelmWithHelmHelper(src: string, tgt: TestTgtType, helmHelper:
132
132
  function _testParseHelmWithoutDOM(src: string, tgt: TestTgtType): void {
133
133
  const io = org.helm.webeditor.IO;
134
134
 
135
- const molHandler = new JSDraw2.MolHandler<HelmType, IHelmEditorOptions>();
135
+ const molHandler = new JSDraw2.MolHandler<HelmType, IHelmBio, IHelmEditorOptions>();
136
136
 
137
137
  const plugin = new org.helm.webeditor.Plugin(molHandler);
138
138
  const origin = new JSDraw2.Point(0, 0);
139
139
  io.parseHelm(plugin, src, origin, undefined);
140
140
 
141
- const m: Mol<HelmType> = plugin.jsd.m;
141
+ const m: HelmMol = plugin.jsd.m;
142
142
  const resHelm = io.getHelm(m);
143
143
  expect(m.atoms.length, tgt.atomCount);
144
144
  expect(m.bonds.length, tgt.bondCount);
@@ -8,6 +8,7 @@ import {helmTypeToPolymerType} from '@datagrok-libraries/bio/src/monomer-works/m
8
8
 
9
9
  import {HelmTypes} from '@datagrok-libraries/bio/src/helm/consts';
10
10
  import {GAP_SYMBOL, GapOriginals, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule/consts';
11
+ import {SeqValueBase} from '@datagrok-libraries/bio/src/utils/macromolecule/seq-handler';
11
12
 
12
13
  export function getHoveredMonomerFromEditorMol(
13
14
  argsX: number, argsY: number, mol: HelmMol, cellHeight?: number
@@ -47,9 +48,11 @@ export function getHoveredMonomerFromEditorMol(
47
48
  return resAtom;
48
49
  }
49
50
 
50
- export function getSeqMonomerFromHelmAtom(atom: HelmAtom): ISeqMonomer {
51
- const canonicalSymbol = atom.elem === GapOriginals[NOTATION.HELM] ? GAP_SYMBOL : atom.elem;
52
- return {position: parseInt(atom.bio!.continuousId as string) - 1, symbol: canonicalSymbol, biotype: atom.bio!.type};
51
+ export function getSeqMonomerFromHelmAtom(seqValue: SeqValueBase, atom: HelmAtom): ISeqMonomer {
52
+ const pos: number = atom.bio!.continuousId - 1;
53
+ const canonicalSymbol = seqValue.getSplitted().getCanonical(pos);
54
+ // const canonicalSymbol = atom.elem === GapOriginals[NOTATION.HELM] ? GAP_SYMBOL : atom.elem;
55
+ return {position: atom.bio!.continuousId - 1, symbol: canonicalSymbol, biotype: atom.bio!.type};
53
56
  }
54
57
 
55
58
  /** Linear
@@ -4,7 +4,7 @@ import * as DG from 'datagrok-api/dg';
4
4
 
5
5
  import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';
6
6
  import {IMonomerLib, Monomer} from '@datagrok-libraries/bio/src/types';
7
- import {Atom, HelmType, IWebEditorMonomer, GetMonomerResType} from '@datagrok-libraries/bio/src/helm/types';
7
+ import {Atom, HelmType, IWebEditorMonomer, GetMonomerResType, IHelmBio, HelmAtom} from '@datagrok-libraries/bio/src/helm/types';
8
8
 
9
9
  import {OrgHelmModule, ScilModule} from '../types';
10
10
  import {RGROUP_CAP_GROUP_NAME, RGROUP_LABEL, SMILES} from '../constants';
@@ -15,8 +15,8 @@ declare const org: OrgHelmModule;
15
15
  declare const scil: ScilModule;
16
16
 
17
17
  type GetMonomerOverridingFunc = (
18
- a: Atom<HelmType> | HelmType, name: string | undefined, monomerLib: IMonomerLib,
19
- originalGetMonomer: (a: Atom<HelmType> | HelmType, name: string) => GetMonomerResType) => GetMonomerResType;
18
+ a: HelmAtom | HelmType, name: string | undefined, monomerLib: IMonomerLib,
19
+ originalGetMonomer: (a: HelmAtom | HelmType, name: string) => GetMonomerResType) => GetMonomerResType;
20
20
 
21
21
  export function getMonomerOverrideAndLogAlert(
22
22
  monomerLib: IMonomerLib, getMonomerOverriding: GetMonomerOverridingFunc, trigger: () => void, logger: ILogger,
@@ -27,7 +27,7 @@ export function getMonomerOverrideAndLogAlert(
27
27
  const alertOriginal = scil.Utils.alert;
28
28
  try {
29
29
  org.helm.webeditor.Monomers.getMonomer =
30
- (a: Atom<HelmType> | HelmType, name?: string): GetMonomerResType => {
30
+ (a: HelmAtom | HelmType, name?: string): GetMonomerResType => {
31
31
  return getMonomerOverriding(a, name, monomerLib, getMonomerOriginal);
32
32
  };
33
33
  // Preventing alert message box for missing monomers with compressed Scilligence.JSDraw2.Lite.js
@@ -4,7 +4,7 @@ import * as ui from 'datagrok-api/ui';
4
4
 
5
5
  import wu from 'wu';
6
6
 
7
- import {HelmType, ISeqMonomer, Mol} from '@datagrok-libraries/bio/src/helm/types';
7
+ import {HelmType, IHelmBio, 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';
@@ -16,6 +16,7 @@ import {getMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/mon
16
16
  import {IMonomerLibBase} from '@datagrok-libraries/bio/src/types/index';
17
17
  import {execMonomerHoverLinks} from '@datagrok-libraries/bio/src/monomer-works/monomer-hover';
18
18
  import {MmcrTemps} from '@datagrok-libraries/bio/src/utils/cell-renderer-consts';
19
+ import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
19
20
 
20
21
  import {getHoveredMonomerFromEditorMol, getSeqMonomerFromHelmAtom} from './get-hovered';
21
22
 
@@ -25,6 +26,7 @@ export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProp
25
26
  private _auxList: (HelmAux | null)[];
26
27
 
27
28
  private sysMonomerLib: IMonomerLibBase | null = null;
29
+ private helmHelper: IHelmHelper | null = null;
28
30
  private helmRenderService: HelmServiceBase | null = null;
29
31
 
30
32
  // eslint-disable-next-line max-len
@@ -43,6 +45,9 @@ export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProp
43
45
  const libHelper = await getMonomerLibHelper();
44
46
  this.sysMonomerLib = libHelper.getMonomerLib();
45
47
  })(),
48
+ (async () => {
49
+ this.helmHelper = await getHelmHelper();
50
+ })(),
46
51
  (async () => {
47
52
  this.helmRenderService = await getHelmService();
48
53
  })(),
@@ -167,7 +172,7 @@ export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProp
167
172
  const bX = aux.bBox.x + (cX - aux.dBox.x) * aux.bBox.width / aux.dBox.width;
168
173
  const bY = aux.bBox.y + (cY - aux.dBox.y) * aux.bBox.height / aux.dBox.height;
169
174
 
170
- const editorMol: Mol<HelmType> | null = aux.mol; // in bBox world
175
+ const editorMol: Mol<HelmType, IHelmBio> | null = aux.mol; // in bBox world
171
176
  if (!editorMol) {
172
177
  this.logger.warning(`${logPrefix}, editorMol of the cell not found.`);
173
178
  return; // The gridCell is not rendered yet
@@ -175,8 +180,10 @@ export class HelmGridCellRendererBack extends CellRendererBackAsyncBase<HelmProp
175
180
  const hoveredAtom = getHoveredMonomerFromEditorMol(bX, bY, editorMol, gridCell.bounds.height);
176
181
 
177
182
  let seqMonomer: ISeqMonomer | null = null;
178
- if (hoveredAtom) {
179
- seqMonomer = getSeqMonomerFromHelmAtom(hoveredAtom);
183
+ if (hoveredAtom && this.helmHelper && gridCell.tableRowIndex != null) {
184
+ const seqHandler = this.helmHelper.seqHelper.getSeqHandler(this.tableCol);
185
+ const seqValue = seqHandler.getValue(gridCell.tableRowIndex);
186
+ seqMonomer = getSeqMonomerFromHelmAtom(seqValue, hoveredAtom);
180
187
  const monomerLib = this.tableCol.temp[MmcrTemps.overriddenLibrary] ?? _package.monomerLib;
181
188
  const tooltipEl = monomerLib ? monomerLib.getTooltip(seqMonomer.biotype, seqMonomer.symbol) :
182
189
  ui.divText('Monomer library is not available');
@@ -5,7 +5,7 @@ import $ from 'cash-dom';
5
5
  import {Subject, Unsubscribable} from 'rxjs';
6
6
  import {LRUCache} from 'lru-cache';
7
7
 
8
- import {HelmEditor, HelmType, IHelmEditorOptions} from '@datagrok-libraries/bio/src/helm/types';
8
+ import {HelmEditor, HelmType, IHelmBio, IHelmEditorOptions} from '@datagrok-libraries/bio/src/helm/types';
9
9
  import {RenderTask} from '@datagrok-libraries/bio/src/utils/cell-renderer-async-base';
10
10
  import {HelmAux, HelmProps, HelmServiceBase} from '@datagrok-libraries/bio/src/viewers/helm-service';
11
11
  import {svgToImage} from '@datagrok-libraries/utils/src/svg';
@@ -49,8 +49,8 @@ export class HelmService extends HelmServiceBase {
49
49
 
50
50
  let resEditor: HelmEditor | undefined = this.editorLruCache.get(editorKey);
51
51
  if (!resEditor) {
52
- const getMonomerFuncs = _package.helmHelper.buildMonomersFuncsFromLib(props.monomerLib);
53
- resEditor = new JSDraw2.Editor<HelmType, IHelmEditorOptions>(this.hostDiv, {
52
+ const getMonomerFuncs = _package.helmHelper.buildMonomersFuncsFromLib(props.monomerLib, );
53
+ resEditor = new JSDraw2.Editor<HelmType, IHelmBio, IHelmEditorOptions>(this.hostDiv, {
54
54
  width: props.width, height: props.height, skin: 'w8', viewonly: true,
55
55
  drawOptions: {getMonomer: getMonomerFuncs.getMonomer},
56
56
  });
@@ -8,11 +8,13 @@ import {fromEvent, Observable, Unsubscribable} from 'rxjs';
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
10
  import {HelmAtom, HelmMol, HelmString, IHelmEditorOptions, IHelmWebEditor} from '@datagrok-libraries/bio/src/helm/types';
11
+ import {SeqValueBase} from '@datagrok-libraries/bio/src/utils/macromolecule/seq-handler';
12
+ import {MonomerNumberingTypes} from '@datagrok-libraries/bio/src/helm/consts';
13
+ import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
11
14
 
12
15
  import {defaultErrorHandler} from '../utils/err-info';
13
16
  import {getHoveredMonomerFromEditorMol, getSeqMonomerFromHelmAtom} from '../utils/get-hovered';
14
17
 
15
- import {MonomerNumberingTypes} from '@datagrok-libraries/bio/src/helm/consts';
16
18
 
17
19
  import {_package} from '../package';
18
20
 
@@ -31,20 +33,27 @@ export class HelmInput extends HelmInputBase {
31
33
  return this.viewerHost;
32
34
  }
33
35
 
34
- getValue(): HelmString {
35
- return this.viewer.editor.getHelm();
36
- }
36
+ private _seqValue: SeqValueBase;
37
37
 
38
- setValue(value: HelmString): void {
39
- this.viewer.editor.setHelm(value);
40
- }
38
+ getValue(): SeqValueBase { return this._seqValue; }
41
39
 
42
- getStringValue(): string {
43
- return this.viewer.editor.getHelm();
40
+ setValue(value: SeqValueBase): void {
41
+ this._seqValue = value;
42
+ this.viewer.editor.setHelm(this._seqValue.helm);
44
43
  }
45
44
 
45
+ getStringValue(): string { return this._seqValue?.helm ?? ''; }
46
+
46
47
  setStringValue(value: string): void {
47
- this.viewer.editor.setHelm(value);
48
+ if (!this._seqValue) {
49
+ let seqCol: DG.Column;
50
+ DG.DataFrame.fromColumns([seqCol = DG.Column.fromList(DG.COLUMN_TYPE.STRING, 'seq', [value])]);
51
+ seqCol.semType = DG.SEMTYPE.MACROMOLECULE;
52
+ seqCol.meta.units = NOTATION.HELM;
53
+ const sh = this.helmHelper.seqHelper.getSeqHandler(seqCol);
54
+ this._seqValue = sh.getValue(0);
55
+ }
56
+ this.viewer.editor.setHelm(this._seqValue.value = value);
48
57
  }
49
58
 
50
59
  // -- IHelmInput --
@@ -55,6 +64,7 @@ export class HelmInput extends HelmInputBase {
55
64
 
56
65
  set molValue(value: HelmMol) {
57
66
  this.viewer.editor.setMol(value);
67
+ this._seqValue.value = this.viewer.editor.getHelm();
58
68
  }
59
69
 
60
70
  get onMouseMove(): Observable<MouseEvent> { return fromEvent<MouseEvent>(this.viewer.host, 'mousemove'); }
@@ -85,9 +95,7 @@ export class HelmInput extends HelmInputBase {
85
95
  classes: 'ui-input-editor',
86
96
  style: {width: '100%', height: '100%', overflow: 'hidden'},
87
97
  });
88
- this.viewer = this.helmHelper.createHelmWebEditor(this.viewerHost, {
89
- drawOptions: {monomerNumbering: MonomerNumberingTypes.continuous},
90
- });
98
+ this.viewer = this.helmHelper.createHelmWebEditor(this.viewerHost, options?.editorOptions);
91
99
 
92
100
  this.editHintDiv = ui.divH([
93
101
  ui.link('Click to edit', () => { this.viewer.host.click(); }, undefined, {}),
@@ -140,16 +148,8 @@ export class HelmInput extends HelmInputBase {
140
148
  ): HelmInput {
141
149
  const input = new HelmInput(helmHelper, monomerLib, name, options);
142
150
  // TODO: Apply options
143
- const value: HelmMol | string | undefined = options?.value;
144
- if (value !== undefined) {
145
- if (value instanceof String || typeof value === 'string')
146
- input.stringValue = value as any as string;
147
- else if (typeof value === 'object' /* && value.T === 'MOL'*/)
148
- input.molValue = value;
149
- else
150
- throw new Error(`Unsupported value of type '${typeof value}'.`);
151
- }
152
-
151
+ if (options?.value != null)
152
+ input.value = options.value;
153
153
  return input;
154
154
  }
155
155
 
@@ -181,7 +181,7 @@ export class HelmInput extends HelmInputBase {
181
181
  const mol = this.viewer.editor.m;
182
182
  const hoveredAtom = getHoveredMonomerFromEditorMol(argsX, argsY, mol, this.viewer.editor.div.clientHeight);
183
183
  if (hoveredAtom) {
184
- const seqMonomer = getSeqMonomerFromHelmAtom(hoveredAtom);
184
+ const seqMonomer = getSeqMonomerFromHelmAtom(this.value, hoveredAtom);
185
185
  const monomerLib = _package.monomerLib;
186
186
  const tooltipEl = monomerLib ? monomerLib.getTooltip(seqMonomer.biotype, seqMonomer.symbol) :
187
187
  ui.divText('Monomer library is not available');