@datagrok/bio 2.0.29 → 2.0.30

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.0.29",
8
+ "version": "2.0.30",
9
9
  "description": "Bio is a [package](https://datagrok.ai/help/develop/develop#packages) for the [Datagrok](https://datagrok.ai) platform",
10
10
  "repository": {
11
11
  "type": "git",
@@ -0,0 +1,7 @@
1
+ numpy==1.16.6
2
+ pandas==0.24.2
3
+ python-dateutil==2.8.2
4
+ pytz==2022.5
5
+ scikit-learn==0.17.1
6
+ scipy==1.2.3
7
+ six==1.16.0
package/src/package.ts CHANGED
@@ -34,9 +34,11 @@ import {splitAlignedSequences} from '@datagrok-libraries/bio/src/utils/splitter'
34
34
  import * as C from './utils/constants';
35
35
  import {SequenceSimilarityViewer} from './analysis/sequence-similarity-viewer';
36
36
  import {SequenceDiversityViewer} from './analysis/sequence-diversity-viewer';
37
- import {substructureSearchDialog} from './substructure-search/substructure-search';
37
+ import {invalidateMols, MONOMERIC_COL_TAGS, substructureSearchDialog} from './substructure-search/substructure-search';
38
38
  import {saveAsFastaUI} from './utils/save-as-fasta';
39
39
  import {BioSubstructureFilter} from './widgets/bio-substructure-filter';
40
+ import { getMonomericMols } from './calculations/monomerLevelMols';
41
+ import { delay } from '@datagrok-libraries/utils/src/test';
40
42
 
41
43
  //tags: init
42
44
  export async function initBio() {
@@ -205,13 +207,35 @@ export async function activityCliffs(df: DG.DataFrame, macroMolecule: DG.Column,
205
207
  //input: dataframe table
206
208
  //input: column macroMolecule { semType: Macromolecule }
207
209
  //input: string methodName { choices:["UMAP", "t-SNE", "SPE"] }
208
- //input: string similarityMetric { choices:["Levenshtein", "Tanimoto"] }
210
+ //input: string similarityMetric { choices:["Tanimoto", "Asymmetric", "Cosine", "Sokal"] }
209
211
  //input: bool plotEmbeddings = true
210
212
  export async function sequenceSpaceTopMenu(table: DG.DataFrame, macroMolecule: DG.Column, methodName: string,
211
- similarityMetric: string = 'Levenshtein', plotEmbeddings: boolean): Promise<DG.Viewer | undefined> {
212
- if (!checkInputColumnUi(macroMolecule, 'Activity Cliffs'))
213
+ similarityMetric: string = 'Tanimoto', plotEmbeddings: boolean): Promise<DG.Viewer | undefined> {
214
+ //delay is required for initial function dialog to close before starting invalidating of molfiles. Otherwise dialog is freezing
215
+ await delay(10);
216
+ if (!checkInputColumnUi(macroMolecule, 'Sequence space'))
213
217
  return;
214
- const encodedCol = encodeMonomers(macroMolecule);
218
+
219
+ if (macroMolecule.version !== macroMolecule.temp[MONOMERIC_COL_TAGS.LAST_INVALIDATED_VERSION])
220
+ await invalidateMols(macroMolecule, false);
221
+ const embedColsNames = getEmbeddingColsNames(table);
222
+
223
+ await grok.functions.call('Chem:getChemSpaceEmbeddings', {
224
+ table: table,
225
+ col: macroMolecule.temp[MONOMERIC_COL_TAGS.MONOMERIC_MOLS],
226
+ methodName: methodName,
227
+ similarityMetric: similarityMetric,
228
+ xAxis: embedColsNames[0],
229
+ yAxis: embedColsNames[1]
230
+ });
231
+
232
+ if (plotEmbeddings) {
233
+ return grok.shell
234
+ .tableView(table.name)
235
+ .scatterPlot({x: embedColsNames[0], y: embedColsNames[1], title: 'Sequence space'});
236
+ };
237
+
238
+ /* const encodedCol = encodeMonomers(macroMolecule);
215
239
  if (!encodedCol)
216
240
  return;
217
241
  const embedColsNames = getEmbeddingColsNames(table);
@@ -237,8 +261,7 @@ export async function sequenceSpaceTopMenu(table: DG.DataFrame, macroMolecule: D
237
261
  if (v.name === table.name)
238
262
  sp = (v as DG.TableView).scatterPlot({x: embedColsNames[0], y: embedColsNames[1], title: 'Sequence space'});
239
263
  }
240
- }
241
- return sp;
264
+ } */
242
265
  };
243
266
 
244
267
  //top-menu: Bio | To Atomic Level...
@@ -6,10 +6,11 @@ import * as bio from '@datagrok-libraries/bio';
6
6
  import * as C from '../utils/constants';
7
7
  import {getMonomericMols} from '../calculations/monomerLevelMols';
8
8
  import {updateDivInnerHTML} from '../utils/ui-utils';
9
+ import { delay } from '@datagrok-libraries/utils/src/test';
9
10
 
10
11
  export const MONOMER_MOLS_COL = 'monomeric-mols';
11
12
 
12
- const enum MONOMERIC_COL_TAGS {
13
+ export const enum MONOMERIC_COL_TAGS {
13
14
  MONOMERIC_MOLS = 'monomeric-mols',
14
15
  LAST_INVALIDATED_VERSION = 'last-invalidated-version',
15
16
  MONOMERS_DICT = 'monomers-dict'
@@ -99,7 +100,7 @@ function prepareSubstructureRegex(substructure: string, separator: string) {
99
100
 
100
101
  export async function helmSubstructureSearch(substructure: string, col: DG.Column): Promise<DG.BitSet> {
101
102
  if (col.version !== col.temp[MONOMERIC_COL_TAGS.LAST_INVALIDATED_VERSION])
102
- await invalidateHelmMols(col);
103
+ await invalidateMols(col, true);
103
104
  const substructureCol = DG.Column.string('helm', 1).init((i) => substructure);
104
105
  substructureCol.setTag(DG.TAGS.UNITS, bio.NOTATION.HELM);
105
106
  const substructureMolsCol =
@@ -112,10 +113,13 @@ export async function helmSubstructureSearch(substructure: string, col: DG.Colum
112
113
  return matchesCol.get(0);
113
114
  }
114
115
 
115
- export async function invalidateHelmMols(col: DG.Column) {
116
+ export async function invalidateMols(col: DG.Column, pattern: boolean) {
117
+ const progressBar = DG.TaskBarProgressIndicator.create(`Invalidating molfiles for ${col.name}`);
118
+ await delay(10);
116
119
  const monomersDict = new Map();
117
- const monomericMolsCol = await getMonomericMols(col, true, monomersDict);
120
+ const monomericMolsCol = await getMonomericMols(col, pattern, monomersDict);
118
121
  col.temp[MONOMERIC_COL_TAGS.MONOMERIC_MOLS] = monomericMolsCol;
119
122
  col.temp[MONOMERIC_COL_TAGS.MONOMERS_DICT] = monomersDict;
120
123
  col.temp[MONOMERIC_COL_TAGS.LAST_INVALIDATED_VERSION] = col.version;
124
+ progressBar.close();
121
125
  }
@@ -207,12 +207,12 @@ export class HelmFilter extends BioFilterBase {
207
207
  await ui.tools.waitForElementInDom(this._filterPanel);
208
208
  this.updateFilterPanel();
209
209
  this._filterPanel.addEventListener('click', (event: MouseEvent) => {
210
+ const {editorDiv, webEditor} = this.helmEditor.createWebEditor(this.helmSubstructure);
210
211
  //@ts-ignore
211
212
  ui.dialog({showHeader: false, showFooter: true})
212
- .add(this.helmEditor.editorView)
213
+ .add(editorDiv)
213
214
  .onOK(() => {
214
- const helmString = this.helmEditor
215
- .webEditor.canvas.getHelm(true).replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
215
+ const helmString = webEditor.canvas.getHelm(true).replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
216
216
  this.helmSubstructure = helmString;
217
217
  this.updateFilterPanel(this.substructure);
218
218
  setTimeout(() => { this.onChanged.next(); }, 10);