@datagrok/peptides 0.4.3 → 0.5.6
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 +3 -3
- package/src/describe.ts +11 -1
- package/src/package.ts +12 -11
- package/src/peptides.ts +21 -4
- package/src/utils/cell-renderer.ts +126 -19
- package/src/utils/chem-palette.ts +317 -206
- package/src/utils/correlation-analysis.ts +149 -68
- package/src/utils/peptide-similarity-space.ts +23 -17
- package/src/utils/split-aligned.ts +8 -0
- package/src/viewers/logo-viewer.ts +48 -0
- package/src/viewers/model.ts +27 -0
- package/src/viewers/sar-viewer.ts +85 -3
- package/src/viewers/spiral-plot.ts +97 -0
- package/src/viewers/stacked-barchart-viewer.ts +81 -2
- package/src/widgets/analyze-peptides.ts +12 -2
- package/src/widgets/manual-alignment.ts +7 -0
- package/src/widgets/peptide-molecule.ts +7 -0
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import * as DG from 'datagrok-api/dg';
|
|
3
3
|
|
|
4
4
|
import {AlignedSequenceEncoder} from '@datagrok-libraries/utils/src/sequence-encoder';
|
|
5
|
-
import {assert
|
|
6
|
-
import {
|
|
5
|
+
import {assert} from '@datagrok-libraries/utils/src/operations';
|
|
6
|
+
import {Matrix} from '@datagrok-libraries/utils/src/type-declarations';
|
|
7
7
|
import {kendallsTau} from '@datagrok-libraries/statistics/src/correlation-coefficient';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -13,111 +13,192 @@ import {kendallsTau} from '@datagrok-libraries/statistics/src/correlation-coeffi
|
|
|
13
13
|
* @param {Matrix} matrix A matrix.
|
|
14
14
|
* @return {DG.DataFrame} The data frame.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
function matrix2DataFrame(matrix: Matrix): DG.DataFrame {
|
|
17
17
|
return DG.DataFrame.fromColumns(matrix.map((v, i) => DG.Column.fromFloat32Array(`${i+1}`, v)));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* Encodes
|
|
21
|
+
* Encodes sequence into a certain scale.
|
|
22
22
|
*
|
|
23
|
-
* @param {DG.
|
|
24
|
-
* @
|
|
23
|
+
* @param {DG.DataFrame} df A data frame containing the sequences.
|
|
24
|
+
* @param {string[]} [positionColumns] If given instructs which columns to consider as sequences containing.
|
|
25
|
+
* @return {DG.DataFrame} The data frame with seqences encoded.
|
|
25
26
|
*/
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
const enc = new AlignedSequenceEncoder();
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
function encodeSequences(df: DG.DataFrame, positionColumns?: string[]): DG.DataFrame {
|
|
28
|
+
const [nCols, nRows] = [positionColumns ? positionColumns.length : df.columns.length, df.rowCount];
|
|
29
|
+
const enc = new AlignedSequenceEncoder('WimleyWhite');
|
|
30
|
+
const positions = new Array(nCols).fill(0).map((_) => new Float32Array(nRows));
|
|
31
|
+
|
|
32
|
+
for (let i = 0; i < nCols; ++i) {
|
|
33
|
+
const col: DG.Column = positionColumns ? df.getCol(positionColumns[i]) : df.columns.byIndex(i);
|
|
34
|
+
|
|
35
|
+
for (let j = 0; j < nRows; ++j) {
|
|
36
|
+
const letter = col.get(j);
|
|
37
|
+
positions[i][j] = enc.encodeLettter(letter);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const posDF = DG.DataFrame.fromColumns(positions.map((v, i) => DG.Column.fromFloat32Array(df.columns.names()[i], v)));
|
|
41
|
+
return posDF;
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
/**
|
|
35
|
-
*
|
|
45
|
+
* Formats an adjacency matrix into <category1>-<category2>-<value> format.
|
|
36
46
|
*
|
|
37
|
-
* @param {DG.DataFrame}
|
|
47
|
+
* @param {DG.DataFrame} adjMatrix A data matrix to deal with.
|
|
38
48
|
* @return {DG.DataFrame} The resulting data frame.
|
|
39
49
|
*/
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
function createNetwork(adjMatrix: DG.DataFrame): DG.DataFrame {
|
|
51
|
+
const nCols = adjMatrix.columns.length;
|
|
52
|
+
const nRows = adjMatrix.rowCount;
|
|
53
|
+
|
|
54
|
+
assert(nCols == nRows);
|
|
55
|
+
|
|
56
|
+
const pos1: Array<number> = [];
|
|
57
|
+
const pos2: Array<number> = [];
|
|
58
|
+
const weight: Array<number> = [];
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < nCols; ++i) {
|
|
61
|
+
const c = adjMatrix.columns.byIndex(i);
|
|
62
|
+
|
|
63
|
+
for (let j = i+1; j < nRows; ++j) {
|
|
64
|
+
const r = c.getRawData()[j];
|
|
65
|
+
|
|
66
|
+
if (Math.abs(r) > 0) {
|
|
67
|
+
pos1.push(i+1);
|
|
68
|
+
pos2.push(j+1);
|
|
69
|
+
weight.push(r);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
49
72
|
}
|
|
50
|
-
|
|
51
|
-
|
|
73
|
+
|
|
74
|
+
const pos1Col = DG.Column.fromList('int', 'pos1', pos1);
|
|
75
|
+
const pos2Col = DG.Column.fromList('int', 'pos2', pos2);
|
|
76
|
+
const weightCol = DG.Column.fromList('double', 'weight', weight);
|
|
77
|
+
|
|
78
|
+
return DG.DataFrame.fromColumns([pos1Col, pos2Col, weightCol]);
|
|
52
79
|
}
|
|
53
80
|
|
|
54
81
|
/**
|
|
55
|
-
* Calculates
|
|
82
|
+
* Calculates Kendall's tau rank correlation matrix.
|
|
56
83
|
*
|
|
57
84
|
* @param {DG.DataFrame} df A data frame to process.
|
|
85
|
+
* @param {number} [alpha=0.05] The significance threshold.
|
|
86
|
+
* @param {number} [rAbsCutoff=0.5] The absolute R cutoff.
|
|
58
87
|
* @return {DG.DataFrame} The correlation matrix.
|
|
59
88
|
*/
|
|
60
|
-
function
|
|
89
|
+
function calcKendallTauMatrix(df: DG.DataFrame, alpha: number = 0.05, rAbsCutoff = 0.5): DG.DataFrame {
|
|
61
90
|
const nItems = df.columns.length;
|
|
62
|
-
const
|
|
91
|
+
const tau = new Array(nItems).fill(0).map((_) => new Float32Array(nItems).fill(0));
|
|
63
92
|
|
|
64
93
|
for (let i = 0; i < nItems; ++i) {
|
|
65
94
|
for (let j = i+1; j < nItems; ++j) {
|
|
66
|
-
|
|
67
|
-
|
|
95
|
+
const res = kendallsTau(df.columns.byIndex(i).getRawData(), df.columns.byIndex(j).getRawData());
|
|
96
|
+
tau[i][j] = (res.prob < alpha) && (Math.abs(res.test) >= rAbsCutoff) ? res.test : 0;
|
|
97
|
+
tau[j][i] = tau[i][j];
|
|
68
98
|
}
|
|
69
99
|
}
|
|
70
|
-
return matrix2DataFrame(
|
|
100
|
+
return matrix2DataFrame(tau);
|
|
71
101
|
}
|
|
72
102
|
|
|
73
103
|
/**
|
|
74
|
-
* Calculates
|
|
104
|
+
* Calculates a correlation matrix via method chosen.
|
|
75
105
|
*
|
|
76
|
-
* @param {DG.DataFrame} df A data frame
|
|
77
|
-
* @param {number} [alpha=0.05] The significance threshold.
|
|
106
|
+
* @param {DG.DataFrame} df A data frame.
|
|
78
107
|
* @return {DG.DataFrame} The correlation matrix.
|
|
79
108
|
*/
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
|
|
109
|
+
function calcCorrelationMatrix(df: DG.DataFrame): DG.DataFrame {
|
|
110
|
+
return calcKendallTauMatrix(df);
|
|
111
|
+
}
|
|
83
112
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
type Weights = {[pos: number]: number};
|
|
114
|
+
type Guide = {[pos: number]: Weights};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Calculates a dictionary with the keys containing the first correlating positions.
|
|
118
|
+
* Values correspond to a dictionary containing the positions and corresponding R-value
|
|
119
|
+
* which the given position correlating with.
|
|
120
|
+
*
|
|
121
|
+
* @param {DG.DataFrame} network A network to process.
|
|
122
|
+
* @return {Guide} The formatted dictionary.
|
|
123
|
+
*/
|
|
124
|
+
function calcGuide(network: DG.DataFrame): Guide {
|
|
125
|
+
assert(network.columns.length == 3);
|
|
126
|
+
|
|
127
|
+
const guide: Guide = {};
|
|
128
|
+
let [pos1Col, pos2Col, weightCol] = Array.from(network.columns);
|
|
129
|
+
|
|
130
|
+
pos1Col = pos1Col.getRawData();
|
|
131
|
+
pos2Col = pos2Col.getRawData();
|
|
132
|
+
weightCol = weightCol.getRawData();
|
|
133
|
+
|
|
134
|
+
function _addWeight(pos1: number, pos2: number, weight: number) {
|
|
135
|
+
if (guide[pos1] == undefined) {
|
|
136
|
+
guide[pos1] = {};
|
|
89
137
|
}
|
|
138
|
+
guide[pos1][pos2] = weight;
|
|
90
139
|
}
|
|
91
|
-
|
|
140
|
+
|
|
141
|
+
for (let i = 0; i < network.rowCount; ++i) {
|
|
142
|
+
const [pos1, pos2, weight] = [pos1Col[i], pos2Col[i], weightCol[i]];
|
|
143
|
+
_addWeight(pos1, pos2, weight);
|
|
144
|
+
_addWeight(pos2, pos1, weight);
|
|
145
|
+
}
|
|
146
|
+
return guide;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function calcCorrelations(df: DG.DataFrame, positionColumns?: string[]): Guide {
|
|
150
|
+
const posDF = encodeSequences(df, positionColumns);
|
|
151
|
+
const ccDF = calcCorrelationMatrix(posDF);
|
|
152
|
+
const nwDF = createNetwork(ccDF);
|
|
153
|
+
const guide = calcGuide(nwDF);
|
|
154
|
+
return guide;
|
|
92
155
|
}
|
|
93
156
|
|
|
94
157
|
/**
|
|
95
|
-
*
|
|
158
|
+
* Formats correlating positions to place in the corresponding tooltips.
|
|
159
|
+
* Higlights correlating positions' headers.
|
|
96
160
|
*
|
|
97
161
|
* @export
|
|
98
|
-
* @
|
|
99
|
-
* @return {[DG.Viewer, DG.Viewer]} These two plots.
|
|
162
|
+
* @class CorrelationAnalysisVisualizer
|
|
100
163
|
*/
|
|
101
|
-
export
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
164
|
+
export class CorrelationAnalysisVisualizer {
|
|
165
|
+
protected guide: Guide;
|
|
166
|
+
protected highlightedColumns: number[];
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Creates an instance of CorrelationAnalysisVisualizer.
|
|
170
|
+
* @param {DG.DataFrame} df A data frame to take sequences from.
|
|
171
|
+
* @param {string[]} positionColumns Optional columns list to take the sequences from.
|
|
172
|
+
* @memberof CorrelationAnalysisVisualizer
|
|
173
|
+
*/
|
|
174
|
+
constructor(df: DG.DataFrame, positionColumns: string[]) {
|
|
175
|
+
if (df) {
|
|
176
|
+
this.guide = calcCorrelations(df, positionColumns);
|
|
177
|
+
this.highlightedColumns = Object.keys(this.guide).map((v) => parseInt(v));
|
|
178
|
+
} else {
|
|
179
|
+
throw new Error('Dataframe was not found in the grid.');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Returns a dictionary with the correlating positions and their R-value.
|
|
185
|
+
*
|
|
186
|
+
* @readonly
|
|
187
|
+
* @type {Guide} The dictionary.
|
|
188
|
+
* @memberof CorrelationAnalysisVisualizer
|
|
189
|
+
*/
|
|
190
|
+
get path(): Guide {
|
|
191
|
+
return this.guide;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Checks if the position column name is found among correlelating ones.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} name The name of the column.
|
|
198
|
+
* @return {boolean} True if the position is correlating with any oter.
|
|
199
|
+
* @memberof CorrelationAnalysisVisualizer
|
|
200
|
+
*/
|
|
201
|
+
public isPositionCorrelating(name: string): boolean {
|
|
202
|
+
return this.highlightedColumns.includes(parseInt(name));
|
|
203
|
+
}
|
|
123
204
|
}
|
|
@@ -8,6 +8,15 @@ import {DimensionalityReducer} from '@datagrok-libraries/utils/src/reduce-dimens
|
|
|
8
8
|
import {Measurer} from '@datagrok-libraries/utils/src/string-measure';
|
|
9
9
|
import {Coordinates} from '@datagrok-libraries/utils/src/type-declarations';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* A worker to perform dimensionality reduction.
|
|
13
|
+
*
|
|
14
|
+
* @param {any[]} columnData The data to process.
|
|
15
|
+
* @param {string} method A method of dimensionality reduction.
|
|
16
|
+
* @param {string} measure A distance metrics.
|
|
17
|
+
* @param {number} cyclesCount Number of iterations to run.
|
|
18
|
+
* @return {Promise<unknown>} Resulting embedding.
|
|
19
|
+
*/
|
|
11
20
|
function createDimensinalityReducingWorker(
|
|
12
21
|
columnData: any[],
|
|
13
22
|
method: string,
|
|
@@ -38,7 +47,6 @@ function inferActivityColumnsName(table: DG.DataFrame): string | null {
|
|
|
38
47
|
const re = /activity|ic50/i;
|
|
39
48
|
for (const name of table.columns.names()) {
|
|
40
49
|
if (name.match(re)) {
|
|
41
|
-
console.log(`${name} found.`);
|
|
42
50
|
return name;
|
|
43
51
|
}
|
|
44
52
|
}
|
|
@@ -101,29 +109,27 @@ export async function createPeptideSimilaritySpaceViewer(
|
|
|
101
109
|
// Add new axes.
|
|
102
110
|
for (const axis of axesNames) {
|
|
103
111
|
const col = table.col(axis);
|
|
112
|
+
const newCol = edf.getCol(axis);
|
|
104
113
|
|
|
105
|
-
if (col
|
|
106
|
-
|
|
114
|
+
if (col != null) {
|
|
115
|
+
for (let i = 0; i < newCol.length; ++i) {
|
|
116
|
+
const v = newCol.get(i);
|
|
117
|
+
table.set(axis, i, v);
|
|
118
|
+
}
|
|
107
119
|
} else {
|
|
108
|
-
table.columns.
|
|
120
|
+
table.columns.insert(newCol);
|
|
109
121
|
}
|
|
110
122
|
}
|
|
111
123
|
|
|
112
|
-
// const viewer = DG.Viewer.scatterPlot(table, {x: '~X', y: '~Y', color: activityColumnName ?? '~MW', size: '~MW'});
|
|
113
124
|
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
|
-
}*/
|
|
125
|
+
const viewer = DG.Viewer.scatterPlot(table, viewerOptions);
|
|
126
|
+
|
|
127
|
+
if (view !== null) {
|
|
128
|
+
view.addViewer(viewer);
|
|
129
|
+
}
|
|
130
|
+
|
|
125
131
|
pi.close();
|
|
126
|
-
return
|
|
132
|
+
return viewer;
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
/**
|
|
@@ -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 = [];
|
package/src/viewers/model.ts
CHANGED
|
@@ -3,6 +3,11 @@ import * as DG from 'datagrok-api/dg';
|
|
|
3
3
|
import {describe} from '../describe';
|
|
4
4
|
import {Subject} from 'rxjs';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Model class for SAR viewers that retrieves and stores data.
|
|
8
|
+
*
|
|
9
|
+
* @class SARViewerModel
|
|
10
|
+
*/
|
|
6
11
|
class SARViewerModel {
|
|
7
12
|
private viewerGrid: Subject<DG.Grid> = new Subject<DG.Grid>();
|
|
8
13
|
private viewerVGrid: Subject<DG.Grid> = new Subject<DG.Grid>();
|
|
@@ -21,6 +26,11 @@ class SARViewerModel {
|
|
|
21
26
|
private isUpdating = false;
|
|
22
27
|
grouping: boolean;
|
|
23
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of SARViewerModel.
|
|
31
|
+
*
|
|
32
|
+
* @memberof SARViewerModel
|
|
33
|
+
*/
|
|
24
34
|
constructor() {
|
|
25
35
|
this.dataFrame = null;
|
|
26
36
|
this.activityColumn = null;
|
|
@@ -35,6 +45,18 @@ class SARViewerModel {
|
|
|
35
45
|
this.groupMapping$ = this.groupMapping.asObservable();
|
|
36
46
|
}
|
|
37
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Updates data with using specified parameters.
|
|
50
|
+
*
|
|
51
|
+
* @param {DG.DataFrame} df Working table.
|
|
52
|
+
* @param {string} activityCol Activity column name.
|
|
53
|
+
* @param {string} activityScaling Activity scaling method.
|
|
54
|
+
* @param {DG.Grid} sourceGrid Working table grid.
|
|
55
|
+
* @param {boolean} twoColorMode Bidirectional analysis enabled.
|
|
56
|
+
* @param {(DG.BitSet | null)} initialBitset Initial bitset.
|
|
57
|
+
* @param {boolean} grouping Grouping enabled.
|
|
58
|
+
* @memberof SARViewerModel
|
|
59
|
+
*/
|
|
38
60
|
async updateData(
|
|
39
61
|
df: DG.DataFrame,
|
|
40
62
|
activityCol: string,
|
|
@@ -54,6 +76,11 @@ class SARViewerModel {
|
|
|
54
76
|
await this.updateDefault();
|
|
55
77
|
}
|
|
56
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Update data using current parameters.
|
|
81
|
+
*
|
|
82
|
+
* @memberof SARViewerModel
|
|
83
|
+
*/
|
|
57
84
|
async updateDefault() {
|
|
58
85
|
if (
|
|
59
86
|
this.dataFrame && this.activityColumn && this.activityScaling &&
|
|
@@ -6,6 +6,13 @@ import $ from 'cash-dom';
|
|
|
6
6
|
|
|
7
7
|
import {model} from './model';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Structure-activity relationship viewer.
|
|
11
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @class SARViewer
|
|
14
|
+
* @extends {DG.JsViewer}
|
|
15
|
+
*/
|
|
9
16
|
export class SARViewer extends DG.JsViewer {
|
|
10
17
|
protected viewerGrid: DG.Grid | null;
|
|
11
18
|
protected sourceGrid: DG.Grid | null;
|
|
@@ -25,6 +32,12 @@ export class SARViewer extends DG.JsViewer {
|
|
|
25
32
|
// protected pValueThreshold: number;
|
|
26
33
|
// protected amountOfBestAARs: number;
|
|
27
34
|
// duplicatesHandingMethod: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Creates an instance of SARViewer.
|
|
38
|
+
*
|
|
39
|
+
* @memberof SARViewer
|
|
40
|
+
*/
|
|
28
41
|
constructor() {
|
|
29
42
|
super();
|
|
30
43
|
|
|
@@ -51,6 +64,11 @@ export class SARViewer extends DG.JsViewer {
|
|
|
51
64
|
this.sourceGrid = null;
|
|
52
65
|
}
|
|
53
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Initializes SARViewer.
|
|
69
|
+
*
|
|
70
|
+
* @memberof SARViewer
|
|
71
|
+
*/
|
|
54
72
|
init() {
|
|
55
73
|
this._initialBitset = this.dataFrame!.filter.clone();
|
|
56
74
|
this.initialized = true;
|
|
@@ -63,16 +81,32 @@ export class SARViewer extends DG.JsViewer {
|
|
|
63
81
|
this.subs.push(model.groupMapping$.subscribe((data) => this.groupMapping = data));
|
|
64
82
|
}
|
|
65
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Function that is executed when the table is attached.
|
|
86
|
+
*
|
|
87
|
+
* @memberof SARViewer
|
|
88
|
+
*/
|
|
66
89
|
onTableAttached() {
|
|
67
90
|
this.sourceGrid = this.view.grid;
|
|
68
91
|
this.sourceGrid?.dataFrame?.setTag('dataType', 'peptides');
|
|
69
92
|
this.render();
|
|
70
93
|
}
|
|
71
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Function that is executed when the viewer is detached from the table.
|
|
97
|
+
*
|
|
98
|
+
* @memberof SARViewer
|
|
99
|
+
*/
|
|
72
100
|
detach() {
|
|
73
101
|
this.subs.forEach((sub) => sub.unsubscribe());
|
|
74
102
|
}
|
|
75
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Function that is executed when the property is changed.
|
|
106
|
+
*
|
|
107
|
+
* @param {DG.Property} property New property.
|
|
108
|
+
* @memberof SARViewer
|
|
109
|
+
*/
|
|
76
110
|
onPropertyChanged(property: DG.Property) {
|
|
77
111
|
super.onPropertyChanged(property);
|
|
78
112
|
|
|
@@ -97,6 +131,12 @@ export class SARViewer extends DG.JsViewer {
|
|
|
97
131
|
this.render();
|
|
98
132
|
}
|
|
99
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Filtering/selecting sequences with the specified amino acid residue at specified position.
|
|
136
|
+
*
|
|
137
|
+
* @private
|
|
138
|
+
* @memberof SARViewer
|
|
139
|
+
*/
|
|
100
140
|
private applyBitset() {
|
|
101
141
|
if (
|
|
102
142
|
this.dataFrame &&
|
|
@@ -133,6 +173,12 @@ export class SARViewer extends DG.JsViewer {
|
|
|
133
173
|
}
|
|
134
174
|
}
|
|
135
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Selecting/filtering sequences according to the current bitset.
|
|
178
|
+
*
|
|
179
|
+
* @private
|
|
180
|
+
* @memberof SARViewer
|
|
181
|
+
*/
|
|
136
182
|
private sourceFilteringFunc() {
|
|
137
183
|
if (this.filterMode) {
|
|
138
184
|
this.dataFrame!.selection.setAll(false, false);
|
|
@@ -143,6 +189,13 @@ export class SARViewer extends DG.JsViewer {
|
|
|
143
189
|
}
|
|
144
190
|
}
|
|
145
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Property panel accordion construction function.
|
|
194
|
+
*
|
|
195
|
+
* @private
|
|
196
|
+
* @param {DG.Accordion} accordion Accordion.
|
|
197
|
+
* @memberof SARViewer
|
|
198
|
+
*/
|
|
146
199
|
private accordionFunc(accordion: DG.Accordion) {
|
|
147
200
|
if (accordion.context instanceof DG.RowGroup) {
|
|
148
201
|
const originalDf: DG.DataFrame = DG.toJs(accordion.context.dataFrame);
|
|
@@ -203,7 +256,13 @@ export class SARViewer extends DG.JsViewer {
|
|
|
203
256
|
}
|
|
204
257
|
}
|
|
205
258
|
|
|
206
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Function for viewer girds synchronization.
|
|
261
|
+
*
|
|
262
|
+
* @param {boolean} sourceVertical Event source is vertical viewer.
|
|
263
|
+
* @memberof SARViewer
|
|
264
|
+
*/
|
|
265
|
+
syncGridsFunc(sourceVertical: boolean) { //TODO: refactor, move
|
|
207
266
|
if (this.viewerGrid && this.viewerGrid.dataFrame && this.viewerVGrid && this.viewerVGrid.dataFrame) {
|
|
208
267
|
if (sourceVertical) {
|
|
209
268
|
const dfCell = this.viewerVGrid.dataFrame.currentCell;
|
|
@@ -245,8 +304,13 @@ export class SARViewer extends DG.JsViewer {
|
|
|
245
304
|
}
|
|
246
305
|
}
|
|
247
306
|
}
|
|
248
|
-
|
|
249
|
-
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Viewer render function.
|
|
310
|
+
*
|
|
311
|
+
* @param {boolean} [computeData=true] Recalculate data.
|
|
312
|
+
* @memberof SARViewer
|
|
313
|
+
*/
|
|
250
314
|
async render(computeData = true) {
|
|
251
315
|
if (!this.initialized) {
|
|
252
316
|
return;
|
|
@@ -282,8 +346,21 @@ export class SARViewer extends DG.JsViewer {
|
|
|
282
346
|
}
|
|
283
347
|
}
|
|
284
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Vertical structure activity relationship viewer.
|
|
351
|
+
*
|
|
352
|
+
* @export
|
|
353
|
+
* @class SARViewerVertical
|
|
354
|
+
* @extends {DG.JsViewer}
|
|
355
|
+
*/
|
|
285
356
|
export class SARViewerVertical extends DG.JsViewer {
|
|
286
357
|
viewerVGrid: DG.Grid | null;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Creates an instance of SARViewerVertical.
|
|
361
|
+
*
|
|
362
|
+
* @memberof SARViewerVertical
|
|
363
|
+
*/
|
|
287
364
|
constructor() {
|
|
288
365
|
super();
|
|
289
366
|
|
|
@@ -294,6 +371,11 @@ export class SARViewerVertical extends DG.JsViewer {
|
|
|
294
371
|
}));
|
|
295
372
|
}
|
|
296
373
|
|
|
374
|
+
/**
|
|
375
|
+
* Viewer render function.
|
|
376
|
+
*
|
|
377
|
+
* @memberof SARViewerVertical
|
|
378
|
+
*/
|
|
297
379
|
render() {
|
|
298
380
|
if (this.viewerVGrid) {
|
|
299
381
|
$(this.root).empty();
|