@datagrok/peptides 0.8.13 → 1.0.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.
Files changed (39) hide show
  1. package/.eslintrc.json +5 -2
  2. package/dist/package-test.js +1268 -1766
  3. package/dist/package.js +1097 -1622
  4. package/dist/vendors-node_modules_datagrok-libraries_ml_src_workers_dimensionality-reducer_js.js +120 -62
  5. package/package.json +13 -17
  6. package/package.png +0 -0
  7. package/src/model.ts +504 -448
  8. package/src/monomer-library.ts +31 -30
  9. package/src/package-test.ts +5 -6
  10. package/src/package.ts +52 -70
  11. package/src/tests/core.ts +67 -0
  12. package/src/tests/msa-tests.ts +3 -3
  13. package/src/tests/peptide-space-test.ts +65 -45
  14. package/src/tests/utils.ts +20 -50
  15. package/src/utils/cell-renderer.ts +25 -151
  16. package/src/utils/chem-palette.ts +3 -14
  17. package/src/utils/constants.ts +5 -0
  18. package/src/utils/filtering-statistics.ts +2 -2
  19. package/src/utils/misc.ts +29 -0
  20. package/src/utils/multiple-sequence-alignment.ts +5 -18
  21. package/src/utils/multivariate-analysis.ts +5 -8
  22. package/src/utils/peptide-similarity-space.ts +12 -9
  23. package/src/utils/types.ts +5 -2
  24. package/src/viewers/peptide-space-viewer.ts +67 -39
  25. package/src/viewers/sar-viewer.ts +34 -37
  26. package/src/viewers/stacked-barchart-viewer.ts +38 -61
  27. package/src/widgets/analyze-peptides.ts +53 -75
  28. package/src/widgets/distribution.ts +34 -18
  29. package/src/widgets/manual-alignment.ts +8 -12
  30. package/src/widgets/peptide-molecule.ts +48 -25
  31. package/src/widgets/subst-table.ts +53 -52
  32. package/src/workers/dimensionality-reducer.ts +8 -13
  33. package/{test-Peptides-f8114def7953-4bf59d70.html → test-Peptides-69a4761f6044-40ac3a0c.html} +2 -2
  34. package/src/peptides.ts +0 -327
  35. package/src/semantics.ts +0 -5
  36. package/src/tests/peptides-tests.ts +0 -60
  37. package/src/utils/SAR-multiple-filter.ts +0 -439
  38. package/src/utils/SAR-multiple-selection.ts +0 -177
  39. package/src/viewers/logo-viewer.ts +0 -195
@@ -1,195 +0,0 @@
1
- import * as ui from 'datagrok-api/ui';
2
- import * as DG from 'datagrok-api/dg';
3
-
4
- import $ from 'cash-dom';
5
-
6
- import * as logojs from 'logojs-react';
7
- // import {splitAlignedPeptides} from '../utils/split-aligned';
8
- import {ChemPalette} from '../utils/chem-palette';
9
- import {PeptidesController} from '../peptides';
10
- import * as C from '../utils/constants';
11
-
12
- /**
13
- * Logo viewer.
14
- *
15
- * @export
16
- * @class Logo
17
- * @extends {DG.JsViewer}
18
- */
19
- export class Logo extends DG.JsViewer {
20
- initialized: boolean;
21
- option: any;
22
- colSemType: string;
23
- splitted: DG.DataFrame | null;
24
- ppm: Array<Array<number>>;
25
- reactHost: HTMLDivElement | null;
26
- PROT_NUMS: { [id: string]: number };
27
- LET_COLORS: Array<any>;
28
- target: DG.DataFrame | undefined | null;
29
-
30
- /**
31
- * Creates an instance of Logo.
32
- *
33
- * @memberof Logo
34
- */
35
- constructor() {
36
- super();
37
- this.initialized = false;
38
- this.colSemType = this.string('colSemType', C.SEM_TYPES.ALIGNED_SEQUENCE);
39
-
40
- this.splitted = null;
41
- this.ppm = [];
42
- this.reactHost = null;
43
- this.target = null;
44
- this.PROT_NUMS = {
45
- 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'K': 9, 'L': 10, 'M': 11,
46
- 'N': 12, 'P': 13, 'Q': 14, 'R': 15, 'S': 16, 'T': 17, 'U': 18, 'V': 19, 'W': 20, 'Y': 21, 'Z': 22,
47
- };
48
- //TODO: use chem palette
49
- this.LET_COLORS = [
50
- {color: 'rgb(44,160,44)', regex: 'A'},
51
- {color: 'rgb(44,160,44)', regex: 'B'},
52
- {color: 'rgb(188,189,34)', regex: 'C'},
53
- {color: 'rgb(31,119,180)', regex: 'D'},
54
- {color: 'rgb(30,110,96)', regex: 'E'},
55
- {color: 'rgb(24,110,79)', regex: 'F'},
56
- {color: 'rgb(214,39,40)', regex: 'G'},
57
- {color: 'rgb(158,218,229)', regex: 'H'},
58
- {color: 'rgb(122, 102, 189)', regex: 'I'},
59
- {color: 'rgb(108, 218, 229)', regex: 'K'},
60
- {color: 'rgb(30,110,96)', regex: 'L'},
61
- {color: 'rgb(141, 124, 217)', regex: 'M'},
62
- {color: 'rgb(235,137,70)', regex: 'N'},
63
- {color: 'rgb(255,152,150)', regex: 'P'},
64
- {color: 'rgb(205, 111, 71)', regex: 'Q'},
65
- {color: 'rgb(23,190,207)', regex: 'R'},
66
- {color: 'rgb(255,187,120)', regex: 'S'},
67
- {color: 'rgb(245,167,100)', regex: 'T'},
68
- {color: 'rgb(188,189,34)', regex: 'U'},
69
- {color: 'rgb(23,190,207', regex: 'V'},
70
- {color: 'rgb(182, 223, 138)', regex: 'W'},
71
- {color: 'rgb(152,223,138)', regex: 'Y'},
72
- {color: 'rgb(205, 111, 71)', regex: 'Z'},
73
- ];
74
- }
75
-
76
- /**
77
- * Initializer function.
78
- *
79
- * @memberof Logo
80
- */
81
- init() {
82
- this.initialized = true;
83
- console.log('INIT');
84
- this.target = this.dataFrame;
85
- [this.splitted] = PeptidesController.splitAlignedPeptides(this.dataFrame!.columns.bySemType(this.colSemType));
86
- this.root.style.width = 'auto';
87
- this.root.style.height = 'auto';
88
- this.root.style.maxHeight = '200px';
89
- }
90
-
91
- /**
92
- * Function to execute when the table is attached.
93
- *
94
- * @memberof Logo
95
- */
96
- onTableAttached() {
97
- if (typeof this.dataFrame !== 'undefined') {
98
- if (!this.initialized)
99
- this.init();
100
-
101
-
102
- this.subs.push(DG.debounce(this.dataFrame.selection.onChanged, 50).subscribe((_: any) => this.render()));
103
- this.subs.push(DG.debounce(this.dataFrame.filter.onChanged, 50).subscribe((_: any) => this.render()));
104
- this.subs.push(DG.debounce(ui.onSizeChanged(this.root), 50).subscribe((_: any) => this.render()));
105
- }
106
-
107
- this.render();
108
- }
109
-
110
- /**
111
- * Function that is executed when the viewer is detached.
112
- *
113
- * @memberof Logo
114
- */
115
- detach() {
116
- this.subs.forEach((sub) => sub.unsubscribe());
117
- }
118
-
119
- /**
120
- * Function that is executed when the viewer property is changed.
121
- *
122
- * @param {DG.Property} property
123
- * @memberof Logo
124
- */
125
- onPropertyChanged(property: DG.Property) {
126
- super.onPropertyChanged(property);
127
-
128
- this.render();
129
- }
130
-
131
- /**
132
- * Function that renders the viewer.
133
- *
134
- * @memberof Logo
135
- */
136
- async render() {
137
- const bits = this.dataFrame!.selection;
138
- let selected = false;
139
- if (bits.trueCount > 0) {
140
- selected = true;
141
- this.target = this.dataFrame!
142
- .groupBy([this.dataFrame!.columns.bySemType(this.colSemType).name])
143
- .whereRowMask(this.dataFrame!.selection)
144
- .aggregate();
145
- }
146
- if (selected)
147
- [this.splitted] = PeptidesController.splitAlignedPeptides(this.target!.columns.bySemType(this.colSemType));
148
- else [this.splitted] = PeptidesController.splitAlignedPeptides(this.dataFrame!.columns.bySemType(this.colSemType));
149
- $(this.root).empty();
150
-
151
- if (typeof this.dataFrame !== 'undefined')
152
- this.findLogo();
153
- }
154
-
155
- /**
156
- * Create logo.
157
- *
158
- * @memberof Logo
159
- */
160
- async findLogo() {
161
- this.getInfoFromDf();
162
- logojs.embedProteinLogo(this.root, {alphabet: this.LET_COLORS, ppm: this.ppm});
163
- }
164
-
165
- /**
166
- * Retrieves information for building logo from the dataframe.
167
- *
168
- * @memberof Logo
169
- */
170
- getInfoFromDf() {
171
- let index: number = 0;
172
- this.ppm = [];
173
-
174
- for (const col of this.splitted!.columns) {
175
- const size = col.length;
176
- this.ppm.push(new Array(22).fill(0));
177
- for (let i = 0; i < col.length; i++) {
178
- const c = col.get(i);
179
- if (c != '-') {
180
- if (c[1] == '(')
181
- this.ppm[index][this.PROT_NUMS[c.substr(0, 1).toUpperCase()]] += 1 / size;
182
- else if (c.substr(0, 3) in ChemPalette.AAFullNames && (c.length == 3 || c.at(3) == '('))
183
- this.ppm[index][this.PROT_NUMS[ChemPalette.AAFullNames[c.substr(0, 3)]]] += 1 / size;
184
- else if (c.at(0)?.toLowerCase() == c.at(0) && c.substr(1, 3) in ChemPalette.AAFullNames &&
185
- (c.length == 4 || c.at(4) == '(')
186
- )
187
- this.ppm[index][this.PROT_NUMS[ChemPalette.AAFullNames[c.substr(1, 3)]]] += 1 / size;
188
- else
189
- this.ppm[index][this.PROT_NUMS[c]] += 1 / size;
190
- }
191
- }
192
- index++;
193
- }
194
- }
195
- }