@datagrok/sequence-translator 1.0.17 → 1.1.4

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.
Files changed (100) hide show
  1. package/.eslintrc.json +4 -3
  2. package/CHANGELOG.md +36 -0
  3. package/detectors.js +8 -0
  4. package/dist/package-test.js +2 -73079
  5. package/dist/package-test.js.map +1 -0
  6. package/dist/package.js +2 -72284
  7. package/dist/package.js.map +1 -0
  8. package/files/axolabs-style.json +97 -0
  9. package/files/codes-to-symbols.json +67 -0
  10. package/files/formats-to-helm.json +63 -0
  11. package/files/linkers.json +22 -0
  12. package/files/monomer-lib.json +1142 -0
  13. package/link-bio +7 -0
  14. package/package.json +30 -31
  15. package/scripts/build-monomer-lib.py +391 -122
  16. package/src/demo/demo-st-ui.ts +71 -0
  17. package/src/demo/handle-error.ts +12 -0
  18. package/src/model/axolabs/axolabs-tab.ts +111 -0
  19. package/src/model/axolabs/const.ts +33 -0
  20. package/src/{axolabs-tab → model/axolabs}/draw-svg.ts +1 -1
  21. package/src/{axolabs-tab → model/axolabs}/helpers.ts +7 -5
  22. package/src/model/const.ts +18 -0
  23. package/src/model/data-loading-utils/const.ts +8 -0
  24. package/src/model/data-loading-utils/json-loader.ts +38 -0
  25. package/src/model/data-loading-utils/types.ts +30 -0
  26. package/src/model/format-translation/const.ts +8 -0
  27. package/src/model/format-translation/conversion-utils.ts +49 -0
  28. package/src/model/format-translation/format-converter.ts +109 -0
  29. package/src/model/helpers.ts +12 -0
  30. package/src/model/monomer-lib/const.ts +3 -0
  31. package/src/model/monomer-lib/lib-wrapper.ts +119 -0
  32. package/src/model/parsing-validation/format-detector.ts +57 -0
  33. package/src/model/parsing-validation/sequence-validator.ts +52 -0
  34. package/src/model/sequence-to-structure-utils/const.ts +1 -0
  35. package/src/{utils/structures-works → model/sequence-to-structure-utils}/mol-transformations.ts +33 -41
  36. package/src/model/sequence-to-structure-utils/monomer-code-parser.ts +92 -0
  37. package/src/model/sequence-to-structure-utils/sdf-tab.ts +97 -0
  38. package/src/model/sequence-to-structure-utils/sequence-to-molfile.ts +409 -0
  39. package/src/package-test.ts +3 -1
  40. package/src/package.ts +113 -91
  41. package/src/tests/const.ts +24 -0
  42. package/src/tests/formats-support.ts +40 -0
  43. package/src/tests/formats-to-helm.ts +53 -0
  44. package/src/tests/helm-to-nucleotides.ts +28 -0
  45. package/src/view/const/main-tab.ts +3 -0
  46. package/src/view/const/view.ts +10 -0
  47. package/src/view/css/axolabs-tab.css +1 -0
  48. package/src/view/css/colored-text-input.css +27 -0
  49. package/src/view/css/main-tab.css +46 -0
  50. package/src/view/css/sdf-tab.css +39 -0
  51. package/src/view/monomer-lib-viewer/viewer.ts +22 -0
  52. package/src/view/tabs/axolabs.ts +719 -0
  53. package/src/view/tabs/main.ts +174 -0
  54. package/src/view/tabs/sdf.ts +193 -0
  55. package/src/view/utils/app-info-dialog.ts +18 -0
  56. package/src/view/utils/colored-input/colored-text-input.ts +56 -0
  57. package/src/view/utils/colored-input/input-painters.ts +44 -0
  58. package/src/view/utils/draw-molecule.ts +86 -0
  59. package/src/view/utils/molecule-img.ts +106 -0
  60. package/src/view/view.ts +127 -0
  61. package/tsconfig.json +12 -18
  62. package/webpack.config.js +17 -4
  63. package/README.md +0 -84
  64. package/css/style.css +0 -18
  65. package/img/Sequence Translator Axolabs.png +0 -0
  66. package/jest.config.js +0 -33
  67. package/setup-unlink-clean.cmd +0 -14
  68. package/setup-unlink-clean.sh +0 -21
  69. package/setup.cmd +0 -14
  70. package/setup.sh +0 -37
  71. package/src/__jest__/remote.test.ts +0 -77
  72. package/src/__jest__/test-node.ts +0 -97
  73. package/src/apps/oligo-sd-file-app.ts +0 -58
  74. package/src/autostart/calculations.ts +0 -40
  75. package/src/autostart/constants.ts +0 -37
  76. package/src/autostart/registration.ts +0 -306
  77. package/src/axolabs-tab/axolabs-tab.ts +0 -873
  78. package/src/axolabs-tab/define-pattern.ts +0 -874
  79. package/src/hardcode-to-be-eliminated/ICDs.ts +0 -3
  80. package/src/hardcode-to-be-eliminated/IDPs.ts +0 -3
  81. package/src/hardcode-to-be-eliminated/const.ts +0 -5
  82. package/src/hardcode-to-be-eliminated/constants.ts +0 -101
  83. package/src/hardcode-to-be-eliminated/converters.ts +0 -323
  84. package/src/hardcode-to-be-eliminated/map.ts +0 -720
  85. package/src/hardcode-to-be-eliminated/salts.ts +0 -2
  86. package/src/hardcode-to-be-eliminated/sources.ts +0 -3
  87. package/src/hardcode-to-be-eliminated/users.ts +0 -3
  88. package/src/main-tab/main-tab.ts +0 -210
  89. package/src/sdf-tab/sdf-tab.ts +0 -163
  90. package/src/sdf-tab/sequence-codes-tools.ts +0 -347
  91. package/src/tests/smiles-tests.ts +0 -458
  92. package/src/utils/const.ts +0 -0
  93. package/src/utils/helpers.ts +0 -28
  94. package/src/utils/parse.ts +0 -27
  95. package/src/utils/sdf-add-columns.ts +0 -118
  96. package/src/utils/sdf-save-table.ts +0 -56
  97. package/src/utils/structures-works/draw-molecule.ts +0 -84
  98. package/src/utils/structures-works/from-monomers.ts +0 -266
  99. package/test-SequenceTranslator-6288c2fbe346-695b7b55.html +0 -259
  100. package/vendors/openchemlib-full.js +0 -293
@@ -1,347 +0,0 @@
1
- import {
2
- map, SYNTHESIZERS, TECHNOLOGIES, MODIFICATIONS, DELIMITER, gcrsCodesWithoutSmiles, NUCLEOTIDES
3
- } from '../hardcode-to-be-eliminated/map';
4
- import {sortByStringLengthInDescendingOrder} from '../utils/helpers';
5
- import {
6
- asoGapmersNucleotidesToBioSpring, asoGapmersNucleotidesToGcrs,
7
- asoGapmersBioSpringToNucleotides, asoGapmersBioSpringToGcrs, gcrsToMermade12, siRnaNucleotideToBioSpringSenseStrand,
8
- siRnaNucleotideToAxolabsSenseStrand, siRnaNucleotidesToGcrs, siRnaBioSpringToNucleotides,
9
- siRnaBioSpringToAxolabs, siRnaBioSpringToGcrs, siRnaAxolabsToNucleotides,
10
- siRnaAxolabsToBioSpring, siRnaAxolabsToGcrs, siRnaGcrsToNucleotides,
11
- siRnaGcrsToBioSpring, siRnaGcrsToAxolabs, gcrsToNucleotides, gcrsToLcms
12
- } from '../hardcode-to-be-eliminated/converters';
13
-
14
- const noTranslationTableAvailable = 'No translation table available';
15
- export const undefinedInputSequence = 'Type of input sequence is undefined';
16
-
17
- export function getFormat(sequence: string): string | null {
18
- const possibleSynthesizers = getListOfPossibleSynthesizersByFirstMatchedCode(sequence);
19
-
20
- if (possibleSynthesizers.length == 0)
21
- return null;
22
-
23
- let outputIndex = 0;
24
-
25
- const firstUniqueCharacters = ['r', 'd'];
26
-
27
- possibleSynthesizers.forEach((synthesizer) => {
28
- const codes = getAllCodesOfSynthesizer(synthesizer);
29
- while (outputIndex < sequence.length) {
30
- const matchedCode = codes.find((c) => c == sequence.slice(outputIndex, outputIndex + c.length));
31
-
32
- if (matchedCode == null)
33
- break;
34
-
35
- if ( // for mistake pattern 'rAA'
36
- outputIndex > 1 &&
37
- NUCLEOTIDES.includes(sequence[outputIndex]) &&
38
- firstUniqueCharacters.includes(sequence[outputIndex - 2])
39
- ) break;
40
-
41
- if ( // for mistake pattern 'ArA'
42
- firstUniqueCharacters.includes(sequence[outputIndex + 1]) &&
43
- NUCLEOTIDES.includes(sequence[outputIndex])
44
- ) {
45
- outputIndex++;
46
- break;
47
- }
48
-
49
- outputIndex += matchedCode.length;
50
- }
51
- });
52
-
53
- const indexOfFirstNotValidChar = (outputIndex == sequence.length) ? -1 : outputIndex;
54
- if (indexOfFirstNotValidChar != -1)
55
- return possibleSynthesizers[0];
56
-
57
- const possibleTechnologies = getListOfPossibleTechnologiesByFirstMatchedCode(sequence, possibleSynthesizers[0]);
58
-
59
- if (possibleTechnologies.length == 0)
60
- return null;
61
-
62
- outputIndex = 0;
63
-
64
- possibleTechnologies.forEach((technology: string) => {
65
- const codes = Object.keys(map[possibleSynthesizers[0]][technology]);
66
- while (outputIndex < sequence.length) {
67
- const matchedCode = codes.find((c) => c == sequence.slice(outputIndex, outputIndex + c.length));
68
-
69
- if (matchedCode == null)
70
- break;
71
-
72
- if ( // for mistake pattern 'rAA'
73
- outputIndex > 1 &&
74
- NUCLEOTIDES.includes(sequence[outputIndex]) &&
75
- firstUniqueCharacters.includes(sequence[outputIndex - 2])
76
- ) break;
77
-
78
- if ( // for mistake pattern 'ArA'
79
- firstUniqueCharacters.includes(sequence[outputIndex + 1]) &&
80
- NUCLEOTIDES.includes(sequence[outputIndex])
81
- ) {
82
- outputIndex++;
83
- break;
84
- }
85
-
86
- outputIndex += matchedCode.length;
87
- }
88
- });
89
-
90
- return possibleSynthesizers[0];
91
- }
92
-
93
-
94
- export function isValidSequence(sequence: string, format: string | null): {
95
- indexOfFirstNotValidChar: number,
96
- synthesizer: string[] | null,
97
- // technology: string[] | null
98
- } {
99
- const possibleSynthesizers = format == null ?
100
- getListOfPossibleSynthesizersByFirstMatchedCode(sequence) :
101
- [format];
102
-
103
- // if (possibleSynthesizers.length > 1) {
104
- // const synthesizer = ui.choiceInput('Choose synthesizer from list: ', possibleSynthesizers[0],
105
- // possibleSynthesizers);
106
- // ui.dialog('Choose Synthesizer')
107
- // .add(ui.panel([synthesizer.root], {style: {fontWeight: 'bold'}}))
108
- // .onOK(() => possibleSynthesizers = [synthesizer.value])
109
- // .onCancel(() => {
110
- // possibleSynthesizers = [possibleSynthesizers[0]];
111
- // grok.shell.warning('Input sequence is expected to be in format ' + possibleSynthesizers[0]);
112
- // })
113
- // .show();
114
- // } else if (possibleSynthesizers.length == 0)
115
- if (possibleSynthesizers.length == 0)
116
- return {indexOfFirstNotValidChar: 0, synthesizer: null};//, technology: null};
117
-
118
- const outputIndices = Array(possibleSynthesizers.length).fill(0);
119
-
120
- const firstUniqueCharacters = ['r', 'd'];
121
- possibleSynthesizers.forEach(function(synthesizer, i) {
122
- const codes = sortByStringLengthInDescendingOrder(getAllCodesOfSynthesizer(synthesizer));
123
- while (outputIndices[i] < sequence.length) {
124
- const matchedCode = codes.find((c) => c == sequence.slice(outputIndices[i], outputIndices[i] + c.length));
125
-
126
- if (matchedCode == null)
127
- break;
128
-
129
- if ( // for mistake pattern 'rAA'
130
- outputIndices[i] > 1 &&
131
- NUCLEOTIDES.includes(sequence[outputIndices[i]]) &&
132
- firstUniqueCharacters.includes(sequence[outputIndices[i] - 2])
133
- ) break;
134
-
135
- if ( // for mistake pattern 'ArA'
136
- firstUniqueCharacters.includes(sequence[outputIndices[i] + 1]) &&
137
- NUCLEOTIDES.includes(sequence[outputIndices[i]])
138
- ) {
139
- outputIndices[i]++;
140
- break;
141
- }
142
-
143
- outputIndices[i] += matchedCode.length;
144
- }
145
- });
146
-
147
- const outputIndex = Math.max(...outputIndices);
148
- const synthesizer = possibleSynthesizers[outputIndices.indexOf(outputIndex)];
149
- const indexOfFirstNotValidChar = (outputIndex == sequence.length) ? -1 : outputIndex;
150
- if (indexOfFirstNotValidChar != -1) {
151
- return {
152
- indexOfFirstNotValidChar: indexOfFirstNotValidChar,
153
- synthesizer: [synthesizer],
154
- // technology: null,
155
- };
156
- }
157
-
158
- // const possibleTechnologies =
159
- // getListOfPossibleTechnologiesByFirstMatchedCode(sequence, possibleSynthesizers[outputIndex]);
160
-
161
- // if (possibleTechnologies.length > 1) {
162
- // const technology = ui.choiceInput('Choose technology from list: ', possibleTechnologies[0],
163
- // possibleTechnologies);
164
- // ui.dialog('Choose Technology')
165
- // .add(ui.panel([technology.root], {style: {fontWeight: 'bold'}}))
166
- // .onOK(() => possibleTechnologies = [technology.value])
167
- // .onCancel(() => {
168
- // possibleTechnologies = [possibleTechnologies[0]];
169
- // grok.shell.warning('Input sequence is expected to be in format ' + possibleTechnologies[0]);
170
- // })
171
- // .show();
172
- // } else if (possibleTechnologies.length == 0)
173
- // if (possibleTechnologies.length == 0)
174
- // return {indexOfFirstNotValidChar: 0, synthesizer: [possibleSynthesizers[3]], technology: null};
175
-
176
- // outputIndex = 0;
177
-
178
- // possibleTechnologies.forEach((technology: string) => {
179
- // const codes = Object.keys(map[possibleSynthesizers[0]][technology]);
180
- // while (outputIndex < sequence.length) {
181
- // const matchedCode = codes.find((c) => c == sequence.slice(outputIndex, outputIndex + c.length));
182
-
183
- // if (matchedCode == null)
184
- // break;
185
-
186
- // if ( // for mistake pattern 'rAA'
187
- // outputIndex > 1 &&
188
- // nucleotides.includes(sequence[outputIndex]) &&
189
- // firstUniqueCharacters.includes(sequence[outputIndex - 2])
190
- // ) break;
191
-
192
- // if ( // for mistake pattern 'ArA'
193
- // firstUniqueCharacters.includes(sequence[outputIndex + 1]) &&
194
- // nucleotides.includes(sequence[outputIndex])
195
- // ) {
196
- // outputIndex++;
197
- // break;
198
- // }
199
-
200
- // outputIndex += matchedCode.length;
201
- // }
202
- // });
203
-
204
- return {
205
- indexOfFirstNotValidChar: indexOfFirstNotValidChar,
206
- synthesizer: [synthesizer],
207
- // technology: [possibleTechnologies[0]],
208
- };
209
- }
210
-
211
- export function getAllCodesOfSynthesizer(synthesizer: string): string[] {
212
- let codes: string[] = [];
213
- for (const technology of Object.keys(map[synthesizer]))
214
- codes = codes.concat(Object.keys(map[synthesizer][technology]));
215
- return codes.concat(Object.keys(MODIFICATIONS)).concat(DELIMITER);
216
- }
217
-
218
- function getListOfPossibleSynthesizersByFirstMatchedCode(sequence: string): string[] {
219
- let synthesizers: string[] = [];
220
- Object.keys(map).forEach((synthesizer: string) => {
221
- let codes = sortByStringLengthInDescendingOrder(getAllCodesOfSynthesizer(synthesizer));
222
- if (synthesizer == 'Janssen GCRS Codes')
223
- codes = codes.concat(gcrsCodesWithoutSmiles);
224
- //TODO: get first non-dropdown code when there are two modifications
225
- let start = 0;
226
- for (let i = 0; i < sequence.length; i++) {
227
- if (sequence[i] == ')' && i != sequence.length - 1) {
228
- start = i + 1;
229
- break;
230
- }
231
- }
232
- if (gcrsCodesWithoutSmiles.some((s: string) => s == sequence.slice(start, start + s.length)))
233
- synthesizers = ['Janssen GCRS Codes'];
234
- if (codes.some((s: string) => s == sequence.slice(start, start + s.length)))
235
- synthesizers.push(synthesizer);
236
- });
237
- return synthesizers;
238
- }
239
-
240
- function getListOfPossibleTechnologiesByFirstMatchedCode(sequence: string, synthesizer: string): string[] {
241
- const technologies: string[] = [];
242
- Object.keys(map[synthesizer]).forEach((technology: string) => {
243
- const codes = Object.keys(map[synthesizer][technology]).concat(Object.keys(MODIFICATIONS));
244
- if (codes.some((s) => s == sequence.slice(0, s.length)))
245
- technologies.push(technology);
246
- });
247
- return technologies;
248
- }
249
-
250
- export function convertSequence(sequence: string, output: {
251
- indexOfFirstNotValidChar: number, synthesizer: string[] | null}) {//, technology: string[] | null}) {
252
- if (output.indexOfFirstNotValidChar != -1) {
253
- return {
254
- // type: '',
255
- indexOfFirstNotValidChar: JSON.stringify(output),
256
- Error: undefinedInputSequence,
257
- };
258
- }
259
- if (output.synthesizer!.includes(SYNTHESIZERS.RAW_NUCLEOTIDES)) {//&& output.technology!.includes(TECHNOLOGIES.DNA)) {
260
- return {
261
- type: SYNTHESIZERS.RAW_NUCLEOTIDES, // + ' ' + TECHNOLOGIES.DNA,
262
- Nucleotides: sequence,
263
- BioSpring: asoGapmersNucleotidesToBioSpring(sequence),
264
- GCRS: asoGapmersNucleotidesToGcrs(sequence),
265
- };
266
- }
267
- if (output.synthesizer!.includes(SYNTHESIZERS.BIOSPRING)) {
268
- // && output.technology!.includes(TECHNOLOGIES.ASO_GAPMERS)) {
269
- return {
270
- type: SYNTHESIZERS.BIOSPRING + ' ' + TECHNOLOGIES.ASO_GAPMERS,
271
- Nucleotides: asoGapmersBioSpringToNucleotides(sequence),
272
- BioSpring: sequence,
273
- GCRS: asoGapmersBioSpringToGcrs(sequence),
274
- };
275
- }
276
- if (output.synthesizer!.includes(SYNTHESIZERS.GCRS)) { // && output.technology!.includes(TECHNOLOGIES.ASO_GAPMERS)) {
277
- return {
278
- type: SYNTHESIZERS.GCRS + ' ' + TECHNOLOGIES.ASO_GAPMERS,
279
- Nucleotides: gcrsToNucleotides(sequence),
280
- BioSpring: siRnaGcrsToBioSpring(sequence),
281
- Axolabs: siRnaGcrsToAxolabs(sequence),
282
- Mermade12: gcrsToMermade12(sequence),
283
- GCRS: sequence,
284
- LCMS: gcrsToLcms(sequence),
285
- };
286
- }
287
- if (output.synthesizer!.includes(SYNTHESIZERS.RAW_NUCLEOTIDES)) {
288
- // && output.technology!.includes(TECHNOLOGIES.RNA)) {
289
- return {
290
- type: SYNTHESIZERS.RAW_NUCLEOTIDES + ' ' + TECHNOLOGIES.RNA,
291
- Nucleotides: sequence,
292
- BioSpring: siRnaNucleotideToBioSpringSenseStrand(sequence),
293
- Axolabs: siRnaNucleotideToAxolabsSenseStrand(sequence),
294
- GCRS: siRnaNucleotidesToGcrs(sequence),
295
- };
296
- }
297
- if (output.synthesizer!.includes(SYNTHESIZERS.BIOSPRING)) { // && output.technology!.includes(TECHNOLOGIES.SI_RNA)) {
298
- return {
299
- type: SYNTHESIZERS.BIOSPRING + ' ' + TECHNOLOGIES.SI_RNA,
300
- Nucleotides: siRnaBioSpringToNucleotides(sequence),
301
- BioSpring: sequence,
302
- Axolabs: siRnaBioSpringToAxolabs(sequence),
303
- GCRS: siRnaBioSpringToGcrs(sequence),
304
- };
305
- }
306
- if (output.synthesizer!.includes(SYNTHESIZERS.AXOLABS)) {
307
- return {
308
- type: SYNTHESIZERS.AXOLABS + ' ' + TECHNOLOGIES.SI_RNA,
309
- Nucleotides: siRnaAxolabsToNucleotides(sequence),
310
- BioSpring: siRnaAxolabsToBioSpring(sequence),
311
- Axolabs: sequence,
312
- GCRS: siRnaAxolabsToGcrs(sequence),
313
- };
314
- }
315
- if (output.synthesizer!.includes(SYNTHESIZERS.GCRS)) { // && output.technology!.includes(TECHNOLOGIES.SI_RNA)) {
316
- return {
317
- type: SYNTHESIZERS.GCRS + ' ' + TECHNOLOGIES.SI_RNA,
318
- Nucleotides: siRnaGcrsToNucleotides(sequence),
319
- BioSpring: siRnaGcrsToBioSpring(sequence),
320
- Axolabs: siRnaGcrsToAxolabs(sequence),
321
- MM12: gcrsToMermade12(sequence),
322
- GCRS: sequence,
323
- LCMS: gcrsToLcms(sequence),
324
- };
325
- }
326
- if (output.synthesizer!.includes(SYNTHESIZERS.GCRS)) {
327
- return {
328
- type: SYNTHESIZERS.GCRS,
329
- Nucleotides: gcrsToNucleotides(sequence),
330
- GCRS: sequence,
331
- Mermade12: gcrsToMermade12(sequence),
332
- LCMS: gcrsToLcms(sequence),
333
- };
334
- }
335
- if (output.synthesizer!.includes(SYNTHESIZERS.MERMADE_12)) {
336
- return {
337
- type: SYNTHESIZERS.MERMADE_12,
338
- Nucleotides: noTranslationTableAvailable,
339
- GCRS: noTranslationTableAvailable,
340
- Mermade12: sequence,
341
- };
342
- }
343
- return {
344
- type: undefinedInputSequence,
345
- Nucleotides: undefinedInputSequence,
346
- };
347
- }