@datagrok/sequence-translator 1.10.5 → 1.10.7
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 +4 -0
- package/detectors.js +3 -1
- package/dist/455.js +1 -1
- package/dist/455.js.map +1 -1
- 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 +9 -6
- package/scripts/build-monomer-lib.py +0 -1
- package/src/apps/common/view/components/colored-input/input-painters.ts +1 -1
- package/src/apps/structure/model/monomer-code-parser.ts +1 -1
- package/src/apps/translator/model/conversion-utils.ts +1 -1
- package/src/demo/demo-st-ui.ts +1 -1
- package/src/package-test.ts +1 -1
- package/src/package.g.ts +14 -0
- package/src/package.ts +27 -13
- package/src/polytool/pt-enumerate-seq-dialog.ts +54 -7
- package/src/polytool/pt-monomer-selection-dialog.ts +200 -0
- package/src/polytool/pt-placeholders-breadth-input.ts +39 -0
- package/src/polytool/pt-placeholders-input.ts +34 -0
- package/src/tests/files-tests.ts +1 -1
- package/src/tests/formats-support.ts +1 -1
- package/src/tests/formats-to-helm.ts +1 -1
- package/src/tests/helm-to-nucleotides.ts +1 -1
- package/src/tests/polytool-chain-from-notation-tests.ts +1 -1
- package/src/tests/polytool-chain-parse-notation-tests.ts +1 -1
- package/src/tests/polytool-convert-tests.ts +1 -1
- package/src/tests/polytool-detectors-custom-notation-test.ts +1 -1
- package/src/tests/polytool-enumerate-breadth-tests.ts +1 -1
- package/src/tests/polytool-enumerate-tests.ts +1 -1
- package/src/tests/polytool-unrule-tests.ts +1 -1
- package/src/tests/toAtomicLevel-tests.ts +1 -1
- package/src/tests/utils/detect-macromolecule-utils.ts +1 -1
- package/src/utils/cyclized.ts +8 -2
- package/test-console-output-1.log +207 -1594
- package/test-record-1.mp4 +0 -0
- package/webpack.config.js +22 -1
|
@@ -7,6 +7,15 @@ import {PolyToolBreadthPlaceholder} from './types';
|
|
|
7
7
|
import {parseMonomerSymbolList} from './pt-placeholders-input';
|
|
8
8
|
import {GridCellRenderArgs} from 'datagrok-api/dg';
|
|
9
9
|
|
|
10
|
+
/** Callback invoked when user double-clicks a Monomers cell in the breadth grid.
|
|
11
|
+
* @param start 0-based start position index
|
|
12
|
+
* @param end 0-based end position index
|
|
13
|
+
* @param currentMonomers current monomer symbols
|
|
14
|
+
* @returns new monomer symbols, or null if cancelled */
|
|
15
|
+
export type BreadthMonomerCellEditCallback = (
|
|
16
|
+
start: number, end: number, currentMonomers: string[],
|
|
17
|
+
) => Promise<string[] | null>;
|
|
18
|
+
|
|
10
19
|
export class PolyToolPlaceholdersBreadthInput extends DG.JsInputBase<DG.DataFrame> {
|
|
11
20
|
get inputType(): string { return 'Breadth'; }
|
|
12
21
|
|
|
@@ -30,6 +39,9 @@ export class PolyToolPlaceholdersBreadthInput extends DG.JsInputBase<DG.DataFram
|
|
|
30
39
|
return dfToPlaceholdersBreadth(this.grid.dataFrame);
|
|
31
40
|
}
|
|
32
41
|
|
|
42
|
+
/** Set this callback to handle double-click editing of the Monomers column */
|
|
43
|
+
onMonomerCellEdit: BreadthMonomerCellEditCallback | null = null;
|
|
44
|
+
|
|
33
45
|
private readonly gridHost: HTMLDivElement;
|
|
34
46
|
public grid: DG.Grid;
|
|
35
47
|
|
|
@@ -91,6 +103,18 @@ export class PolyToolPlaceholdersBreadthInput extends DG.JsInputBase<DG.DataFram
|
|
|
91
103
|
}
|
|
92
104
|
});
|
|
93
105
|
|
|
106
|
+
// Make Monomers column non-editable (editing via double-click dialog)
|
|
107
|
+
const monomersGridCol = this.grid.columns.byName('Monomers');
|
|
108
|
+
if (monomersGridCol)
|
|
109
|
+
monomersGridCol.editable = false;
|
|
110
|
+
|
|
111
|
+
// Double-click on Monomers cell opens the monomer selection dialog
|
|
112
|
+
this.subs.push(this.grid.onCellDoubleClick.subscribe((gc: DG.GridCell) => {
|
|
113
|
+
if (gc.tableColumn?.name === 'Monomers' &&
|
|
114
|
+
gc.tableRowIndex != null && gc.tableRowIndex >= 0)
|
|
115
|
+
this.handleMonomerCellDoubleClick(gc.tableRowIndex);
|
|
116
|
+
}));
|
|
117
|
+
|
|
94
118
|
this.updateGridHeight(heightRowCount ?? this.grid.dataFrame.rowCount + 0.7);
|
|
95
119
|
this.subs.push(ui.onSizeChanged(this.grid.root)
|
|
96
120
|
.subscribe(this.gridRootOnSizeChanged.bind(this)));
|
|
@@ -140,6 +164,21 @@ export class PolyToolPlaceholdersBreadthInput extends DG.JsInputBase<DG.DataFram
|
|
|
140
164
|
|
|
141
165
|
// -- Handle events --
|
|
142
166
|
|
|
167
|
+
private async handleMonomerCellDoubleClick(tableRowIdx: number): Promise<void> {
|
|
168
|
+
if (!this.onMonomerCellEdit)
|
|
169
|
+
return;
|
|
170
|
+
const df = this.grid.dataFrame;
|
|
171
|
+
const start = parseInt(df.get('Start', tableRowIdx)) - 1;
|
|
172
|
+
const end = parseInt(df.get('End', tableRowIdx)) - 1;
|
|
173
|
+
if (isNaN(start) || isNaN(end))
|
|
174
|
+
return;
|
|
175
|
+
const currentStr: string = df.get('Monomers', tableRowIdx) ?? '';
|
|
176
|
+
const currentMonomers = parseMonomerSymbolList(currentStr);
|
|
177
|
+
const result = await this.onMonomerCellEdit(start, end, currentMonomers);
|
|
178
|
+
if (result !== null)
|
|
179
|
+
df.set('Monomers', tableRowIdx, result.join(', '));
|
|
180
|
+
}
|
|
181
|
+
|
|
143
182
|
private gridRootOnSizeChanged(): void {
|
|
144
183
|
this.grid.columns.byIndex(4)!.width = this.grid.root.clientWidth - this.grid.horzScroll.root.offsetWidth -
|
|
145
184
|
this.grid.columns.byIndex(0)!.width - this.grid.columns.byIndex(1)!.width -
|
|
@@ -7,6 +7,12 @@ import {fromEvent, Unsubscribable} from 'rxjs';
|
|
|
7
7
|
import {PolyToolPlaceholder} from './types';
|
|
8
8
|
import {GridCellRenderArgs} from 'datagrok-api/dg';
|
|
9
9
|
|
|
10
|
+
/** Callback invoked when user double-clicks a Monomers cell.
|
|
11
|
+
* @param position 0-based position index
|
|
12
|
+
* @param currentMonomers current monomer symbols
|
|
13
|
+
* @returns new monomer symbols, or null if cancelled */
|
|
14
|
+
export type MonomerCellEditCallback = (position: number, currentMonomers: string[]) => Promise<string[] | null>;
|
|
15
|
+
|
|
10
16
|
export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
|
|
11
17
|
get inputType(): string { return 'Positions'; }
|
|
12
18
|
|
|
@@ -38,6 +44,9 @@ export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
|
|
|
38
44
|
return dfToPlaceholders(this.grid.dataFrame);
|
|
39
45
|
}
|
|
40
46
|
|
|
47
|
+
/** Set this callback to handle double-click editing of the Monomers column */
|
|
48
|
+
onMonomerCellEdit: MonomerCellEditCallback | null = null;
|
|
49
|
+
|
|
41
50
|
private readonly gridHost: HTMLDivElement;
|
|
42
51
|
private grid!: DG.Grid;
|
|
43
52
|
|
|
@@ -89,6 +98,17 @@ export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
|
|
|
89
98
|
}
|
|
90
99
|
});
|
|
91
100
|
|
|
101
|
+
// Make Monomers column non-editable (editing is done via double-click dialog)
|
|
102
|
+
const monomersGridCol = this.grid.columns.byName('Monomers');
|
|
103
|
+
if (monomersGridCol)
|
|
104
|
+
monomersGridCol.editable = false;
|
|
105
|
+
|
|
106
|
+
// Double-click on Monomers cell opens the monomer selection dialog
|
|
107
|
+
this.subs.push(this.grid.onCellDoubleClick.subscribe((gc: DG.GridCell) => {
|
|
108
|
+
if (gc.tableColumn?.name === 'Monomers' && gc.tableRowIndex != null && gc.tableRowIndex >= 0)
|
|
109
|
+
this.handleMonomerCellDoubleClick(gc.tableRowIndex);
|
|
110
|
+
}));
|
|
111
|
+
|
|
92
112
|
this.updateGridHeight(heightRowCount ?? this.grid.dataFrame.rowCount + 0.7);
|
|
93
113
|
this.subs.push(ui.onSizeChanged(this.grid.root)
|
|
94
114
|
.subscribe(this.gridRootOnSizeChanged.bind(this)));
|
|
@@ -160,6 +180,20 @@ export class PolyToolPlaceholdersInput extends DG.JsInputBase<DG.DataFrame> {
|
|
|
160
180
|
|
|
161
181
|
// -- Handle events --
|
|
162
182
|
|
|
183
|
+
private async handleMonomerCellDoubleClick(tableRowIdx: number): Promise<void> {
|
|
184
|
+
if (!this.onMonomerCellEdit)
|
|
185
|
+
return;
|
|
186
|
+
const df = this.grid.dataFrame;
|
|
187
|
+
const position = parseInt(df.get('Position', tableRowIdx)) - 1;
|
|
188
|
+
if (isNaN(position))
|
|
189
|
+
return;
|
|
190
|
+
const currentMonomersStr: string = df.get('Monomers', tableRowIdx) ?? '';
|
|
191
|
+
const currentMonomers = parseMonomerSymbolList(currentMonomersStr);
|
|
192
|
+
const result = await this.onMonomerCellEdit(position, currentMonomers);
|
|
193
|
+
if (result !== null)
|
|
194
|
+
df.set('Monomers', tableRowIdx, result.join(', '));
|
|
195
|
+
}
|
|
196
|
+
|
|
163
197
|
private gridRootOnSizeChanged(): void {
|
|
164
198
|
this.grid.columns.byIndex(3)!.width = this.grid.root.clientWidth - this.grid.horzScroll.root.offsetWidth -
|
|
165
199
|
this.grid.columns.byIndex(0)!.width - this.grid.columns.byIndex(1)!.width -
|
package/src/tests/files-tests.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {after, before, category, expect, test} from '@datagrok-libraries/
|
|
5
|
+
import {after, before, category, expect, test} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
7
7
|
|
|
8
8
|
import {getHelm} from './utils';
|
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {before, category, expect, test} from '@datagrok-libraries/
|
|
5
|
+
import {before, category, expect, test} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
import {DEFAULT_FORMATS} from '../apps/common/model/const';
|
|
7
7
|
import {getTranslatedSequences} from '../apps/translator/model/conversion-utils';
|
|
8
8
|
import {ITranslationHelper} from '../types';
|
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {before, category, expect, test} from '@datagrok-libraries/
|
|
5
|
+
import {before, category, expect, test} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
import {getFormat, getHelm} from './utils';
|
|
7
7
|
import {ITranslationHelper} from '../types';
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {before, category, expect, test} from '@datagrok-libraries/
|
|
5
|
+
import {before, category, expect, test} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
import {getNucleotidesSequence} from '../apps/translator/model/conversion-utils';
|
|
7
7
|
import {ITranslationHelper} from '../types';
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ import * as grok from 'datagrok-api/grok';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
|
|
6
|
-
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/
|
|
6
|
+
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/test/src/test';
|
|
7
7
|
import {Chain} from '../polytool/conversion/pt-chain';
|
|
8
8
|
import {getRules} from '../polytool/conversion/pt-rules';
|
|
9
9
|
import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
@@ -3,7 +3,7 @@ import * as grok from 'datagrok-api/grok';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
|
|
6
|
-
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/
|
|
6
|
+
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/test/src/test';
|
|
7
7
|
import {Chain} from '../polytool/conversion/pt-chain';
|
|
8
8
|
import {getInnerIdx, getOuterIdx} from '../polytool/conversion/pt-misc';
|
|
9
9
|
import {getRules} from '../polytool/conversion/pt-rules';
|
|
@@ -4,7 +4,7 @@ import * as ui from 'datagrok-api/ui';
|
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
|
|
6
6
|
import {before, after, category, expect, test, expectArray, testEvent, expectObject}
|
|
7
|
-
from '@datagrok-libraries/
|
|
7
|
+
from '@datagrok-libraries/test/src/test';
|
|
8
8
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/types/monomer-library';
|
|
9
9
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
10
10
|
import {
|
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {category, test, expect, before} from '@datagrok-libraries/
|
|
5
|
+
import {category, test, expect, before} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
import {ISeqHelper, getSeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
7
7
|
import {ALIGNMENT, ALPHABET, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
8
8
|
import {_testNeg, _testPos, DetectorTestData, DfReaderFunc, PosCol} from './utils/detect-macromolecule-utils';
|
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {before, after, category, expect, test, expectArray} from '@datagrok-libraries/
|
|
5
|
+
import {before, after, category, expect, test, expectArray} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
7
7
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/types/monomer-library';
|
|
8
8
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {before, after, category, expect, test, expectArray} from '@datagrok-libraries/
|
|
5
|
+
import {before, after, category, expect, test, expectArray} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
7
7
|
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/types/monomer-library';
|
|
8
8
|
import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
|
|
@@ -2,7 +2,7 @@ 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
4
|
|
|
5
|
-
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/
|
|
5
|
+
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/test/src/test';
|
|
6
6
|
|
|
7
7
|
import {doPolyToolUnrule} from '../polytool/pt-unrule';
|
|
8
8
|
import {getRules} from '../polytool/conversion/pt-rules';
|
|
@@ -3,7 +3,7 @@ import * as grok from 'datagrok-api/grok';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
|
|
6
|
-
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/
|
|
6
|
+
import {before, after, category, expect, test, expectArray, testEvent, delay} from '@datagrok-libraries/test/src/test';
|
|
7
7
|
import {Monomer, MonomerLibData} from '@datagrok-libraries/bio/src/types/monomer-library';
|
|
8
8
|
|
|
9
9
|
import {PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
|
|
@@ -3,7 +3,7 @@ import * as DG from 'datagrok-api/dg';
|
|
|
3
3
|
import * as grok from 'datagrok-api/grok';
|
|
4
4
|
|
|
5
5
|
import {ALIGNMENT, NOTATION, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
6
|
-
import {delay, expect} from '@datagrok-libraries/
|
|
6
|
+
import {delay, expect} from '@datagrok-libraries/test/src/test';
|
|
7
7
|
import {ISeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
8
8
|
|
|
9
9
|
export type DetectorTestData = { [testName: string]: { csv: string, neg?: string[], pos?: { [colName: string]: PosCol } } };
|
package/src/utils/cyclized.ts
CHANGED
|
@@ -6,7 +6,7 @@ import wu from 'wu';
|
|
|
6
6
|
|
|
7
7
|
/* eslint-disable max-len */
|
|
8
8
|
import {ISeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
9
|
-
import {INotationProvider, ISeqSplitted, SeqSplittedBase, SplitterFunc} from '@datagrok-libraries/bio/src/utils/macromolecule/types';
|
|
9
|
+
import {INotationProvider, ISeqSplitted, NotationProviderBase, SeqSplittedBase, SplitterFunc} from '@datagrok-libraries/bio/src/utils/macromolecule/types';
|
|
10
10
|
import {getSplitterWithSeparator} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
11
11
|
import {GAP_SYMBOL, GapOriginals, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule/consts';
|
|
12
12
|
import {CellRendererBackBase} from '@datagrok-libraries/bio/src/utils/cell-renderer-back-base';
|
|
@@ -22,16 +22,22 @@ import {CyclizedCellRendererBack} from './cell-renderer-cyclized';
|
|
|
22
22
|
|
|
23
23
|
/* eslint-enable max-len */
|
|
24
24
|
|
|
25
|
-
export class CyclizedNotationProvider implements INotationProvider {
|
|
25
|
+
export class CyclizedNotationProvider extends NotationProviderBase implements INotationProvider {
|
|
26
26
|
private readonly separatorSplitter: SplitterFunc;
|
|
27
27
|
public readonly splitter: SplitterFunc;
|
|
28
28
|
|
|
29
|
+
static override get notationName(): string { return 'Harmonized Sequence'; }
|
|
30
|
+
static override get implementsFromHelm(): boolean { return false; }
|
|
31
|
+
static override convertFromHelm(helm: string, options: any): string {
|
|
32
|
+
throw new Error('converting from helm not supported yet');
|
|
33
|
+
}
|
|
29
34
|
get defaultGapOriginal(): string { return ''; }
|
|
30
35
|
|
|
31
36
|
constructor(
|
|
32
37
|
public readonly separator: string,
|
|
33
38
|
protected readonly helmHelper: IHelmHelper
|
|
34
39
|
) {
|
|
40
|
+
super();
|
|
35
41
|
this.separatorSplitter = getSplitterWithSeparator(this.separator);
|
|
36
42
|
this.splitter = this._splitter.bind(this);
|
|
37
43
|
}
|