@datagrok/bio 2.18.1 → 2.18.3

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
@@ -5,7 +5,7 @@
5
5
  "name": "Leonid Stolbov",
6
6
  "email": "lstolbov@datagrok.ai"
7
7
  },
8
- "version": "2.18.1",
8
+ "version": "2.18.3",
9
9
  "description": "Bioinformatics support (import/export of sequences, conversion, visualization, analysis). [See more](https://github.com/datagrok-ai/public/blob/master/packages/Bio/README.md) for details.",
10
10
  "repository": {
11
11
  "type": "git",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@biowasm/aioli": "^3.1.0",
47
- "@datagrok-libraries/bio": "^5.47.1",
47
+ "@datagrok-libraries/bio": "^5.48.1",
48
48
  "@datagrok-libraries/chem-meta": "^1.2.7",
49
49
  "@datagrok-libraries/math": "^1.2.4",
50
50
  "@datagrok-libraries/ml": "^6.7.6",
@@ -65,7 +65,7 @@ category('renderers', () => {
65
65
 
66
66
  test('scatterPlotTooltip', async () => {
67
67
  await _testScatterPlotTooltip();
68
- });
68
+ }, {skipReason: 'GROK-17450'});
69
69
 
70
70
  async function _rendererMacromoleculeFasta() {
71
71
  const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/FASTA.csv');
@@ -15,8 +15,6 @@ const Tags = new class {
15
15
  tooltipHandlerTemp = 'tooltip-handler.Monomer';
16
16
  }();
17
17
 
18
- const svgMolOptions = {autoCrop: true, autoCropMargin: 0, suppressChiralText: true};
19
-
20
18
  export class MonomerCellRendererBack extends CellRendererWithMonomerLibBackBase {
21
19
  constructor(gridCol: DG.GridColumn | null, tableCol: DG.Column) {
22
20
  super(gridCol, tableCol);
@@ -25,6 +25,12 @@ const monomerRe = /[\w()]+/;
25
25
  //** Do not mess with monomer symbol with parenthesis enclosed in square brackets */
26
26
  const ambMonomerRe = RegExp(String.raw`\(${monomerRe}(,${monomerRe})+\)`);
27
27
 
28
+ const drawMoleculeCall = (s: string) => {
29
+ const canvas = ui.canvas(250, 250);
30
+ grok.chem.canvasMol(0, 0, 250, 250, canvas, s);
31
+ return canvas;
32
+ };
33
+
28
34
  export type MonomerLibDataType = { [polymerType: string]: { [monomerSymbol: string]: Monomer } };
29
35
 
30
36
  const whiteColorV = new Vector([255.0, 255.0, 255.0]);
@@ -189,10 +195,10 @@ export class MonomerLibBase implements IMonomerLibBase {
189
195
  const chemOptions = {autoCrop: true, autoCropMargin: 0, suppressChiralText: true};
190
196
  let structureEl: HTMLElement;
191
197
  if (monomer.molfile)
192
- structureEl = grok.chem.svgMol(monomer.molfile, undefined, undefined, chemOptions);
198
+ structureEl = drawMoleculeCall(monomer.molfile);
193
199
  else if (monomer.smiles) {
194
200
  structureEl = ui.divV([
195
- grok.chem.svgMol(monomer.smiles, undefined, undefined, chemOptions),
201
+ drawMoleculeCall(monomer.smiles),
196
202
  ui.divText('from smiles', {style: {fontSize: 'smaller'}}),
197
203
  ]);
198
204
  } else {
@@ -271,13 +277,12 @@ export class MonomerLibBase implements IMonomerLibBase {
271
277
  }
272
278
 
273
279
  const naSymbol: string | undefined = monomer[OPT.NATURAL_ANALOG];
274
- if (!res && naSymbol) {
280
+ if (!res && naSymbol)
275
281
  return this.getMonomerColors(biotype, naSymbol);
276
- }
277
282
  }
278
283
 
279
284
  if (!res)
280
- res = {textColor: "#202020", lineColor: "#202020", backgroundColor: "#A0A0A0"};
285
+ res = {textColor: '#202020', lineColor: '#202020', backgroundColor: '#A0A0A0'};
281
286
 
282
287
  return {
283
288
  textcolor: res.text ?? res.textColor,
@@ -97,6 +97,8 @@ export class DuplicateMonomerManager {
97
97
  DuplicateMonomerManager._instance = new DuplicateMonomerManager();
98
98
  await DuplicateMonomerManager._instance.refresh();
99
99
  const libManager = await MonomerLibManager.getInstance();
100
+ // reason: subscription happens only once, and is needed throught the lifetime of the app
101
+ // eslint-disable-next-line rxjs/no-async-subscribe, rxjs/no-ignored-subscription
100
102
  libManager.getMonomerLib().onChanged.subscribe(async () => await DuplicateMonomerManager._instance.refresh());
101
103
  }
102
104
  DuplicateMonomerManager._instance.refresh();
@@ -1087,12 +1087,24 @@ function monomerFromDfRow(dfRow: DG.Row): Monomer {
1087
1087
  if (typeof metaJSON[key] === 'object')
1088
1088
  metaJSON[key] = JSON.stringify(metaJSON[key]);
1089
1089
  }
1090
+ const smiles = dfRow.get(MONOMER_DF_COLUMN_NAMES.MONOMER);
1091
+ if (!smiles)
1092
+ throw new Error('Monomer SMILES is empty');
1093
+ let molfile = '';
1094
+
1095
+ try {
1096
+ molfile = grok.chem.convert(smiles, DG.chem.Notation.Smiles, DG.chem.Notation.MolBlock);
1097
+ molfile = getCorrectedMolBlock(molfile);
1098
+ } catch (e) {
1099
+ grok.shell.error(`Error converting SMILES to molfile, \n ${smiles}`);
1100
+ console.error(e);
1101
+ }
1090
1102
 
1091
1103
  return {
1092
1104
  symbol: dfRow.get(MONOMER_DF_COLUMN_NAMES.SYMBOL),
1093
1105
  name: dfRow.get(MONOMER_DF_COLUMN_NAMES.NAME),
1094
- molfile: '',
1095
- smiles: dfRow.get(MONOMER_DF_COLUMN_NAMES.MONOMER),
1106
+ molfile: molfile,
1107
+ smiles: smiles,
1096
1108
  polymerType: dfRow.get(MONOMER_DF_COLUMN_NAMES.POLYMER_TYPE),
1097
1109
  monomerType: dfRow.get(MONOMER_DF_COLUMN_NAMES.MONOMER_TYPE),
1098
1110
  naturalAnalog: dfRow.get(MONOMER_DF_COLUMN_NAMES.NATURAL_ANALOG),