@datagrok/sequence-translator 1.2.6 → 1.2.9
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/.eslintrc.json +5 -5
- package/CHANGELOG.md +12 -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 +2 -1
- package/dist/package.js.LICENSE.txt +8 -0
- package/dist/package.js.map +1 -1
- package/files/pattern-app-data.json +80 -0
- package/package.json +21 -14
- package/src/{model → apps/common/model}/const.ts +1 -1
- package/src/{model/data-loading-utils → apps/common/model/data-loader}/const.ts +7 -2
- package/src/apps/common/model/data-loader/json-loader.ts +48 -0
- package/src/{model/data-loading-utils → apps/common/model/data-loader}/types.ts +13 -6
- package/src/{model → apps/common/model}/monomer-lib/lib-wrapper.ts +9 -12
- package/src/apps/common/model/oligo-toolkit-package.ts +30 -0
- package/src/{model → apps/common/model}/parsing-validation/format-detector.ts +5 -5
- package/src/{model → apps/common/model}/parsing-validation/format-handler.ts +18 -19
- package/src/{model → apps/common/model}/parsing-validation/sequence-validator.ts +1 -1
- package/src/apps/common/view/app-ui-base.ts +28 -0
- package/src/apps/common/view/combined-app-ui.ts +66 -0
- package/src/{view/utils → apps/common/view/components}/colored-input/colored-text-input.ts +1 -1
- package/src/{view/utils → apps/common/view/components}/draw-molecule.ts +1 -1
- package/src/{view/utils → apps/common/view/components}/molecule-img.ts +3 -3
- package/src/{view/const/ui.ts → apps/common/view/const.ts} +4 -4
- package/src/apps/common/view/isolated-app-ui.ts +43 -0
- package/src/{view/monomer-lib-viewer/viewer.ts → apps/common/view/monomer-lib-viewer.ts} +2 -2
- package/src/apps/common/view/utils.ts +29 -0
- package/src/apps/pattern/model/const.ts +121 -0
- package/src/apps/pattern/model/data-manager.ts +297 -0
- package/src/apps/pattern/model/event-bus.ts +470 -0
- package/src/apps/pattern/model/router.ts +46 -0
- package/src/apps/pattern/model/subscription-manager.ts +21 -0
- package/src/apps/pattern/model/translator.ts +68 -0
- package/src/apps/pattern/model/types.ts +52 -0
- package/src/apps/pattern/model/utils.ts +110 -0
- package/src/apps/pattern/view/components/bulk-convert/column-input.ts +69 -0
- package/src/apps/pattern/view/components/bulk-convert/table-controls.ts +37 -0
- package/src/apps/pattern/view/components/bulk-convert/table-input.ts +95 -0
- package/src/apps/pattern/view/components/edit-block-controls.ts +196 -0
- package/src/apps/pattern/view/components/left-section.ts +44 -0
- package/src/apps/pattern/view/components/load-block-controls.ts +198 -0
- package/src/apps/pattern/view/components/numeric-label-visibility-controls.ts +69 -0
- package/src/apps/pattern/view/components/right-section.ts +148 -0
- package/src/apps/pattern/view/components/strand-editor/dialog.ts +79 -0
- package/src/apps/pattern/view/components/strand-editor/header-controls.ts +105 -0
- package/src/apps/pattern/view/components/strand-editor/strand-controls.ts +159 -0
- package/src/apps/pattern/view/components/terminal-modification-editor.ts +127 -0
- package/src/apps/pattern/view/components/translation-examples-block.ts +139 -0
- package/src/{view/style/pattern-app.css → apps/pattern/view/style.css} +4 -0
- package/src/apps/pattern/view/svg-utils/const.ts +63 -0
- package/src/apps/pattern/view/svg-utils/dimensions-calculator.ts +498 -0
- package/src/apps/pattern/view/svg-utils/svg-display-manager.ts +45 -0
- package/src/apps/pattern/view/svg-utils/svg-element-factory.ts +82 -0
- package/src/apps/pattern/view/svg-utils/svg-renderer.ts +396 -0
- package/src/apps/pattern/view/svg-utils/utils.ts +37 -0
- package/src/apps/pattern/view/types.ts +14 -0
- package/src/apps/pattern/view/ui.ts +61 -0
- package/src/{model/structure-app → apps/structure/model}/mol-transformations.ts +3 -3
- package/src/{model/structure-app → apps/structure/model}/monomer-code-parser.ts +9 -10
- package/src/{model/structure-app → apps/structure/model}/oligo-structure.ts +4 -4
- package/src/{model/structure-app → apps/structure/model}/sequence-to-molfile.ts +2 -2
- package/src/{view/apps/oligo-structure.ts → apps/structure/view/ui.ts} +31 -17
- package/src/{model/translator-app → apps/translator/model}/conversion-utils.ts +25 -7
- package/src/{model/translator-app → apps/translator/model}/format-converter.ts +7 -12
- package/src/{view/const/oligo-translator.ts → apps/translator/view/const.ts} +2 -0
- package/src/apps/translator/view/ui.ts +547 -0
- package/src/demo/demo-st-ui.ts +12 -32
- package/src/package.ts +76 -56
- package/src/plugins/mermade.ts +9 -9
- package/src/polytool/const.ts +40 -0
- package/src/polytool/csv-to-json-monomer-lib-converter.ts +40 -0
- package/src/polytool/cyclized.ts +56 -0
- package/src/polytool/monomer-lib-handler.ts +115 -0
- package/src/polytool/transformation.ts +326 -0
- package/src/polytool/ui.ts +59 -0
- package/src/polytool/utils.ts +20 -0
- package/src/tests/const.ts +5 -5
- package/src/tests/formats-support.ts +6 -6
- package/src/tests/formats-to-helm.ts +5 -5
- package/src/tests/helm-to-nucleotides.ts +5 -5
- package/tsconfig.json +4 -10
- package/webpack.config.js +3 -0
- package/files/axolabs-style.json +0 -97
- package/src/model/data-loading-utils/json-loader.ts +0 -38
- package/src/model/pattern-app/const.ts +0 -33
- package/src/model/pattern-app/draw-svg.ts +0 -193
- package/src/model/pattern-app/helpers.ts +0 -96
- package/src/model/pattern-app/oligo-pattern.ts +0 -111
- package/src/view/app-ui.ts +0 -193
- package/src/view/apps/oligo-pattern.ts +0 -759
- package/src/view/apps/oligo-translator.ts +0 -184
- /package/src/{model → apps/common/model}/helpers.ts +0 -0
- /package/src/{model → apps/common/model}/monomer-lib/const.ts +0 -0
- /package/src/{view/utils → apps/common/view/components}/app-info-dialog.ts +0 -0
- /package/src/{view/utils → apps/common/view/components}/colored-input/input-painters.ts +0 -0
- /package/src/{view/style/colored-text-input.css → apps/common/view/components/colored-input/style.css} +0 -0
- /package/src/{view/utils → apps/common/view/components}/router.ts +0 -0
- /package/src/{model/structure-app → apps/structure/model}/const.ts +0 -0
- /package/src/{view/style/structure-app.css → apps/structure/view/style.css} +0 -0
- /package/src/{model/translator-app → apps/translator/model}/const.ts +0 -0
- /package/src/{view/style/translator-app.css → apps/translator/view/style.css} +0 -0
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/* Do not change these import lines to match external modules in webpack configuration */
|
|
2
|
-
import * as grok from 'datagrok-api/grok';
|
|
3
|
-
import * as ui from 'datagrok-api/ui';
|
|
4
|
-
import * as DG from 'datagrok-api/dg';
|
|
5
|
-
|
|
6
|
-
import * as rxjs from 'rxjs';
|
|
7
|
-
import '../style/translator-app.css';
|
|
8
|
-
|
|
9
|
-
import {highlightInvalidSubsequence} from '../utils/colored-input/input-painters';
|
|
10
|
-
import {ColoredTextInput} from '../utils/colored-input/colored-text-input';
|
|
11
|
-
import {SequenceToMolfileConverter} from '../../model/structure-app/sequence-to-molfile';
|
|
12
|
-
import {getTranslatedSequences} from '../../model/translator-app/conversion-utils';
|
|
13
|
-
import {MoleculeImage} from '../utils/molecule-img';
|
|
14
|
-
import {download} from '../../model/helpers';
|
|
15
|
-
import {SEQUENCE_COPIED_MSG, SEQ_TOOLTIP_MSG} from '../const/oligo-translator';
|
|
16
|
-
import {DEFAULT_AXOLABS_INPUT} from '../const/ui';
|
|
17
|
-
import {FormatDetector} from '../../model/parsing-validation/format-detector';
|
|
18
|
-
import {SequenceValidator} from '../../model/parsing-validation/sequence-validator';
|
|
19
|
-
import {FormatConverter} from '../../model/translator-app/format-converter';
|
|
20
|
-
import {codesToHelmDictionary} from '../../model/data-loading-utils/json-loader';
|
|
21
|
-
import {DEFAULT_FORMATS} from '../../model/const';
|
|
22
|
-
|
|
23
|
-
export class TranslatorLayoutHandler {
|
|
24
|
-
constructor() {
|
|
25
|
-
const INPUT_FORMATS = Object.keys(codesToHelmDictionary).concat(DEFAULT_FORMATS.HELM);
|
|
26
|
-
this.moleculeImgDiv = ui.div([]);
|
|
27
|
-
this.moleculeImgDiv.className = 'mol-host';
|
|
28
|
-
this.moleculeImgDiv.style.border = '1px solid var(--grey-2)';
|
|
29
|
-
this.moleculeImgDiv.style.borderRadius = '1px';
|
|
30
|
-
this.moleculeImgDiv.style.marginTop = '12px';
|
|
31
|
-
|
|
32
|
-
this.outputTableDiv = ui.div([]);
|
|
33
|
-
this.formatChoiceInput = ui.choiceInput('', DEFAULT_FORMATS.HELM, INPUT_FORMATS, async () => {
|
|
34
|
-
this.format = this.formatChoiceInput.value;
|
|
35
|
-
this.updateTable();
|
|
36
|
-
await this.updateMolImg();
|
|
37
|
-
});
|
|
38
|
-
this.sequenceInputBase = ui.textInput('', DEFAULT_AXOLABS_INPUT,
|
|
39
|
-
() => { this.onInput.next(); });
|
|
40
|
-
|
|
41
|
-
this.init();
|
|
42
|
-
|
|
43
|
-
DG.debounce<string>(this.onInput, 300).subscribe(async () => {
|
|
44
|
-
this.init();
|
|
45
|
-
this.formatChoiceInput.value = this.format;
|
|
46
|
-
this.updateTable();
|
|
47
|
-
await this.updateMolImg();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// todo: reduce # of state vars by further refactoring legacy code
|
|
52
|
-
private onInput = new rxjs.Subject<string>();
|
|
53
|
-
private moleculeImgDiv: HTMLDivElement;
|
|
54
|
-
private outputTableDiv: HTMLDivElement;
|
|
55
|
-
private formatChoiceInput: DG.InputBase;
|
|
56
|
-
private sequenceInputBase: DG.InputBase;
|
|
57
|
-
private molfile: string;
|
|
58
|
-
public sequence: string;
|
|
59
|
-
private format: string | null;
|
|
60
|
-
|
|
61
|
-
async getHtmlElement(): Promise<HTMLDivElement> {
|
|
62
|
-
const sequenceColoredInput = new ColoredTextInput(this.sequenceInputBase, highlightInvalidSubsequence);
|
|
63
|
-
|
|
64
|
-
const downloadMolfileButton = ui.button(
|
|
65
|
-
'Get SDF',
|
|
66
|
-
() => { this.saveMolfile(); },
|
|
67
|
-
'Save structure as SDF');
|
|
68
|
-
|
|
69
|
-
const copySmilesButton = ui.button(
|
|
70
|
-
'Copy SMILES',
|
|
71
|
-
() => { this.copySmiles(); },
|
|
72
|
-
'Copy SMILES for the sequence');
|
|
73
|
-
|
|
74
|
-
const formatChoiceInput = ui.div([this.formatChoiceInput]);
|
|
75
|
-
|
|
76
|
-
const clearButton = ui.button(
|
|
77
|
-
ui.icons.delete(() => { sequenceColoredInput.inputBase.value = '' }),
|
|
78
|
-
() => {}
|
|
79
|
-
);
|
|
80
|
-
ui.tooltip.bind(clearButton, 'Clear input');
|
|
81
|
-
|
|
82
|
-
const inputTableRow = {
|
|
83
|
-
format: formatChoiceInput,
|
|
84
|
-
textInput: sequenceColoredInput.root,
|
|
85
|
-
clearBtn: clearButton
|
|
86
|
-
};
|
|
87
|
-
const upperBlock = ui.table(
|
|
88
|
-
[inputTableRow], (item) => [item.format, item.textInput, item.clearBtn]
|
|
89
|
-
);
|
|
90
|
-
upperBlock.classList.add('st-translator-input-table');
|
|
91
|
-
|
|
92
|
-
const outputTable = ui.block([
|
|
93
|
-
this.outputTableDiv,
|
|
94
|
-
downloadMolfileButton,
|
|
95
|
-
copySmilesButton,
|
|
96
|
-
]);
|
|
97
|
-
|
|
98
|
-
const mainTabBody = ui.box(
|
|
99
|
-
ui.panel([
|
|
100
|
-
upperBlock,
|
|
101
|
-
outputTable,
|
|
102
|
-
ui.block([ui.box(this.moleculeImgDiv)])
|
|
103
|
-
]),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
this.formatChoiceInput.value = this.format;
|
|
107
|
-
this.updateTable();
|
|
108
|
-
await this.updateMolImg();
|
|
109
|
-
return mainTabBody;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
private saveMolfile(): void {
|
|
113
|
-
const result = (new SequenceToMolfileConverter(this.sequence, false,
|
|
114
|
-
this.formatChoiceInput.value!)).convert() + '\n$$$$';
|
|
115
|
-
download(this.sequence + '.sdf', encodeURIComponent(result));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private copySmiles(): void {
|
|
119
|
-
const smiles = DG.chem.convert(this.molfile, DG.chem.Notation.MolBlock, DG.chem.Notation.Smiles);
|
|
120
|
-
navigator.clipboard.writeText(smiles).then(
|
|
121
|
-
() => grok.shell.info(SEQUENCE_COPIED_MSG)
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private updateTable(): void {
|
|
126
|
-
this.outputTableDiv.innerHTML = '';
|
|
127
|
-
// todo: does not detect correctly (U-A)(U-A)
|
|
128
|
-
const indexOfInvalidChar = (!this.format) ? 0 : (new SequenceValidator(this.sequence)).getInvalidCodeIndex(this.format!);
|
|
129
|
-
const translatedSequences = getTranslatedSequences(this.sequence, indexOfInvalidChar, this.format!);
|
|
130
|
-
const tableRows = [];
|
|
131
|
-
|
|
132
|
-
for (const key of Object.keys(translatedSequences)) {
|
|
133
|
-
const sequence = ('indexOfFirstInvalidChar' in translatedSequences) ?
|
|
134
|
-
ui.divH([]) :
|
|
135
|
-
ui.link(
|
|
136
|
-
translatedSequences[key],
|
|
137
|
-
() => navigator.clipboard.writeText(translatedSequences[key])
|
|
138
|
-
.then(() => grok.shell.info(SEQUENCE_COPIED_MSG)),
|
|
139
|
-
SEQ_TOOLTIP_MSG, ''
|
|
140
|
-
);
|
|
141
|
-
tableRows.push({
|
|
142
|
-
format: key,
|
|
143
|
-
sequence: sequence,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
const outputTable = ui.table(tableRows, (item) => [item.format, item.sequence], ['FORMAT', 'SEQUENCE']);
|
|
147
|
-
|
|
148
|
-
this.outputTableDiv.append(outputTable);
|
|
149
|
-
this.outputTableDiv.classList.add('st-translator-output-table');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
private async updateMolImg(): Promise<void> {
|
|
153
|
-
const canvasWidth = 500;
|
|
154
|
-
const canvasHeight = 170;
|
|
155
|
-
const molImgObj = new MoleculeImage(this.molfile);
|
|
156
|
-
await molImgObj.drawMolecule(this.moleculeImgDiv, canvasWidth, canvasHeight);
|
|
157
|
-
// should the canvas be returned from the above function?
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// todo: sort mehtods
|
|
161
|
-
private init(): void {
|
|
162
|
-
this.sequence = this.getFormattedSequence();
|
|
163
|
-
|
|
164
|
-
this.format = (new FormatDetector(this.sequence)).getFormat();
|
|
165
|
-
|
|
166
|
-
// warning: getMolfile relies on 'this.format', so the order is important
|
|
167
|
-
this.molfile = this.getMolfile();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
private getFormattedSequence(): string {
|
|
171
|
-
return this.sequenceInputBase.value.replace(/\s/g, '');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
private getMolfile(): string {
|
|
175
|
-
if (!this.format)
|
|
176
|
-
return '';
|
|
177
|
-
if (this.format === DEFAULT_FORMATS.HELM) {
|
|
178
|
-
const axolabs = (new FormatConverter(this.sequence, this.format).convertTo(DEFAULT_FORMATS.AXOLABS));
|
|
179
|
-
return (new SequenceToMolfileConverter(axolabs, false, DEFAULT_FORMATS.AXOLABS).convert());
|
|
180
|
-
}
|
|
181
|
-
const molfile = (new SequenceToMolfileConverter(this.sequence, false, this.format)).convert();
|
|
182
|
-
return molfile;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|