@datagrok/peptides 1.7.2 → 1.8.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/src/package.ts CHANGED
@@ -7,23 +7,36 @@ import {analyzePeptidesUI} from './widgets/peptides';
7
7
  import {PeptideSimilaritySpaceWidget} from './utils/peptide-similarity-space';
8
8
  import {manualAlignmentWidget} from './widgets/manual-alignment';
9
9
  import {MonomerPosition, MostPotentResiduesViewer} from './viewers/sar-viewer';
10
-
10
+ import {getTreeHelper, ITreeHelper} from '@datagrok-libraries/bio/src/trees/tree-helper';
11
+ import {IDendrogramService, getDendrogramService} from '@datagrok-libraries/bio/src/trees/dendrogram';
11
12
  import {PeptideSpaceViewer} from './viewers/peptide-space-viewer';
12
- import {LogoSummary} from './viewers/logo-summary';
13
+ import {LogoSummaryTable} from './viewers/logo-summary';
13
14
  import {MonomerWorks} from '@datagrok-libraries/bio/src/monomer-works/monomer-works';
14
15
  import {PeptidesModel} from './model';
15
16
 
16
17
  let monomerWorks: MonomerWorks | null = null;
18
+ let treeHelper: ITreeHelper | null = null;
19
+ let dendrogramService: IDendrogramService | null = null;
17
20
 
18
21
  export const _package = new DG.Package();
19
22
 
20
- export function getMonomerWorks(): MonomerWorks | null {
21
- return monomerWorks;
23
+ export function getMonomerWorksInstance(): MonomerWorks {
24
+ return monomerWorks!;
25
+ }
26
+
27
+ export function getTreeHelperInstance(): ITreeHelper {
28
+ return treeHelper!;
29
+ }
30
+
31
+ export function getDendrogramServiceInstance(): IDendrogramService {
32
+ return dendrogramService!;
22
33
  }
23
34
 
24
35
  //tags: init
25
36
  export async function initPeptides(): Promise<void> {
26
37
  monomerWorks ??= new MonomerWorks(await grok.functions.call('Bio:getBioLib'));
38
+ treeHelper ??= await getTreeHelper();
39
+ dendrogramService ??= await getDendrogramService();
27
40
  }
28
41
 
29
42
  async function openDemoData(chosenFile: string): Promise<void> {
@@ -44,24 +57,22 @@ export function Peptides(): void {
44
57
  const wikiLink = ui.link('wiki', 'https://github.com/datagrok-ai/public/blob/master/help/domains/bio/peptides.md');
45
58
  const textLink = ui.inlineText(['For more details, see our ', wikiLink, '.']);
46
59
 
47
- const appDescription = ui.info(
48
- [
49
- ui.list([
50
- '- automatic recognition of peptide sequences',
51
- '- native integration with tons of Datagrok out-of-the box features (visualization, filtering, clustering, ' +
60
+ const appDescription = ui.info([
61
+ ui.list([
62
+ '- automatic recognition of peptide sequences',
63
+ '- native integration with tons of Datagrok out-of-the box features (visualization, filtering, clustering, ' +
52
64
  'multivariate analysis, etc)',
53
- '- custom rendering in the spreadsheet',
54
- '- interactive logo plots',
55
- '- rendering residues',
56
- '- structure-activity relationship:',
57
- ' ',
58
- 'a) highlighting statistically significant changes in activity in the [position, monomer] spreadsheet',
59
- 'b) for the specific [position, monomer], visualizing changes of activity distribution (specific monomer in ' +
65
+ '- custom rendering in the spreadsheet',
66
+ '- interactive logo plots',
67
+ '- rendering residues',
68
+ '- structure-activity relationship:',
69
+ ' ',
70
+ 'a) highlighting statistically significant changes in activity in the [position, monomer] spreadsheet',
71
+ 'b) for the specific [position, monomer], visualizing changes of activity distribution (specific monomer in ' +
60
72
  'this position vs rest of the monomers in this position)',
61
- 'c) interactivity',
62
- ]),
63
- ],
64
- 'Use and analyse peptide sequence data to support your research:',
73
+ 'c) interactivity',
74
+ ]),
75
+ ], 'Use and analyse peptide sequence data to support your research:',
65
76
  );
66
77
 
67
78
  const windows = grok.shell.windows;
@@ -101,32 +112,36 @@ export function peptidesPanel(col: DG.Column): DG.Widget {
101
112
  return new DG.Widget(analyzeObject.host);
102
113
  }
103
114
 
104
- //name: peptide-sar-viewer
105
- //description: Peptides SAR Viewer
115
+ //name: Monomer-Position
116
+ //description: Peptides Monomer-Position Viewer
106
117
  //tags: viewer
118
+ //meta.icon: files/icons/peptide-sar-viewer.svg
107
119
  //output: viewer result
108
- export function sar(): MonomerPosition {
120
+ export function monomerPosition(): MonomerPosition {
109
121
  return new MonomerPosition();
110
122
  }
111
123
 
112
- //name: peptide-sar-viewer-vertical
113
- //description: Peptides Vertical SAR Viewer
124
+ //name: Most Potent Residues
125
+ //description: Peptides Most Potent Residues Viewer
114
126
  //tags: viewer
127
+ //meta.icon: files/icons/peptide-sar-vertical-viewer.svg
115
128
  //output: viewer result
116
- export function sarVertical(): MostPotentResiduesViewer {
129
+ export function mostPotentResidues(): MostPotentResiduesViewer {
117
130
  return new MostPotentResiduesViewer();
118
131
  }
119
132
 
120
- //name: logo-summary-viewer
133
+ //name: Logo Summary Table
121
134
  //tags: viewer
135
+ //meta.icon: files/icons/logo-summary-viewer.svg
122
136
  //output: viewer result
123
- export function logoSummary(): LogoSummary {
124
- return new LogoSummary();
137
+ export function logoSummaryTable(): LogoSummaryTable {
138
+ return new LogoSummaryTable();
125
139
  }
126
140
 
127
141
  //name: peptide-space-viewer
128
142
  //description: Peptide Space Viewer
129
143
  //tags: viewer
144
+ //meta.icon: files/icons/peptide-space-viewer.svg
130
145
  //output: viewer result
131
146
  export function peptideSpace(): PeptideSpaceViewer {
132
147
  return new PeptideSpaceViewer();
@@ -1,4 +1,4 @@
1
- import {/*before, after, */after, category, test} from '@datagrok-libraries/utils/src/test';
1
+ import {category, test} from '@datagrok-libraries/utils/src/test';
2
2
  import * as utils from './utils';
3
3
  import {DimensionalityReducer} from '@datagrok-libraries/ml/src/reduce-dimensionality';
4
4
  import {cleanAlignedSequencesColumn} from '../utils/peptide-similarity-space';
@@ -7,7 +7,6 @@ import {aligned1} from './test-data';
7
7
  import * as DG from 'datagrok-api/dg';
8
8
  import * as grok from 'datagrok-api/grok';
9
9
  import {StringMetrics} from '@datagrok-libraries/ml/src/typed-metrics';
10
- import {_package} from '../package-test';
11
10
 
12
11
  let table: DG.DataFrame;
13
12
  let view: DG.TableView;
@@ -1,6 +1,4 @@
1
1
  import * as DG from 'datagrok-api/dg';
2
- import * as grok from 'datagrok-api/grok';
3
- //import * as ui from 'datagrok-api/ui';
4
2
 
5
3
  import {category, test, testViewer} from '@datagrok-libraries/utils/src/test';
6
4
  import {aligned1} from './test-data';
@@ -2,7 +2,7 @@ import * as DG from 'datagrok-api/dg';
2
2
 
3
3
  import * as C from './constants';
4
4
  import * as types from './types';
5
- import {PositionStats, SummaryStats, MonomerPositionStats} from '../model';
5
+ import {PositionStats, MonomerPositionStats} from '../model';
6
6
  import {SeqPalette} from '@datagrok-libraries/bio/src/seq-palettes';
7
7
  import {monomerToShort} from '@datagrok-libraries/bio/src/utils/macromolecule';
8
8
 
@@ -0,0 +1,16 @@
1
+ import {DistanceMatrix} from '@datagrok-libraries/bio/src/trees/distance-matrix';
2
+ import {stringDistanceMetricsMethods} from '@datagrok-libraries/ml/src/typed-metrics';
3
+
4
+ const ctx: Worker = self as any;
5
+
6
+ ctx.addEventListener('message', async ({data: {peptidesList, metric}}) => {
7
+ const data: {error?: any, distances?: Float32Array} = {};
8
+ try {
9
+ const dm = DistanceMatrix.calc(peptidesList,
10
+ (a: string, b: string) => stringDistanceMetricsMethods[metric](a, b));
11
+ data.distances = dm.data;
12
+ } catch (e) {
13
+ data.error = e;
14
+ }
15
+ self.postMessage(data);
16
+ });
@@ -11,7 +11,6 @@ import {
11
11
  } from '@datagrok-libraries/ml/src/workers/dimensionality-reducing-worker-creator';
12
12
  import {Measure, StringMetrics} from '@datagrok-libraries/ml/src/typed-metrics';
13
13
  import {Coordinates} from '@datagrok-libraries/utils/src/type-declarations';
14
- import * as C from './constants';
15
14
 
16
15
  /**
17
16
  * Cast an aligned sequences column to clean sequences.
@@ -1,3 +1,4 @@
1
+ import * as DG from 'datagrok-api/dg';
1
2
  import {tTest} from '@datagrok-libraries/statistics/src/tests';
2
3
  import {RawData} from './types';
3
4
 
@@ -36,3 +37,11 @@ export function getStats(data: RawData | number[], maskInfo: MaskInfo): Stats {
36
37
  ratio: selected.length / data.length,
37
38
  };
38
39
  }
40
+
41
+ export function getAggregatedValue(col: DG.Column<number>, agg: DG.AggregationType, mask?: DG.BitSet): number {
42
+ const stat = DG.Stats.fromColumn(col, mask);
43
+ if (!(agg in stat))
44
+ throw new Error(`Aggregation type ${agg} is not supported`);
45
+ //@ts-ignore: this is a hack to avoid using switch to access the getters
46
+ return stat[agg] as number;
47
+ }
@@ -17,9 +17,13 @@ export type PeptidesSettings = {
17
17
  clustersColumnName?: string,
18
18
  scaling?: ScalingMethods,
19
19
  isBidirectional?: boolean,
20
+ showMonomerPosition?: boolean,
21
+ showMostPotentResidues?: boolean,
22
+ showLogoSummaryTable?: boolean,
23
+ showDendrogram?: boolean,
20
24
  maxMutations?: number,
21
25
  minActivityDelta?: number,
22
- columns?: {[col: string]: string},
26
+ columns?: {[col: string]: DG.AggregationType},
23
27
  };
24
28
 
25
29
  export type DrawOptions = {
@@ -0,0 +1,11 @@
1
+ import {StringMetrics} from '@datagrok-libraries/ml/src/typed-metrics';
2
+
3
+ export function createDistanceMatrixWorker(peptidesList: string[], metric: StringMetrics): Promise<Float32Array> {
4
+ return new Promise(function(resolve, reject) {
5
+ const worker = new Worker(new URL('./distance-matrix.worker', import.meta.url));
6
+ worker.postMessage({peptidesList, metric});
7
+ worker.onmessage = ({data: {error, distances}}): void => {
8
+ error ? reject(error) : resolve(distances);
9
+ };
10
+ });
11
+ }