@datagrok/helm 2.1.30 → 2.1.31

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.1.30",
4
+ "version": "2.1.31",
5
5
  "author": {
6
6
  "name": "Oleksandra Serhiienko",
7
7
  "email": "oserhiienko@datagrok.ai"
@@ -15,8 +15,8 @@
15
15
  "helm/JSDraw/Pistoia.HELM-uncompressed.js"
16
16
  ],
17
17
  "dependencies": {
18
- "@datagrok-libraries/bio": "^5.39.29",
19
- "@datagrok-libraries/chem-meta": "^1.2.2",
18
+ "@datagrok-libraries/bio": "^5.40.0",
19
+ "@datagrok-libraries/chem-meta": "^1.2.3",
20
20
  "@datagrok-libraries/utils": "^4.1.45",
21
21
  "cash-dom": "^8.1.1",
22
22
  "datagrok-api": "^1.17.0",
@@ -37,8 +37,8 @@
37
37
  "@typescript-eslint/parser": "^5.11.0",
38
38
  "eslint": "^8.18.0",
39
39
  "eslint-config-google": "^0.14.0",
40
- "@datagrok/bio": "^2.11.38",
41
- "@datagrok/chem": "^1.8.13"
40
+ "@datagrok/bio": "^2.12.0",
41
+ "@datagrok/chem": "^1.9.0"
42
42
  },
43
43
  "scripts": {
44
44
  "link-all": "npm link @datagrok-libraries/chem-meta datagrok-api @datagrok-libraries/utils @datagrok-libraries/bio",
package/src/package.ts CHANGED
@@ -7,7 +7,7 @@ import $ from 'cash-dom';
7
7
 
8
8
  import {errorToConsole} from '@datagrok-libraries/utils/src/to-console';
9
9
  import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
10
- import {GapSymbols, UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
10
+ import {GapOriginals, SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
11
11
  import {IMonomerLib, Monomer} from '@datagrok-libraries/bio/src/types';
12
12
  import {IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
13
13
 
@@ -156,17 +156,17 @@ export function helmCellRenderer(): HelmCellRenderer {
156
156
  return new HelmCellRenderer();
157
157
  }
158
158
 
159
- function checkMonomersAndOpenWebEditor(cell?: DG.Cell, value?: string, units?: string) {
159
+ function checkMonomersAndOpenWebEditor(cell: DG.Cell, value?: string, units?: string) {
160
160
  const cellValue: string = !!cell && units === undefined ? cell.value : value;
161
161
  const monomerList: string[] = parseHelm(cellValue);
162
- const monomers = findMonomers(monomerList);
163
- if (monomers.size === 0)
162
+ const missedMonomerSet = findMonomers(monomerList);
163
+ if (missedMonomerSet.size === 0)
164
164
  webEditor(cell, value, units);
165
- else if (monomers.size === 1 && monomers.has(GapSymbols[NOTATION.HELM]))
166
- grok.shell.warning(`WebEditor doesn't support Helm with gaps '${GapSymbols[NOTATION.HELM]}'.`);
165
+ else if (missedMonomerSet.size === 1 && missedMonomerSet.has(GapOriginals[NOTATION.HELM]))
166
+ grok.shell.warning(`WebEditor doesn't support Helm with gaps '${GapOriginals[NOTATION.HELM]}'.`);
167
167
  else {
168
168
  grok.shell.warning(
169
- `Monomers ${Array.from(monomers).map((m) => `'${m}'`).join(', ')} are absent! <br/>` +
169
+ `Monomers ${Array.from(missedMonomerSet).map((m) => `'${m}'`).join(', ')} are absent! <br/>` +
170
170
  `Please, upload the monomer library! <br/>` +
171
171
  `<a href="https://datagrok.ai/help/domains/bio/macromolecules" target="_blank">Learn more</a>`);
172
172
  }
@@ -187,11 +187,11 @@ export function editMoleculeCell(cell: DG.GridCell): void {
187
187
  export function openEditor(mol: string): void {
188
188
  const df = grok.shell.tv.grid.dataFrame;
189
189
  const col = df.columns.bySemType('Macromolecule')!;
190
- const colUh = UnitsHandler.getOrCreate(col);
190
+ const colSh = SeqHandler.forColumn(col);
191
191
  const colUnits = col.getTag(DG.TAGS.UNITS);
192
192
  if (colUnits === NOTATION.HELM)
193
193
  checkMonomersAndOpenWebEditor(df.currentCell, undefined, undefined);
194
- const convert = colUh.getConverter(NOTATION.HELM);
194
+ const convert = colSh.getConverter(NOTATION.HELM);
195
195
  const helmMol = convert(mol);
196
196
  checkMonomersAndOpenWebEditor(df.currentCell, helmMol, col.getTag(DG.TAGS.UNITS));
197
197
  }
@@ -204,11 +204,13 @@ export function propertiesWidget(sequence: DG.SemanticValue): DG.Widget {
204
204
  return getPropertiesWidget(sequence);
205
205
  }
206
206
 
207
- function webEditor(cell?: DG.Cell, value?: string, units?: string) {
207
+ function webEditor(cell: DG.Cell, value?: string, units?: string) {
208
208
  const view = ui.div();
209
- const df = grok.shell.tv.grid.dataFrame;
210
- const col = df.columns.bySemType('Macromolecule')!;
211
- const uh = UnitsHandler.getOrCreate(col);
209
+ // const df = grok.shell.tv.grid.dataFrame;
210
+ // const col = df.columns.bySemType('Macromolecule')!;
211
+ const col = cell.column;
212
+ const sh = SeqHandler.forColumn(col);
213
+ const rowIdx = cell.rowIndex;
212
214
  // @ts-ignore
213
215
  org.helm.webeditor.MolViewer.molscale = 0.8;
214
216
  // @ts-ignore
@@ -244,13 +246,13 @@ function webEditor(cell?: DG.Cell, value?: string, units?: string) {
244
246
  ui.dialog({showHeader: false, showFooter: true})
245
247
  .add(view)
246
248
  .onOK(() => {
247
- const helmValue = app.canvas.getHelm(true).replace(/<\/span>/g, '')
249
+ const helmValue: string = app.canvas.getHelm(true).replace(/<\/span>/g, '')
248
250
  .replace(/<span style='background:#bbf;'>/g, '');
249
251
  if (!!cell) {
250
252
  if (units === undefined)
251
253
  cell.value = helmValue;
252
254
  else {
253
- const convertedRes = uh.convertHelmToFastaSeparator(helmValue, units!);
255
+ const convertedRes = sh.convertHelmToFastaSeparator(helmValue, units!, sh.separator);
254
256
  cell.value = convertedRes;
255
257
  }
256
258
  }
@@ -4,7 +4,7 @@ import * as grok from 'datagrok-api/grok';
4
4
 
5
5
  import {category, expect, expectObject, test} from '@datagrok-libraries/utils/src/test';
6
6
  import {ALPHABET, NOTATION, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
7
- import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
7
+ import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
8
8
 
9
9
  import {getPropertiesDict} from '../widgets/properties-widget';
10
10
 
@@ -75,7 +75,7 @@ function testPropertiesDict(
75
75
  col.setTag(DG.TAGS.UNITS, units);
76
76
  if (separator) col.setTag(bioTAGS.separator, separator);
77
77
  if (alphabet) col.setTag(bioTAGS.alphabet, alphabet);
78
- const uh = UnitsHandler.getOrCreate(col);
78
+ const uh = SeqHandler.forColumn(col);
79
79
  const actPropDict = getPropertiesDict(seq, uh);
80
80
  expectObject(actPropDict, expPropDict);
81
81
  }
@@ -4,13 +4,13 @@ import * as DG from 'datagrok-api/dg';
4
4
 
5
5
  import $ from 'cash-dom';
6
6
 
7
- import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
7
+ import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
8
8
  import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
9
9
 
10
10
  import {removeGapsFromHelm} from '../utils';
11
11
 
12
- export function getPropertiesDict(seq: string, uh: UnitsHandler): {} {
13
- const helmString = uh.isHelm() ? seq : uh.getConverter(NOTATION.HELM)(seq);
12
+ export function getPropertiesDict(seq: string, sh: SeqHandler): {} {
13
+ const helmString = sh.isHelm() ? seq : sh.getConverter(NOTATION.HELM)(seq);
14
14
  // Remove gap symbols for compatibility with WebEditor
15
15
  const helmString2 = removeGapsFromHelm(helmString);
16
16
 
@@ -36,8 +36,8 @@ export function getPropertiesDict(seq: string, uh: UnitsHandler): {} {
36
36
 
37
37
 
38
38
  export function getPropertiesWidget(value: DG.SemanticValue): DG.Widget {
39
- const uh = UnitsHandler.getOrCreate(value.cell.column);
40
- const propDict = getPropertiesDict(value.value, uh);
39
+ const sh = SeqHandler.forColumn(value.cell.column);
40
+ const propDict = getPropertiesDict(value.value, sh);
41
41
  return new DG.Widget(
42
42
  ui.tableFromMap(propDict)
43
43
  );