@datagrok/sequence-translator 1.3.10 → 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.
@@ -0,0 +1,218 @@
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 wu from 'wu';
6
+ import {Unsubscribable} from 'rxjs';
7
+
8
+ import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
9
+ import {HelmAtom, HelmMol} from '@datagrok-libraries/helm-web-editor/src/types/org-helm';
10
+ import {getHelmHelper, HelmInputBase} from '@datagrok-libraries/bio/src/helm/helm-helper';
11
+
12
+ import {
13
+ PolyToolEnumeratorParams, PolyToolEnumeratorType, PolyToolEnumeratorTypes, PolyToolPlaceholders
14
+ } from './types';
15
+
16
+ import {PT_UI_DIALOG_ENUMERATION} from './const';
17
+ import {getLibrariesList} from './utils';
18
+ import {getPtEnumeratorHelm, PT_HELM_EXAMPLE} from './pt-enumeration-helm';
19
+ import {PolyToolPlaceholdersInput} from './pt-placeholders-input';
20
+ import {Dialog} from 'datagrok-api/dg';
21
+ import {defaultErrorHandler} from '../utils/err-info';
22
+
23
+ import {_package} from '../package';
24
+
25
+ type PolyToolEnumerateInputs = {
26
+ enumeratorType: DG.ChoiceInput<PolyToolEnumeratorType>
27
+ macromolecule: HelmInputBase;
28
+ placeholders: PolyToolPlaceholdersInput;
29
+ toAtomicLevel: DG.InputBase<boolean>;
30
+ };
31
+
32
+
33
+ export class PolyToolEnumerateDialog extends DG.Dialog {
34
+ protected constructor(
35
+ // public readonly inputs2: PolyToolEnumerateInputs
36
+ ) {
37
+ const dlg = ui.dialog({title: PT_UI_DIALOG_ENUMERATION});
38
+ super(dlg.dart);
39
+
40
+ // for (const [key, value] of Object.entries(this.inputs2)) { this.add(value); }
41
+ }
42
+
43
+ public override show(options?: { modal?: boolean; resizable?: boolean; fullScreen?: boolean; center?: boolean; centerAt?: Element; x?: number; y?: number; width?: number; height?: number; backgroundColor?: string; showNextTo?: HTMLElement }): Dialog {
44
+ return super.show(options);
45
+ }
46
+
47
+ public static async create2(cell?: DG.Cell, resizeInputs?: () => void): Promise<[PolyToolEnumerateDialog, PolyToolEnumerateInputs]> {
48
+ const logPrefix = `ST: PT: HelmDialog()`;
49
+
50
+ const [libList, helmHelper] = await Promise.all([getLibrariesList(), getHelmHelper()]);
51
+
52
+ const helmValue = cell ? cell.value : PT_HELM_EXAMPLE;
53
+ const posDf = DG.DataFrame.fromObjects([{Position: '', Monomers: ''}, {Position: '', Monomers: ''}]);
54
+
55
+ const macromoleculeInput = helmHelper.createHelmInput(
56
+ 'Macromolecule', {value: helmValue, editable: false});
57
+
58
+ const inputs: PolyToolEnumerateInputs = {
59
+ enumeratorType: ui.input.choice<PolyToolEnumeratorType>(
60
+ 'Enumerator type', {
61
+ value: PolyToolEnumeratorTypes.Single,
62
+ items: Object.values(PolyToolEnumeratorTypes)
63
+ }) as DG.ChoiceInput<PolyToolEnumeratorType>,
64
+ macromolecule: macromoleculeInput,
65
+
66
+ placeholders: await PolyToolPlaceholdersInput.create(
67
+ 'Placeholders', posDf, {
68
+ showAddNewRowIcon: true,
69
+ showRemoveRowIcon: true,
70
+ showRowHeader: false,
71
+ showCellTooltip: false,
72
+ }/*, 2/**/),
73
+
74
+ toAtomicLevel: ui.input.bool(
75
+ 'To atomic level', {value: true}),
76
+ };
77
+
78
+ const subs: Unsubscribable[] = [];
79
+ const destroy = () => { for (const sub of subs) sub.unsubscribe(); };
80
+
81
+ subs.push(inputs.macromolecule.onMouseMove.subscribe((e: MouseEvent) => {
82
+ try {
83
+ _package.logger.debug(`${logPrefix}, placeholdersInput.onMouseMove()`);
84
+
85
+ const argsX = e.offsetX;
86
+ const argsY = e.offsetY;
87
+ const mol = inputs.macromolecule.molValue;
88
+ const hoveredAtom = helmHelper.getHoveredAtom(argsX, argsY, mol, inputs.macromolecule.root.clientHeight);
89
+ if (hoveredAtom) {
90
+ const hoveredAtomContIdx = hoveredAtom._parent.atoms.indexOf(hoveredAtom);
91
+ const hoveredAtomContIdxStr = (hoveredAtomContIdx + 1).toString();
92
+ const substitutingMonomers = inputs.placeholders.placeholdersValue[hoveredAtomContIdx];
93
+
94
+ if (substitutingMonomers) {
95
+ const cnt = ui.divText(substitutingMonomers.join(', '));
96
+ inputs.macromolecule.showTooltip(cnt, hoveredAtom);
97
+ e.preventDefault();
98
+ e.stopPropagation();
99
+ }
100
+ }
101
+ } catch (err: any) {
102
+ defaultErrorHandler(err, false);
103
+ }
104
+ }));
105
+ subs.push(inputs.macromolecule.onClick.subscribe((e: MouseEvent) => {
106
+ try {
107
+ _package.logger.debug(`${logPrefix}, placeholdersInput.onClick()`);
108
+
109
+ const argsX = e.offsetX;
110
+ const argsY = e.offsetY;
111
+ const mol = inputs.macromolecule.molValue;
112
+ const clickedAtom = helmHelper.getHoveredAtom(argsX, argsY, mol, inputs.macromolecule.root.clientHeight);
113
+ if (clickedAtom) {
114
+ const clickedAtomContIdx = clickedAtom._parent.atoms.indexOf(clickedAtom);
115
+ const clickedAtomContIdxStr = (clickedAtomContIdx + 1).toString();
116
+
117
+ const phDf = inputs.placeholders.grid.dataFrame;
118
+ const posList = phDf.columns.byName('Position').toList();
119
+ let rowIdx = posList.indexOf(clickedAtomContIdxStr);
120
+ if (rowIdx === -1) {
121
+ rowIdx = posList.findIndex((v) => isNaN(v));
122
+ if (rowIdx === -1)
123
+ rowIdx = phDf.rows.addNew([clickedAtomContIdxStr, '']).idx;
124
+ phDf.set('Position', rowIdx, clickedAtomContIdxStr);
125
+ // const tgtCell = inputs.placeholders.grid.cell('Monomers', rowIdx);
126
+ }
127
+ phDf.currentCell = phDf.cell(rowIdx, 'Monomers');
128
+ //const gridRowIdx = inputs.placeholders.grid.tableRowToGrid(rowIdx);
129
+ //const monomersGCell = inputs.placeholders.grid.cell('Monomers', gridRowIdx);
130
+ const k = 42;
131
+ }
132
+ } catch (err: any) {
133
+ defaultErrorHandler(err);
134
+ }
135
+ }));
136
+ subs.push(inputs.placeholders.grid.dataFrame.onDataChanged.subscribe(() => {
137
+ updateMolView();
138
+ }));
139
+
140
+
141
+ // TODO: suspect
142
+ subs.push(ui.onSizeChanged(inputs.placeholders.root).subscribe(() => {
143
+ if (resizeInputs) resizeInputs();
144
+ }));
145
+
146
+ // Displays the molecule from a current cell (monitors changes)
147
+ subs.push(grok.events.onCurrentCellChanged.subscribe(() => {
148
+ const cell = grok.shell.tv.dataFrame.currentCell;
149
+
150
+ if (cell.column.semType === DG.SEMTYPE.MACROMOLECULE && cell.column.meta.units === NOTATION.HELM)
151
+ inputs.macromolecule.stringValue = cell.value;
152
+ }));
153
+
154
+ inputs.macromolecule.root.style.setProperty('min-width', '250px', 'important');
155
+ // inputs.macromolecule.root.style.setProperty('max-height', '300px', 'important');
156
+
157
+ const updateMolView = () => {
158
+ const mol = inputs.macromolecule.molValue;
159
+ for (let aI = 0; aI < mol.atoms.length; aI++) {
160
+ const a = mol.atoms[aI];
161
+ a.highlighted = aI in inputs.placeholders.placeholdersValue;
162
+ inputs.macromolecule.redraw();
163
+ }
164
+ };
165
+
166
+ const dialog = new PolyToolEnumerateDialog()
167
+ .add(inputs.enumeratorType)
168
+ .add(inputs.macromolecule)
169
+ .add(inputs.placeholders)
170
+ .add(inputs.toAtomicLevel)
171
+ .onOK(async () => {
172
+ try {
173
+ const helmString = inputs.macromolecule.stringValue;
174
+ const helmSelections: number[] = wu.enumerate<HelmAtom>(inputs.macromolecule.molValue.atoms)
175
+ .filter(([a, aI]) => a.highlighted)
176
+ .map(([a, aI]) => aI).toArray();
177
+ if (helmString === undefined || helmString === '') {
178
+ grok.shell.warning('PolyTool: no molecule was provided');
179
+ } else /* if (helmSelections === undefined || helmSelections.length < 1) {
180
+ grok.shell.warning('PolyTool: no selection was provided');
181
+ } else /**/ {
182
+ await getHelmHelper(); // initializes JSDraw and org
183
+
184
+ const params: PolyToolEnumeratorParams = {
185
+ type: inputs.enumeratorType.value!,
186
+ placeholders: inputs.placeholders.placeholdersValue,
187
+ };
188
+ if (Object.keys(params.placeholders).length === 0) {
189
+ grok.shell.warning(`${PT_UI_DIALOG_ENUMERATION}: placeholders are empty`);
190
+ return;
191
+ }
192
+
193
+ const enumHelmList = getPtEnumeratorHelm(helmString, params);
194
+ const enumHelmCol = DG.Column.fromStrings('Enumerated', enumHelmList);
195
+ const enumeratorResDf = DG.DataFrame.fromColumns([enumHelmCol]);
196
+
197
+ if (inputs.toAtomicLevel.value) {
198
+ const enumMolCol = await grok.functions.call('Bio:getMolFromHelm', {
199
+ 'df': enumeratorResDf,
200
+ 'helmCol': enumHelmCol,
201
+ 'chiralityEngine': true,
202
+ });
203
+ enumMolCol.name = enumeratorResDf.columns.getUnusedName(`molfile(${enumHelmCol.name})`);
204
+ enumMolCol.semType = DG.SEMTYPE.MOLECULE;
205
+ enumeratorResDf.columns.add(enumMolCol, true);
206
+ }
207
+ grok.shell.addTableView(enumeratorResDf);
208
+ }
209
+ } catch (err: any) {
210
+ defaultErrorHandler(err);
211
+ } finally {
212
+ destroy();
213
+ }
214
+ })
215
+ .onCancel(() => { destroy(); }) as PolyToolEnumerateDialog;
216
+ return [dialog, inputs];
217
+ }
218
+ }
@@ -1,22 +1,74 @@
1
1
  import * as ui from 'datagrok-api/ui';
2
2
  import * as grok from 'datagrok-api/grok';
3
3
  import * as DG from 'datagrok-api/dg';
4
+
5
+ import {HelmType, JSDraw2ModuleType, OrgType, HelmAtom, HelmMol} from '@datagrok-libraries/bio/src/helm/types';
6
+
4
7
  import {Chain} from './pt-conversion';
5
- import {getAvailableMonomers} from './utils'
8
+ import {getAvailableMonomers} from './utils';
9
+ import {PolyToolEnumeratorParams, PolyToolEnumeratorTypes, PolyToolPlaceholders} from './types';
6
10
 
7
11
  export const PT_HELM_EXAMPLE = 'PEPTIDE1{[R].[F].[T].[G].[H].[F].[G].[A].[A].[Y].[P].[E].[NH2]}$$$$';
8
12
 
9
- export async function getEnumerationHelm(helmString: string, helmSelections: number[], screenLibrary: string):
10
- Promise<string[]> {
11
- const variableMonomers = await getAvailableMonomers(screenLibrary);
12
- const chain: Chain = Chain.fromHelm(helmString);
13
- const size = helmSelections.length * variableMonomers.length;
14
- const enumerations = new Array<string>(size);
13
+ /** Initialized by getHelmHelper via init Helm package */
14
+ declare const JSDraw2: JSDraw2ModuleType;
15
+ declare const org: OrgType;
15
16
 
16
- for (let i = 0; i < helmSelections.length; i++) {
17
- for (let j = 0; j < variableMonomers.length; j++)
18
- enumerations[i * variableMonomers.length + j] = chain.getHelmChanged(helmSelections[i], variableMonomers[j]);
17
+ function polyToolEnumeratorCore(m: HelmMol, position: number, monomerList: string[]): HelmMol[] {
18
+ const resMolList: HelmMol[] = new Array<HelmMol>(monomerList.length);
19
+ for (let i = 0; i < monomerList.length; i++) {
20
+ const symbolName = monomerList[i];
21
+ const resM = resMolList[i] = m.clone();
22
+ resM.atoms[position].elem = symbolName;
19
23
  }
24
+ return resMolList;
25
+ }
26
+
27
+ /**
28
+ * @param {string} helm Molecule string Helm format
29
+ * @param placeholders Placeholders by zero-based position key
30
+ * @returns {string[]} List of enumerated molecules in Helm format
31
+ */
32
+ function getPtEnumeratorSingle(helm: string, placeholders: PolyToolPlaceholders): string[] {
33
+ const molHandler = new JSDraw2.MolHandler<HelmType>();
34
+ const plugin = new org.helm.webeditor.Plugin(molHandler);
35
+ const io = org.helm.webeditor.IO;
36
+
37
+ const origin = new JSDraw2.Point(0, 0);
38
+ io.parseHelm(plugin, helm, origin, undefined);
39
+
40
+ const coreResList: HelmMol[][] = Object.entries(placeholders)
41
+ .map(([p, monomerList]: [string, string[]]) => polyToolEnumeratorCore(molHandler.m, parseInt(p), monomerList));
42
+ const resMolList = coreResList.reduce((acc, posList) => acc.concat(posList), []);
43
+
44
+ const resHelmList = resMolList.map((m: HelmMol) => org.helm.webeditor.IO.getHelm(m)!);
45
+ return resHelmList;
46
+ }
20
47
 
21
- return enumerations;
48
+ function getPtEnumeratorMatrix(helm: string, placeholders: PolyToolPlaceholders): string[] {
49
+ const molHandler = new JSDraw2.MolHandler<HelmType>();
50
+ const plugin = new org.helm.webeditor.Plugin(molHandler);
51
+ const io = org.helm.webeditor.IO;
52
+
53
+ const origin = new JSDraw2.Point(0, 0);
54
+ io.parseHelm(plugin, helm, origin, undefined);
55
+
56
+ let resMolList = [molHandler.m];
57
+ for (const [p, monomerList] of Object.entries(placeholders)) {
58
+ const pos: number = parseInt(p);
59
+ const posResMolList: HelmMol[][] = resMolList.map((m: HelmMol) => polyToolEnumeratorCore(m, pos, monomerList));
60
+ resMolList = posResMolList.reduce((acc, l) => acc.concat(l), []);
61
+ }
62
+
63
+ const resHelmList = resMolList.map((m: HelmMol) => org.helm.webeditor.IO.getHelm(m)!);
64
+ return resHelmList;
65
+ }
66
+
67
+ export function getPtEnumeratorHelm(helm: string, params: PolyToolEnumeratorParams): string[] {
68
+ switch (params.type) {
69
+ case PolyToolEnumeratorTypes.Single:
70
+ return getPtEnumeratorSingle(helm, params.placeholders);
71
+ case PolyToolEnumeratorTypes.Matrix:
72
+ return getPtEnumeratorMatrix(helm, params.placeholders);
73
+ }
22
74
  }
@@ -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(1)].G.[NH2]}$$$$V2.0',
40
+ 'PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0',
41
+ 'PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0',
42
+ ]
43
+ },
44
+ 'matrix1': {
45
+ src: 'PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$',
46
+ params:
47
+ {
48
+ type: PolyToolEnumeratorTypes.Matrix,
49
+ placeholders: {
50
+ [1]: ['D', 'L'],
51
+ [4]: ['K', 'P', 'F4COO'],
52
+ [6]: ['Y', 'T'],
53
+ }
54
+ },
55
+ tgt: [
56
+ 'PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0',
57
+ 'PEPTIDE1{[Ac(1)].D.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0',
58
+ 'PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0',
59
+ 'PEPTIDE1{[Ac(1)].D.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0',
60
+ 'PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0',
61
+ 'PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0',
62
+ 'PEPTIDE1{[Ac(1)].L.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0',
63
+ 'PEPTIDE1{[Ac(1)].L.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0',
64
+ 'PEPTIDE1{[Ac(1)].L.W.G.P.L.Y.[C(1)].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
+ });
@@ -6,7 +6,7 @@ import {defaultErrorHandler} from './err-info';
6
6
  import {_package, addContextMenu} from '../package';
7
7
  import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
8
8
  import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
9
- import {polyToolEnumerateHelmUI} from '../polytool/pt-ui';
9
+ import {polyToolEnumerateHelmUI} from '../polytool/pt-dialog';
10
10
 
11
11
  export type SequenceTranslatorWindowType = Window & {
12
12
  $sequenceTranslator?: {
@@ -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
- test: /\.ts(x?)$/,
22
- use: 'ts-loader',
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',
@@ -1,25 +0,0 @@
1
- import * as grok from 'datagrok-api/grok';
2
- import * as DG from 'datagrok-api/dg';
3
- import * as ui from 'datagrok-api/ui';
4
-
5
- import {getPolyToolEnumerationHelmDialog, getPolyToolEnumerationChemDialog} from './pt-dialog';
6
-
7
- export function polyToolEnumerateHelmUI(cell?: DG.Cell): void {
8
- getPolyToolEnumerationHelmDialog(cell)
9
- .then((dialog) => {
10
- dialog.show({resizable: true});
11
- })
12
- .catch((_err: any) => {
13
- grok.shell.warning('To run PolyTool Enumeration, sketch the macromolecule and select monomers to vary');
14
- });
15
- }
16
-
17
- export function polyToolEnumerateChemUI(cell?: DG.Cell): void {
18
- getPolyToolEnumerationChemDialog(cell)
19
- .then((dialog) => {
20
- dialog.show({resizable: true});
21
- })
22
- .catch((_err: any) => {
23
- grok.shell.warning('To run PolyTool Enumeration, sketch the molecule and specify the R group to vary');
24
- });
25
- }