@datagrok/sequence-translator 1.3.11 → 1.3.12
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 +10 -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 +8 -7
- package/src/apps/common/model/oligo-toolkit-package.ts +5 -3
- package/src/package-test.ts +1 -0
- package/src/package.ts +7 -7
- package/src/polytool/const.ts +10 -0
- package/src/polytool/pt-conversion.ts +1 -0
- package/src/polytool/pt-dialog.ts +69 -74
- package/src/polytool/pt-enumeration-chem.ts +1 -16
- package/src/polytool/pt-enumeration-helm-dialog.ts +218 -0
- package/src/polytool/pt-enumeration-helm.ts +63 -11
- package/src/polytool/pt-placeholders-input.ts +127 -0
- package/src/polytool/types.ts +18 -0
- package/src/tests/polytool-enumerate-tests.ts +78 -0
- package/src/utils/err-info.ts +2 -2
- package/webpack.config.js +3 -10
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as ui from 'datagrok-api/ui';
|
|
2
|
+
import * as grok from 'datagrok-api/grok';
|
|
3
|
+
import * as DG from 'datagrok-api/dg';
|
|
4
|
+
|
|
5
|
+
import {PolyToolPlaceholders} from './types';
|
|
6
|
+
|
|
7
|
+
export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
|
|
8
|
+
get inputType(): string { return 'Positions'; }
|
|
9
|
+
|
|
10
|
+
get dataType(): string { return DG.TYPE.DATA_FRAME; }
|
|
11
|
+
|
|
12
|
+
getInput(): HTMLElement { return this.gridHost; }
|
|
13
|
+
|
|
14
|
+
getValue(): DG.DataFrame {
|
|
15
|
+
return this.grid.dataFrame;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setValue(value: DG.DataFrame): void {
|
|
19
|
+
this.grid.dataFrame = value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getStringValue(): string {
|
|
23
|
+
return this.grid.dataFrame.toCsv();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setStringValue(str: string): void {
|
|
27
|
+
this.grid.dataFrame = DG.DataFrame.fromCsv(str);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get placeholdersValue() {
|
|
31
|
+
return dfToPlaceholders(this.grid.dataFrame);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private readonly gridHost: HTMLDivElement;
|
|
35
|
+
public readonly grid: DG.Grid;
|
|
36
|
+
|
|
37
|
+
protected constructor(name: string | undefined, grid: DG.Grid, heightRowCount?: number) {
|
|
38
|
+
super();
|
|
39
|
+
|
|
40
|
+
if (name) this.captionLabel.innerText = name;
|
|
41
|
+
|
|
42
|
+
this.gridHost = ui.div([], {
|
|
43
|
+
classes: 'ui-input-editor',
|
|
44
|
+
style: {width: '100%', height: '100%', marginTop: '-8px'},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.grid = grid;
|
|
48
|
+
this.gridHost.append(this.grid.root);
|
|
49
|
+
|
|
50
|
+
if (heightRowCount != null) {
|
|
51
|
+
this.updateGridHeight(heightRowCount + 0.7);
|
|
52
|
+
} else {
|
|
53
|
+
this.updateGridHeight(this.grid.dataFrame.rowCount + 0.6);
|
|
54
|
+
this.grid.dataFrame.onRowsAdded
|
|
55
|
+
.subscribe(() => { this.updateGridHeight(this.grid.dataFrame.rowCount + 0.6); });
|
|
56
|
+
}
|
|
57
|
+
this.grid.root.style.width = `100%`;
|
|
58
|
+
|
|
59
|
+
ui.onSizeChanged(this.grid.root).subscribe(() => {
|
|
60
|
+
this.grid.columns.byIndex(2)!.width = this.grid.root.clientWidth - this.grid.horzScroll.root.offsetWidth -
|
|
61
|
+
this.grid.columns.byIndex(0)!.width - this.grid.columns.byIndex(1)!.width - 10;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.root.classList.add('ui-input-polytool-pos-grid');
|
|
65
|
+
this.root.append(this.gridHost);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public static async create(
|
|
69
|
+
name?: string, value?: DG.DataFrame, options?: {}, heightRowCount?: number
|
|
70
|
+
): Promise<PolyToolPlaceholdersInput> {
|
|
71
|
+
const df: DG.DataFrame = value ?? DG.DataFrame.create(0);
|
|
72
|
+
const grid = (await df.plot.fromType(DG.VIEWER.GRID, options)) as DG.Grid;
|
|
73
|
+
return new PolyToolPlaceholdersInput(name, grid, heightRowCount);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// -- Update view --
|
|
77
|
+
|
|
78
|
+
private updateGridHeight(visibleRowCount: number): void {
|
|
79
|
+
const gridHeight = this.grid.colHeaderHeight + visibleRowCount * this.grid.props.rowHeight + 6 + 2;
|
|
80
|
+
this.grid.root.style.height = `${gridHeight}px`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// -- Handle events --
|
|
84
|
+
|
|
85
|
+
private rootOnSizeChanged(): void {
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function getPlaceholdersFromText(src: string): PolyToolPlaceholders {
|
|
91
|
+
const res: PolyToolPlaceholders = {};
|
|
92
|
+
for (const line of src.split('\n')) {
|
|
93
|
+
const lineM = /^\s*(?<pos>\d+)\s*:\s*(?<monomers>.+)$/.exec(line);
|
|
94
|
+
if (lineM) {
|
|
95
|
+
const pos: number = parseInt(lineM.groups!['pos']) - 1;
|
|
96
|
+
const monomerList: string[] = lineM.groups!['monomers'].split(',').map(m => m.trim());
|
|
97
|
+
if (!(pos in res)) res[pos] = [];
|
|
98
|
+
res[pos].push(...monomerList);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return res;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function dfToPlaceholders(df: DG.DataFrame): PolyToolPlaceholders {
|
|
105
|
+
const res: PolyToolPlaceholders = {};
|
|
106
|
+
for (let rowI = 0; rowI < df.rowCount; rowI++) {
|
|
107
|
+
const pos = parseInt(df.get('Position', rowI));
|
|
108
|
+
if (!isNaN(pos)) {
|
|
109
|
+
const monomerSymbolList = parseMonomerSymbolList(df.get('Monomers', rowI));
|
|
110
|
+
if (monomerSymbolList.length > 0)
|
|
111
|
+
res[pos - 1] = monomerSymbolList;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function parseMonomerSymbolList(src: string): string[] {
|
|
118
|
+
// L, L-hArg(Et,Et), "hArg(Et,Et)"
|
|
119
|
+
return src.split(/,(?![^(]*\))/)
|
|
120
|
+
.map((s) => {
|
|
121
|
+
s = s.trim();
|
|
122
|
+
if (s.slice(0, 1) === `"` && s.slice(-1) === `"`) s = s.slice(1, -1);
|
|
123
|
+
if (s.slice(0, 1) === `'` && s.slice(-1) === `'`) s = s.slice(1, -1);
|
|
124
|
+
return s.trim();
|
|
125
|
+
})
|
|
126
|
+
.filter((s) => !!s);
|
|
127
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as ui from 'datagrok-api/ui';
|
|
2
|
+
import * as grok from 'datagrok-api/grok';
|
|
3
|
+
import * as DG from 'datagrok-api/dg';
|
|
4
|
+
|
|
5
|
+
export enum PolyToolEnumeratorTypes {
|
|
6
|
+
Single = 'single',
|
|
7
|
+
Matrix = 'matrix',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type PolyToolEnumeratorType = typeof PolyToolEnumeratorTypes[keyof typeof PolyToolEnumeratorTypes];
|
|
11
|
+
|
|
12
|
+
export type PolyToolPlaceholders = { [position: number]: string[] };
|
|
13
|
+
|
|
14
|
+
export type PolyToolEnumeratorParams = {
|
|
15
|
+
type: PolyToolEnumeratorType;
|
|
16
|
+
/** position key is zero-based */
|
|
17
|
+
placeholders: PolyToolPlaceholders;
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as grok from 'datagrok-api/grok';
|
|
2
|
+
import * as ui from 'datagrok-api/ui';
|
|
3
|
+
import * as DG from 'datagrok-api/dg';
|
|
4
|
+
|
|
5
|
+
import {before, after, category, expect, test, expectArray} from '@datagrok-libraries/utils/src/test';
|
|
6
|
+
import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
7
|
+
|
|
8
|
+
import {PolyToolEnumeratorParams, PolyToolEnumeratorTypes} from '../polytool/types';
|
|
9
|
+
import {polyToolEnumerateHelm} from '../package';
|
|
10
|
+
import {getPtEnumeratorHelm} from '../polytool/pt-enumeration-helm';
|
|
11
|
+
import {HelmMol} from '@datagrok-libraries/bio/src/helm/types';
|
|
12
|
+
|
|
13
|
+
category('PolyTool', () => {
|
|
14
|
+
let helmHelper: IHelmHelper;
|
|
15
|
+
|
|
16
|
+
before(async () => {
|
|
17
|
+
helmHelper = await getHelmHelper(); // initialize JSDraw2 and org
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
after(async () => {
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const tests: {
|
|
25
|
+
[testName: string]: { src: string, params: PolyToolEnumeratorParams, tgt: string[] }
|
|
26
|
+
} = {
|
|
27
|
+
'single1': {
|
|
28
|
+
src: 'PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$',
|
|
29
|
+
params: {
|
|
30
|
+
type: PolyToolEnumeratorTypes.Single,
|
|
31
|
+
placeholders: {
|
|
32
|
+
[4]: ['K', 'P', 'F4COO'],
|
|
33
|
+
[6]: ['Y', 'T'],
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
tgt: [
|
|
37
|
+
'PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0',
|
|
38
|
+
'PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0',
|
|
39
|
+
'PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C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].G.[NH2]}$$$$V2.0',
|
|
65
|
+
'PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0',
|
|
66
|
+
'PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0',
|
|
67
|
+
'PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0',
|
|
68
|
+
],
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
for (const [testName, testData] of Object.entries(tests)) {
|
|
73
|
+
test(`enumerator-${testName}`, async () => {
|
|
74
|
+
const res = getPtEnumeratorHelm(testData.src, testData.params);
|
|
75
|
+
expectArray(res, testData.tgt);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
package/src/utils/err-info.ts
CHANGED
|
@@ -6,8 +6,8 @@ import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
|
6
6
|
|
|
7
7
|
import {_package} from '../package';
|
|
8
8
|
|
|
9
|
-
export function defaultErrorHandler(err: any): void {
|
|
9
|
+
export function defaultErrorHandler(err: any, shell: boolean = true): void {
|
|
10
10
|
const [errMsg, errStack] = errInfo(err);
|
|
11
11
|
_package.logger.error(errMsg, undefined, errStack);
|
|
12
|
-
grok.shell.error(errMsg);
|
|
12
|
+
if (shell) grok.shell.error(errMsg);
|
|
13
13
|
}
|
package/webpack.config.js
CHANGED
|
@@ -17,16 +17,9 @@ module.exports = {
|
|
|
17
17
|
},
|
|
18
18
|
module: {
|
|
19
19
|
rules: [
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exclude: /node_modules/,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
test: /\.css$/,
|
|
27
|
-
use: ['style-loader', 'css-loader'],
|
|
28
|
-
exclude: /node_modules/,
|
|
29
|
-
},
|
|
20
|
+
{test: /\.js$/, enforce: 'pre', use: ['source-map-loader'], exclude: [/node_modules/]},
|
|
21
|
+
{test: /\.ts(x?)$/, use: 'ts-loader', exclude: [/node_modules/]},
|
|
22
|
+
{test: /\.css$/, use: ['style-loader', 'css-loader'], exclude: [/node_modules/]},
|
|
30
23
|
],
|
|
31
24
|
},
|
|
32
25
|
devtool: 'source-map',
|