@datagrok/peptides 0.0.1 → 0.4.2
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/.eslintrc.json +1 -1
- package/detectors.js +2 -2
- package/package.json +19 -12
- package/scripts/smiles-to-3D.py +13 -0
- package/src/{peptide-sar-viewer/describe.ts → describe.ts} +104 -78
- package/src/package.ts +79 -137
- package/src/peptides.ts +76 -0
- package/src/utils/cell-renderer.ts +77 -101
- package/src/utils/chem-palette.ts +80 -53
- package/src/utils/correlation-analysis.ts +126 -0
- package/src/utils/molecular-measure.ts +175 -0
- package/src/utils/peptide-similarity-space.ts +242 -0
- package/src/utils/split-aligned.ts +65 -0
- package/src/{peptide-logo-viewer → viewers}/logo-viewer.ts +6 -4
- package/src/viewers/model.ts +76 -0
- package/src/{peptide-sar-viewer → viewers}/sar-viewer.ts +67 -23
- package/src/{stacked-barchart → viewers}/stacked-barchart-viewer.ts +29 -31
- package/src/widgets/analyze-peptides.ts +87 -0
- package/src/widgets/manual-alignment.ts +36 -0
- package/src/widgets/peptide-molecule.ts +42 -0
- package/src/workers/dimensionality-reducer.ts +29 -0
- package/tsconfig.json +12 -13
- package/webpack.config.js +4 -4
- package/src/split-aligned.ts +0 -42
- package/src/utils/misc.ts +0 -101
package/src/peptides.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as ui from 'datagrok-api/ui';
|
|
2
|
+
import * as DG from 'datagrok-api/dg';
|
|
3
|
+
import {createPeptideSimilaritySpaceViewer} from './utils/peptide-similarity-space';
|
|
4
|
+
import {addViewerToHeader} from './viewers/stacked-barchart-viewer';
|
|
5
|
+
|
|
6
|
+
export class Peptides {
|
|
7
|
+
async init(
|
|
8
|
+
tableGrid: DG.Grid,
|
|
9
|
+
view: DG.TableView,
|
|
10
|
+
currentDf: DG.DataFrame,
|
|
11
|
+
options: {[key: string]: string},
|
|
12
|
+
col: DG.Column,
|
|
13
|
+
activityColumnChoice: string,
|
|
14
|
+
) {
|
|
15
|
+
for (let i = 0; i < tableGrid.columns.length; i++) {
|
|
16
|
+
const col = tableGrid.columns.byIndex(i);
|
|
17
|
+
if (col &&
|
|
18
|
+
col.name &&
|
|
19
|
+
col.column?.semType != 'aminoAcids'
|
|
20
|
+
) {
|
|
21
|
+
//@ts-ignore
|
|
22
|
+
tableGrid.columns.byIndex(i)?.visible = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const originalDfColumns = (currentDf.columns as DG.ColumnList).names();
|
|
27
|
+
|
|
28
|
+
const sarViewer = view.addViewer('peptide-sar-viewer', options);
|
|
29
|
+
const sarNode = view.dockManager.dock(sarViewer, DG.DOCK_TYPE.DOWN, null, 'SAR Viewer');
|
|
30
|
+
|
|
31
|
+
const sarViewerVertical = view.addViewer('peptide-sar-viewer-vertical');
|
|
32
|
+
view.dockManager.dock(sarViewerVertical, DG.DOCK_TYPE.RIGHT, sarNode, 'SAR Vertical Viewer');
|
|
33
|
+
|
|
34
|
+
const peptideSpaceViewer = await createPeptideSimilaritySpaceViewer(
|
|
35
|
+
currentDf,
|
|
36
|
+
col,
|
|
37
|
+
't-SNE',
|
|
38
|
+
'Levenshtein',
|
|
39
|
+
100,
|
|
40
|
+
view,
|
|
41
|
+
`${activityColumnChoice}Scaled`,
|
|
42
|
+
);
|
|
43
|
+
view.dockManager.dock(peptideSpaceViewer, DG.DOCK_TYPE.LEFT, sarNode, 'Peptide Space Viewer', 0.3);
|
|
44
|
+
|
|
45
|
+
const StackedBarchartProm = currentDf.plot.fromType('StackedBarChartAA');
|
|
46
|
+
addViewerToHeader(tableGrid, StackedBarchartProm);
|
|
47
|
+
|
|
48
|
+
const hideIcon = ui.iconFA('window-close', () => { //undo?, times?
|
|
49
|
+
const viewers = [];
|
|
50
|
+
for (const viewer of view.viewers) {
|
|
51
|
+
if (viewer.type !== DG.VIEWER.GRID) {
|
|
52
|
+
viewers.push(viewer);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
viewers.forEach((v) => v.close());
|
|
56
|
+
|
|
57
|
+
const cols = (currentDf.columns as DG.ColumnList);
|
|
58
|
+
for (const colName of cols.names()) {
|
|
59
|
+
if (!originalDfColumns.includes(colName)) {
|
|
60
|
+
cols.remove(colName);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
currentDf.selection.setAll(false);
|
|
65
|
+
currentDf.filter.setAll(true);
|
|
66
|
+
|
|
67
|
+
tableGrid.setOptions({'colHeaderHeight': 20});
|
|
68
|
+
tableGrid.columns.setVisible(originalDfColumns);
|
|
69
|
+
|
|
70
|
+
view.setRibbonPanels(ribbonPanels);
|
|
71
|
+
}, 'Close viewers and restore dataframe');
|
|
72
|
+
|
|
73
|
+
const ribbonPanels = view.getRibbonPanels();
|
|
74
|
+
view.setRibbonPanels([[hideIcon]]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {ChemPalette} from './chem-palette';
|
|
2
2
|
import * as DG from 'datagrok-api/dg';
|
|
3
|
+
|
|
3
4
|
const cp = new ChemPalette('grok');
|
|
4
5
|
|
|
5
6
|
export function expandColumn(col:DG.Column,
|
|
@@ -22,35 +23,27 @@ export function expandColumn(col:DG.Column,
|
|
|
22
23
|
timeout);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
export function setAARRenderer(
|
|
26
|
-
col:DG.Column,
|
|
27
|
-
grid:DG.Grid|null = null,
|
|
28
|
-
) {
|
|
26
|
+
export function setAARRenderer(col: DG.Column, grid: DG.Grid | null = null, grouping = false) {
|
|
29
27
|
col.semType = 'aminoAcids';
|
|
30
28
|
col.setTag('cell.renderer', 'aminoAcids');
|
|
29
|
+
if (grouping) {
|
|
30
|
+
col.setTag('groups', `${grouping}`);
|
|
31
|
+
}
|
|
31
32
|
if (grid) {
|
|
32
|
-
expandColumn(col, grid, (ent) => measureAAR(ent
|
|
33
|
+
expandColumn(col, grid, (ent) => measureAAR(ent));
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
export function measureAAR(s:string
|
|
37
|
-
hideMod = false):number {
|
|
37
|
+
export function measureAAR(s: string): number {
|
|
38
38
|
const end = s.lastIndexOf(')');
|
|
39
39
|
const beg = s.indexOf('(');
|
|
40
|
-
return end == beg ? s.length:s.length - (end-beg)+1;
|
|
40
|
+
return end == beg ? s.length : s.length - (end - beg) + 1;
|
|
41
41
|
}
|
|
42
|
+
|
|
42
43
|
function printLeftCentered(
|
|
43
|
-
x: number,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
h: number,
|
|
47
|
-
g: CanvasRenderingContext2D,
|
|
48
|
-
s: string,
|
|
49
|
-
color = ChemPalette.undefinedColor,
|
|
50
|
-
pivot: number = 0,
|
|
51
|
-
left = false,
|
|
52
|
-
hideMod = false,
|
|
53
|
-
) {
|
|
44
|
+
x: number, y: number, w: number, h: number,
|
|
45
|
+
g: CanvasRenderingContext2D, s: string, color = ChemPalette.undefinedColor,
|
|
46
|
+
pivot: number = 0, left = false, hideMod = false) {
|
|
54
47
|
g.textAlign = 'start';
|
|
55
48
|
let colorPart = pivot == -1 ? s.substring(0) : s.substring(0, pivot);
|
|
56
49
|
if (colorPart.length == 1) {
|
|
@@ -60,7 +53,7 @@ function printLeftCentered(
|
|
|
60
53
|
if (colorPart.substring(0, 3) in ChemPalette.AAFullNames) {
|
|
61
54
|
colorPart = ChemPalette.AAFullNames[s.substring(0, 3)] + colorPart.substr(3);
|
|
62
55
|
} else if (colorPart.substring(1, 4) in ChemPalette.AAFullNames) {
|
|
63
|
-
colorPart = colorPart
|
|
56
|
+
colorPart = colorPart[0] + ChemPalette.AAFullNames[s.substring(1, 4)] + colorPart.substr(4);
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
59
|
let grayPart = pivot == -1 ? '' : s.substr(pivot);
|
|
@@ -80,42 +73,36 @@ function printLeftCentered(
|
|
|
80
73
|
const textSize = g.measureText(colorPart + grayPart);
|
|
81
74
|
const indent = 5;
|
|
82
75
|
|
|
83
|
-
|
|
84
76
|
const colorTextSize = g.measureText(colorPart);
|
|
85
|
-
|
|
77
|
+
|
|
78
|
+
function draw(dx1: number, dx2: number) {
|
|
86
79
|
g.fillStyle = color;
|
|
87
80
|
g.fillText(
|
|
88
81
|
colorPart,
|
|
89
|
-
x +
|
|
82
|
+
x + dx1,
|
|
90
83
|
y + (textSize.fontBoundingBoxAscent + textSize.fontBoundingBoxDescent) / 2,
|
|
91
84
|
);
|
|
92
85
|
g.fillStyle = ChemPalette.undefinedColor;
|
|
93
86
|
g.fillText(
|
|
94
87
|
grayPart,
|
|
95
|
-
x +
|
|
88
|
+
x + dx2,
|
|
96
89
|
y + (textSize.fontBoundingBoxAscent + textSize.fontBoundingBoxDescent) / 2,
|
|
97
90
|
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
if (left || textSize.width > w) {
|
|
95
|
+
draw(indent, indent + colorTextSize.width);
|
|
98
96
|
return x + colorTextSize.width + g.measureText(grayPart).width;
|
|
99
97
|
} else {
|
|
100
|
-
|
|
101
|
-
g.fillText(
|
|
102
|
-
colorPart,
|
|
103
|
-
x + (w - textSize.width) / 2,
|
|
104
|
-
y + (textSize.fontBoundingBoxAscent + textSize.fontBoundingBoxDescent) / 2,
|
|
105
|
-
);
|
|
106
|
-
g.fillStyle = ChemPalette.undefinedColor;
|
|
107
|
-
g.fillText(
|
|
108
|
-
grayPart,
|
|
109
|
-
x + (w - textSize.width) / 2 + colorTextSize.width,
|
|
110
|
-
y + (textSize.fontBoundingBoxAscent + textSize.fontBoundingBoxDescent) / 2,
|
|
111
|
-
);
|
|
98
|
+
draw((w - textSize.width) / 2, (w - textSize.width) / 2 + colorTextSize.width);
|
|
112
99
|
return x + (w - textSize.width) / 2 + colorTextSize.width;
|
|
113
100
|
}
|
|
114
101
|
}
|
|
115
102
|
|
|
116
|
-
export class AminoAcidsCellRenderer extends DG.GridCellRenderer {
|
|
117
|
-
private fontSize = 15;
|
|
118
103
|
|
|
104
|
+
export class AminoAcidsCellRenderer extends DG.GridCellRenderer {
|
|
105
|
+
chemPalette: ChemPalette | null;
|
|
119
106
|
|
|
120
107
|
get name() {
|
|
121
108
|
return 'aminoAcidsCR';
|
|
@@ -125,21 +112,21 @@ export class AminoAcidsCellRenderer extends DG.GridCellRenderer {
|
|
|
125
112
|
return 'aminoAcids';
|
|
126
113
|
}
|
|
127
114
|
|
|
115
|
+
constructor() {
|
|
116
|
+
super();
|
|
117
|
+
this.chemPalette = null;
|
|
118
|
+
}
|
|
128
119
|
|
|
129
|
-
render(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
h: number,
|
|
135
|
-
gridCell: DG.GridCell,
|
|
136
|
-
cellStyle: DG.GridCellStyle,
|
|
137
|
-
) {
|
|
120
|
+
render(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number,
|
|
121
|
+
gridCell: DG.GridCell, cellStyle: DG.GridCellStyle) {
|
|
122
|
+
if (this.chemPalette === null) {
|
|
123
|
+
this.chemPalette = new ChemPalette('grok', gridCell.tableColumn?.getTag('groups') ? true : false);
|
|
124
|
+
}
|
|
138
125
|
g.save();
|
|
139
126
|
g.beginPath();
|
|
140
127
|
g.rect(x, y, w, h);
|
|
141
128
|
g.clip();
|
|
142
|
-
g.font =
|
|
129
|
+
g.font = `14px monospace`;
|
|
143
130
|
g.textBaseline = 'top';
|
|
144
131
|
const s: string = gridCell.cell.value ? gridCell.cell.value : '-';
|
|
145
132
|
const [color, pivot] = cp.getColorPivot(s);
|
|
@@ -148,64 +135,54 @@ export class AminoAcidsCellRenderer extends DG.GridCellRenderer {
|
|
|
148
135
|
}
|
|
149
136
|
}
|
|
150
137
|
|
|
151
|
-
export class AlignedSequenceCellRenderer extends DG.GridCellRenderer {
|
|
152
|
-
private maxCellWidth = 200;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
constructor() {
|
|
156
|
-
super();
|
|
157
|
-
}
|
|
158
138
|
|
|
139
|
+
export class AlignedSequenceCellRenderer extends DG.GridCellRenderer {
|
|
140
|
+
get name() {
|
|
141
|
+
return 'alignedSequenceCR';
|
|
142
|
+
}
|
|
159
143
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
144
|
+
get cellType() {
|
|
145
|
+
return 'alignedSequence';
|
|
146
|
+
}
|
|
163
147
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
148
|
+
render(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number,
|
|
149
|
+
gridCell: DG.GridCell, cellStyle: DG.GridCellStyle ) {
|
|
150
|
+
w = Math.min(gridCell.grid.canvas.width - x, w);
|
|
151
|
+
g.save();
|
|
152
|
+
g.beginPath();
|
|
153
|
+
g.rect(x, y, w, h);
|
|
154
|
+
g.clip();
|
|
155
|
+
g.font = '14px monospace';
|
|
156
|
+
g.textBaseline = 'top';
|
|
157
|
+
const s: string = gridCell.cell.value ?? '';
|
|
158
|
+
|
|
159
|
+
//TODO: can this be replaced/merged with splitSequence?
|
|
160
|
+
const subParts = s.split('-');
|
|
161
|
+
const [text, simplified] = processSequence(subParts);
|
|
162
|
+
const textSize = g.measureText(text.join(''));
|
|
163
|
+
x = Math.max(x, x + (w - textSize.width) / 2);
|
|
164
|
+
|
|
165
|
+
subParts.forEach((amino: string, index) => {
|
|
166
|
+
const [color, pivot] = cp.getColorPivot(amino);
|
|
167
|
+
g.fillStyle = ChemPalette.undefinedColor;
|
|
168
|
+
if (index + 1 < subParts.length) {
|
|
169
|
+
const gap = simplified?'':' ';
|
|
170
|
+
amino += `${amino?'':'-'}${gap}`;
|
|
171
|
+
}
|
|
172
|
+
x = printLeftCentered(x, y, w, h, g, amino, color, pivot, true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
g.restore();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
167
178
|
|
|
168
179
|
|
|
169
|
-
render(
|
|
170
|
-
g: CanvasRenderingContext2D,
|
|
171
|
-
x: number,
|
|
172
|
-
y: number,
|
|
173
|
-
w: number,
|
|
174
|
-
h: number,
|
|
175
|
-
gridCell: DG.GridCell,
|
|
176
|
-
cellStyle: DG.GridCellStyle,
|
|
177
|
-
) {
|
|
178
|
-
w = Math.min(gridCell.grid.canvas.width-x, w);
|
|
179
|
-
g.save();
|
|
180
|
-
g.beginPath();
|
|
181
|
-
g.rect(x, y, w, h);
|
|
182
|
-
g.clip();
|
|
183
|
-
g.font = '15px monospace';
|
|
184
|
-
g.textBaseline = 'top';
|
|
185
|
-
const s: string = gridCell.cell.value;
|
|
186
|
-
|
|
187
|
-
const subParts = s.split('-');
|
|
188
|
-
const [text, simplified] = processSequence(subParts);
|
|
189
|
-
const textSize = g.measureText(text.join(''));
|
|
190
|
-
x = Math.max(x, x+(w-textSize.width)/2);
|
|
191
|
-
subParts.forEach((amino: string, index) => {
|
|
192
|
-
const [color, pivot] = cp.getColorPivot(amino);
|
|
193
|
-
g.fillStyle = ChemPalette.undefinedColor;
|
|
194
|
-
if (index + 1 < subParts.length) {
|
|
195
|
-
const gap = simplified?'':' ';
|
|
196
|
-
amino += `${amino?'':'-'}${gap}`;
|
|
197
|
-
}
|
|
198
|
-
x = printLeftCentered(x, y, w, h, g, amino, color, pivot, true);
|
|
199
|
-
});
|
|
200
|
-
g.restore();
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
180
|
export function processSequence(subParts:string[]) : [string[], boolean] {
|
|
204
|
-
const simplified = !subParts.some((amino, index)=>
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
181
|
+
const simplified = !subParts.some((amino, index) =>
|
|
182
|
+
amino.length > 1 &&
|
|
183
|
+
index != 0 &&
|
|
184
|
+
index != subParts.length - 1);
|
|
185
|
+
|
|
209
186
|
const text:string[] = [];
|
|
210
187
|
subParts.forEach((amino: string, index) => {
|
|
211
188
|
if (index < subParts.length) {
|
|
@@ -216,4 +193,3 @@ export function processSequence(subParts:string[]) : [string[], boolean] {
|
|
|
216
193
|
});
|
|
217
194
|
return [text, simplified];
|
|
218
195
|
}
|
|
219
|
-
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import * as grok from 'datagrok-api/grok';
|
|
2
2
|
import * as ui from 'datagrok-api/ui';
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
|
+
|
|
5
|
+
|
|
4
6
|
export class ChemPalette {
|
|
5
|
-
cp:{
|
|
6
|
-
|
|
7
|
+
cp: {[key: string]: string} = {};
|
|
8
|
+
|
|
9
|
+
constructor(scheme: string, grouping = false) {
|
|
7
10
|
if (scheme == 'grok') {
|
|
8
|
-
this.cp = ChemPalette.getDatagrok();
|
|
11
|
+
this.cp = ChemPalette.getDatagrok(grouping);
|
|
9
12
|
}
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
showTooltip(cell:DG.GridCell, x:number, y:number) {
|
|
13
16
|
const s = cell.cell.value as string;
|
|
14
17
|
let toDisplay = [ui.divText(s)];
|
|
15
|
-
|
|
16
|
-
const [_c, aar, _p] = this.getColorAAPivot(s);
|
|
18
|
+
const [, aar] = this.getColorAAPivot(s);
|
|
17
19
|
if (aar in ChemPalette.AASmiles) {
|
|
18
20
|
if (s in ChemPalette.AANames) {
|
|
19
21
|
toDisplay = [ui.divText(ChemPalette.AANames[s])];
|
|
@@ -21,43 +23,51 @@ export class ChemPalette {
|
|
|
21
23
|
if (s in ChemPalette.AAFullNames) {
|
|
22
24
|
toDisplay = [ui.divText(ChemPalette.AANames[ChemPalette.AAFullNames[s]])];
|
|
23
25
|
}
|
|
24
|
-
const
|
|
26
|
+
const options = {
|
|
27
|
+
autoCrop: true,
|
|
28
|
+
autoCropMargin: 0,
|
|
29
|
+
suppressChiralText: true,
|
|
30
|
+
};
|
|
31
|
+
const sketch = grok.chem.svgMol(ChemPalette.AASmiles[aar], undefined, undefined, options);
|
|
25
32
|
toDisplay.push(sketch);
|
|
26
33
|
}
|
|
27
34
|
ui.tooltip.show(ui.divV(toDisplay), x, y);
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
getColor( c: string) {
|
|
31
|
-
|
|
32
|
-
const [color, _] = this.getColorPivot(c);
|
|
38
|
+
const [color] = this.getColorPivot(c);
|
|
33
39
|
return color;
|
|
34
40
|
}
|
|
41
|
+
|
|
35
42
|
getColorAAPivot(c = ''): [string, string, number] {
|
|
36
|
-
if (c.length == 1 || c
|
|
37
|
-
const amino = c
|
|
43
|
+
if (c.length == 1 || c[1] == '(') {
|
|
44
|
+
const amino = c[0]?.toUpperCase()!;
|
|
38
45
|
return amino in this.cp?
|
|
39
46
|
[this.cp[amino], amino, 1]:
|
|
40
47
|
[ChemPalette.undefinedColor, '', 1];
|
|
41
48
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
|
|
50
|
+
if (c[0] == 'd' && c[1]! in this.cp) {
|
|
51
|
+
if (c.length == 2 || c[2] == '(') {
|
|
52
|
+
const amino = c[1]?.toUpperCase()!;
|
|
45
53
|
return amino in this.cp?
|
|
46
54
|
[this.cp[amino], amino, 2]:
|
|
47
55
|
[ChemPalette.undefinedColor, '', 2];
|
|
48
56
|
}
|
|
49
57
|
}
|
|
58
|
+
|
|
50
59
|
if (c.substr(0, 3) in ChemPalette.AAFullNames) {
|
|
51
|
-
if (c.length == 3 || c
|
|
60
|
+
if (c.length == 3 || c[3] == '(') {
|
|
52
61
|
const amino = ChemPalette.AAFullNames[c.substr(0, 3)];
|
|
53
62
|
return amino in this.cp?
|
|
54
63
|
[this.cp[amino], amino, 3]:
|
|
55
64
|
[ChemPalette.undefinedColor, '', 3];
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
|
-
|
|
67
|
+
|
|
68
|
+
if (c[0]?.toLowerCase() == c[0]) {
|
|
59
69
|
if (c.substr(1, 3) in ChemPalette.AAFullNames) {
|
|
60
|
-
if (c.length == 4 || c
|
|
70
|
+
if (c.length == 4 || c[4] == '(') {
|
|
61
71
|
const amino = ChemPalette.AAFullNames[c.substr(1, 3)];
|
|
62
72
|
return amino in this.cp?
|
|
63
73
|
[this.cp[amino], amino, 4]:
|
|
@@ -65,16 +75,16 @@ export class ChemPalette {
|
|
|
65
75
|
}
|
|
66
76
|
}
|
|
67
77
|
}
|
|
78
|
+
|
|
68
79
|
return [ChemPalette.undefinedColor, '', 0];
|
|
69
|
-
//return c ? DG.Color.toRgb(this.colorScale(c)) : 'rgb(127,127,127)'
|
|
70
80
|
}
|
|
81
|
+
|
|
71
82
|
getColorPivot(c = ''): [string, number] {
|
|
72
|
-
|
|
73
|
-
const [color, _, pivot] = this.getColorAAPivot(c);
|
|
83
|
+
const [color,, pivot] = this.getColorAAPivot(c);
|
|
74
84
|
return [color, pivot];
|
|
75
85
|
};
|
|
76
86
|
|
|
77
|
-
static colourPalette: {
|
|
87
|
+
static colourPalette: {[key: string]: string[]} = {
|
|
78
88
|
'orange': ['rgb(255,187,120)', 'rgb(245,167,100)', 'rgb(235,137,70)', 'rgb(205, 111, 71)'],
|
|
79
89
|
'all_green': ['rgb(44,160,44)', 'rgb(74,160,74)', 'rgb(23,103,57)', 'rgb(30,110,96)', 'rgb(60,131,95)',
|
|
80
90
|
'rgb(24,110,79)', 'rgb(152,223,138)', 'rgb(182, 223, 138)', 'rgb(152, 193, 138)'],
|
|
@@ -97,29 +107,47 @@ export class ChemPalette {
|
|
|
97
107
|
'white': ['rgb(230,230,230)'],
|
|
98
108
|
}
|
|
99
109
|
|
|
100
|
-
static grokGroups: [string[], string][] = [
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
];
|
|
108
|
-
static
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
// static grokGroups: [string[], string][] = [
|
|
111
|
+
// [['C', 'U'], 'yellow'],
|
|
112
|
+
// [['G', 'P'], 'red'],
|
|
113
|
+
// [['A', 'V', 'I', 'L', 'M', 'F', 'Y', 'W'], 'all_green'],
|
|
114
|
+
// [['R', 'H', 'K'], 'light_blue'],
|
|
115
|
+
// [['D', 'E'], 'dark_blue'],
|
|
116
|
+
// [['S', 'T', 'N', 'Q'], 'orange'],
|
|
117
|
+
// ];
|
|
118
|
+
static grokGroups: {[key: string]: string[]} = {
|
|
119
|
+
'yellow': ['C', 'U'],
|
|
120
|
+
'red': ['G', 'P'],
|
|
121
|
+
'all_green': ['A', 'V', 'I', 'L', 'M', 'F', 'Y', 'W'],
|
|
122
|
+
'light_blue': ['R', 'H', 'K'],
|
|
123
|
+
'dark_blue': ['D', 'E'],
|
|
124
|
+
'orange': ['S', 'T', 'N', 'Q'],
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
static leskGroups: {[key: string]: string[]} = {
|
|
128
|
+
'orange': ['G', 'A', 'S', 'T'],
|
|
129
|
+
'all_green': ['C', 'V', 'I', 'L', 'P', 'F', 'Y', 'M', 'W'],
|
|
130
|
+
'magenta': ['N', 'Q', 'H'],
|
|
131
|
+
'red': ['D', 'E'],
|
|
132
|
+
'all_blue': ['K', 'R'],
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static undefinedColor = 'rgb(100,100,100)';
|
|
136
|
+
|
|
137
|
+
static makePalette(dt: {[key: string]: string[]}, simplified = false, grouping = false) {
|
|
111
138
|
const palette: { [key: string]: string } = {};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
palette[
|
|
139
|
+
const groups = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
140
|
+
let currentGroup = 0;
|
|
141
|
+
for (const [color, monomers] of Object.entries(dt)) {
|
|
142
|
+
monomers.forEach((monomer, index) => {
|
|
143
|
+
palette[grouping ? groups[currentGroup] : monomer] = ChemPalette.colourPalette[color][simplified ? 0 : index];
|
|
117
144
|
});
|
|
118
|
-
|
|
145
|
+
currentGroup++;
|
|
146
|
+
}
|
|
119
147
|
return palette;
|
|
120
148
|
}
|
|
121
149
|
|
|
122
|
-
static AANames:{
|
|
150
|
+
static AANames: {[key: string]: string} = {
|
|
123
151
|
'G': 'Glycine',
|
|
124
152
|
'L': 'Leucine',
|
|
125
153
|
'Y': 'Tyrosine',
|
|
@@ -141,7 +169,8 @@ export class ChemPalette {
|
|
|
141
169
|
'M': 'Methionine',
|
|
142
170
|
'T': 'Threonine',
|
|
143
171
|
}
|
|
144
|
-
|
|
172
|
+
|
|
173
|
+
static AASmiles: {[key: string]: string} = {
|
|
145
174
|
'G': 'NCC(=O)O',
|
|
146
175
|
'L': 'N[C@H](CC(C)C)C(=O)O',
|
|
147
176
|
'Y': 'NC(CC1=CC=C(O)C=C1)C(=O)O',
|
|
@@ -153,7 +182,7 @@ export class ChemPalette {
|
|
|
153
182
|
'F': 'NC(CC1=CC=CC=C1)C(=O)O',
|
|
154
183
|
'A': 'N[C@H](C)C(=O)O',
|
|
155
184
|
'K': 'NC(CCCCN)C(=O)O',
|
|
156
|
-
'R': 'N[C
|
|
185
|
+
'R': 'N[C@H](CCCNC(=N)C)C(=O)O',
|
|
157
186
|
'H': 'NC(CC1=CN=C[N]1)C(=O)O',
|
|
158
187
|
'C': 'N[C@@H](CS)C(=O)O',
|
|
159
188
|
'V': 'NC(C(C)C)C(=O)O',
|
|
@@ -163,7 +192,8 @@ export class ChemPalette {
|
|
|
163
192
|
'M': 'NC(CCSC)C(=O)O',
|
|
164
193
|
'T': 'NC(C(O)C)C(=O)O',
|
|
165
194
|
}
|
|
166
|
-
|
|
195
|
+
|
|
196
|
+
static AASmilesTruncated: {[key: string]: string} = {
|
|
167
197
|
'G': '*C*',
|
|
168
198
|
'L': 'CC(C)C[C@H](*)*',
|
|
169
199
|
'Y': 'C1=CC(=CC=C1CC(*)*)O',
|
|
@@ -175,7 +205,7 @@ export class ChemPalette {
|
|
|
175
205
|
'F': 'C1=CC=C(C=C1)CC(*)*',
|
|
176
206
|
'A': 'C[C@H](*)*',
|
|
177
207
|
'K': 'C(CCN)CC(*)*',
|
|
178
|
-
'R': '*[C
|
|
208
|
+
'R': '*[C@H](CCCNC(=N)C)*',
|
|
179
209
|
'H': 'C1=C(NC=N1)CC(*)*',
|
|
180
210
|
'C': 'C([C@@H](*)*)S',
|
|
181
211
|
'V': 'CC(C)C(*)*',
|
|
@@ -186,7 +216,7 @@ export class ChemPalette {
|
|
|
186
216
|
'T': 'CC(O)C(*)*',
|
|
187
217
|
}
|
|
188
218
|
|
|
189
|
-
static AAFullNames: {
|
|
219
|
+
static AAFullNames: {[key: string]: string} = {
|
|
190
220
|
'Ala': 'A',
|
|
191
221
|
'Arg': 'R',
|
|
192
222
|
'Asn': 'N',
|
|
@@ -207,16 +237,13 @@ export class ChemPalette {
|
|
|
207
237
|
'Trp': 'W',
|
|
208
238
|
'Tyr': 'Y',
|
|
209
239
|
'Val': 'V',
|
|
210
|
-
}
|
|
240
|
+
}
|
|
211
241
|
|
|
212
|
-
static getDatagrok =
|
|
213
|
-
return ChemPalette.makePalette(ChemPalette.grokGroups);
|
|
214
|
-
}
|
|
242
|
+
static getDatagrok(grouping = false) {
|
|
243
|
+
return ChemPalette.makePalette(ChemPalette.grokGroups, false, grouping);
|
|
244
|
+
}
|
|
215
245
|
|
|
216
|
-
getLesk
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
[['N', 'Q', 'H'], 'magenta'],
|
|
220
|
-
[['D', 'E'], 'red'],
|
|
221
|
-
[['K', 'R'], 'all_blue']])
|
|
246
|
+
static getLesk() {
|
|
247
|
+
return ChemPalette.makePalette(ChemPalette.leskGroups);
|
|
248
|
+
}
|
|
222
249
|
}
|