@datagrok/peptides 1.24.0 → 1.25.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/CHANGELOG.md +8 -0
- package/dist/216.js +1 -1
- package/dist/216.js.map +1 -1
- package/dist/774.js +2 -0
- package/dist/774.js.map +1 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +3 -3
- package/src/model.ts +1 -4
- package/src/tests/misc.ts +4 -2
- package/src/utils/algorithms.ts +18 -27
- package/src/utils/cell-renderer.ts +1 -1
- package/src/utils/constants.ts +1 -4
- package/src/utils/misc.ts +2 -1
- package/src/utils/parallel-mutation-cliffs.ts +1 -4
- package/src/viewers/logo-summary.ts +1 -4
- package/src/viewers/sar-viewer.ts +151 -96
- package/src/widgets/selection.ts +1 -1
- package/src/workers/mutation-cliffs-worker.ts +7 -3
- package/test-console-output-1.log +89 -152
- package/test-record-1.mp4 +0 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/peptides",
|
|
3
3
|
"friendlyName": "Peptides",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.25.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Davit Rizhinashvili",
|
|
7
7
|
"email": "drizhinashvili@datagrok.ai"
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
"directory": "packages/Peptides"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@datagrok-libraries/bio": "^5.
|
|
16
|
+
"@datagrok-libraries/bio": "^5.61.3",
|
|
17
17
|
"@datagrok-libraries/math": "^1.2.6",
|
|
18
|
-
"@datagrok-libraries/ml": "^6.10.
|
|
18
|
+
"@datagrok-libraries/ml": "^6.10.7",
|
|
19
19
|
"@datagrok-libraries/statistics": "^1.2.12",
|
|
20
20
|
"@datagrok-libraries/tutorials": "^1.7.4",
|
|
21
21
|
"@datagrok-libraries/utils": "^4.6.9",
|
package/src/model.ts
CHANGED
|
@@ -312,9 +312,7 @@ export class PeptidesModel {
|
|
|
312
312
|
* @return {type.Selection} - Current Monomer-Position selection that came from WebLogo in header
|
|
313
313
|
*/
|
|
314
314
|
get webLogoSelection(): type.Selection {
|
|
315
|
-
|
|
316
|
-
this._webLogoSelection ??= tagSelection === null && this.positionColumns !== null ?
|
|
317
|
-
initSelection(this.positionColumns) : JSON.parse(tagSelection ?? `{}`);
|
|
315
|
+
this._webLogoSelection ??= initSelection(this.positionColumns ?? []);
|
|
318
316
|
return this._webLogoSelection!;
|
|
319
317
|
}
|
|
320
318
|
|
|
@@ -323,7 +321,6 @@ export class PeptidesModel {
|
|
|
323
321
|
*/
|
|
324
322
|
set webLogoSelection(selection: type.Selection) {
|
|
325
323
|
this._webLogoSelection = selection;
|
|
326
|
-
this.df.setTag(`${C.SUFFIXES.WL}${C.TAGS.INVARIANT_MAP_SELECTION}`, JSON.stringify(selection));
|
|
327
324
|
this.fireBitsetChanged(null);
|
|
328
325
|
this.analysisView.grid.invalidate();
|
|
329
326
|
}
|
package/src/tests/misc.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {findMutations, MutationCliffsOptions} from '../utils/algorithms';
|
|
|
6
6
|
import * as type from '../utils/types';
|
|
7
7
|
import {extractColInfo} from '../utils/misc';
|
|
8
8
|
import {PeptideUtils} from '../peptideUtils';
|
|
9
|
+
import BitArray from '@datagrok-libraries/utils/src/bit-array';
|
|
9
10
|
|
|
10
11
|
category('Algorithms', () => {
|
|
11
12
|
let activityCol: type.RawData;
|
|
@@ -53,8 +54,9 @@ category('Algorithms', () => {
|
|
|
53
54
|
expect(d32[0], 1, `MutationCliffsInfo['D']['3'][2] should have value 1`);
|
|
54
55
|
|
|
55
56
|
// Check with target
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
const filter = new BitArray(3, false);
|
|
58
|
+
filter.setBit(0, true);
|
|
59
|
+
settings.filter = filter.buffer;
|
|
58
60
|
mutationCliffsInfo = await findMutations(activityCol, monomerColumns, settings);
|
|
59
61
|
expect(mutationCliffsInfo.size, 0, `MutationCliffsInfo should be empty for target '1'`);
|
|
60
62
|
});
|
package/src/utils/algorithms.ts
CHANGED
|
@@ -18,8 +18,7 @@ import {
|
|
|
18
18
|
export type MutationCliffsOptions = {
|
|
19
19
|
maxMutations?: number,
|
|
20
20
|
minActivityDelta?: number,
|
|
21
|
-
|
|
22
|
-
currentTarget?: string | null
|
|
21
|
+
filter?: Uint32Array
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
/**
|
|
@@ -98,10 +97,6 @@ export function calculateMonomerPositionStatistics(activityCol: DG.Column<number
|
|
|
98
97
|
positionColumns: DG.Column<string>[], options: {
|
|
99
98
|
isFiltered?: boolean,
|
|
100
99
|
columns?: string[],
|
|
101
|
-
target?: {
|
|
102
|
-
col: DG.Column<string>,
|
|
103
|
-
cat: string,
|
|
104
|
-
},
|
|
105
100
|
aggValue?: {
|
|
106
101
|
col: DG.Column,
|
|
107
102
|
type: DG.AGG
|
|
@@ -109,27 +104,23 @@ export function calculateMonomerPositionStatistics(activityCol: DG.Column<number
|
|
|
109
104
|
} = {}): MonomerPositionStats {
|
|
110
105
|
options.isFiltered ??= false;
|
|
111
106
|
const monomerPositionObject = {general: {}} as MonomerPositionStats & { general: SummaryStats };
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
const activityColData: Float64Array = activityCol.getRawData() as Float64Array;
|
|
108
|
+
const sourceDfLen = activityCol.length;
|
|
114
109
|
options.columns ??= positionColumns.map((col) => col.name);
|
|
115
|
-
if (options.isFiltered) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
const targetColIndexes = options.target?.col?.getRawData();
|
|
131
|
-
const targetColCat = options.target?.col.categories;
|
|
132
|
-
const targetIndex = options.target?.cat ? targetColCat?.indexOf(options.target.cat) : -1;
|
|
110
|
+
// if (options.isFiltered) {
|
|
111
|
+
// sourceDfLen = filter.trueCount;
|
|
112
|
+
// const tempActivityData = new Float64Array(sourceDfLen);
|
|
113
|
+
// const selectedIndexes = filter.getSelectedIndexes();
|
|
114
|
+
// for (let i = 0; i < sourceDfLen; ++i)
|
|
115
|
+
// tempActivityData[i] = activityColData[selectedIndexes[i]];
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// activityColData = tempActivityData;
|
|
119
|
+
// positionColumns = DG.DataFrame.fromColumns(positionColumns).clone(filter, options.columns).columns.toList();
|
|
120
|
+
// if (options.aggValue)
|
|
121
|
+
// options.aggValue.col = options.aggValue.col.clone(filter);
|
|
122
|
+
// }
|
|
123
|
+
|
|
133
124
|
for (const posCol of positionColumns) {
|
|
134
125
|
if (!options.columns.includes(posCol.name))
|
|
135
126
|
continue;
|
|
@@ -147,7 +138,7 @@ export function calculateMonomerPositionStatistics(activityCol: DG.Column<number
|
|
|
147
138
|
|
|
148
139
|
const boolArray: boolean[] = new Array(sourceDfLen).fill(false);
|
|
149
140
|
for (let i = 0; i < sourceDfLen; ++i) {
|
|
150
|
-
if (posColData[i] === categoryIndex && (!
|
|
141
|
+
if (posColData[i] === categoryIndex && (!options.isFiltered || filter.get(i)))
|
|
151
142
|
boolArray[i] = true;
|
|
152
143
|
}
|
|
153
144
|
const bitArray = BitArray.fromValues(boolArray);
|
|
@@ -127,7 +127,7 @@ export function renderMutationCliffCell(canvasContext: CanvasRenderingContext2D,
|
|
|
127
127
|
} else if (viewer instanceof MostPotentResidues) {
|
|
128
128
|
// in case of most potent residues viewer, we render the invariant of monomer-position. i.e. how many sequences there are with that monomer at that position
|
|
129
129
|
// same as in invariant map viewer
|
|
130
|
-
const positionStats = viewer.monomerPositionStats
|
|
130
|
+
const positionStats = viewer.monomerPositionStats;
|
|
131
131
|
const count = positionStats?.[currentPosition]?.[currentMonomer]?.count;
|
|
132
132
|
if (count)
|
|
133
133
|
canvasContext.fillText(count.toString(), midX + halfWidth - 5, midY, halfWidth - 5);
|
package/src/utils/constants.ts
CHANGED
|
@@ -12,6 +12,7 @@ export enum COLUMNS_NAMES {
|
|
|
12
12
|
COUNT = 'Count',
|
|
13
13
|
RATIO = 'Ratio',
|
|
14
14
|
MEAN = 'Mean',
|
|
15
|
+
TOTAL_COUNT = '∑'
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export enum LST_COLUMN_NAMES {
|
|
@@ -28,13 +29,9 @@ export enum TAGS {
|
|
|
28
29
|
MONOMER = 'monomer',
|
|
29
30
|
POSITION = 'pos',
|
|
30
31
|
SEPARATOR = 'separator',
|
|
31
|
-
SELECTION = 'selection',
|
|
32
|
-
MUTATION_CLIFFS_SELECTION = 'mutationCliffsSelection',
|
|
33
32
|
ALPHABET = 'alphabet',
|
|
34
33
|
FILTER = 'filter',
|
|
35
|
-
INVARIANT_MAP_SELECTION = 'invariantMapSelection',
|
|
36
34
|
SAR_MODE = 'sarMode',
|
|
37
|
-
CLUSTER_SELECTION = 'clusterSelection',
|
|
38
35
|
VISIBLE = 'visible',
|
|
39
36
|
SETTINGS = 'settings',
|
|
40
37
|
CUSTOM_CLUSTER = 'customCluster',
|
package/src/utils/misc.ts
CHANGED
|
@@ -388,7 +388,8 @@ export function getSelectionBitset(selection: type.Selection, stats: MasksInfo):
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
return (combinedBitset != null) ?
|
|
391
|
+
return (combinedBitset != null) ?
|
|
392
|
+
DG.BitSet.fromBytes(combinedBitset!.buffer.buffer as ArrayBuffer, combinedBitset!.length) : null;
|
|
392
393
|
}
|
|
393
394
|
|
|
394
395
|
/**
|
|
@@ -22,8 +22,6 @@ export class ParallelMutationCliffs {
|
|
|
22
22
|
options: MutationCliffsOptions = {}): Promise<type.MutationCliffs> {
|
|
23
23
|
const substitutionsInfo: type.MutationCliffs = new Map();
|
|
24
24
|
try {
|
|
25
|
-
const currentTargetIdx = options.targetCol?.cat!.indexOf(options.currentTarget!) ?? -1;
|
|
26
|
-
|
|
27
25
|
const len = activityArray.length;
|
|
28
26
|
const promises = new Array<Promise<ParallelMutationReturnType>>(this._workerCount);
|
|
29
27
|
const matSize = len * (len - 1) / 2; // size of reduced upper triangular matrix
|
|
@@ -34,13 +32,12 @@ export class ParallelMutationCliffs {
|
|
|
34
32
|
monomerInfoArray.forEach((monomerInfo) => {
|
|
35
33
|
monomerInfo.cat = monomerInfo.cat?.slice();
|
|
36
34
|
});
|
|
37
|
-
options.targetCol?.cat && (options.targetCol.cat = options.targetCol.cat.slice());
|
|
38
35
|
for (let idx = 0; idx < this._workerCount; idx++) {
|
|
39
36
|
promises[idx] = new Promise((resolveWorker, rejectWorker) => {
|
|
40
37
|
const startIdx = Math.floor(idx * chunkSize);
|
|
41
38
|
const endIdx = idx === this._workerCount - 1 ? matSize : Math.floor((idx + 1) * chunkSize);
|
|
42
39
|
this._workers[idx].postMessage(
|
|
43
|
-
{startIdx, endIdx, activityArray, monomerInfoArray, settings: options
|
|
40
|
+
{startIdx, endIdx, activityArray, monomerInfoArray, settings: options});
|
|
44
41
|
this._workers[idx].onmessage = ({data: {pos, seq1Idxs, seq2Idxs, error}}): void => {
|
|
45
42
|
if (error) {
|
|
46
43
|
this._workers[idx]?.terminate();
|
|
@@ -195,9 +195,7 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
|
|
|
195
195
|
* @return - cluster selection.
|
|
196
196
|
*/
|
|
197
197
|
get clusterSelection(): type.Selection {
|
|
198
|
-
|
|
199
|
-
this._clusterSelection ??= tagSelection === null ? this.initClusterSelection({notify: false}) :
|
|
200
|
-
JSON.parse(tagSelection);
|
|
198
|
+
this._clusterSelection ??= this.initClusterSelection({notify: false});
|
|
201
199
|
return this._clusterSelection!;
|
|
202
200
|
}
|
|
203
201
|
|
|
@@ -207,7 +205,6 @@ export class LogoSummaryTable extends DG.JsViewer implements ILogoSummaryTable {
|
|
|
207
205
|
*/
|
|
208
206
|
set clusterSelection(selection: type.Selection) {
|
|
209
207
|
this._clusterSelection = selection;
|
|
210
|
-
this.dataFrame.setTag(C.TAGS.CLUSTER_SELECTION, JSON.stringify(selection));
|
|
211
208
|
this.model.fireBitsetChanged(VIEWER_TYPE.LOGO_SUMMARY_TABLE);
|
|
212
209
|
this.model.analysisView.grid.invalidate();
|
|
213
210
|
}
|