@datagrok/bio 1.5.7 → 1.5.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.
Files changed (41) hide show
  1. package/css/helm.css +3 -0
  2. package/detectors.js +33 -22
  3. package/dist/package-test.js +1225 -453
  4. package/dist/package.js +979 -287
  5. package/files/samples/sample_FASTA.csv +66 -66
  6. package/files/samples/testDemog.csv +5851 -0
  7. package/files/samples/testHelm.csv +6 -0
  8. package/files/samples/{id.csv → testId.csv} +0 -0
  9. package/files/samples/{sar-small.csv → testSmiles.csv} +0 -0
  10. package/files/samples/testSmiles2.csv +12248 -0
  11. package/helm/JSDraw/Pistoia.HELM-uncompressed.js +9694 -0
  12. package/helm/JSDraw/Pistoia.HELM.js +27 -0
  13. package/helm/JSDraw/ReadMe.txt +8 -0
  14. package/helm/JSDraw/Scilligence.JSDraw2.Lite-uncompressed.js +31126 -0
  15. package/helm/JSDraw/Scilligence.JSDraw2.Lite.js +12 -0
  16. package/helm/JSDraw/Scilligence.JSDraw2.Resources.js +762 -0
  17. package/helm/JSDraw/dojo.js +250 -0
  18. package/helm/JSDraw/test.html +21 -0
  19. package/package.json +9 -2
  20. package/src/monomer-library.ts +199 -0
  21. package/src/package-test.ts +2 -0
  22. package/src/package.ts +71 -20
  23. package/src/tests/convert-test.ts +143 -22
  24. package/src/tests/detectors-test.ts +139 -156
  25. package/src/tests/renderer-test.ts +58 -0
  26. package/src/tests/splitter-test.ts +22 -0
  27. package/src/tests/types.ts +7 -0
  28. package/src/utils/atomic-works.ts +218 -97
  29. package/src/utils/cell-renderer.ts +211 -0
  30. package/src/utils/chem-palette.ts +280 -0
  31. package/src/utils/convert.ts +25 -16
  32. package/src/utils/misc.ts +29 -0
  33. package/src/utils/multiple-sequence-alignment.ts +5 -3
  34. package/src/utils/notation-converter.ts +120 -84
  35. package/src/utils/sequence-activity-cliffs.ts +2 -2
  36. package/src/utils/types.ts +13 -0
  37. package/src/utils/utils.ts +35 -30
  38. package/test-Bio-34f75e5127b8-936bf89b.html +256 -0
  39. package/files/sample_FASTA.csv +0 -66
  40. package/files/sample_FASTA_with_activities.csv +0 -66
  41. package/files/sample_MSA.csv +0 -541
@@ -33,23 +33,35 @@ C1CCCCC1
33
33
  CCCCCC
34
34
  `;
35
35
 
36
- const csvDfN1: string = `seq
36
+ const csvDfDna1: string = `seq
37
37
  ACGTC
38
38
  CAGTGT
39
39
  TTCAAC
40
+ `;
41
+
42
+ const csvDfRna1: string = `seq
43
+ ACGUC
44
+ CAGUGU
45
+ UUCAAC
40
46
  `;
41
47
 
42
48
  /** Pure amino acids sequence */
43
- const csvDfAA1: string = `seq
49
+ const csvDfPt1: string = `seq
44
50
  FWPHEY
45
51
  YNRQWYV
46
52
  MKPSEYV
47
53
  `;
48
54
 
49
- const csvDfSepNt: string = `seq
55
+ const csvDfSepDna: string = `seq
50
56
  A*C*G*T*C
51
57
  C*A*G*T*G*T
52
58
  T*T*C*A*A*C
59
+ `;
60
+
61
+ const csvDfSepRna: string = `seq
62
+ A*C*G*U*C
63
+ C*A*G*U*G*U
64
+ U*U*C*A*A*C
53
65
  `;
54
66
 
55
67
  const csvDfSepPt: string = `seq
@@ -70,49 +82,57 @@ rut12/her2/rty/wert//abc/abc1/dfgg
70
82
  rut12/rty/her2/abc/cfr3//wert/rut12
71
83
  `;
72
84
 
73
- const csvDfSepMsaN1: string = `seq
85
+ const csvDfSepMsaDna1: string = `seq
74
86
  A-C--G-T--C-T
75
87
  C-A-C--T--G-T
76
88
  A-C-C-G-T-A-C-T
77
89
  `;
78
90
 
79
- const csvDfMsaN1: string = `seq
91
+ const csvDfMsaDna1: string = `seq
80
92
  AC-GT-CT
81
93
  CAC-T-GT
82
94
  ACCGTACT
83
95
  `;
84
96
 
85
- const csvDfMsaAA1: string = `seq
97
+ const csvDfMsaPt1: string = `seq
86
98
  FWR-WYV-KHP
87
99
  YNR-WYV-KHP
88
100
  MWRSWY-CKHP
89
101
  `;
90
102
 
91
103
  const enum Samples {
92
- peptidesComplex = 'PeptidesComplex',
93
- fastaCsv = 'FastaCsv',
94
- msaComplex = 'MsaComplex',
95
- idCsv = 'IdCsv',
96
- sarSmallCsv = 'SarSmallCsv',
97
- HelmCsv = 'HelmCsv',
104
+ peptidesComplex = 'peptidesComplex',
105
+ fastaCsv = 'fastaCsv',
106
+ fastaFasta = 'fastaFasta',
107
+ msaComplex = 'msaComplex',
108
+ helmCsv = 'helmCsv',
109
+ testDemogCsv = 'testDemogCsv',
110
+ testHelmCsv = 'testHelmCsv',
111
+ testIdCsv = 'testIdCsv',
112
+ testSmilesCsv = 'testSmilesCsv',
113
+ testSmiles2Csv = 'testSmiles2Csv',
98
114
  }
99
115
 
100
116
  const samples: { [key: string]: string } = {
101
- 'PeptidesComplex': 'System:AppData/Bio/samples/peptides_complex_msa.csv',
102
- 'FastaCsv': 'System:AppData/Bio/samples/sample_FASTA.csv',
103
- 'MsaComplex': 'System:AppData/Bio/samples/sample_MSA.csv',
104
- 'IdCsv': 'System:AppData/Bio/samples/id.csv',
105
- 'SarSmallCsv': 'System:AppData/Bio/samples/sar-small.csv',
106
- 'HelmCsv': 'System:AppData/Bio/samples/sample_HELM.csv',
117
+ 'peptidesComplex': 'System:AppData/Bio/samples/peptides_complex_msa.csv',
118
+ 'fastaCsv': 'System:AppData/Bio/samples/sample_FASTA.csv',
119
+ 'fastaFasta': 'System:AppData/Bio/samples/sample_FASTA.fasta',
120
+ 'msaComplex': 'System:AppData/Bio/samples/sample_MSA.csv',
121
+ 'helmCsv': 'System:AppData/Bio/samples/sample_HELM.csv',
122
+ 'testDemogCsv': 'System:AppData/Bio/samples/testDemog.csv',
123
+ 'testHelmCsv': 'System:AppData/Bio/samples/testHelm.csv',
124
+ 'testIdCsv': 'System:AppData/Bio/samples/id.csv',
125
+ 'testSmilesCsv': 'System:AppData/Bio/samples/testSmiles.csv',
126
+ 'testSmiles2Csv': 'System:AppData/Bio/samples/testSmiles2.csv',
107
127
  };
108
128
 
109
129
  const _samplesDfs: { [key: string]: Promise<DG.DataFrame> } = {};
110
- const readSamplesCsv: (key: string) => DfReaderFunc = (key: string) => {
130
+
131
+ function readSamples(key: string, readFile: (file: string) => Promise<DG.DataFrame> = readFileCsv): DfReaderFunc {
111
132
  return async () => {
112
133
  if (!(key in _samplesDfs)) {
113
134
  _samplesDfs[key] = (async (): Promise<DG.DataFrame> => {
114
- const csv: string = await grok.dapi.files.readAsText(samples[key]);
115
- const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
135
+ const df: DG.DataFrame = await readFile(samples[key]);
116
136
  await grok.data.detectSemanticTypes(df);
117
137
  return df;
118
138
  })();
@@ -121,6 +141,18 @@ MWRSWY-CKHP
121
141
  };
122
142
  };
123
143
 
144
+ async function readFileCsv(file: string): Promise<DG.DataFrame> {
145
+ const csv: string = await grok.dapi.files.readAsText(file);
146
+ const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
147
+ return df;
148
+ }
149
+
150
+ async function readFileFasta(file: string): Promise<DG.DataFrame> {
151
+ const txt: string = await grok.dapi.files.readAsText(file);
152
+ const df: DG.DataFrame = importFasta(txt)[0];
153
+ return df;
154
+ }
155
+
124
156
  const _csvDfs: { [key: string]: Promise<DG.DataFrame> } = {};
125
157
  const readCsv: (key: string, csv: string) => DfReaderFunc = (key: string, csv: string) => {
126
158
  return async () => {
@@ -140,69 +172,127 @@ MWRSWY-CKHP
140
172
  test('Negative3', async () => { await _testNeg(readCsv('csvDf3', csvDf3), 'col1'); });
141
173
  test('NegativeSmiles', async () => { await _testNeg(readCsv('csvDfSmiles', csvDfSmiles), 'col1'); });
142
174
 
143
- test('N1', async () => { await _testN1(csvDfN1); });
144
- test('AA1', async () => { await _testAA1(csvDfAA1); });
145
- test('MsaN1', async () => { await _testMsaN1(csvDfMsaN1); });
146
- test('MsaAA1', async () => { await _testMsaAA1(csvDfMsaAA1); });
175
+ test('Dna1', async () => {
176
+ await _testPos(readCsv('csvDfDna1', csvDfDna1), 'seq', 'fasta:SEQ:DNA');
177
+ });
178
+ test('Rna1', async () => {
179
+ await _testPos(readCsv('csvDfRna1', csvDfRna1), 'seq', 'fasta:SEQ:RNA');
180
+ });
181
+ test('AA1', async () => {
182
+ await _testPos(readCsv('csvDfPt1', csvDfPt1), 'seq', 'fasta:SEQ:PT');
183
+ });
184
+ test('MsaDna1', async () => {
185
+ await _testPos(readCsv('csvDfMsaDna1', csvDfMsaDna1), 'seq', 'fasta:SEQ.MSA:DNA');
186
+ });
147
187
 
148
- test('SepNt', async () => { await _testSepNt(csvDfSepNt, '*'); });
149
- test('SepPt', async () => { await _testSepPt(csvDfSepPt, '-'); });
150
- test('SepUn1', async () => { await _testSepUn(csvDfSepUn1, '-'); });
151
- test('SepUn2', async () => { await _testSepUn(csvDfSepUn2, '/'); });
188
+ test('MsaAA1', async () => {
189
+ await _testPos(readCsv('csvDfMsaPt1', csvDfMsaPt1), 'seq', 'fasta:SEQ.MSA:PT');
190
+ });
152
191
 
153
- test('SepMsaN1', async () => { await _testSepMsaN1(csvDfSepMsaN1); });
192
+ test('SepDna', async () => {
193
+ await _testPos(readCsv('csvDfSepDna', csvDfSepDna), 'seq', 'separator:SEQ:DNA', '*');
194
+ });
195
+ test('SepRna', async () => {
196
+ await _testPos(readCsv('csvDfSepRna', csvDfSepRna), 'seq', 'separator:SEQ:RNA', '*');
197
+ });
198
+ test('SepPt', async () => {
199
+ await _testPos(readCsv('csvDfSepPt', csvDfSepPt), 'seq', 'separator:SEQ:PT', '-');
200
+ });
201
+ test('SepUn1', async () => {
202
+ await _testPos(readCsv('csvDfSepUn1', csvDfSepUn1), 'seq', 'separator:SEQ:UN', '-');
203
+ });
204
+ test('SepUn2', async () => {
205
+ await _testPos(readCsv('csvDfSepUn2', csvDfSepUn2), 'seq', 'separator:SEQ:UN', '/');
206
+ });
207
+
208
+ test('SepMsaN1', async () => {
209
+ await _testPos(readCsv('csvDfSepMsaDna1', csvDfSepMsaDna1), 'seq', 'separator:SEQ.MSA:DNA', '-');
210
+ });
154
211
 
155
212
  test('SamplesFastaCsvPt', async () => {
156
- await _testSamplesFastaCsvPt();
213
+ await _testPos(readSamples(Samples.fastaCsv), 'sequence', 'fasta:SEQ:PT');
157
214
  });
158
215
  test('SamplesFastaCsvNegativeEntry', async () => {
159
- await _testNeg(readSamplesCsv(Samples.fastaCsv), 'Entry');
216
+ await _testNeg(readSamples(Samples.fastaCsv), 'Entry');
160
217
  });
161
218
  test('SamplesFastaCsvNegativeLength', async () => {
162
- await _testNeg(readSamplesCsv(Samples.fastaCsv), 'Length');
219
+ await _testNeg(readSamples(Samples.fastaCsv), 'Length');
163
220
  });
164
221
  test('SamplesFastaCsvNegativeUniProtKB', async () => {
165
- await _testNeg(readSamplesCsv(Samples.fastaCsv), 'UniProtKB');
222
+ await _testNeg(readSamples(Samples.fastaCsv), 'UniProtKB');
166
223
  });
167
224
 
168
- test('SamplesFastaFastaPt', async () => { await _testSamplesFastaFastaPt(); });
169
-
170
- // System:AppData/Bio/samples/peptides_complex_align.csv contains monomers with spaces
171
- // test('SamplesPeptidesComplexUn', async () => {
172
- // await _testSamplesPeptidesComplexUn();
173
- // });
225
+ test('SamplesFastaFastaPt', async () => {
226
+ await _testPos(readSamples(Samples.fastaFasta, readFileFasta), 'sequence', 'fasta:SEQ:PT');
227
+ });
174
228
 
175
229
  test('samplesPeptidesComplexNegativeID', async () => {
176
- await _testNeg(readSamplesCsv(Samples.peptidesComplex), 'ID');
230
+ await _testNeg(readSamples(Samples.peptidesComplex), 'ID');
177
231
  });
178
232
  test('SamplesPeptidesComplexNegativeMeasured', async () => {
179
- await _testNeg(readSamplesCsv(Samples.peptidesComplex), 'Measured');
233
+ await _testNeg(readSamples(Samples.peptidesComplex), 'Measured');
180
234
  });
181
235
  test('SamplesPeptidesComplexNegativeValue', async () => {
182
- await _testNeg(readSamplesCsv(Samples.peptidesComplex), 'Value');
236
+ await _testNeg(readSamples(Samples.peptidesComplex), 'Value');
183
237
  });
184
238
 
185
239
  test('samplesMsaComplexUn', async () => {
186
- await _testPos(readSamplesCsv(Samples.msaComplex), 'MSA', 'separator:SEQ.MSA:UN', '/');
240
+ await _testPos(readSamples(Samples.msaComplex), 'MSA', 'separator:SEQ.MSA:UN', '/');
187
241
  });
188
242
  test('samplesMsaComplexNegativeActivity', async () => {
189
- await _testNeg(readSamplesCsv(Samples.msaComplex), 'Activity');
243
+ await _testNeg(readSamples(Samples.msaComplex), 'Activity');
190
244
  });
191
245
 
192
246
  test('samplesIdCsvNegativeID', async () => {
193
- await _testNeg(readSamplesCsv(Samples.idCsv), 'ID');
247
+ await _testNeg(readSamples(Samples.testIdCsv), 'ID');
194
248
  });
195
249
 
196
250
  test('samplesSarSmallCsvNegativeSmiles', async () => {
197
- await _testNeg(readSamplesCsv(Samples.sarSmallCsv), 'smiles');
251
+ await _testNeg(readSamples(Samples.testSmilesCsv), 'smiles');
198
252
  });
199
253
 
200
254
  test('samplesHelmCsvHELM', async () => {
201
- await _testPos(readSamplesCsv(Samples.HelmCsv), 'HELM', 'HELM', null);
255
+ await _testPos(readSamples(Samples.helmCsv), 'HELM', 'HELM', null);
202
256
  });
203
257
 
204
258
  test('samplesHelmCsvNegativeActivity', async () => {
205
- await _testNeg(readSamplesCsv(Samples.HelmCsv), 'Activity');
259
+ await _testNeg(readSamples(Samples.helmCsv), 'Activity');
260
+ });
261
+
262
+ // sample_testHelm.csb
263
+ // columns: ID,Test type,HELM string,Valid?,Mol Weight,Mol Formula,SMILES
264
+ test('samplesTestHelmNegativeID', async () => {
265
+ await _testNeg(readSamples(Samples.testHelmCsv), 'ID');
266
+ });
267
+ test('samplesTestHelmNegativeTestType', async () => {
268
+ await _testNeg(readSamples(Samples.testHelmCsv), 'Test type');
269
+ });
270
+ test('samplesTestHelmPositiveHelmString', async () => {
271
+ await _testPos(readSamples(Samples.testHelmCsv), 'HELM string', 'HELM');
272
+ });
273
+ test('samplesTestHelmNegativeValid', async () => {
274
+ await _testNeg(readSamples(Samples.testHelmCsv), 'Valid?');
275
+ });
276
+ test('samplesTestHelmNegativeMolWeight', async () => {
277
+ await _testNeg(readSamples(Samples.testHelmCsv), 'Mol Weight');
278
+ });
279
+ test('samplesTestHelmNegativeMolFormula', async () => {
280
+ await _testNeg(readSamples(Samples.testHelmCsv), 'Mol Formula');
281
+ });
282
+ test('samplesTestHelmNegativeSmiles', async () => {
283
+ await _testNeg(readSamples(Samples.testHelmCsv), 'Smiles');
284
+ });
285
+
286
+ test('samplesTestDemogNegativeAll', async () => {
287
+ const dfFunc: DfReaderFunc = readSamples(Samples.testDemogCsv);
288
+ const df: DG.DataFrame = await dfFunc();
289
+
290
+ for (const col of df.columns.toList())
291
+ await _testNeg(dfFunc, col.name);
292
+ });
293
+
294
+ test('samplesTestSmiles2NegativeSmiles', async () => {
295
+ await _testNeg(readSamples(Samples.testSmiles2Csv), 'SMILES');
206
296
  });
207
297
  });
208
298
 
@@ -223,110 +313,3 @@ export async function _testPos(readDf: DfReaderFunc, colName: string, units: str
223
313
  expect(col.getTag('separator'), separator);
224
314
  }
225
315
 
226
- export async function _testN1(csvDfN1: string) {
227
- const dfN1: DG.DataFrame = DG.DataFrame.fromCsv(csvDfN1);
228
- await grok.data.detectSemanticTypes(dfN1);
229
-
230
- const col: DG.Column = dfN1.col('seq')!;
231
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
232
- expect(col.getTag(DG.TAGS.UNITS), 'fasta:SEQ:NT');
233
- }
234
-
235
- export async function _testAA1(csvDfAA1: string) {
236
- const dfAA1: DG.DataFrame = DG.DataFrame.fromCsv(csvDfAA1);
237
- await grok.data.detectSemanticTypes(dfAA1);
238
-
239
- const col: DG.Column = dfAA1.col('seq')!;
240
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
241
- expect(col.getTag(DG.TAGS.UNITS), 'fasta:SEQ:PT');
242
- }
243
-
244
- export async function _testMsaN1(csvDfMsaN1: string) {
245
- const dfMsaN1: DG.DataFrame = DG.DataFrame.fromCsv(csvDfMsaN1);
246
- await grok.data.detectSemanticTypes(dfMsaN1);
247
-
248
- const col: DG.Column = dfMsaN1.col('seq')!;
249
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
250
- expect(col.getTag(DG.TAGS.UNITS), 'fasta:SEQ.MSA:NT');
251
- }
252
-
253
- export async function _testMsaAA1(csvDfMsaAA1: string) {
254
- const dfMsaAA1: DG.DataFrame = DG.DataFrame.fromCsv(csvDfMsaAA1);
255
- await grok.data.detectSemanticTypes(dfMsaAA1);
256
-
257
- const col: DG.Column = dfMsaAA1.col('seq')!;
258
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
259
- expect(col.getTag(DG.TAGS.UNITS), 'fasta:SEQ.MSA:PT');
260
- }
261
-
262
- export async function _testSepNt(csv: string, separator: string) {
263
- const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
264
- await grok.data.detectSemanticTypes(df);
265
-
266
- const col: DG.Column = df.col('seq')!;
267
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
268
- expect(col.getTag(DG.TAGS.UNITS), 'separator:SEQ:NT');
269
- expect(col.getTag('separator'), separator);
270
- }
271
-
272
- export async function _testSepPt(csv: string, separator: string) {
273
- const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
274
- await grok.data.detectSemanticTypes(df);
275
-
276
- const col: DG.Column = df.col('seq')!;
277
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
278
- expect(col.getTag(DG.TAGS.UNITS), 'separator:SEQ:PT');
279
- expect(col.getTag('separator'), separator);
280
- }
281
-
282
- export async function _testSepUn(csv: string, separator: string) {
283
- const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
284
- await grok.data.detectSemanticTypes(df);
285
-
286
- const col: DG.Column = df.col('seq')!;
287
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
288
- expect(col.getTag(DG.TAGS.UNITS), 'separator:SEQ:UN');
289
- expect(col.getTag('separator'), separator);
290
- }
291
-
292
- export async function _testSepMsaN1(csvDfSepMsaN1: string) {
293
- const dfSepMsaN1: DG.DataFrame = DG.DataFrame.fromCsv(csvDfSepMsaN1);
294
- await grok.data.detectSemanticTypes(dfSepMsaN1);
295
-
296
- const col: DG.Column = dfSepMsaN1.col('seq')!;
297
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
298
- expect(col.getTag(DG.TAGS.UNITS), 'separator:SEQ.MSA:NT');
299
- }
300
-
301
- export async function _testSamplesFastaCsvPt() {
302
- const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/sample_FASTA.csv');
303
- const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
304
- await grok.data.detectSemanticTypes(df);
305
-
306
- const col: DG.Column = df.col('sequence')!;
307
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
308
- expect(col.getTag(DG.TAGS.UNITS), 'fasta:SEQ:PT');
309
- expect(col.getTag('separator'), null);
310
- }
311
-
312
- export async function _testSamplesFastaFastaPt() {
313
- const fasta: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/sample_FASTA.fasta');
314
- const df: DG.DataFrame = importFasta(fasta)[0];
315
-
316
- const col: DG.Column = df.col('sequence')!;
317
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
318
- expect(col.getTag(DG.TAGS.UNITS), 'fasta:SEQ:PT');
319
- expect(col.getTag('separator'), null);
320
- }
321
-
322
- export async function _testSamplesPeptidesComplexUn() {
323
- const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/peptides_complex_aligned.csv');
324
- const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
325
- await grok.data.detectSemanticTypes(df);
326
-
327
- const col: DG.Column = df.col('AlignedSequence')!;
328
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
329
- expect(col.getTag(DG.TAGS.UNITS), 'separator:SEQ.MSA:UN');
330
- expect(col.getTag('separator'), '-');
331
- }
332
-
@@ -0,0 +1,58 @@
1
+ import {after, before, category, test, expect, expectObject} from '@datagrok-libraries/utils/src/test';
2
+
3
+ import * as grok from 'datagrok-api/grok';
4
+ import * as ui from 'datagrok-api/ui';
5
+ import * as DG from 'datagrok-api/dg';
6
+ import {importFasta, multipleSequenceAlignmentAny} from '../package';
7
+
8
+ category('renderers', () => {
9
+ let tvList: DG.TableView[];
10
+
11
+ before(async () => {
12
+ tvList = [];
13
+ });
14
+
15
+ after(async () => {
16
+ tvList.forEach((tv: DG.TableView) => tv.close());
17
+ });
18
+
19
+ test('afterMsa', async () => {
20
+ await _testAfterMsa();
21
+ });
22
+
23
+ async function _testAfterMsa() {
24
+ const fastaTxt: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/sample_FASTA.fasta');
25
+ const df: DG.DataFrame = importFasta(fastaTxt)[0];
26
+
27
+ const srcSeqCol: DG.Column | null = df.col('sequence');
28
+ expect(srcSeqCol !== null, true);
29
+ console.log('Bio: tests/renderers/afterMsa, src data loaded');
30
+
31
+ const tv: DG.TableView = grok.shell.addTableView(df);
32
+ console.log('Bio: tests/renderers/afterMsa, table view');
33
+
34
+ await grok.data.detectSemanticTypes(df);
35
+ console.log('Bio: tests/renderers/afterMsa, detectSemanticTypes');
36
+
37
+ console.log('Bio: tests/renderers/afterMsa, src before test semType' +
38
+ `semType="${srcSeqCol!.semType}", units="${srcSeqCol!.getTag(DG.TAGS.UNITS)}", ` +
39
+ `cell.renderer="${srcSeqCol!.getTag('cell.renderer')}"`);
40
+ expect(srcSeqCol!.semType, DG.SEMTYPE.MACROMOLECULE);
41
+ expect(srcSeqCol!.getTag(DG.TAGS.UNITS), 'fasta:SEQ:PT');
42
+ expect(srcSeqCol!.getTag('cell.renderer'), 'Macromolecule');
43
+ console.log('Bio: tests/renderers/afterMsa, src semType tested');
44
+
45
+ const msaSeqCol: DG.Column | null = await multipleSequenceAlignmentAny(df, srcSeqCol!);
46
+ console.log('Bio: tests/renderers/afterMsa, msaSeqCol created');
47
+
48
+ tv.grid.invalidate();
49
+ console.log('Bio: tests/renderers/afterMsa, tv.grid invalidated');
50
+
51
+ expect(msaSeqCol!.semType, DG.SEMTYPE.MACROMOLECULE);
52
+ expect(msaSeqCol!.getTag(DG.TAGS.UNITS), 'fasta:SEQ.MSA:PT');
53
+ expect(msaSeqCol!.getTag('cell.renderer'), 'Macromolecule');
54
+ console.log('Bio: tests/renderers/afterMsa, msa semType tested');
55
+
56
+ tvList.push(tv);
57
+ }
58
+ });
@@ -0,0 +1,22 @@
1
+ import {after, before, category, test, expect, expectObject} from '@datagrok-libraries/utils/src/test';
2
+
3
+ import * as grok from 'datagrok-api/grok';
4
+ import * as ui from 'datagrok-api/ui';
5
+ import * as DG from 'datagrok-api/dg';
6
+ import {WebLogo, SplitterFunc} from '@datagrok-libraries/bio/src/viewers/web-logo';
7
+
8
+ category('splitter', () => {
9
+ const helm1 = 'PEPTIDE1{meI.hHis.Aca.N.T.dE.Thr_PO3H2.Aca.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.D-Orn.D-aThr.Phe_4Me}$$$';
10
+ const helm2 = 'PEPTIDE1{meI.hHis.Hcy.Q.T.W.Q.Phe_4NH2.D-Tyr_Et.Tyr_ab-dehydroMe.dV.E.N.N.meK}$$$';
11
+
12
+ test('helm1', async () => { await _testHelmSplitter(helm1); });
13
+ test('helm2', async () => { await _testHelmSplitter(helm2); });
14
+ });
15
+
16
+ export async function _testHelmSplitter(txt: string) {
17
+ // const splitter: SplitterFunc = WebLogo.getSplitterAsHelm();
18
+ //
19
+ // const mList: string[] = splitter(txt);
20
+ // expect(mList.length, 12);
21
+ }
22
+
@@ -0,0 +1,7 @@
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
+ export type DfReaderFunc = () => Promise<DG.DataFrame>;
6
+
7
+ export type ConverterFunc = (srcCol: DG.Column) => DG.Column;