@datagrok/sequence-translator 1.6.3 → 1.6.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.
@@ -1,3 +1,5 @@
1
+ /* eslint-disable max-lines-per-function */
2
+ /* eslint-disable max-len */
1
3
  import * as ui from 'datagrok-api/ui';
2
4
  import * as grok from 'datagrok-api/grok';
3
5
  import * as DG from 'datagrok-api/dg';
@@ -11,7 +13,7 @@ import {getHelmHelper, HelmInputBase, IHelmHelper} from '@datagrok-libraries/bio
11
13
  import {getMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
12
14
  import {HelmType, PolymerType} from '@datagrok-libraries/bio/src/helm/types';
13
15
  import {helmTypeToPolymerType} from '@datagrok-libraries/bio/src/monomer-works/monomer-works';
14
- import {getSeqHelper, ISeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
16
+ import {getSeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
15
17
  import '@datagrok-libraries/bio/src/types/input';
16
18
  import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
17
19
  import {InputColumnBase} from '@datagrok-libraries/bio/src/types/input';
@@ -19,7 +21,7 @@ import {SeqValueBase} from '@datagrok-libraries/bio/src/utils/macromolecule/seq-
19
21
  import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
20
22
 
21
23
  import {PolyToolEnumeratorParams, PolyToolEnumeratorType, PolyToolEnumeratorTypes} from './types';
22
- import {getLibrariesList} from './utils';
24
+ import {getLibrariesList, LIB_PATH} from './utils';
23
25
  import {doPolyToolEnumerateHelm, PT_HELM_EXAMPLE} from './pt-enumeration-helm';
24
26
  import {PolyToolPlaceholdersInput} from './pt-placeholders-input';
25
27
  import {defaultErrorHandler} from '../utils/err-info';
@@ -31,11 +33,10 @@ import {Chain} from './conversion/pt-chain';
31
33
  import {polyToolConvert} from './pt-dialog';
32
34
 
33
35
  import {_package, applyNotationProviderForCyclized} from '../package';
34
- import {getUnusedColName} from '@datagrok-libraries/bio/src/monomer-works/utils';
35
36
  import {buildMonomerHoverLink} from '@datagrok-libraries/bio/src/monomer-works/monomer-hover';
36
- import {MmcrTemps} from '@datagrok-libraries/bio/src/utils/cell-renderer-consts';
37
37
  import {getRdKitModule} from '@datagrok-libraries/bio/src/chem/rdkit-module';
38
- import {PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
38
+
39
+ import {PolymerTypes} from '@datagrok-libraries/js-draw-lite/src/types/org';
39
40
 
40
41
  type PolyToolEnumerateInputs = {
41
42
  macromolecule: HelmInputBase;
@@ -48,11 +49,13 @@ type PolyToolEnumerateInputs = {
48
49
  generateHelm: DG.InputBase<boolean>;
49
50
  chiralityEngine: DG.InputBase<boolean>;
50
51
  highlightMonomers: DG.InputBase<boolean>;
52
+ library: DG.InputBase<string>;
51
53
  rules: { header: HTMLElement, form: HTMLDivElement },
52
54
  };
53
55
 
54
56
  type PolyToolEnumerateHelmSerialized = {
55
- macromolecule: string;
57
+ // macromolecule: string;
58
+ description?: string;
56
59
  placeholders: string;
57
60
  placeholdersBreadth: string;
58
61
  enumeratorType: PolyToolEnumeratorType;
@@ -63,6 +66,7 @@ type PolyToolEnumerateHelmSerialized = {
63
66
  chiralityEngine: boolean;
64
67
  highlightMonomers: boolean;
65
68
  rules: string[],
69
+ library: string;
66
70
  };
67
71
 
68
72
  export async function polyToolEnumerateHelmUI(cell?: DG.Cell): Promise<void> {
@@ -72,8 +76,9 @@ export async function polyToolEnumerateHelmUI(cell?: DG.Cell): Promise<void> {
72
76
  const maxHeight = window.innerHeight;
73
77
 
74
78
  try {
79
+ // eslint-disable-next-line prefer-const
75
80
  let dialog: DG.Dialog;
76
- const resizeInputs = () => {
81
+ function resizeInputs() {
77
82
  if (dialog == null) return;
78
83
 
79
84
  const dialogContentEl = $(dialog.root).find('div.d4-dialog-contents').get(0)! as HTMLElement;
@@ -101,10 +106,10 @@ export async function polyToolEnumerateHelmUI(cell?: DG.Cell): Promise<void> {
101
106
  let isFirstShow = true;
102
107
  ui.onSizeChanged(dialog.root).subscribe(() => {
103
108
  if (isFirstShow) {
104
- const dialogRootCash = $(dialog.root);
105
- const contentMaxHeight = maxHeight -
106
- dialogRootCash.find('div.d4-dialog-header').get(0)!.offsetHeight -
107
- dialogRootCash.find('div.d4-dialog-footer').get(0)!.offsetHeight;
109
+ // const dialogRootCash = $(dialog.root);
110
+ // const contentMaxHeight = maxHeight -
111
+ // dialogRootCash.find('div.d4-dialog-header').get(0)!.offsetHeight -
112
+ // dialogRootCash.find('div.d4-dialog-footer').get(0)!.offsetHeight;
108
113
 
109
114
  const dialogWidth = maxWidth * 0.7;
110
115
  const dialogHeight = maxHeight * 0.7;
@@ -123,7 +128,7 @@ export async function polyToolEnumerateHelmUI(cell?: DG.Cell): Promise<void> {
123
128
  resizeInputs();
124
129
 
125
130
  _package.logger.debug('PolyToolEnumerateHelmUI: dialog before show');
126
- const res = dialog.show({width: Math.max(350, maxWidth * 0.7), /* center: true,*/ resizable: true});
131
+ const _res = dialog.show({width: Math.max(350, maxWidth * 0.7), /* center: true,*/ resizable: true});
127
132
  _package.logger.debug('PolyToolEnumerateHelmUI: dialog after show');
128
133
  } catch (err: any) {
129
134
  const [errMsg, errStack] = errInfo(err);
@@ -138,6 +143,8 @@ async function getPolyToolEnumerateDialog(
138
143
  const logPrefix = `ST: PT: HelmDialog()`;
139
144
  let inputs: PolyToolEnumerateInputs;
140
145
  const subs: Unsubscribable[] = [];
146
+ // will store previous enumeration type to support logic of cleanups
147
+ let prevEnumerationType: PolyToolEnumeratorType = PolyToolEnumeratorTypes.Single;
141
148
  const destroy = () => {
142
149
  for (const sub of subs) sub.unsubscribe();
143
150
  inputs.placeholders.detach();
@@ -148,7 +155,7 @@ async function getPolyToolEnumerateDialog(
148
155
  const seqHelper = await getSeqHelper();
149
156
  const emptyDf: DG.DataFrame = DG.DataFrame.fromColumns([]);
150
157
 
151
- const [libList, helmHelper] = await Promise.all([getLibrariesList(), getHelmHelper()]);
158
+ const [_libList, helmHelper] = await Promise.all([getLibrariesList(), getHelmHelper()]);
152
159
  const monomerLibFuncs = helmHelper.buildMonomersFuncsFromLib(monomerLib);
153
160
 
154
161
  const getValue = (cell?: DG.Cell): [SeqValueBase, PolyToolDataRole] => {
@@ -175,6 +182,7 @@ async function getPolyToolEnumerateDialog(
175
182
  let ruleInputs: RuleInputs;
176
183
  const trivialNameSampleDiv = ui.divText('', {style: {marginLeft: '8px', marginTop: '2px'}});
177
184
  const warningsTextDiv = ui.divText('', {style: {color: 'red'}});
185
+ // #### Inputs
178
186
  inputs = {
179
187
  macromolecule: helmHelper.createHelmInput(
180
188
  'Macromolecule', {
@@ -187,8 +195,7 @@ async function getPolyToolEnumerateDialog(
187
195
  if (aa.T === 'ATOM') {
188
196
  const canonicalSymbol = seqValue.getSplitted().getCanonical(aa.bio!.continuousId - 1);
189
197
  return monomerLibFuncs.getMonomer(aa.bio!.type, canonicalSymbol);
190
- } else
191
- return monomerLibFuncs.getMonomer(a, name);
198
+ } else { return monomerLibFuncs.getMonomer(a, name); }
192
199
  },
193
200
  },
194
201
  }
@@ -202,7 +209,7 @@ async function getPolyToolEnumerateDialog(
202
209
  }),
203
210
  enumeratorType: ui.input.choice<PolyToolEnumeratorType>(
204
211
  'Enumerator type', {
205
- value: PolyToolEnumeratorTypes.Single,
212
+ value: prevEnumerationType,
206
213
  items: Object.values(PolyToolEnumeratorTypes)
207
214
  }) as DG.ChoiceInput<PolyToolEnumeratorType>,
208
215
  placeholdersBreadth: await PolyToolPlaceholdersBreadthInput.create(
@@ -246,14 +253,31 @@ async function getPolyToolEnumerateDialog(
246
253
  },
247
254
  nullable: true,
248
255
  }),
256
+ library: ui.input.choice('Monomer Library', {items: _libList, value: _libList[0], nullable: true}) as DG.InputBase<string>,
249
257
  };
250
-
258
+ // #### Inputs END
259
+ inputs.library.root.style.setProperty('display', 'none');
251
260
  inputs.trivialNameCol.addOptions(trivialNameSampleDiv);
252
261
 
253
262
  let placeholdersValidity: string | null = null;
254
263
  inputs.placeholders.addValidator((value: string): string | null => {
255
264
  const errors: string[] = [];
256
265
  try {
266
+ // for library, ony one placeholder is allowed
267
+ if (inputs.enumeratorType.value === PolyToolEnumeratorTypes.Library) {
268
+ setTimeout(() => { updateWarnings(); }, 10);
269
+ const pcs = inputs.placeholders.placeholdersValue;
270
+ if (pcs.length > 1)
271
+ return 'Only one placeholder is allowed for Library mode';
272
+ if (pcs.length === 1) {
273
+ if (pcs[0].position == null)
274
+ return 'Position is required for Library mode';
275
+ if (pcs[0].position > inputs.macromolecule.molValue.atoms.length)
276
+ return `There is no monomer at position ${pcs[0].position + 1}.`;
277
+ }
278
+ return null;
279
+ }
280
+
257
281
  if (dataRole !== PolyToolDataRole.macromolecule)
258
282
  return null;
259
283
 
@@ -349,6 +373,35 @@ async function getPolyToolEnumerateDialog(
349
373
  // return placeholdersValidity;
350
374
  // });
351
375
 
376
+ inputs.library.addValidator((_value) => {
377
+ if (inputs.enumeratorType.value === PolyToolEnumeratorTypes.Library && !inputs.library.value)
378
+ return 'Monomer Library is required for this enumerator type';
379
+ return null;
380
+ });
381
+
382
+ inputs.library.onChanged.subscribe(() => {
383
+ if (inputs.enumeratorType.value === PolyToolEnumeratorTypes.Library)
384
+ inputs.placeholders.setMonomersValue(0, inputs.library.value ?? '');
385
+ });
386
+
387
+ inputs.enumeratorType.onChanged.subscribe((_) => {
388
+ const isLibraryModeChosen = inputs.enumeratorType.value === PolyToolEnumeratorTypes.Library;
389
+ inputs.library.root.style.setProperty('display', isLibraryModeChosen ? 'flex' : 'none');
390
+ try {
391
+ if ((prevEnumerationType !== PolyToolEnumeratorTypes.Library && isLibraryModeChosen) || (prevEnumerationType === PolyToolEnumeratorTypes.Library && !isLibraryModeChosen)) {
392
+ const prevSinglePosition = inputs.placeholders.placeholdersValue.length === 1 ? inputs.placeholders.placeholdersValue[0].position : null;
393
+ // clear the placeHolders input and helm inputs if switching happened to/from Library mode
394
+ inputs.placeholders.clearInput();
395
+ inputs.placeholdersBreadth.clearInput();
396
+ if (isLibraryModeChosen && prevSinglePosition != null)
397
+ inputs.placeholders.addPosition(prevSinglePosition, inputs.library.value ?? '');
398
+ }
399
+ } catch (err: any) {
400
+ defaultErrorHandler(err, false);
401
+ }
402
+ prevEnumerationType = inputs.enumeratorType.value;
403
+ });
404
+
352
405
  subs.push(inputs.macromolecule.onMouseMove.subscribe((e: MouseEvent) => {
353
406
  try {
354
407
  _package.logger.debug(`${logPrefix}, placeholdersInput.onMouseMove()`);
@@ -384,7 +437,12 @@ async function getPolyToolEnumerateDialog(
384
437
  if (clickedAtom) {
385
438
  const clickedAtomContIdx = clickedAtom._parent.atoms.indexOf(clickedAtom);
386
439
  const clickedAtomContIdxStr = String(clickedAtomContIdx + 1);
387
- inputs.placeholders.addPosition(clickedAtomContIdx);
440
+ let monomerValue = '';
441
+ if (inputs.enumeratorType.value === PolyToolEnumeratorTypes.Library) {
442
+ inputs.placeholders.clearInput();
443
+ monomerValue = inputs.library.value ?? '';
444
+ }
445
+ inputs.placeholders.addPosition(clickedAtomContIdx, monomerValue);
388
446
  }
389
447
  } catch (err: any) {
390
448
  defaultErrorHandler(err);
@@ -485,11 +543,19 @@ async function getPolyToolEnumerateDialog(
485
543
  const helmSelections: number[] = wu.enumerate<HelmAtom>(inputs.macromolecule.molValue.atoms)
486
544
  .filter(([a, aI]) => a.highlighted)
487
545
  .map(([a, aI]) => aI).toArray();
546
+ if (inputs.enumeratorType.value === PolyToolEnumeratorTypes.Library) {
547
+ if (helmSelections.length === 0) {
548
+ grok.shell.warning('PolyTool: position for enumeration was not selected');
549
+ return;
550
+ }
551
+ if (!inputs.library.value) {
552
+ grok.shell.warning('PolyTool: No monomer library was selected');
553
+ return;
554
+ }
555
+ }
488
556
  if (srcHelm === undefined || srcHelm === '') {
489
557
  grok.shell.warning('PolyTool: no molecule was provided');
490
- } else /* if (helmSelections === undefined || helmSelections.length < 1) {
491
- grok.shell.warning('PolyTool: no selection was provided');
492
- } else /**/ {
558
+ } else {
493
559
  if (Object.keys(inputs.placeholders.placeholdersValue).length === 0 &&
494
560
  Object.keys(inputs.placeholdersBreadth.placeholdersBreadthValue).length === 0
495
561
  ) {
@@ -497,9 +563,28 @@ async function getPolyToolEnumerateDialog(
497
563
  return;
498
564
  }
499
565
  await getHelmHelper(); // initializes JSDraw and org
566
+
567
+ const placeHoldersValue = inputs.placeholders.placeholdersValue;
568
+ let enumerationType = inputs.enumeratorType.value;
569
+ if (enumerationType === PolyToolEnumeratorTypes.Library) {
570
+ if (placeHoldersValue.length !== 1) {
571
+ grok.shell.warning('Only one placeholder is allowed for Library mode');
572
+ return;
573
+ }
574
+ if (!placeHoldersValue[0].monomers || !_libList.includes(placeHoldersValue[0].monomers[0])) {
575
+ grok.shell.warning('Valid Monomer Library is required for this enumerator type');
576
+ return;
577
+ }
578
+ const monLibName = placeHoldersValue[0].monomers[0];
579
+ const monLib = await libHelper.readLibrary(LIB_PATH, monLibName);
580
+ const peptideMonomers = monLib.getMonomerSymbolsByType(PolymerTypes.PEPTIDE);
581
+ placeHoldersValue[0].monomers = peptideMonomers;
582
+ enumerationType = PolyToolEnumeratorTypes.Single;
583
+ }
584
+
500
585
  const params: PolyToolEnumeratorParams = {
501
- placeholders: inputs.placeholders.placeholdersValue,
502
- type: inputs.enumeratorType.value!,
586
+ placeholders: placeHoldersValue,
587
+ type: enumerationType,
503
588
  breadthPlaceholders: inputs.placeholdersBreadth.placeholdersBreadthValue,
504
589
  keepOriginal: inputs.keepOriginal.value,
505
590
  };
@@ -522,26 +607,26 @@ async function getPolyToolEnumerateDialog(
522
607
  const dialog = ui.dialog({title: PT_UI_DIALOG_ENUMERATION, showFooter: true})
523
608
  .add(inputs.macromolecule.root)
524
609
  .add(ui.divH([
525
- ui.divV([
526
- inputs.placeholders.root,
527
- inputs.enumeratorType.root,],
528
- {style: {width: '50%'}}
529
- ),
530
- ui.divV([
531
- inputs.placeholdersBreadth.root],
532
- {style: {width: '50%'}}),],
533
- {style: {width: '100%'}}))
610
+ ui.divV([
611
+ inputs.placeholders.root,
612
+ inputs.enumeratorType.root, inputs.library.root],
613
+ {style: {width: '50%'}}
614
+ ),
615
+ ui.divV([
616
+ inputs.placeholdersBreadth.root],
617
+ {style: {width: '50%'}})],
618
+ {style: {width: '100%'}}))
534
619
  .add(ui.divH([
535
- ui.divV([
536
- inputs.trivialNameCol.root,
537
- inputs.keepOriginal.root],
538
- {style: {width: '50%'}}),
539
- ui.divV([
540
- ui.divH([inputs.toAtomicLevel.root, inputs.generateHelm.root]),
541
- ui.divH([inputs.chiralityEngine.root, inputs.highlightMonomers.root]),
542
- inputs.rules.header, inputs.rules.form],
543
- {style: {width: '50%'}}),],
544
- {style: {width: '100%'}}))
620
+ ui.divV([
621
+ inputs.trivialNameCol.root,
622
+ inputs.keepOriginal.root],
623
+ {style: {width: '50%'}}),
624
+ ui.divV([
625
+ ui.divH([inputs.toAtomicLevel.root, inputs.generateHelm.root]),
626
+ ui.divH([inputs.chiralityEngine.root, inputs.highlightMonomers.root]),
627
+ inputs.rules.header, inputs.rules.form],
628
+ {style: {width: '50%'}})],
629
+ {style: {width: '100%'}}))
545
630
  .add(warningsTextDiv)
546
631
  // .addButton('Enumerate', () => {
547
632
  // execDialog()
@@ -554,7 +639,8 @@ async function getPolyToolEnumerateDialog(
554
639
  dialog.history(
555
640
  /* getInput */ (): PolyToolEnumerateHelmSerialized => {
556
641
  return {
557
- macromolecule: inputs.macromolecule.stringValue,
642
+ // macromolecule: inputs.macromolecule.stringValue,
643
+ description: `${inputs.enumeratorType.value} ${inputs.placeholders.placeholdersValue?.map((v) => (v.position?.toString() ?? '') + ': ' + v.monomers?.join(', ')).join('; ')}`,
558
644
  placeholders: inputs.placeholders.stringValue,
559
645
  enumeratorType: inputs.enumeratorType.value,
560
646
  placeholdersBreadth: inputs.placeholdersBreadth.stringValue,
@@ -565,10 +651,11 @@ async function getPolyToolEnumerateDialog(
565
651
  chiralityEngine: inputs.chiralityEngine.value,
566
652
  highlightMonomers: inputs.highlightMonomers.value,
567
653
  rules: ruleFileList,
654
+ library: inputs.library.value,
568
655
  };
569
656
  },
570
657
  /* applyInput */ (x: PolyToolEnumerateHelmSerialized): void => {
571
- inputs.macromolecule.stringValue = x.macromolecule;
658
+ //inputs.macromolecule.stringValue = x.macromolecule;
572
659
  inputs.placeholders.stringValue = x.placeholders;
573
660
  inputs.enumeratorType.value = x.enumeratorType ?? PolyToolEnumeratorTypes.Single;
574
661
  inputs.placeholdersBreadth.stringValue = x.placeholdersBreadth;
@@ -579,6 +666,7 @@ async function getPolyToolEnumerateDialog(
579
666
  inputs.chiralityEngine.value = x.chiralityEngine ?? false;
580
667
  inputs.highlightMonomers.value = x.highlightMonomers ?? false;
581
668
  ruleInputs.setActive(x.rules);
669
+ inputs.library.value = x.library;
582
670
  });
583
671
  return dialog;
584
672
  } catch (err: any) {
@@ -642,7 +730,7 @@ async function polyToolEnumerateSeq(
642
730
  buildMonomerHoverLink(resHelmCol, resMolCol, monomerLib, helmHelper.seqHelper, rdKitModule);
643
731
  } else if (dataRole === PolyToolDataRole.template) {
644
732
  const talRes = await polyToolConvert(enumCol,
645
- toAtomicLevel.generateHelm, toAtomicLevel.chiralityEngine, toAtomicLevel.rules);
733
+ toAtomicLevel.generateHelm, false, toAtomicLevel.chiralityEngine, false, toAtomicLevel.rules);
646
734
  resHelmCol = talRes[0];
647
735
  }
648
736
  }
@@ -54,6 +54,15 @@ export class PolyToolPlaceholdersBreadthInput extends DG.JsInputBase<DG.DataFram
54
54
  for (const sub of this.subs) sub.unsubscribe();
55
55
  for (const sub of this.dataFrameSubs) sub.unsubscribe();
56
56
  }
57
+ public clearInput(): void {
58
+ const df: DG.DataFrame = DG.DataFrame.fromColumns([
59
+ DG.Column.fromType(DG.COLUMN_TYPE.STRING, 'Remove', 0),
60
+ DG.Column.fromType(DG.COLUMN_TYPE.INT, 'Start', 0),
61
+ DG.Column.fromType(DG.COLUMN_TYPE.INT, 'End', 0),
62
+ DG.Column.fromType(DG.COLUMN_TYPE.STRING, 'Monomers', 0),
63
+ ])!;
64
+ this.setDataFrame(df);
65
+ }
57
66
 
58
67
  async render(heightRowCount?: number, options?: {}): Promise<void> {
59
68
  let removeCol: DG.Column<boolean>;
@@ -26,6 +26,14 @@ export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
26
26
  this.setDataFrame(DG.DataFrame.fromCsv(str));
27
27
  }
28
28
 
29
+ clearInput(): void {
30
+ const df: DG.DataFrame = DG.DataFrame.fromColumns([
31
+ DG.Column.fromType(DG.COLUMN_TYPE.STRING, 'Remove', 0),
32
+ DG.Column.fromType(DG.COLUMN_TYPE.INT, 'Position', 0),
33
+ DG.Column.fromType(DG.COLUMN_TYPE.STRING, 'Monomers', 0)])!;
34
+ this.setDataFrame(df);
35
+ }
36
+
29
37
  get placeholdersValue(): PolyToolPlaceholder[] {
30
38
  return dfToPlaceholders(this.grid.dataFrame);
31
39
  }
@@ -61,7 +69,7 @@ export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
61
69
  const df: DG.DataFrame = DG.DataFrame.fromColumns([
62
70
  removeCol = DG.Column.fromType(DG.COLUMN_TYPE.STRING, 'Remove', 0),
63
71
  DG.Column.fromType(DG.COLUMN_TYPE.INT, 'Position', 0),
64
- DG.Column.fromType(DG.COLUMN_TYPE.STRING, 'Monomers', 0),])!;
72
+ DG.Column.fromType(DG.COLUMN_TYPE.STRING, 'Monomers', 0)])!;
65
73
  removeCol.setTag(DG.TAGS.FRIENDLY_NAME, '');
66
74
  this.grid = (await df.plot.fromType(DG.VIEWER.GRID, options)) as DG.Grid;
67
75
  this.grid.sort(['Position']);
@@ -116,20 +124,25 @@ export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
116
124
  }
117
125
 
118
126
  /** @param {number} posOutIdx continuous (outer) position index, 0-based */
119
- addPosition(posOutIdx: number): void {
127
+ addPosition(posOutIdx: number, monomersValue?: string): void {
120
128
  const phDf = this.grid.dataFrame;
121
129
  const posList = phDf.columns.byName('Position').toList();
122
130
  let rowIdx = posList.indexOf(posOutIdx + 1);
123
131
  if (rowIdx === -1) {
124
132
  rowIdx = posList.findIndex((v) => isNaN(v));
125
133
  if (rowIdx === -1)
126
- rowIdx = phDf.rows.addNew(['', posOutIdx + 1, '']).idx;
127
- const tgtCell = this.grid.cell('Monomers', rowIdx);
134
+ rowIdx = phDf.rows.addNew(['', posOutIdx + 1, monomersValue ?? '']).idx;
135
+ const _tgtCell = this.grid.cell('Monomers', rowIdx);
128
136
  }
129
137
  phDf.currentCell = phDf.cell(rowIdx, 'Monomers');
130
138
  //const gridRowIdx = inputs.placeholders.grid.tableRowToGrid(rowIdx);
131
139
  //const monomersGCell = inputs.placeholders.grid.cell('Monomers', gridRowIdx);
132
- const k = 42;
140
+ }
141
+
142
+ setMonomersValue(index: number, monomersValue: string): void {
143
+ const df = this.grid.dataFrame;
144
+ if (df.rowCount <= index) return;
145
+ df.set('Monomers', index, monomersValue);
133
146
  }
134
147
 
135
148
  public static async create(
@@ -7,6 +7,7 @@ import {PolymerType} from '@datagrok-libraries/bio/src/helm/types';
7
7
  export enum PolyToolEnumeratorTypes {
8
8
  Single = 'single',
9
9
  Matrix = 'matrix',
10
+ Library = 'library',
10
11
  }
11
12
 
12
13
  export type PolyToolEnumeratorType = typeof PolyToolEnumeratorTypes[keyof typeof PolyToolEnumeratorTypes];
@@ -12,7 +12,7 @@ import {
12
12
  } from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
13
13
 
14
14
  declare const org: OrgType;
15
- const LIB_PATH = 'System:AppData/Bio/monomer-libraries/';
15
+ export const LIB_PATH = 'System:AppData/Bio/monomer-libraries/';
16
16
 
17
17
  export function _setPeptideColumn(col: DG.Column): void {
18
18
  addCommonTags(col);
@@ -100,14 +100,14 @@ category('PolyTool: Convert', () => {
100
100
  test(`toHelm-${testName}`, async () => {
101
101
  const rules = await getRules(['rules_example.json']);
102
102
  const res = doPolyToolConvert([testData.src.seq], rules, helmHelper);
103
- expect(res[0], testData.tgt.helm);
103
+ expect(res[0][0], testData.tgt.helm);
104
104
  });
105
105
  }
106
106
 
107
107
  for (const [testName, testData] of Object.entries(tests)) {
108
108
  test(`toAtomicLevel-${testName}`, async () => {
109
109
  const rules = await getRules(['rules_example.json']);
110
- const helmList = doPolyToolConvert([testData.src.seq], rules, helmHelper);
110
+ const [helmList, isLinear] = doPolyToolConvert([testData.src.seq], rules, helmHelper);
111
111
 
112
112
  const lib = await getOverriddenLibrary(rules);
113
113
 
package/src/global.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import * as grokNamespace from 'datagrok-api/grok';
2
- import * as uiNamespace from 'datagrok-api/ui';
3
- import * as DGNamespace from 'datagrok-api/dg';
4
- import * as rxjsNamespace from 'rxjs';
5
- import $Namespace from 'cash-dom';
6
-
7
- declare global {
8
- const grok: typeof grokNamespace;
9
- const ui: typeof uiNamespace;
10
- const DG: typeof DGNamespace;
11
- const rjxs: typeof rxjsNamespace;
12
- const $: typeof $Namespace;
13
- }