@datagrok/sequence-translator 1.4.3 → 1.4.5
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 +2 -1
- package/dist/package-test.js.LICENSE.txt +8 -0
- 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 +4 -4
- package/files/samples/cyclized.csv +3 -2
- package/package.json +14 -14
- package/src/apps/common/model/oligo-toolkit-package.ts +12 -0
- 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/package-test.ts +2 -0
- package/src/package.ts +30 -4
- package/src/polytool/pt-conversion.ts +361 -32
- package/src/polytool/pt-dialog.ts +18 -25
- package/src/polytool/pt-enumeration-helm-dialog.ts +18 -11
- package/src/polytool/pt-enumeration-helm.ts +3 -2
- package/src/polytool/pt-unrule-dialog.ts +2 -2
- package/src/polytool/pt-unrule.ts +1 -1
- package/src/polytool/types.ts +18 -0
- package/src/tests/polytool-chain-from-notation-tests.ts +45 -0
- package/src/tests/polytool-chain-parse-notation-tests.ts +59 -0
- package/src/tests/polytool-detectors-custom-notation-test.ts +43 -0
- package/src/tests/toAtomicLevel-tests.ts +26 -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 +0 -3
- package/src/utils/cyclized.ts +90 -0
- package/src/utils/dimerized.ts +10 -0
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"type": "reaction",
|
|
28
|
-
"code": "
|
|
28
|
+
"code": "4",
|
|
29
29
|
"monomericSubstitution": {
|
|
30
|
-
"firstMonomer": "
|
|
31
|
-
"secondMonomer": "
|
|
32
|
-
"reaction": "[
|
|
30
|
+
"firstMonomer": "azG",
|
|
31
|
+
"secondMonomer": "aG",
|
|
32
|
+
"reaction": "[C:1]N=[N+]=[N-].[C:2]C#C>>[C:1]N1-N=NC=C1[C:2]",
|
|
33
33
|
"name": "GGaz"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
n,seqs
|
|
2
2
|
1,R-F-C(1)-T-G-H-F-Y-G-H-F-Y-G-H-F-Y-P-C(1)-meI
|
|
3
|
-
2,C(1)-T-G-
|
|
3
|
+
2,C(1)-T-G-Aca-F-Y-P-C(1)-meI
|
|
4
4
|
3,R-F-C(1)-T-G-H-F-Y-P-C(1)
|
|
5
5
|
4,C(1)-T-G-H-F-H-P-C(1)
|
|
6
6
|
5,R-F-D(2)-T-G-H-F-Y-P-NH2(2)
|
|
7
|
-
6,R-F-
|
|
7
|
+
6,R-F-azG(4)-T-G-H-F-Y-P-aG(4)-meI
|
|
8
|
+
7,R-F-aG(4)-T-G-H-F-Y-P-azG(4)-meI
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/sequence-translator",
|
|
3
3
|
"friendlyName": "Sequence Translator",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.5",
|
|
5
5
|
"author": {
|
|
6
|
-
"name": "Alexey
|
|
6
|
+
"name": "Alexey Chopovsky",
|
|
7
7
|
"email": "achopovsky@datagrok.ai"
|
|
8
8
|
},
|
|
9
9
|
"description": "SequenceTranslator translates [oligonucleotide](https://en.wikipedia.org/wiki/Oligonucleotide) sequences between [different representations](https://github.com/datagrok-ai/public/tree/master/packages/SequenceTranslator#sequence-representations).",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@datagrok-libraries/bio": "^5.
|
|
25
|
+
"@datagrok-libraries/bio": "^5.45.2",
|
|
26
26
|
"@datagrok-libraries/chem-meta": "^1.2.7",
|
|
27
|
-
"@datagrok-libraries/tutorials": "^1.4.
|
|
28
|
-
"@datagrok-libraries/utils": "^4.3.
|
|
27
|
+
"@datagrok-libraries/tutorials": "^1.4.3",
|
|
28
|
+
"@datagrok-libraries/utils": "^4.3.6",
|
|
29
29
|
"@types/react": "^18.0.15",
|
|
30
30
|
"cash-dom": "^8.1.0",
|
|
31
31
|
"datagrok-api": "^1.21.1",
|
|
@@ -36,32 +36,32 @@
|
|
|
36
36
|
"ts-loader": "^9.3.1",
|
|
37
37
|
"typeahead-standalone": "4.14.1",
|
|
38
38
|
"typescript": "^5.4.2",
|
|
39
|
-
"wu": "
|
|
39
|
+
"wu": "^2.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@datagrok-libraries/helm-web-editor": "^1.1.
|
|
43
|
-
"@datagrok-libraries/js-draw-lite": "^0.0.
|
|
44
|
-
"@datagrok/bio": "^2.
|
|
45
|
-
"@datagrok/helm": "^2.5.
|
|
46
|
-
"@datagrok/chem": "^1.12.
|
|
42
|
+
"@datagrok-libraries/helm-web-editor": "^1.1.12",
|
|
43
|
+
"@datagrok-libraries/js-draw-lite": "^0.0.9",
|
|
44
|
+
"@datagrok/bio": "^2.16.2",
|
|
45
|
+
"@datagrok/helm": "^2.5.4",
|
|
46
|
+
"@datagrok/chem": "^1.12.3",
|
|
47
47
|
"@types/jquery": "^3.5.14",
|
|
48
48
|
"@types/js-yaml": "^4.0.5",
|
|
49
49
|
"@types/lodash": "^4.14.202",
|
|
50
50
|
"@types/node-fetch": "^2.6.2",
|
|
51
51
|
"@types/object-hash": "^3.0.6",
|
|
52
52
|
"@types/react": "^18.0.15",
|
|
53
|
-
"@types/wu": "
|
|
53
|
+
"@types/wu": "^2.1.44",
|
|
54
54
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
55
55
|
"@typescript-eslint/parser": "^7.2.0",
|
|
56
56
|
"css-loader": "^6.7.3",
|
|
57
57
|
"eslint": "^8.57.0",
|
|
58
|
-
"eslint-config-google": "
|
|
58
|
+
"eslint-config-google": "^0.14.0",
|
|
59
59
|
"style-loader": "^3.3.1",
|
|
60
60
|
"ts-loader": "^9.3.1",
|
|
61
61
|
"typescript": "^4.7.4",
|
|
62
62
|
"typescript-eslint": "^7.2.0",
|
|
63
63
|
"webpack": "^5.75.0",
|
|
64
|
-
"webpack-cli": "
|
|
64
|
+
"webpack-cli": "^5.1.4"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"link-api": "npm link datagrok-api",
|
|
@@ -16,8 +16,16 @@ import {MonomerLibWrapper} from './monomer-lib/lib-wrapper';
|
|
|
16
16
|
import {FormatConverter} from '../../translator/model/format-converter';
|
|
17
17
|
import {FormatDetector} from './parsing-validation/format-detector';
|
|
18
18
|
import {highlightInvalidSubsequence} from '../view/components/colored-input/input-painters';
|
|
19
|
+
import {ISeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
19
20
|
|
|
20
21
|
export class OligoToolkitPackage extends DG.Package implements ITranslationHelper {
|
|
22
|
+
private _seqHelper: ISeqHelper;
|
|
23
|
+
public get seqHelper(): ISeqHelper {
|
|
24
|
+
if (!this._seqHelper)
|
|
25
|
+
throw new Error('Package SequenceTranslator .seqHelper is not initialized');
|
|
26
|
+
return this._seqHelper;
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
private _monomerLib?: IMonomerLib;
|
|
22
30
|
get monomerLib(): IMonomerLib {
|
|
23
31
|
if (!this._monomerLib)
|
|
@@ -47,6 +55,10 @@ export class OligoToolkitPackage extends DG.Package implements ITranslationHelpe
|
|
|
47
55
|
|
|
48
56
|
private initPromise?: Promise<void>;
|
|
49
57
|
|
|
58
|
+
completeInit(seqHelper: ISeqHelper): void {
|
|
59
|
+
this._seqHelper = seqHelper;
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
async initLibData(): Promise<void> {
|
|
51
63
|
if (!this.initPromise) {
|
|
52
64
|
this.initPromise = (async () => {
|
|
@@ -17,8 +17,8 @@ export class MoleculeImage {
|
|
|
17
17
|
this.molblock = molblok;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
private _validMolBlock
|
|
21
|
-
get molblock(): string { return this._validMolBlock
|
|
20
|
+
private _validMolBlock!: string;
|
|
21
|
+
get molblock(): string { return this._validMolBlock!; }
|
|
22
22
|
|
|
23
23
|
set molblock(value: string) {
|
|
24
24
|
if (value === '') {
|
|
@@ -33,7 +33,7 @@ export class DataManager {
|
|
|
33
33
|
instance.currentUserName = await instance.fetchCurrentUserName();
|
|
34
34
|
instance.currentUserId = await instance.fetchCurrentUserId();
|
|
35
35
|
|
|
36
|
-
const patternRecords =
|
|
36
|
+
const patternRecords = instance.fetchPatterns();
|
|
37
37
|
await instance.initializePatternMaps(patternRecords);
|
|
38
38
|
|
|
39
39
|
return instance;
|
|
@@ -81,7 +81,7 @@ export class DataManager {
|
|
|
81
81
|
if (hash === null || hash === '')
|
|
82
82
|
return null;
|
|
83
83
|
try {
|
|
84
|
-
const patternConfig =
|
|
84
|
+
const patternConfig = grok.userSettings.getValue(STORAGE_NAME, hash, false) ?? 'null';
|
|
85
85
|
const config = JSON.parse(patternConfig) as PatternConfigRecord;
|
|
86
86
|
return config;
|
|
87
87
|
} catch {
|
|
@@ -181,7 +181,7 @@ export class DataManager {
|
|
|
181
181
|
[D.MODIFY]: timestamp,
|
|
182
182
|
};
|
|
183
183
|
const record = JSON.stringify(recordObj);
|
|
184
|
-
|
|
184
|
+
grok.userSettings.add(STORAGE_NAME, hash, record, false);
|
|
185
185
|
this.currentUserPatternNameToHash.set(patternName, hash);
|
|
186
186
|
|
|
187
187
|
eventBus.selectAuthor(this.getCurrentUserAuthorshipCategory());
|
|
@@ -212,14 +212,14 @@ export class DataManager {
|
|
|
212
212
|
newRecordObj[R.DATE] = {
|
|
213
213
|
[D.MODIFY]: timestamp,
|
|
214
214
|
};
|
|
215
|
-
const oldPattern =
|
|
215
|
+
const oldPattern = grok.userSettings.getValue(STORAGE_NAME, oldHash, false) ?? 'null';
|
|
216
216
|
const oldPatternsRecord = JSON.parse(oldPattern) as PatternConfigRecord;
|
|
217
217
|
if (oldPatternsRecord[R.DATE] !== undefined && oldPatternsRecord[R.DATE][D.CREATE] != undefined)
|
|
218
218
|
newRecordObj[R.DATE][D.CREATE] = oldPatternsRecord[R.DATE][D.CREATE];
|
|
219
219
|
|
|
220
220
|
const newRecord = JSON.stringify(newRecordObj);
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
grok.userSettings.add(STORAGE_NAME, newHash, newRecord, false);
|
|
222
|
+
grok.userSettings.delete(STORAGE_NAME, oldHash, false);
|
|
223
223
|
|
|
224
224
|
this.currentUserPatternNameToHash.set(patternName, newHash);
|
|
225
225
|
eventBus.requestPatternLoad(newHash);
|
|
@@ -237,7 +237,7 @@ export class DataManager {
|
|
|
237
237
|
}
|
|
238
238
|
if (hash === undefined)
|
|
239
239
|
throw new Error(`Pattern with name ${patternName} not found`);
|
|
240
|
-
|
|
240
|
+
grok.userSettings.delete(STORAGE_NAME, hash, false);
|
|
241
241
|
this.currentUserPatternNameToHash.delete(patternName);
|
|
242
242
|
eventBus.updatePatternList();
|
|
243
243
|
|
|
@@ -264,8 +264,8 @@ export class DataManager {
|
|
|
264
264
|
return (await grok.dapi.users.current()).id;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
private
|
|
268
|
-
const patternsRecord =
|
|
267
|
+
private fetchPatterns(): RawPatternRecords {
|
|
268
|
+
const patternsRecord = (grok.userSettings.get(STORAGE_NAME, false) ?? {}) as RawPatternRecords;
|
|
269
269
|
return patternsRecord;
|
|
270
270
|
}
|
|
271
271
|
|
|
@@ -3,9 +3,10 @@ import * as DG from 'datagrok-api/dg';
|
|
|
3
3
|
import * as grok from 'datagrok-api/grok';
|
|
4
4
|
import * as ui from 'datagrok-api/ui';
|
|
5
5
|
|
|
6
|
+
import $ from 'cash-dom';
|
|
6
7
|
import {Subject, BehaviorSubject, Observable} from 'rxjs';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import {ISeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
9
10
|
import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
10
11
|
|
|
11
12
|
import {DEFAULT_FORMATS} from '../../common/model/const';
|
|
@@ -22,7 +23,6 @@ import {ITranslationHelper} from '../../../types';
|
|
|
22
23
|
|
|
23
24
|
import {NUCLEOTIDES_FORMAT, SEQUENCE_COPIED_MSG, SEQ_TOOLTIP_MSG} from './const';
|
|
24
25
|
import './style.css';
|
|
25
|
-
import $ from 'cash-dom';
|
|
26
26
|
import {_package} from '../../../package';
|
|
27
27
|
|
|
28
28
|
const enum REQUIRED_COLUMN_LABEL {
|
|
@@ -34,9 +34,10 @@ const REQUIRED_COLUMN_LABELS = [REQUIRED_COLUMN_LABEL.SEQUENCE];
|
|
|
34
34
|
class TranslatorAppLayout {
|
|
35
35
|
private eventBus: EventBus;
|
|
36
36
|
private inputFormats = Object.keys(_package.jsonData.codesToHelmDict).concat(DEFAULT_FORMATS.HELM);
|
|
37
|
+
private readonly seqHelper: ISeqHelper = _package.seqHelper;
|
|
37
38
|
|
|
38
39
|
constructor(
|
|
39
|
-
private readonly th: ITranslationHelper
|
|
40
|
+
private readonly th: ITranslationHelper,
|
|
40
41
|
) {
|
|
41
42
|
this.moleculeImgDiv = ui.div([]);
|
|
42
43
|
this.moleculeImgDiv.className = 'mol-host';
|
|
@@ -171,9 +172,9 @@ class TranslatorAppLayout {
|
|
|
171
172
|
translatedColumn.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
172
173
|
const units = outputFormat == NUCLEOTIDES_FORMAT ? NOTATION.FASTA : NOTATION.HELM;
|
|
173
174
|
translatedColumn.meta.units = units;
|
|
174
|
-
const seqHandler =
|
|
175
|
-
const setUnits = outputFormat == NUCLEOTIDES_FORMAT ?
|
|
176
|
-
|
|
175
|
+
const seqHandler = this.seqHelper.getSeqHandler(translatedColumn as DG.Column<string>);
|
|
176
|
+
const setUnits = outputFormat == NUCLEOTIDES_FORMAT ? this.seqHelper.setUnitsToFastaColumn :
|
|
177
|
+
this.seqHelper.setUnitsToHelmColumn;
|
|
177
178
|
setUnits(seqHandler);
|
|
178
179
|
}
|
|
179
180
|
|
|
@@ -462,8 +463,7 @@ class ColumnInputsManager {
|
|
|
462
463
|
const input = ui.input.choice(`${columnLabel}`, {
|
|
463
464
|
value: selectedColumnName, items: columnNames,
|
|
464
465
|
onValueChanged: (value) => this.selectColumnIfTableNotNull(selectedTable, value, columnLabel)
|
|
465
|
-
}
|
|
466
|
-
);
|
|
466
|
+
});
|
|
467
467
|
|
|
468
468
|
return input;
|
|
469
469
|
}
|
package/src/package-test.ts
CHANGED
|
@@ -8,10 +8,12 @@ import './tests/formats-to-helm';
|
|
|
8
8
|
import './tests/helm-to-nucleotides';
|
|
9
9
|
import './tests/formats-support';
|
|
10
10
|
import './tests/files-tests';
|
|
11
|
+
import './tests/polytool-detectors-custom-notation-test';
|
|
11
12
|
import './tests/polytool-convert-tests';
|
|
12
13
|
import './tests/polytool-unrule-tests';
|
|
13
14
|
import './tests/polytool-enumerate-tests';
|
|
14
15
|
import './tests/polytool-enumerate-breadth-tests';
|
|
16
|
+
import './tests/polytool-chain-parse-notation-tests';
|
|
15
17
|
import './tests/toAtomicLevel-tests';
|
|
16
18
|
|
|
17
19
|
import {OligoToolkitTestPackage} from './tests/utils';
|
package/src/package.ts
CHANGED
|
@@ -2,16 +2,15 @@ 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 {
|
|
5
|
+
import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule/consts';
|
|
6
|
+
import {SeqTemps} from '@datagrok-libraries/bio/src/utils/macromolecule/seq-handler';
|
|
7
|
+
|
|
6
8
|
import {OligoToolkitPackage} from './apps/common/model/oligo-toolkit-package';
|
|
7
|
-
import {FormatDetector} from './apps/common/model/parsing-validation/format-detector';
|
|
8
|
-
import {SequenceValidator} from './apps/common/model/parsing-validation/sequence-validator';
|
|
9
9
|
import {APP_NAME} from './apps/common/view/const';
|
|
10
10
|
import {getSpecifiedAppUI} from './apps/common/view/utils';
|
|
11
11
|
import {CombinedAppUI} from './apps/common/view/combined-app-ui';
|
|
12
12
|
import {linkStrandsV3000} from './apps/structure/model/mol-transformations';
|
|
13
13
|
import {SequenceToMolfileConverter} from './apps/structure/model/sequence-to-molfile';
|
|
14
|
-
import {FormatConverter} from './apps/translator/model/format-converter';
|
|
15
14
|
import {demoOligoPatternUI, demoOligoStructureUI, demoOligoTranslatorUI} from './demo/demo-st-ui';
|
|
16
15
|
import {getExternalAppViewFactories} from './plugins/mermade';
|
|
17
16
|
import {defaultErrorHandler} from './utils/err-info';
|
|
@@ -26,9 +25,27 @@ import {ITranslationHelper} from './types';
|
|
|
26
25
|
import {addContextMenuUI} from './utils/context-menu';
|
|
27
26
|
import {PolyToolConvertFuncEditor} from './polytool/pt-convert-editor';
|
|
28
27
|
import {polyToolUnruleUI} from './polytool/pt-unrule';
|
|
28
|
+
import {CyclizedNotationProvider} from './utils/cyclized';
|
|
29
|
+
import {getSeqHelper} from '@datagrok-libraries/bio/src/utils/seq-helper';
|
|
29
30
|
|
|
30
31
|
export const _package: OligoToolkitPackage = new OligoToolkitPackage({debug: true}/**/);
|
|
31
32
|
|
|
33
|
+
let initSequenceTranslatorPromise: Promise<void> | null = null;
|
|
34
|
+
|
|
35
|
+
//tags: init
|
|
36
|
+
export async function init(): Promise<void> {
|
|
37
|
+
if (initSequenceTranslatorPromise === null)
|
|
38
|
+
initSequenceTranslatorPromise = initSequenceTranslatorInt();
|
|
39
|
+
return initSequenceTranslatorPromise;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function initSequenceTranslatorInt(): Promise<void> {
|
|
43
|
+
const [seqHelper] = await Promise.all([
|
|
44
|
+
getSeqHelper(),
|
|
45
|
+
]);
|
|
46
|
+
_package.completeInit(seqHelper);
|
|
47
|
+
}
|
|
48
|
+
|
|
32
49
|
//name: Oligo Toolkit
|
|
33
50
|
//meta.icon: img/icons/toolkit.png
|
|
34
51
|
//meta.browsePath: Oligo
|
|
@@ -277,3 +294,12 @@ export async function ptEnumeratorHelmApp(): Promise<void> {
|
|
|
277
294
|
export async function ptEnumeratorChemApp(): Promise<void> {
|
|
278
295
|
polyToolEnumerateChemUI();
|
|
279
296
|
}
|
|
297
|
+
|
|
298
|
+
//name: applyNotationProviderForHarmonizedSequence
|
|
299
|
+
//input: column col
|
|
300
|
+
//input: string separator
|
|
301
|
+
export function applyNotationProviderForCyclized(col: DG.Column<string>, separator: string) {
|
|
302
|
+
col.meta.units = NOTATION.CUSTOM;
|
|
303
|
+
col.tags['pt-role'] = 'template';
|
|
304
|
+
col.temp[SeqTemps.notationProvider] = new CyclizedNotationProvider(separator, _package.seqHelper);
|
|
305
|
+
}
|