@datagrok/helm 2.1.5 → 2.1.7

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,14 +1,14 @@
1
1
  {
2
2
  "name": "@datagrok/helm",
3
3
  "friendlyName": "Helm",
4
- "version": "2.1.5",
4
+ "version": "2.1.7",
5
5
  "author": {
6
6
  "name": "Oleksandra Serhiienko",
7
7
  "email": "oserhiienko@datagrok.ai"
8
8
  },
9
- "description": "",
9
+ "description": "Provides support for HELM notation (importing, detecting, rendering, conversion). [Learn more](https://github.com/datagrok-ai/public/blob/master/packages/Helm/README.md)",
10
10
  "dependencies": {
11
- "@datagrok-libraries/bio": "^5.22.0",
11
+ "@datagrok-libraries/bio": "^5.22.1",
12
12
  "@datagrok-libraries/utils": "^1.19.1",
13
13
  "cash-dom": "^8.1.1",
14
14
  "datagrok-api": "^1.10.2",
package/src/package.ts CHANGED
@@ -10,6 +10,7 @@ import {IMonomerLib, Monomer} from '@datagrok-libraries/bio/src/types';
10
10
  import {NotationConverter} from '@datagrok-libraries/bio/src/utils/notation-converter';
11
11
  import {findMonomers} from './utils';
12
12
  import {errorToConsole} from '@datagrok-libraries/utils/src/to-console';
13
+ import { NOTATION } from '@datagrok-libraries/bio/src/utils/macromolecule';
13
14
 
14
15
  export const _package = new DG.Package();
15
16
  let monomerLib: IMonomerLib | null = null;
@@ -93,16 +94,23 @@ export function helmCellRenderer(): HelmCellRenderer {
93
94
  return new HelmCellRenderer();
94
95
  }
95
96
 
97
+ function checkMonomersAndOpenWebEditor(cell?: DG.Cell, value?: string, units?: string) {
98
+ const cellValue = typeof units === 'undefined' ? cell.value : value;
99
+ const monomers = findMonomers(cellValue);
100
+ if (monomers.size == 0)
101
+ webEditor(cell, value, units);
102
+ else
103
+ grok.shell.warning(`Monomers ${Array.from(monomers).join(', ')} are absent! <br/>` +
104
+ `Please, upload the monomer library! <br/>` +
105
+ `<a href="https://datagrok.ai/help/domains/bio/macromolecules" target="_blank">Learn more</a>`);
106
+ }
107
+
96
108
  //tags: cellEditor
97
109
  //description: Macromolecule
98
110
  //input: grid_cell cell
111
+ //meta.columnTags: quality=Macromolecule, units=helm
99
112
  export function editMoleculeCell(cell: DG.GridCell): void {
100
- const monomers = findMonomers(cell.cell.value);
101
- if (cell.gridColumn.column.tags[DG.TAGS.UNITS] === 'helm')
102
- if (monomers.size == 0)
103
- webEditor(cell);
104
- else
105
- grok.shell.warning(`Monomers ${Array.from(monomers).join(', ')} are absent!`);
113
+ checkMonomersAndOpenWebEditor(cell.cell, undefined, undefined);
106
114
  }
107
115
 
108
116
  //name: Open Helm Web Editor
@@ -111,13 +119,13 @@ export function editMoleculeCell(cell: DG.GridCell): void {
111
119
  //input: string mol { semType: Macromolecule }
112
120
  export function openEditor(mol: string): void {
113
121
  let df = grok.shell.tv.grid.dataFrame;
114
- let converter = new NotationConverter(df.columns.bySemType('Macromolecule'));
115
- const resStr = converter.convertStringToHelm(mol, '/');
116
- const monomers = findMonomers(resStr);
117
- if (monomers.size == 0)
118
- webEditor(undefined, resStr);
119
- else
120
- grok.shell.warning(`Monomers ${Array.from(monomers).join(', ')} are absent!`);
122
+ let col = df.columns.bySemType('Macromolecule');
123
+ const colUnits = col.getTag(DG.TAGS.UNITS);
124
+ if (colUnits === NOTATION.HELM)
125
+ checkMonomersAndOpenWebEditor(df.currentCell, undefined, undefined);
126
+ let converter = new NotationConverter(col);
127
+ const resStr = converter.convertStringToHelm(mol, '/');
128
+ checkMonomersAndOpenWebEditor(df.currentCell, resStr, col.getTag(DG.TAGS.UNITS));
121
129
  }
122
130
 
123
131
  //name: Properties
@@ -146,8 +154,10 @@ export async function propertiesPanel(helmString: string) {
146
154
  );
147
155
  }
148
156
 
149
- function webEditor(cell?: DG.GridCell, value?: string) {
157
+ function webEditor(cell?: DG.Cell, value?: string, units?: string) {
150
158
  let view = ui.div();
159
+ let df = grok.shell.tv.grid.dataFrame;
160
+ let converter = new NotationConverter(df.columns.bySemType('Macromolecule'));
151
161
  org.helm.webeditor.MolViewer.molscale = 0.8;
152
162
  let app = new scil.helm.App(view, {
153
163
  showabout: false,
@@ -172,8 +182,8 @@ function webEditor(cell?: DG.GridCell, value?: string) {
172
182
  app.structureview.resize(sizes.rightwidth, sizes.bottomheight + app.toolbarheight);
173
183
  app.mex.resize(sizes.topheight - 80);
174
184
  setTimeout(function() {
175
- if (typeof cell !== 'undefined') {
176
- app.canvas.helm.setSequence(cell.cell.value, 'HELM');
185
+ if (typeof units === 'undefined') {
186
+ app.canvas.helm.setSequence(cell.value, 'HELM');
177
187
  } else {
178
188
  app.canvas.helm.setSequence(value, 'HELM');
179
189
  }
@@ -182,59 +192,16 @@ function webEditor(cell?: DG.GridCell, value?: string) {
182
192
  ui.dialog({showHeader: false, showFooter: true})
183
193
  .add(view)
184
194
  .onOK(() => {
185
- if (typeof cell !== 'undefined') {
186
- cell.cell.value = app.canvas.getHelm(true).replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
195
+ let helmValue = app.canvas.getHelm(true).replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
196
+ if (typeof units === 'undefined') {
197
+ cell.value = helmValue;
198
+ } else {
199
+ let convertedRes = converter.convertHelmToFastaSeparator(helmValue, units);
200
+ cell.value = convertedRes;
187
201
  }
188
202
  }).show({modal: true, fullScreen: true});
189
203
  }
190
204
 
191
- async function accessServer(url: string, key: string) {
192
- const params: RequestInit = {
193
- method: 'GET',
194
- headers: {
195
- 'Accept': 'application/json',
196
- }
197
- };
198
- const response = await fetch(url, params);
199
- const json = await response.json();
200
- return json[key];
201
- }
202
-
203
- //name: helmToFasta
204
- //input: string helmString {semType: Macromolecule}
205
- //output: string res
206
- export async function helmToFasta(helmString: string) {
207
- const url = `http://localhost:8081/WebService/service/Fasta/Produce/${helmString}`;
208
- return await accessServer(url, 'FastaFile');
209
- }
210
-
211
- //name: helmToRNA
212
- //description: converts to rna analogue sequence
213
- //input: string helmString {semType: Macromolecule}
214
- //output: string res
215
- export async function helmToRNA(helmString: string) {
216
- const url = `http://localhost:8081/WebService/service/Fasta/Convert/RNA/${helmString}`;
217
- return await accessServer(url, 'Sequence');
218
- }
219
-
220
- //name: helmToPeptide
221
- //description: converts to peptide analogue sequence
222
- //input: string helmString {semType: Macromolecule}
223
- //output: string res
224
- export async function helmToPeptide(helmString: string) {
225
- const url = `http://localhost:8081/WebService/service/Fasta/Convert/PEPTIDE/${helmString}`;
226
- return await accessServer(url, 'Sequence');
227
- }
228
-
229
- //name: helmToSmiles
230
- //description: converts to smiles
231
- //input: string helmString {semType: Macromolecule}
232
- //output: string smiles {semType: Molecule}
233
- export async function helmToSmiles(helmString: string) {
234
- const url = `http://localhost:8081/WebService/service/SMILES/${helmString}`;
235
- return await accessServer(url, 'SMILES');
236
- }
237
-
238
205
  function getRS(smiles: string) {
239
206
  const newS = smiles.match(/(?<=\[)[^\][]*(?=])/gm);
240
207
  const res = {};
package/tsconfig.json CHANGED
@@ -12,7 +12,7 @@
12
12
  // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
13
13
  // "declaration": true, /* Generates corresponding '.d.ts' file. */
14
14
  // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
- // "sourceMap": true, /* Generates corresponding '.map' file. */
15
+ "sourceMap": true, /* Generates corresponding '.map' file. */
16
16
  // "outFile": "./", /* Concatenate and emit output to single file. */
17
17
  // "outDir": "./", /* Redirect output structure to the directory. */
18
18
  // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
package/webpack.config.js CHANGED
@@ -28,7 +28,7 @@ module.exports = {
28
28
  },
29
29
  ],
30
30
  },
31
- devtool: 'inline-source-map',
31
+ devtool: 'source-map',
32
32
  externals: {
33
33
  'datagrok-api/dg': 'DG',
34
34
  'datagrok-api/grok': 'grok',