@datagrok/bio 2.8.6 → 2.10.0

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.8.6",
8
+ "version": "2.10.0",
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",
@@ -34,14 +34,14 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@biowasm/aioli": "^3.1.0",
37
- "@datagrok-libraries/bio": "^5.36.0",
37
+ "@datagrok-libraries/bio": "^5.38.0",
38
38
  "@datagrok-libraries/chem-meta": "^1.0.1",
39
39
  "@datagrok-libraries/ml": "^6.3.39",
40
40
  "@datagrok-libraries/tutorials": "^1.3.6",
41
41
  "@datagrok-libraries/utils": "^4.0.17",
42
42
  "cash-dom": "^8.0.0",
43
43
  "css-loader": "^6.7.3",
44
- "datagrok-api": "^1.13.3",
44
+ "datagrok-api": "^1.16.0",
45
45
  "dayjs": "^1.11.4",
46
46
  "fastest-levenshtein": "^1.0.16",
47
47
  "openchemlib": "6.0.1",
@@ -62,8 +62,8 @@
62
62
  "webpack": "^5.76.3",
63
63
  "webpack-bundle-analyzer": "latest",
64
64
  "webpack-cli": "^4.9.1",
65
- "@datagrok/chem": "1.4.21",
66
- "@datagrok/helm": "2.1.7"
65
+ "@datagrok/chem": "1.7.2",
66
+ "@datagrok/helm": "2.1.16"
67
67
  },
68
68
  "scripts": {
69
69
  "link-api": "npm link datagrok-api",
@@ -6,7 +6,6 @@ import {ISequenceSpaceParams} from '@datagrok-libraries/ml/src/viewers/activity-
6
6
  import {invalidateMols, MONOMERIC_COL_TAGS} from '../substructure-search/substructure-search';
7
7
  import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
8
8
  import * as grok from 'datagrok-api/grok';
9
- import {NotationConverter} from '@datagrok-libraries/bio/src/utils/notation-converter';
10
9
  import {ALPHABET, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
11
10
  import {MmDistanceFunctionsNames} from '@datagrok-libraries/ml/src/macromolecule-distance-functions';
12
11
 
@@ -57,17 +56,17 @@ export async function sequenceSpaceByFingerprints(spaceParams: ISequenceSpacePar
57
56
  }
58
57
 
59
58
  export async function getSequenceSpace(spaceParams: ISequenceSpaceParams): Promise<ISequenceSpaceResult> {
60
- const nc = new NotationConverter(spaceParams.seqCol);
61
- if (nc.isFasta() || (nc.isSeparator() && nc.alphabet && nc.alphabet !== ALPHABET.UN)) {
59
+ const ncUH = UnitsHandler.getOrCreate(spaceParams.seqCol);
60
+ if (ncUH.isFasta() || (ncUH.isSeparator() && ncUH.alphabet && ncUH.alphabet !== ALPHABET.UN)) {
62
61
  let distanceFName = MmDistanceFunctionsNames.LEVENSHTEIN;
63
62
  let seqList = spaceParams.seqCol.toList();
64
- if (nc.isSeparator()) {
65
- const fastaCol = nc.convert(NOTATION.FASTA);
63
+ if (ncUH.isSeparator()) {
64
+ const fastaCol = ncUH.convert(NOTATION.FASTA);
66
65
  seqList = fastaCol.toList();
67
66
  const uh = UnitsHandler.getOrCreate(fastaCol);
68
67
  distanceFName = uh.getDistanceFunctionName();
69
68
  } else {
70
- distanceFName = nc.getDistanceFunctionName();
69
+ distanceFName = ncUH.getDistanceFunctionName();
71
70
  }
72
71
  for (let i = 0; i < seqList.length; i++) {
73
72
  // toList puts empty values in array and it causes downstream errors. replace with null
@@ -0,0 +1,56 @@
1
+ import * as grok from 'datagrok-api/grok';
2
+ import * as ui from 'datagrok-api/ui';
3
+ import * as DG from 'datagrok-api/dg';
4
+
5
+ import {TAGS, positionSeparator} from '@datagrok-libraries/bio/src/utils/macromolecule';
6
+ import {IWebLogoViewer} from '@datagrok-libraries/bio/src/viewers/web-logo';
7
+
8
+ import {_package} from '../package';
9
+
10
+ const csv = `seq,value
11
+ ATCCGTCGT,0.5
12
+ TGTTCGTCA,0.4
13
+ ATGGTCGTA,0.7
14
+ ATCCGTGCA,0.1`;
15
+
16
+ const positionNames = ['1', '1A', '1C', '2', '4', '4A', '4B', '5', '6'].join(positionSeparator);
17
+
18
+ const regions = [
19
+ {name: 'first region', start: '1', end: '2'},
20
+ {name: 'second region', start: '1C', end: '4'},
21
+ {name: 'overlapping second', start: '1C', end: '4A'},
22
+ {name: 'whole sequence', start: '1', end: '6'},
23
+ {name: 'bad start', start: '0', end: '6'},
24
+ {name: 'bad end', start: '1', end: '4C'},
25
+ {name: 'bad start & end', start: '0', end: '4C'},
26
+ ];
27
+
28
+ export class GetRegionApp {
29
+ df: DG.DataFrame;
30
+ view: DG.TableView;
31
+
32
+ constructor(
33
+ private readonly urlParams: URLSearchParams,
34
+ private readonly funcName: string
35
+ ) {}
36
+
37
+ async init(): Promise<void> {
38
+ this.df = DG.DataFrame.fromCsv(csv);
39
+ const seqCol = this.df.getCol('seq');
40
+ seqCol.setTag(TAGS.positionNames, positionNames);
41
+ seqCol.setTag(TAGS.regions, JSON.stringify(regions));
42
+
43
+ await this.buildView();
44
+ }
45
+
46
+ // -- View --
47
+
48
+ async buildView(): Promise<void> {
49
+ this.view = grok.shell.addTableView(this.df);
50
+ this.view.path = this.view.basePath = `func/${_package.name}.${this.funcName}`;
51
+
52
+ const viewer: DG.Viewer & IWebLogoViewer = (await this.view.dataFrame.plot
53
+ .fromType('WebLogo')) as DG.Viewer & IWebLogoViewer;
54
+ this.view.dockManager.dock(viewer, DG.DOCK_TYPE.DOWN, null, 'WebLogo', 0.35);
55
+ }
56
+ }
@@ -11,15 +11,12 @@ import {PROPS as wlPROPS} from '../viewers/web-logo-viewer';
11
11
  import {_package} from '../package';
12
12
 
13
13
  export class WebLogoApp {
14
- private _funcName: string = '';
15
-
16
14
  df: DG.DataFrame;
17
15
  view: DG.TableView;
18
16
 
19
- constructor(private readonly urlParams: URLSearchParams) {}
17
+ constructor(private readonly urlParams: URLSearchParams, private readonly funcName: string) {}
20
18
 
21
- async init(df: DG.DataFrame, funcName: string): Promise<void> {
22
- this._funcName = funcName;
19
+ async init(df: DG.DataFrame): Promise<void> {
23
20
  this.df = df;
24
21
 
25
22
  await this.buildView();
@@ -33,7 +30,7 @@ export class WebLogoApp {
33
30
  .toArray().join('&');
34
31
 
35
32
  this.view = grok.shell.addTableView(this.df);
36
- this.view.path = this.view.basePath = `func/${_package.name}.${this._funcName}?${urlParamsTxt}`;
33
+ this.view.path = this.view.basePath = `func/${_package.name}.${this.funcName}?${urlParamsTxt}`;
37
34
 
38
35
  const options: { [p: string]: any } = {sequenceColumnName: 'sequence'};
39
36
  for (const [optName, optValue] of this.urlParams.entries()) {
@@ -24,10 +24,12 @@ import './tests/pepsea-tests';
24
24
  import './tests/viewers';
25
25
  import './tests/units-handler-tests';
26
26
  import './tests/units-handler-splitted-tests';
27
+ import './tests/units-handler-get-region';
27
28
  import './tests/to-atomic-level-tests';
28
29
  import './tests/mm-distance-tests';
29
30
  import './tests/activity-cliffs-tests';
30
31
  import './tests/sequence-space-test';
32
+ import './tests/scoring';
31
33
 
32
34
 
33
35
  export const _package = new DG.Package();
@@ -14,7 +14,6 @@ export const enum BioPackagePropertiesNames {
14
14
 
15
15
 
16
16
  export class BioPackageProperties extends Map<string, any> {
17
-
18
17
  private _onPropertyChanged: Subject<string> = new Subject<string>();
19
18
  public get onPropertyChanged(): Observable<string> { return this._onPropertyChanged; }
20
19
 
@@ -58,4 +57,17 @@ export class BioPackage extends DG.Package {
58
57
  public get properties(): BioPackageProperties { return this._properties; };
59
58
 
60
59
  public set properties(value: BioPackageProperties) { this._properties = value; }
60
+
61
+ private _initialized: boolean = false;
62
+
63
+ public get initialized(): boolean { return this._initialized;}
64
+
65
+ public completeInit(): void { this._initialized = true;}
66
+
67
+ handleErrorUI(err: any) {
68
+ const errMsg = err instanceof Error ? err.message : err.toString();
69
+ const errStack = err instanceof Error ? err.stack : undefined;
70
+ grok.shell.error(errMsg);
71
+ this.logger.error(errMsg, undefined, errStack);
72
+ }
61
73
  }
package/src/package.ts CHANGED
@@ -21,7 +21,7 @@ import {removeEmptyStringRows} from '@datagrok-libraries/utils/src/dataframe-uti
21
21
 
22
22
  import {SequenceSimilarityViewer} from './analysis/sequence-similarity-viewer';
23
23
  import {SequenceDiversityViewer} from './analysis/sequence-diversity-viewer';
24
- import {substructureSearchDialog} from './substructure-search/substructure-search';
24
+ import {SubstructureSearchDialog} from './substructure-search/substructure-search';
25
25
  import {saveAsFastaUI} from './utils/save-as-fasta';
26
26
  import {BioSubstructureFilter} from './widgets/bio-substructure-filter';
27
27
  import {delay} from '@datagrok-libraries/utils/src/test';
@@ -40,10 +40,11 @@ import {
40
40
  getLibFileNameList,
41
41
  getLibraryPanelUI
42
42
  } from './utils/monomer-lib';
43
- import {getMacromoleculeColumn} from './utils/ui-utils';
43
+ import {getMacromoleculeColumns} from './utils/ui-utils';
44
44
  import {DimReductionMethods, ITSNEOptions, IUMAPOptions} from '@datagrok-libraries/ml/src/reduce-dimensionality';
45
45
  import {SequenceSpaceFunctionEditor} from '@datagrok-libraries/ml/src/functionEditors/seq-space-editor';
46
46
  import {ActivityCliffsFunctionEditor} from '@datagrok-libraries/ml/src/functionEditors/activity-cliffs-editor';
47
+ import {SCORE, calculateScores} from '@datagrok-libraries/bio/src/utils/macromolecule/scoring';
47
48
 
48
49
  import {demoBio01UI} from './demo/bio01-similarity-diversity';
49
50
  import {demoBio01aUI} from './demo/bio01a-hierarchical-clustering-and-sequence-space';
@@ -54,7 +55,6 @@ import {checkInputColumnUI} from './utils/check-input-column';
54
55
  import {multipleSequenceAlignmentUI} from './utils/multiple-sequence-alignment-ui';
55
56
  import {MmDistanceFunctionsNames} from '@datagrok-libraries/ml/src/macromolecule-distance-functions';
56
57
  import {BitArrayMetrics, BitArrayMetricsNames} from '@datagrok-libraries/ml/src/typed-metrics';
57
- import {NotationConverter} from '@datagrok-libraries/bio/src/utils/notation-converter';
58
58
  import {WebLogoApp} from './apps/web-logo-app';
59
59
  import {SplitToMonomersFunctionEditor} from './function-edtiors/split-to-monomers-editor';
60
60
  import {splitToMonomersUI} from './utils/split-to-monomers';
@@ -65,10 +65,13 @@ import {PackageSettingsEditorWidget} from './widgets/package-settings-editor-wid
65
65
  import {getCompositionAnalysisWidget} from './widgets/composition-analysis-widget';
66
66
  import {MacromoleculeColumnWidget} from './utils/macromolecule-column-widget';
67
67
  import {addCopyMenuUI} from './utils/context-menu';
68
+ import {getRegionDo} from './utils/get-region';
69
+ import {GetRegionApp} from './apps/get-region-app';
70
+ import {GetRegionFuncEditor} from './utils/get-region-func-editor';
68
71
 
69
72
  export const _package = new BioPackage();
70
73
 
71
- // /** Avoid reassinging {@link monomerLib} because consumers subscribe to {@link IMonomerLib.onChanged} event */
74
+ // /** Avoid reassigning {@link monomerLib} because consumers subscribe to {@link IMonomerLib.onChanged} event */
72
75
  // let monomerLib: MonomerLib | null = null;
73
76
 
74
77
  //name: getMonomerLibHelper
@@ -103,7 +106,9 @@ export async function initBio() {
103
106
  const bioPkgProps = new BioPackageProperties(pkgProps);
104
107
  _package.properties = bioPkgProps;
105
108
  })(),
106
- ]);
109
+ ]).finally(() => {
110
+ _package.completeInit();
111
+ });
107
112
 
108
113
  const monomerLib = MonomerLibHelper.instance.getBioLib();
109
114
  const monomers: string[] = [];
@@ -149,14 +154,96 @@ export function getBioLib(): IMonomerLib {
149
154
  return MonomerLibHelper.instance.getBioLib();
150
155
  }
151
156
 
157
+ // -- Panels --
158
+
159
+ //name: Get Region
160
+ //description: Creates a new column with sequences of the region between start and end
161
+ //tags: panel
162
+ //input: column seqCol {semType: Macromolecule}
163
+ //output: widget result
164
+ export function getRegionPanel(seqCol: DG.Column<string>): DG.Widget {
165
+ // const host = ui.divV([
166
+ // ui.inputs([
167
+ // ui.stringInput('Region', ''),
168
+ // ]),
169
+ // ui.button('Ok', () => {})
170
+ // ]);
171
+ // return DG.Widget.fromRoot(host);
172
+ const funcName: string = 'getRegionTopMenu';
173
+ const funcList = DG.Func.find({package: _package.name, name: funcName});
174
+ if (funcList.length !== 1) throw new Error(`Package '${_package.name}' func '${funcName}' not found`);
175
+ const func = funcList[0];
176
+ const funcCall = func.prepare({table: seqCol.dataFrame, sequence: seqCol});
177
+ const funcEditor = new GetRegionFuncEditor(funcCall);
178
+ return funcEditor.widget();
179
+ }
180
+
152
181
  //name: Manage Libraries
153
- //input: column seqColumn {semType: Macromolecule}
182
+ //description:
154
183
  //tags: panel, exclude-actions-panel
184
+ //input: column seqColumn {semType: Macromolecule}
155
185
  //output: widget result
156
186
  export async function libraryPanel(_seqColumn: DG.Column): Promise<DG.Widget> {
157
187
  return getLibraryPanelUI();
158
188
  }
159
189
 
190
+ // -- Func Editors --
191
+
192
+ //name: GetRegionEditor
193
+ //tags: editor
194
+ //input: funccall call
195
+ export function GetRegionEditor(call: DG.FuncCall): void {
196
+ try {
197
+ const funcEditor = new GetRegionFuncEditor(call);
198
+ funcEditor.dialog();
199
+ } catch (err: any) {
200
+ const errMsg = err instanceof Error ? err.message : err.toString();
201
+ const errStack = err instanceof Error ? err.stack : undefined;
202
+ grok.shell.error(`Get region editor error: ${errMsg}`);
203
+ _package.logger.error(errMsg, undefined, errStack);
204
+ }
205
+ }
206
+
207
+ //name: SplitToMonomersEditor
208
+ //tags: editor
209
+ //input: funccall call
210
+ export function SplitToMonomersEditor(call: DG.FuncCall): void {
211
+ const funcEditor = new SplitToMonomersFunctionEditor();
212
+ ui.dialog({title: 'Split to Monomers'})
213
+ .add(funcEditor.paramsUI)
214
+ .onOK(async () => {
215
+ return call.func.prepare(funcEditor.funcParams).call(true);
216
+ })
217
+ .show();
218
+ }
219
+
220
+ //name: SequenceSpaceEditor
221
+ //tags: editor
222
+ //input: funccall call
223
+ export function SequenceSpaceEditor(call: DG.FuncCall) {
224
+ const funcEditor = new SequenceSpaceFunctionEditor(DG.SEMTYPE.MACROMOLECULE);
225
+ ui.dialog({title: 'Sequence Space'})
226
+ .add(funcEditor.paramsUI)
227
+ .onOK(async () => {
228
+ return call.func.prepare(funcEditor.funcParams).call(true);
229
+ })
230
+ .show();
231
+ }
232
+
233
+ //name: SeqActivityCliffsEditor
234
+ //tags: editor
235
+ //input: funccall call
236
+ export function SeqActivityCliffsEditor(call: DG.FuncCall) {
237
+ const funcEditor = new ActivityCliffsFunctionEditor(DG.SEMTYPE.MACROMOLECULE);
238
+ ui.dialog({title: 'Activity Cliffs'})
239
+ .add(funcEditor.paramsUI)
240
+ .onOK(async () => {
241
+ return call.func.prepare(funcEditor.funcParams).call(true);
242
+ })
243
+ .show();
244
+ }
245
+
246
+
160
247
  // -- Package settings editor --
161
248
 
162
249
  //name: packageSettingsEditor
@@ -181,6 +268,8 @@ export function fastaSequenceCellRenderer(): MacromoleculeSequenceCellRenderer {
181
268
  return new MacromoleculeSequenceCellRenderer();
182
269
  }
183
270
 
271
+ // -- Property panels --
272
+
184
273
  //name: Sequence Renderer
185
274
  //input: column molColumn {semType: Macromolecule}
186
275
  //tags: panel
@@ -250,17 +339,39 @@ export function vdRegionsViewer() {
250
339
  return new VdRegionsViewer();
251
340
  }
252
341
 
253
- //name: SeqActivityCliffsEditor
254
- //tags: editor
255
- //input: funccall call
256
- export function SeqActivityCliffsEditor(call: DG.FuncCall) {
257
- const funcEditor = new ActivityCliffsFunctionEditor(DG.SEMTYPE.MACROMOLECULE);
258
- ui.dialog({title: 'Activity Cliffs'})
259
- .add(funcEditor.paramsUI)
260
- .onOK(async () => {
261
- return call.func.prepare(funcEditor.funcParams).call(true);
262
- })
263
- .show();
342
+
343
+ // -- Top menu --
344
+
345
+ //name: getRegion
346
+ //description: Gets a new column with sequences of the region between start and end
347
+ //input: column sequence
348
+ //input: string start {optional: true}
349
+ //input: string end {optional: true}
350
+ //input: string name {optional: true} [Name of the column to be created]
351
+ //output: column result
352
+ export function getRegion(
353
+ sequence: DG.Column<string>, start: string | undefined, end: string | undefined, name: string | undefined
354
+ ): DG.Column<string> {
355
+ return getRegionDo(sequence,
356
+ start ?? null, end ?? null, name ?? null);
357
+ }
358
+
359
+ //top-menu: Bio | Convert | Get Region...
360
+ //name: Get Region
361
+ //description: Get sequences for a region specified from a Macromolecule
362
+ //input: dataframe table [Input data table]
363
+ //input: column sequence {semType: Macromolecule} [Sequence column]
364
+ //input: string start {optional: true} [Region start position name]
365
+ //input: string end {optional: true} [Region end position name]
366
+ //input: string name {optional: true} [Region column name]
367
+ //editor: Bio:GetRegionEditor
368
+ export function getRegionTopMenu(
369
+ table: DG.DataFrame, sequence: DG.Column,
370
+ start: string | undefined, end: string | undefined, name: string | undefined
371
+ ): void {
372
+ const regCol = getRegionDo(sequence, start ?? null, end ?? null, name ?? null);
373
+ sequence.dataFrame.columns.add(regCol);
374
+ regCol.setTag(DG.TAGS.CELL_RENDERER, 'sequence');
264
375
  }
265
376
 
266
377
  //top-menu: Bio | Analyze | Activity Cliffs...
@@ -286,14 +397,14 @@ export async function activityCliffs(df: DG.DataFrame, macroMolecule: DG.Column,
286
397
  'separator': macroMolecule.getTag(bioTAGS.separator),
287
398
  'alphabet': macroMolecule.getTag(bioTAGS.alphabet),
288
399
  };
289
- const nc = new NotationConverter(macroMolecule);
400
+ const ncUH = UnitsHandler.getOrCreate(macroMolecule);
290
401
  let columnDistanceMetric: BitArrayMetrics | MmDistanceFunctionsNames = BitArrayMetricsNames.Tanimoto;
291
402
  let seqCol = macroMolecule;
292
- if (nc.isFasta() || (nc.isSeparator() && nc.alphabet && nc.alphabet !== ALPHABET.UN)) {
293
- if (nc.isFasta()) {
294
- columnDistanceMetric = nc.getDistanceFunctionName();
403
+ if (ncUH.isFasta() || (ncUH.isSeparator() && ncUH.alphabet && ncUH.alphabet !== ALPHABET.UN)) {
404
+ if (ncUH.isFasta()) {
405
+ columnDistanceMetric = ncUH.getDistanceFunctionName();
295
406
  } else {
296
- seqCol = nc.convert(NOTATION.FASTA);
407
+ seqCol = ncUH.convert(NOTATION.FASTA);
297
408
  const uh = UnitsHandler.getOrCreate(seqCol);
298
409
  columnDistanceMetric = uh.getDistanceFunctionName();
299
410
  tags.units = NOTATION.FASTA;
@@ -344,19 +455,6 @@ export async function activityCliffs(df: DG.DataFrame, macroMolecule: DG.Column,
344
455
  }
345
456
  }
346
457
 
347
- //name: SequenceSpaceEditor
348
- //tags: editor
349
- //input: funccall call
350
- export function SequenceSpaceEditor(call: DG.FuncCall) {
351
- const funcEditor = new SequenceSpaceFunctionEditor(DG.SEMTYPE.MACROMOLECULE);
352
- ui.dialog({title: 'Sequence Space'})
353
- .add(funcEditor.paramsUI)
354
- .onOK(async () => {
355
- return call.func.prepare(funcEditor.funcParams).call(true);
356
- })
357
- .show();
358
- }
359
-
360
458
  //top-menu: Bio | Analyze | Sequence Space...
361
459
  //name: Sequence Space
362
460
  //description: Creates 2D sequence space with projected sequences by pairwise distance
@@ -602,7 +700,7 @@ export function importBam(fileContent: string): DG.DataFrame [] {
602
700
  //top-menu: Bio | Convert | Notation...
603
701
  //name: convertDialog
604
702
  export function convertDialog() {
605
- const col = getMacromoleculeColumn();
703
+ const col = getMacromoleculeColumns()[0];
606
704
  convert(col);
607
705
  }
608
706
 
@@ -666,19 +764,6 @@ export async function testDetectMacromolecule(path: string): Promise<DG.DataFram
666
764
  return resDf;
667
765
  }
668
766
 
669
- //name: SplitToMonomersEditor
670
- //tags: editor
671
- //input: funccall call
672
- export function SplitToMonomersEditor(call: DG.FuncCall): void {
673
- const funcEditor = new SplitToMonomersFunctionEditor();
674
- ui.dialog({title: 'Split to Monomers'})
675
- .add(funcEditor.paramsUI)
676
- .onOK(async () => {
677
- return call.func.prepare(funcEditor.funcParams).call(true);
678
- })
679
- .show();
680
- }
681
-
682
767
  //top-menu: Bio | Convert | Split to Monomers...
683
768
  //name: Split to Monomers
684
769
  //input: dataframe table
@@ -734,12 +819,56 @@ export function diversitySearchTopMenu() {
734
819
  view.dockManager.dock(viewer, 'down');
735
820
  }
736
821
 
737
- //top-menu: Bio | Search | Substructure...
738
- //name: bioSubstructureSearch
739
- //description: Finds sequence with the given subsequence
740
- export function bioSubstructureSearch(): void {
741
- const col = getMacromoleculeColumn();
742
- substructureSearchDialog(col);
822
+ //name: SearchSubsequenceEditor
823
+ //tags: editor
824
+ //input: funccall call
825
+ export function searchSubsequenceEditor(call: DG.FuncCall) {
826
+ const columns = getMacromoleculeColumns();
827
+ if (columns.length === 1)
828
+ call.func.prepare({macromolecules: columns[0]}).call(true);
829
+ else
830
+ new SubstructureSearchDialog(columns);
831
+ }
832
+
833
+ //top-menu: Bio | Search | Subsequence...
834
+ //name: Subsequence Search
835
+ //input: column macromolecules
836
+ //editor: Bio:SearchSubsequenceEditor
837
+ export function SubsequenceSearchTopMenu(macromolecules: DG.Column): void {
838
+ grok.shell.tv.getFiltersGroup({createDefaultFilters: false}).updateOrAdd({
839
+ type: 'Bio:bioSubstructureFilter',
840
+ column: macromolecules.name,
841
+ columnName: macromolecules.name,
842
+ });
843
+ grok.shell.tv.grid.scrollToCell(macromolecules, 0);
844
+ }
845
+
846
+ //top-menu: Bio | Calculate | Identity...
847
+ //name: Identity Scoring
848
+ //description: Adds a column with fraction of matching monomers
849
+ //input: dataframe table [Table containing Macromolecule column]
850
+ //input: column macromolecules {semType: Macromolecule} [Sequences to score]
851
+ //input: string reference [Sequence, matching column format]
852
+ //output: column scores
853
+ export async function sequenceIdentityScoring(
854
+ table: DG.DataFrame, macromolecule: DG.Column, reference: string
855
+ ): Promise<DG.Column<number>> {
856
+ const scores = calculateScores(table, macromolecule, reference, SCORE.IDENTITY);
857
+ return scores;
858
+ }
859
+
860
+ //top-menu: Bio | Calculate | Similarity...
861
+ //name: Similarity Scoring
862
+ //description: Adds a column with similarity scores, calculated as sum of monomer fingerprint similarities
863
+ //input: dataframe table [Table containing Macromolecule column]
864
+ //input: column macromolecules {semType: Macromolecule} [Sequences to score]
865
+ //input: string reference [Sequence, matching column format]
866
+ //output: column scores
867
+ export async function sequenceSimilarityScoring(
868
+ table: DG.DataFrame, macromolecule: DG.Column, reference: string
869
+ ): Promise<DG.Column<number>> {
870
+ const scores = calculateScores(table, macromolecule, reference, SCORE.SIMILARITY);
871
+ return scores;
743
872
  }
744
873
 
745
874
  //name: saveAsFasta
@@ -765,10 +894,22 @@ export async function webLogoLargeApp(): Promise<void> {
765
894
  const pi = DG.TaskBarProgressIndicator.create('WebLogo');
766
895
  try {
767
896
  const urlParams = new URLSearchParams(window.location.search);
768
- const app = new WebLogoApp(urlParams);
897
+ const app = new WebLogoApp(urlParams, 'webLogoLargeApp');
769
898
  const df: DG.DataFrame = await _package.files.readCsv('data/sample_PT_100000x5.csv');
770
899
  await grok.data.detectSemanticTypes(df);
771
- await app.init(df, 'webLogoLargeApp');
900
+ await app.init(df);
901
+ } finally {
902
+ pi.close();
903
+ }
904
+ }
905
+
906
+ //name: getRegionApp
907
+ export async function getRegionApp(): Promise<void> {
908
+ const pi = DG.TaskBarProgressIndicator.create('getRegion ...');
909
+ try {
910
+ const urlParams = new URLSearchParams(window.location.search);
911
+ const app = new GetRegionApp(urlParams, 'getRegionApp');
912
+ await app.init();
772
913
  } finally {
773
914
  pi.close();
774
915
  }