@datagrok/sequence-translator 1.0.9 → 1.0.10

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.
@@ -1,8 +1,7 @@
1
1
 
2
2
  import {map, SYNTHESIZERS, TECHNOLOGIES, MODIFICATIONS, delimiter, gcrsCodesWithoutSmiles} from './map';
3
3
  import {asoGapmersNucleotidesToBioSpring, asoGapmersNucleotidesToGcrs,
4
- asoGapmersBioSpringToNucleotides, asoGapmersBioSpringToGcrs, asoGapmersGcrsToNucleotides,
5
- asoGapmersGcrsToBioSpring, gcrsToMermade12, siRnaNucleotideToBioSpringSenseStrand,
4
+ asoGapmersBioSpringToNucleotides, asoGapmersBioSpringToGcrs, gcrsToMermade12, siRnaNucleotideToBioSpringSenseStrand,
6
5
  siRnaNucleotideToAxolabsSenseStrand, siRnaNucleotidesToGcrs, siRnaBioSpringToNucleotides,
7
6
  siRnaBioSpringToAxolabs, siRnaBioSpringToGcrs, siRnaAxolabsToNucleotides,
8
7
  siRnaAxolabsToBioSpring, siRnaAxolabsToGcrs, siRnaGcrsToNucleotides,
@@ -95,7 +94,7 @@ function sortByStringLengthInDescendingOrder(array: string[]): string[] {
95
94
  export function isValidSequence(sequence: string, format: string | null): {
96
95
  indexOfFirstNotValidChar: number,
97
96
  synthesizer: string[] | null,
98
- technology: string[] | null
97
+ // technology: string[] | null
99
98
  } {
100
99
  const possibleSynthesizers = format == null ?
101
100
  getListOfPossibleSynthesizersByFirstMatchedCode(sequence) :
@@ -114,49 +113,51 @@ export function isValidSequence(sequence: string, format: string | null): {
114
113
  // .show();
115
114
  // } else if (possibleSynthesizers.length == 0)
116
115
  if (possibleSynthesizers.length == 0)
117
- return {indexOfFirstNotValidChar: 0, synthesizer: null, technology: null};
116
+ return {indexOfFirstNotValidChar: 0, synthesizer: null};//, technology: null};
118
117
 
119
- let outputIndex = 0;
118
+ const outputIndices = Array(possibleSynthesizers.length).fill(0);
120
119
 
121
120
  const firstUniqueCharacters = ['r', 'd'];
122
121
  const nucleotides = ['A', 'U', 'T', 'C', 'G'];
123
-
124
- possibleSynthesizers.forEach((synthesizer) => {
122
+ possibleSynthesizers.forEach(function(synthesizer, i) {
125
123
  const codes = sortByStringLengthInDescendingOrder(getAllCodesOfSynthesizer(synthesizer));
126
- while (outputIndex < sequence.length) {
127
- const matchedCode = codes.find((c) => c == sequence.slice(outputIndex, outputIndex + c.length));
124
+ while (outputIndices[i] < sequence.length) {
125
+ const matchedCode = codes.find((c) => c == sequence.slice(outputIndices[i], outputIndices[i] + c.length));
128
126
 
129
127
  if (matchedCode == null)
130
128
  break;
131
129
 
132
130
  if ( // for mistake pattern 'rAA'
133
- outputIndex > 1 &&
134
- nucleotides.includes(sequence[outputIndex]) &&
135
- firstUniqueCharacters.includes(sequence[outputIndex - 2])
131
+ outputIndices[i] > 1 &&
132
+ nucleotides.includes(sequence[outputIndices[i]]) &&
133
+ firstUniqueCharacters.includes(sequence[outputIndices[i] - 2])
136
134
  ) break;
137
135
 
138
136
  if ( // for mistake pattern 'ArA'
139
- firstUniqueCharacters.includes(sequence[outputIndex + 1]) &&
140
- nucleotides.includes(sequence[outputIndex])
137
+ firstUniqueCharacters.includes(sequence[outputIndices[i] + 1]) &&
138
+ nucleotides.includes(sequence[outputIndices[i]])
141
139
  ) {
142
- outputIndex++;
140
+ outputIndices[i]++;
143
141
  break;
144
142
  }
145
143
 
146
- outputIndex += matchedCode.length;
144
+ outputIndices[i] += matchedCode.length;
147
145
  }
148
146
  });
149
147
 
148
+ const outputIndex = Math.max(...outputIndices);
149
+ const synthesizer = possibleSynthesizers[outputIndices.indexOf(outputIndex)];
150
150
  const indexOfFirstNotValidChar = (outputIndex == sequence.length) ? -1 : outputIndex;
151
151
  if (indexOfFirstNotValidChar != -1) {
152
152
  return {
153
153
  indexOfFirstNotValidChar: indexOfFirstNotValidChar,
154
- synthesizer: possibleSynthesizers,
155
- technology: null,
154
+ synthesizer: [synthesizer],
155
+ // technology: null,
156
156
  };
157
157
  }
158
158
 
159
- const possibleTechnologies = getListOfPossibleTechnologiesByFirstMatchedCode(sequence, possibleSynthesizers[0]);
159
+ // const possibleTechnologies =
160
+ // getListOfPossibleTechnologiesByFirstMatchedCode(sequence, possibleSynthesizers[outputIndex]);
160
161
 
161
162
  // if (possibleTechnologies.length > 1) {
162
163
  // const technology = ui.choiceInput('Choose technology from list: ', possibleTechnologies[0],
@@ -173,7 +174,7 @@ export function isValidSequence(sequence: string, format: string | null): {
173
174
  // if (possibleTechnologies.length == 0)
174
175
  // return {indexOfFirstNotValidChar: 0, synthesizer: [possibleSynthesizers[3]], technology: null};
175
176
 
176
- outputIndex = 0;
177
+ // outputIndex = 0;
177
178
 
178
179
  // possibleTechnologies.forEach((technology: string) => {
179
180
  // const codes = Object.keys(map[possibleSynthesizers[0]][technology]);
@@ -203,8 +204,8 @@ export function isValidSequence(sequence: string, format: string | null): {
203
204
 
204
205
  return {
205
206
  indexOfFirstNotValidChar: indexOfFirstNotValidChar,
206
- synthesizer: possibleSynthesizers,
207
- technology: [possibleTechnologies[outputIndex]],
207
+ synthesizer: [synthesizer],
208
+ // technology: [possibleTechnologies[0]],
208
209
  };
209
210
  }
210
211
 
@@ -248,7 +249,7 @@ function getListOfPossibleTechnologiesByFirstMatchedCode(sequence: string, synth
248
249
  }
249
250
 
250
251
  export function convertSequence(sequence: string, output: {
251
- indexOfFirstNotValidChar: number, synthesizer: string[] | null, technology: string[] | null}) {
252
+ indexOfFirstNotValidChar: number, synthesizer: string[] | null}) {//, technology: string[] | null}) {
252
253
  if (output.indexOfFirstNotValidChar != -1) {
253
254
  return {
254
255
  // type: '',
@@ -264,7 +265,8 @@ export function convertSequence(sequence: string, output: {
264
265
  GCRS: asoGapmersNucleotidesToGcrs(sequence),
265
266
  };
266
267
  }
267
- if (output.synthesizer!.includes(SYNTHESIZERS.BIOSPRING) && output.technology!.includes(TECHNOLOGIES.ASO_GAPMERS)) {
268
+ if (output.synthesizer!.includes(SYNTHESIZERS.BIOSPRING)) {
269
+ // && output.technology!.includes(TECHNOLOGIES.ASO_GAPMERS)) {
268
270
  return {
269
271
  type: SYNTHESIZERS.BIOSPRING + ' ' + TECHNOLOGIES.ASO_GAPMERS,
270
272
  Nucleotides: asoGapmersBioSpringToNucleotides(sequence),
@@ -272,17 +274,19 @@ export function convertSequence(sequence: string, output: {
272
274
  GCRS: asoGapmersBioSpringToGcrs(sequence),
273
275
  };
274
276
  }
275
- if (output.synthesizer!.includes(SYNTHESIZERS.GCRS) && output.technology!.includes(TECHNOLOGIES.ASO_GAPMERS)) {
277
+ if (output.synthesizer!.includes(SYNTHESIZERS.GCRS)) { // && output.technology!.includes(TECHNOLOGIES.ASO_GAPMERS)) {
276
278
  return {
277
279
  type: SYNTHESIZERS.GCRS + ' ' + TECHNOLOGIES.ASO_GAPMERS,
278
- Nucleotides: asoGapmersGcrsToNucleotides(sequence),
279
- BioSpring: asoGapmersGcrsToBioSpring(sequence),
280
+ Nucleotides: gcrsToNucleotides(sequence),
281
+ BioSpring: siRnaGcrsToBioSpring(sequence),
282
+ Axolabs: siRnaGcrsToAxolabs(sequence),
280
283
  Mermade12: gcrsToMermade12(sequence),
281
284
  GCRS: sequence,
282
285
  LCMS: gcrsToLcms(sequence),
283
286
  };
284
287
  }
285
- if (output.synthesizer!.includes(SYNTHESIZERS.RAW_NUCLEOTIDES) && output.technology!.includes(TECHNOLOGIES.RNA)) {
288
+ if (output.synthesizer!.includes(SYNTHESIZERS.RAW_NUCLEOTIDES)) {
289
+ // && output.technology!.includes(TECHNOLOGIES.RNA)) {
286
290
  return {
287
291
  type: SYNTHESIZERS.RAW_NUCLEOTIDES + ' ' + TECHNOLOGIES.RNA,
288
292
  Nucleotides: sequence,
@@ -291,7 +295,7 @@ export function convertSequence(sequence: string, output: {
291
295
  GCRS: siRnaNucleotidesToGcrs(sequence),
292
296
  };
293
297
  }
294
- if (output.synthesizer!.includes(SYNTHESIZERS.BIOSPRING) && output.technology!.includes(TECHNOLOGIES.SI_RNA)) {
298
+ if (output.synthesizer!.includes(SYNTHESIZERS.BIOSPRING)) { // && output.technology!.includes(TECHNOLOGIES.SI_RNA)) {
295
299
  return {
296
300
  type: SYNTHESIZERS.BIOSPRING + ' ' + TECHNOLOGIES.SI_RNA,
297
301
  Nucleotides: siRnaBioSpringToNucleotides(sequence),
@@ -309,7 +313,7 @@ export function convertSequence(sequence: string, output: {
309
313
  GCRS: siRnaAxolabsToGcrs(sequence),
310
314
  };
311
315
  }
312
- if (output.synthesizer!.includes(SYNTHESIZERS.GCRS) && output.technology!.includes(TECHNOLOGIES.SI_RNA)) {
316
+ if (output.synthesizer!.includes(SYNTHESIZERS.GCRS)) { // && output.technology!.includes(TECHNOLOGIES.SI_RNA)) {
313
317
  return {
314
318
  type: SYNTHESIZERS.GCRS + ' ' + TECHNOLOGIES.SI_RNA,
315
319
  Nucleotides: siRnaGcrsToNucleotides(sequence),
@@ -1,4 +1,4 @@
1
- <html><head><meta charset="utf-8"/><title>SequenceTranslator Test Report. Datagrok version datagrok/datagrok:latest SHA=7770371320b2. Commit 1d307ddc.</title><style type="text/css">html,
1
+ <html><head><meta charset="utf-8"/><title>SequenceTranslator Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit 0c0e8404.</title><style type="text/css">html,
2
2
  body {
3
3
  font-family: Arial, Helvetica, sans-serif;
4
4
  font-size: 1rem;
@@ -229,7 +229,7 @@ header {
229
229
  font-size: 1rem;
230
230
  padding: 0 0.5rem;
231
231
  }
232
- </style></head><body><div id="jesthtml-content"><header><h1 id="title">SequenceTranslator Test Report. Datagrok version datagrok/datagrok:latest SHA=7770371320b2. Commit 1d307ddc.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-09-29 08:43:13</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div><div id="test-summary"><div class="summary-total">Tests (1)</div><div class="summary-passed">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div></div></div><div id="suite-1" class="suite-container"><div class="suite-info"><div class="suite-path">/home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/remote.test.ts</div><div class="suite-time warn">17.787s</div></div><div class="suite-tests"><div class="test-result passed"><div class="test-info"><div class="test-suitename"> </div><div class="test-title">TEST</div><div class="test-status">passed</div><div class="test-duration">2.717s</div></div></div></div><div class="suite-consolelog"><div class="suite-consolelog-header">Console Log</div><div class="suite-consolelog-item"><pre class="suite-consolelog-item-origin"> at Object.&lt;anonymous&gt; (/home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/test-node.ts:62:11)
232
+ </style></head><body><div id="jesthtml-content"><header><h1 id="title">SequenceTranslator Test Report. Datagrok version datagrok/datagrok:latest SHA=916a90d7d48b. Commit 0c0e8404.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-10-19 11:03:39</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div><div id="test-summary"><div class="summary-total">Tests (1)</div><div class="summary-passed">1 passed</div><div class="summary-failed summary-empty">0 failed</div><div class="summary-pending summary-empty">0 pending</div></div></div></div><div id="suite-1" class="suite-container"><div class="suite-info"><div class="suite-path">/home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/remote.test.ts</div><div class="suite-time warn">19.305s</div></div><div class="suite-tests"><div class="test-result passed"><div class="test-info"><div class="test-suitename"> </div><div class="test-title">TEST</div><div class="test-status">passed</div><div class="test-duration">3.874s</div></div></div></div><div class="suite-consolelog"><div class="suite-consolelog-header">Console Log</div><div class="suite-consolelog-item"><pre class="suite-consolelog-item-origin"> at Object.&lt;anonymous&gt; (/home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/test-node.ts:62:11)
233
233
  at Generator.next (&lt;anonymous&gt;)
234
234
  at fulfilled (/home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/test-node.ts:28:58)
235
235
  at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Using web root: http://localhost:8080</pre></div><div class="suite-consolelog-item"><pre class="suite-consolelog-item-origin"> at /home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/remote.test.ts:40:11
@@ -242,15 +242,15 @@ header {
242
242
  at new Promise (&lt;anonymous&gt;)</pre><pre class="suite-consolelog-item-message">Testing SequenceTranslator package</pre></div><div class="suite-consolelog-item"><pre class="suite-consolelog-item-origin"> at /home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/remote.test.ts:66:11
243
243
  at Generator.next (&lt;anonymous&gt;)
244
244
  at fulfilled (/home/runner/work/public/public/packages/SequenceTranslator/src/__jest__/remote.test.ts:28:58)
245
- at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Test result : Success : 2 : SequenceTranslator.sequence-translator.usCfCfUfGfAf : OK
245
+ at processTicksAndRejections (internal/process/task_queues.js:97:5)</pre><pre class="suite-consolelog-item-message">Test result : Success : 1 : SequenceTranslator.sequence-translator.usCfCfUfGfAf : OK
246
246
  Test result : Success : 1 : SequenceTranslator.sequence-translator.usAfsusgsgsg : OK
247
- Test result : Success : 0 : SequenceTranslator.sequence-translator.UfUfUfsCfsuacg : OK
247
+ Test result : Success : 1 : SequenceTranslator.sequence-translator.UfUfUfsCfsuacg : OK
248
248
  Test result : Success : 0 : SequenceTranslator.sequence-translator.susususauasu : OK
249
249
  Test result : Success : 0 : SequenceTranslator.sequence-translator.CfGfCfsGfsCf : OK
250
- Test result : Success : 1 : SequenceTranslator.sequence-translator.acacacsacsac : OK
250
+ Test result : Success : 0 : SequenceTranslator.sequence-translator.acacacsacsac : OK
251
251
  Test result : Success : 0 : SequenceTranslator.sequence-translator.cccgggusug : OK
252
252
  Test result : Success : 0 : SequenceTranslator.sequence-translator.UfAfCfGfGfCfAfUf : OK
253
- Test result : Success : 0 : SequenceTranslator.sequence-translator.(invabasic)cuCfuUfsc : OK
254
- Test result : Success : 0 : SequenceTranslator.sequence-translator.(invabasic)usAfsucuCfuUfAfgcugUfgCfacususu : OK
255
- Test result : Success : 0 : SequenceTranslator.sequence-translator.(invabasic)asacgGfuGfCfAfacucuauuca : OK
253
+ Test result : Success : 1 : SequenceTranslator.sequence-translator.(invabasic)cuCfuUfsc : OK
254
+ Test result : Success : 1 : SequenceTranslator.sequence-translator.(invabasic)usAfsucuCfuUfAfgcugUfgCfacususu : OK
255
+ Test result : Success : 1 : SequenceTranslator.sequence-translator.(invabasic)asacgGfuGfCfAfacucuauuca : OK
256
256
  </pre></div></div></div></div></body></html>