@datagrok/peptides 0.4.3 → 0.7.1
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/detectors.js +1 -1
- package/package.json +15 -10
- package/src/describe.ts +216 -102
- package/src/{viewers/model.ts → model.ts} +28 -1
- package/src/package.ts +15 -23
- package/src/peptides.ts +60 -6
- package/src/styles.css +46 -0
- package/src/utils/cell-renderer.ts +126 -19
- package/src/utils/chem-palette.ts +317 -206
- package/src/utils/peptide-similarity-space.ts +21 -41
- package/src/utils/split-aligned.ts +8 -0
- package/src/viewers/logo-viewer.ts +48 -0
- package/src/viewers/sar-viewer.ts +263 -170
- package/src/viewers/stacked-barchart-viewer.ts +12 -2
- package/src/viewers/subst-viewer.ts +276 -0
- package/src/widgets/analyze-peptides.ts +26 -6
- package/src/widgets/manual-alignment.ts +14 -6
- package/src/widgets/peptide-molecule.ts +7 -0
- package/src/workers/dimensionality-reducer.ts +2 -2
- package/webpack.config.js +5 -1
- package/src/utils/correlation-analysis.ts +0 -123
|
@@ -3,31 +3,14 @@ import * as ui from 'datagrok-api/ui';
|
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
4
|
|
|
5
5
|
import {getSequenceMolecularWeight} from './molecular-measure';
|
|
6
|
-
import {AlignedSequenceEncoder} from '@datagrok-libraries/
|
|
7
|
-
import {DimensionalityReducer} from '@datagrok-libraries/
|
|
8
|
-
import {
|
|
6
|
+
import {AlignedSequenceEncoder} from '@datagrok-libraries/bio/src/sequence-encoder';
|
|
7
|
+
import {DimensionalityReducer} from '@datagrok-libraries/ml/src/reduce-dimensionality';
|
|
8
|
+
import {
|
|
9
|
+
createDimensinalityReducingWorker,
|
|
10
|
+
} from '@datagrok-libraries/ml/src/workers/dimensionality-reducing-worker-creator';
|
|
11
|
+
import {StringMeasure} from '@datagrok-libraries/ml/src/string-measure';
|
|
9
12
|
import {Coordinates} from '@datagrok-libraries/utils/src/type-declarations';
|
|
10
13
|
|
|
11
|
-
function createDimensinalityReducingWorker(
|
|
12
|
-
columnData: any[],
|
|
13
|
-
method: string,
|
|
14
|
-
measure: string,
|
|
15
|
-
cyclesCount: number,
|
|
16
|
-
): Promise<unknown> {
|
|
17
|
-
return new Promise(function(resolve) {
|
|
18
|
-
const worker = new Worker(new URL('../workers/dimensionality-reducer.ts', import.meta.url));
|
|
19
|
-
worker.postMessage({
|
|
20
|
-
columnData: columnData,
|
|
21
|
-
method: method,
|
|
22
|
-
measure: measure,
|
|
23
|
-
cyclesCount: cyclesCount,
|
|
24
|
-
});
|
|
25
|
-
worker.onmessage = ({data: {embedding}}) => {
|
|
26
|
-
resolve(embedding);
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
14
|
/**
|
|
32
15
|
* Finds a column with an activity.
|
|
33
16
|
*
|
|
@@ -38,7 +21,6 @@ function inferActivityColumnsName(table: DG.DataFrame): string | null {
|
|
|
38
21
|
const re = /activity|ic50/i;
|
|
39
22
|
for (const name of table.columns.names()) {
|
|
40
23
|
if (name.match(re)) {
|
|
41
|
-
console.log(`${name} found.`);
|
|
42
24
|
return name;
|
|
43
25
|
}
|
|
44
26
|
}
|
|
@@ -101,29 +83,27 @@ export async function createPeptideSimilaritySpaceViewer(
|
|
|
101
83
|
// Add new axes.
|
|
102
84
|
for (const axis of axesNames) {
|
|
103
85
|
const col = table.col(axis);
|
|
86
|
+
const newCol = edf.getCol(axis);
|
|
104
87
|
|
|
105
|
-
if (col
|
|
106
|
-
|
|
88
|
+
if (col != null) {
|
|
89
|
+
for (let i = 0; i < newCol.length; ++i) {
|
|
90
|
+
const v = newCol.get(i);
|
|
91
|
+
table.set(axis, i, v);
|
|
92
|
+
}
|
|
107
93
|
} else {
|
|
108
|
-
table.columns.
|
|
94
|
+
table.columns.insert(newCol);
|
|
109
95
|
}
|
|
110
96
|
}
|
|
111
97
|
|
|
112
|
-
// const viewer = DG.Viewer.scatterPlot(table, {x: '~X', y: '~Y', color: activityColumnName ?? '~MW', size: '~MW'});
|
|
113
98
|
const viewerOptions = {x: '~X', y: '~Y', color: activityColumnName ?? '~MW', size: '~MW'};
|
|
114
|
-
const viewer =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
table.getCol('~Y').min,
|
|
121
|
-
table.getCol('~X').max,
|
|
122
|
-
table.getCol('~Y').max,
|
|
123
|
-
);
|
|
124
|
-
}*/
|
|
99
|
+
const viewer = DG.Viewer.scatterPlot(table, viewerOptions);
|
|
100
|
+
|
|
101
|
+
if (view !== null) {
|
|
102
|
+
view.addViewer(viewer);
|
|
103
|
+
}
|
|
104
|
+
|
|
125
105
|
pi.close();
|
|
126
|
-
return
|
|
106
|
+
return viewer;
|
|
127
107
|
}
|
|
128
108
|
|
|
129
109
|
/**
|
|
@@ -151,7 +131,7 @@ export class PeptideSimilaritySpaceWidget {
|
|
|
151
131
|
*/
|
|
152
132
|
constructor(alignedSequencesColumn: DG.Column, view: DG.TableView) {
|
|
153
133
|
this.availableMethods = DimensionalityReducer.availableMethods;
|
|
154
|
-
this.availableMetrics =
|
|
134
|
+
this.availableMetrics = StringMeasure.availableMeasures;
|
|
155
135
|
this.method = this.availableMethods[0];
|
|
156
136
|
this.metrics = this.availableMetrics[0];
|
|
157
137
|
this.currentDf = alignedSequencesColumn.dataFrame;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Split aligned sequence string into separate parts containing amino acid residues.
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @param {DG.Column} peptideColumn Column containing aligned sequences.
|
|
8
|
+
* @param {boolean} [filter=true] Filter out columns with all the same residues.
|
|
9
|
+
* @return {[DG.DataFrame, number[]]} DataFrame containing split sequence and a list of invalid indexes.
|
|
10
|
+
*/
|
|
3
11
|
export function splitAlignedPeptides(peptideColumn: DG.Column, filter: boolean = true): [DG.DataFrame, number[]] {
|
|
4
12
|
const splitPeptidesArray: string[][] = [];
|
|
5
13
|
let currentSplitPeptide: string[];
|
|
@@ -7,6 +7,13 @@ import * as logojs from 'logojs-react';
|
|
|
7
7
|
import {splitAlignedPeptides} from '../utils/split-aligned';
|
|
8
8
|
import {ChemPalette} from '../utils/chem-palette';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Logo viewer.
|
|
12
|
+
*
|
|
13
|
+
* @export
|
|
14
|
+
* @class Logo
|
|
15
|
+
* @extends {DG.JsViewer}
|
|
16
|
+
*/
|
|
10
17
|
export class Logo extends DG.JsViewer {
|
|
11
18
|
initialized: boolean;
|
|
12
19
|
option: any;
|
|
@@ -18,6 +25,11 @@ export class Logo extends DG.JsViewer {
|
|
|
18
25
|
LET_COLORS: Array<any>;
|
|
19
26
|
target: DG.DataFrame | undefined | null;
|
|
20
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Creates an instance of Logo.
|
|
30
|
+
*
|
|
31
|
+
* @memberof Logo
|
|
32
|
+
*/
|
|
21
33
|
constructor() {
|
|
22
34
|
super();
|
|
23
35
|
this.initialized = false;
|
|
@@ -59,6 +71,11 @@ export class Logo extends DG.JsViewer {
|
|
|
59
71
|
];
|
|
60
72
|
}
|
|
61
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Initializer function.
|
|
76
|
+
*
|
|
77
|
+
* @memberof Logo
|
|
78
|
+
*/
|
|
62
79
|
init() {
|
|
63
80
|
this.initialized = true;
|
|
64
81
|
console.log('INIT');
|
|
@@ -69,6 +86,11 @@ export class Logo extends DG.JsViewer {
|
|
|
69
86
|
this.root.style.maxHeight = '200px';
|
|
70
87
|
}
|
|
71
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Function to execute when the table is attached.
|
|
91
|
+
*
|
|
92
|
+
* @memberof Logo
|
|
93
|
+
*/
|
|
72
94
|
onTableAttached() {
|
|
73
95
|
if (typeof this.dataFrame !== 'undefined') {
|
|
74
96
|
if (!this.initialized) {
|
|
@@ -83,16 +105,32 @@ export class Logo extends DG.JsViewer {
|
|
|
83
105
|
this.render();
|
|
84
106
|
}
|
|
85
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Function that is executed when the viewer is detached.
|
|
110
|
+
*
|
|
111
|
+
* @memberof Logo
|
|
112
|
+
*/
|
|
86
113
|
detach() {
|
|
87
114
|
this.subs.forEach((sub) => sub.unsubscribe());
|
|
88
115
|
}
|
|
89
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Function that is executed when the viewer property is changed.
|
|
119
|
+
*
|
|
120
|
+
* @param {DG.Property} property
|
|
121
|
+
* @memberof Logo
|
|
122
|
+
*/
|
|
90
123
|
onPropertyChanged(property: DG.Property) {
|
|
91
124
|
super.onPropertyChanged(property);
|
|
92
125
|
|
|
93
126
|
this.render();
|
|
94
127
|
}
|
|
95
128
|
|
|
129
|
+
/**
|
|
130
|
+
* Function that renders the viewer.
|
|
131
|
+
*
|
|
132
|
+
* @memberof Logo
|
|
133
|
+
*/
|
|
96
134
|
async render() {
|
|
97
135
|
const bits = this.dataFrame!.selection;
|
|
98
136
|
let selected = false;
|
|
@@ -113,11 +151,21 @@ export class Logo extends DG.JsViewer {
|
|
|
113
151
|
}
|
|
114
152
|
}
|
|
115
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Create logo.
|
|
156
|
+
*
|
|
157
|
+
* @memberof Logo
|
|
158
|
+
*/
|
|
116
159
|
async findLogo() {
|
|
117
160
|
this.getInfoFromDf();
|
|
118
161
|
logojs.embedProteinLogo(this.root, {alphabet: this.LET_COLORS, ppm: this.ppm});
|
|
119
162
|
}
|
|
120
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Retrieves information for building logo from the dataframe.
|
|
166
|
+
*
|
|
167
|
+
* @memberof Logo
|
|
168
|
+
*/
|
|
121
169
|
getInfoFromDf() {
|
|
122
170
|
let index: number = 0;
|
|
123
171
|
this.ppm = [];
|