@datagrok/sequence-translator 1.4.4 → 1.4.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/CHANGELOG.md +24 -0
- package/detectors.js +24 -0
- package/dist/455.js +2 -0
- package/dist/455.js.map +1 -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/files/polytool-rules/rules_example.json +2 -2
- package/files/samples/HELM.csv +6 -0
- package/files/samples/cyclized.csv +4 -3
- package/files/samples/cyclized_MSA.csv +5 -0
- package/package.json +13 -13
- package/src/apps/common/model/oligo-toolkit-package.ts +23 -4
- package/src/apps/common/view/components/molecule-img.ts +2 -2
- package/src/apps/pattern/model/data-manager.ts +9 -9
- package/src/apps/translator/view/ui.ts +8 -8
- package/src/consts.ts +12 -0
- package/src/global.d.ts +13 -0
- package/src/package-test.ts +3 -0
- package/src/package.ts +32 -5
- package/src/polytool/pt-conversion.ts +395 -81
- package/src/polytool/pt-dialog.ts +29 -13
- package/src/polytool/pt-enumeration-helm-dialog.ts +79 -34
- package/src/polytool/pt-enumeration-helm.ts +12 -8
- package/src/polytool/pt-placeholders-breadth-input.ts +4 -4
- package/src/polytool/pt-placeholders-input.ts +6 -6
- package/src/polytool/pt-unrule-dialog.ts +7 -3
- package/src/polytool/pt-unrule.ts +4 -3
- package/src/polytool/types.ts +4 -4
- package/src/tests/polytool-chain-from-notation-tests.ts +108 -18
- package/src/tests/polytool-chain-parse-notation-tests.ts +100 -0
- package/src/tests/polytool-convert-tests.ts +102 -25
- package/src/tests/polytool-detectors-custom-notation-test.ts +43 -0
- package/src/tests/polytool-enumerate-breadth-tests.ts +4 -4
- package/src/tests/toAtomicLevel-tests.ts +1 -1
- package/src/tests/utils/detect-macromolecule-utils.ts +64 -0
- package/src/tests/{utils.ts → utils/index.ts} +2 -2
- package/src/utils/context-menu.ts +2 -5
- package/src/utils/cyclized.ts +88 -0
- package/src/utils/dimerized.ts +10 -0
|
@@ -0,0 +1,88 @@
|
|
|
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 wu from 'wu';
|
|
6
|
+
|
|
7
|
+
/* eslint-disable max-len */
|
|
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';
|
|
10
|
+
import {getSplitterWithSeparator} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
11
|
+
import {GAP_SYMBOL, GapOriginals, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule/consts';
|
|
12
|
+
import {CellRendererBackBase} from '@datagrok-libraries/bio/src/utils/cell-renderer-back-base';
|
|
13
|
+
import {MonomerPlacer} from '@datagrok-libraries/bio/src/utils/cell-renderer-monomer-placer';
|
|
14
|
+
import {monomerToShort, StringListSeqSplitted} from '@datagrok-libraries/bio/src/utils/macromolecule/utils';
|
|
15
|
+
import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
|
|
16
|
+
import {getHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
17
|
+
|
|
18
|
+
import {Chain} from '../polytool/pt-conversion';
|
|
19
|
+
|
|
20
|
+
import {_package} from '../package';
|
|
21
|
+
|
|
22
|
+
/* eslint-enable max-len */
|
|
23
|
+
|
|
24
|
+
export class CyclizedNotationProvider implements INotationProvider {
|
|
25
|
+
private readonly separatorSplitter: SplitterFunc;
|
|
26
|
+
public readonly splitter: SplitterFunc;
|
|
27
|
+
|
|
28
|
+
constructor(
|
|
29
|
+
public readonly separator: string,
|
|
30
|
+
protected readonly seqHelper: ISeqHelper
|
|
31
|
+
) {
|
|
32
|
+
this.separatorSplitter = getSplitterWithSeparator(this.separator);
|
|
33
|
+
this.splitter = this._splitter.bind(this);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private _splitter(seq: string): ISeqSplitted {
|
|
37
|
+
const baseSS: ISeqSplitted = this.separatorSplitter(seq);
|
|
38
|
+
return new CyclizedSeqSplitted(
|
|
39
|
+
wu.count(0).take(baseSS.length).map((p) => baseSS.getOriginal(p)).toArray(),
|
|
40
|
+
GapOriginals[NOTATION.SEPARATOR]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public async getHelm(seq: string, options?: any): Promise<string> {
|
|
44
|
+
const helmHelper = await getHelmHelper();
|
|
45
|
+
const seqChain = await Chain.parseNotation(seq, helmHelper);
|
|
46
|
+
const resPseudoHelm = seqChain.getNotationHelm();
|
|
47
|
+
return resPseudoHelm;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public createCellRendererBack(gridCol: DG.GridColumn | null, tableCol: DG.Column<string>): CellRendererBackBase<string> {
|
|
51
|
+
let maxLengthOfMonomer: number = 4; // (_package.bioProperties ? _package.bioProperties.maxMonomerLength : 4) ?? 50;
|
|
52
|
+
const back = new MonomerPlacer(gridCol, tableCol, _package.logger, maxLengthOfMonomer,
|
|
53
|
+
() => {
|
|
54
|
+
const sh = this.seqHelper.getSeqHandler(tableCol);
|
|
55
|
+
return {
|
|
56
|
+
seqHandler: sh,
|
|
57
|
+
monomerCharWidth: 7,
|
|
58
|
+
separatorWidth: 11,
|
|
59
|
+
monomerToShort: monomerToShort,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
back.init().then(() => {});
|
|
63
|
+
return back;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Gets canonical monomers for original ones with cyclization marks */
|
|
68
|
+
export class CyclizedSeqSplitted extends StringListSeqSplitted {
|
|
69
|
+
private readonly seqCList: (string | null)[];
|
|
70
|
+
|
|
71
|
+
override getCanonical(posIdx: number): string {
|
|
72
|
+
if (this.isGap(posIdx)) return GAP_SYMBOL;
|
|
73
|
+
|
|
74
|
+
let cmRes: string | null = this.seqCList[posIdx];
|
|
75
|
+
if (cmRes === null) {
|
|
76
|
+
const om = this.getOriginal(posIdx);
|
|
77
|
+
cmRes = om;
|
|
78
|
+
if (om[om.length - 1] === ')')
|
|
79
|
+
cmRes = this.seqCList[posIdx] = om.replace(/\(\d+\)$/, '');
|
|
80
|
+
}
|
|
81
|
+
return cmRes;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
constructor(seqOList: SeqSplittedBase, gapOriginalMonomer: string) {
|
|
85
|
+
super(seqOList, gapOriginalMonomer);
|
|
86
|
+
this.seqCList = new Array<string | null>(this.length).fill(null);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 {CyclizedNotationProvider} from './cyclized';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export class DimerizedNotationProvider extends CyclizedNotationProvider {
|
|
9
|
+
|
|
10
|
+
}
|