@vitessce/config 3.0.1 → 3.1.1

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,9 +1,9 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { generateConfigs } from './VitessceAutoConfig.js';
3
- describe('src/VitessceAutoConfig.js', () => {
2
+ import { generateConfig, getHintOptions } from './VitessceAutoConfig.js';
3
+ import { HINT_TYPE_TO_FILE_TYPE_MAP } from './constants.js';
4
+ describe('generateConfig', () => {
4
5
  it('generates config for OME-TIFF file correctly', async () => {
5
6
  const urls = ['somefile.ome.tif'];
6
- const expectedName = urls[0].split('/').at(-1);
7
7
  const expectedConfig = {
8
8
  version: '1.0.15',
9
9
  name: 'An automatically generated config. Adjust values and add layout components if needed.',
@@ -11,7 +11,7 @@ describe('src/VitessceAutoConfig.js', () => {
11
11
  datasets: [
12
12
  {
13
13
  uid: 'A',
14
- name: expectedName,
14
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
15
15
  files: [
16
16
  {
17
17
  fileType: 'raster.json',
@@ -21,7 +21,7 @@ describe('src/VitessceAutoConfig.js', () => {
21
21
  metadata: {
22
22
  isBitmask: false,
23
23
  },
24
- name: expectedName,
24
+ name: 'somefile.ome.tif',
25
25
  type: 'ome-tiff',
26
26
  url: urls[0],
27
27
  },
@@ -76,12 +76,11 @@ describe('src/VitessceAutoConfig.js', () => {
76
76
  ],
77
77
  initStrategy: 'auto',
78
78
  };
79
- const config = await generateConfigs(urls);
79
+ const config = await generateConfig(urls);
80
80
  expect(config).toEqual(expectedConfig);
81
81
  });
82
82
  it('generates config for OME-ZARR file correctly', async () => {
83
83
  const urls = ['anotherfile.ome.zarr'];
84
- const expectedName = urls[0].split('/').at(-1);
85
84
  const expectedConfig = {
86
85
  version: '1.0.15',
87
86
  name: 'An automatically generated config. Adjust values and add layout components if needed.',
@@ -89,7 +88,7 @@ describe('src/VitessceAutoConfig.js', () => {
89
88
  datasets: [
90
89
  {
91
90
  uid: 'A',
92
- name: expectedName,
91
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
93
92
  files: [
94
93
  {
95
94
  url: urls[0],
@@ -133,26 +132,19 @@ describe('src/VitessceAutoConfig.js', () => {
133
132
  y: 6,
134
133
  w: 6,
135
134
  h: 6,
136
- },
137
- {
138
- component: 'status',
139
- coordinationScopes: {
140
- dataset: 'A',
135
+ props: {
136
+ disable3d: [],
137
+ disableChannelsIfRgbDetected: true,
141
138
  },
142
- x: 6,
143
- y: 6,
144
- w: 6,
145
- h: 6,
146
139
  },
147
140
  ],
148
141
  initStrategy: 'auto',
149
142
  };
150
- const config = await generateConfigs(urls);
143
+ const config = await generateConfig(urls);
151
144
  expect(config).toEqual(expectedConfig);
152
145
  });
153
146
  it('generates config for Anndata-ZARR file correctly', async () => {
154
147
  const urls = ['http://localhost:4204/@fixtures/zarr/partials/.anndata.zarr'];
155
- const expectedName = urls[0].split('/').at(-1);
156
148
  const expectedConfig = {
157
149
  version: '1.0.15',
158
150
  name: 'An automatically generated config. Adjust values and add layout components if needed.',
@@ -160,7 +152,7 @@ describe('src/VitessceAutoConfig.js', () => {
160
152
  datasets: [
161
153
  {
162
154
  uid: 'A',
163
- name: expectedName,
155
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
164
156
  files: [
165
157
  {
166
158
  url: urls[0],
@@ -216,7 +208,7 @@ describe('src/VitessceAutoConfig.js', () => {
216
208
  x: 0,
217
209
  y: 0,
218
210
  w: 6,
219
- h: 6,
211
+ h: 4,
220
212
  },
221
213
  {
222
214
  component: 'scatterplot',
@@ -227,7 +219,27 @@ describe('src/VitessceAutoConfig.js', () => {
227
219
  x: 6,
228
220
  y: 0,
229
221
  w: 6,
230
- h: 6,
222
+ h: 4,
223
+ },
224
+ {
225
+ component: 'obsSetSizes',
226
+ coordinationScopes: {
227
+ dataset: 'A',
228
+ },
229
+ h: 4,
230
+ w: 6,
231
+ x: 0,
232
+ y: 4,
233
+ },
234
+ {
235
+ component: 'obsSetFeatureValueDistribution',
236
+ coordinationScopes: {
237
+ dataset: 'A',
238
+ },
239
+ h: 4,
240
+ w: 6,
241
+ x: 6,
242
+ y: 4,
231
243
  },
232
244
  {
233
245
  component: 'heatmap',
@@ -235,9 +247,9 @@ describe('src/VitessceAutoConfig.js', () => {
235
247
  dataset: 'A',
236
248
  },
237
249
  x: 0,
238
- y: 6,
250
+ y: 8,
239
251
  w: 6,
240
- h: 6,
252
+ h: 4,
241
253
  props: {
242
254
  transpose: true,
243
255
  },
@@ -248,19 +260,18 @@ describe('src/VitessceAutoConfig.js', () => {
248
260
  dataset: 'A',
249
261
  },
250
262
  x: 6,
251
- y: 6,
263
+ y: 8,
252
264
  w: 6,
253
- h: 6,
265
+ h: 4,
254
266
  },
255
267
  ],
256
268
  initStrategy: 'auto',
257
269
  };
258
- const config = await generateConfigs(urls);
270
+ const config = await generateConfig(urls);
259
271
  expect(config).toEqual(expectedConfig);
260
272
  });
261
- it('generates empty config for Anndata-ZARR file with empty .zmetadata', async () => {
273
+ it('generates correct config for Anndata-ZARR file with empty .zmetadata', async () => {
262
274
  const urls = ['http://localhost:4204/@fixtures/zarr/partials/emptymeta.h5ad.zarr'];
263
- const expectedName = urls[0].split('/').at(-1);
264
275
  const expectedConfig = {
265
276
  version: '1.0.15',
266
277
  name: 'An automatically generated config. Adjust values and add layout components if needed.',
@@ -268,7 +279,7 @@ describe('src/VitessceAutoConfig.js', () => {
268
279
  datasets: [
269
280
  {
270
281
  uid: 'A',
271
- name: expectedName,
282
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
272
283
  files: [
273
284
  {
274
285
  url: urls[0],
@@ -293,10 +304,31 @@ describe('src/VitessceAutoConfig.js', () => {
293
304
  A: 'A',
294
305
  },
295
306
  },
296
- layout: [],
307
+ layout: [
308
+ {
309
+ component: 'obsSetSizes',
310
+ coordinationScopes: {
311
+ dataset: 'A',
312
+ },
313
+ h: 6,
314
+ w: 12,
315
+ x: 0,
316
+ y: 0,
317
+ },
318
+ {
319
+ component: 'obsSetFeatureValueDistribution',
320
+ coordinationScopes: {
321
+ dataset: 'A',
322
+ },
323
+ h: 6,
324
+ w: 12,
325
+ x: 0,
326
+ y: 6,
327
+ },
328
+ ],
297
329
  initStrategy: 'auto',
298
330
  };
299
- const config = await generateConfigs(urls);
331
+ const config = await generateConfig(urls);
300
332
  expect(config).toEqual(expectedConfig);
301
333
  });
302
334
  it('raises an error for Anndata-ZARR file with misconfigured .zmetadata', async () => {
@@ -304,7 +336,7 @@ describe('src/VitessceAutoConfig.js', () => {
304
336
  // References:
305
337
  // - https://vitest.dev/api/expect.html#tothrowerror
306
338
  // - https://vitest.dev/api/expect.html#rejects
307
- await expect(() => generateConfigs(urls))
339
+ await expect(() => generateConfig(urls))
308
340
  .rejects
309
341
  .toThrowError('Could not generate config: .zmetadata file is not valid.');
310
342
  });
@@ -318,7 +350,7 @@ describe('src/VitessceAutoConfig.js', () => {
318
350
  datasets: [
319
351
  {
320
352
  uid: 'A',
321
- name: expectedNames[0],
353
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
322
354
  files: [
323
355
  {
324
356
  fileType: 'raster.json',
@@ -337,12 +369,6 @@ describe('src/VitessceAutoConfig.js', () => {
337
369
  usePhysicalSizeScaling: false,
338
370
  },
339
371
  },
340
- ],
341
- },
342
- {
343
- uid: 'B',
344
- name: expectedNames[1],
345
- files: [
346
372
  {
347
373
  url: urls[1],
348
374
  fileType: 'raster.ome-zarr',
@@ -353,7 +379,6 @@ describe('src/VitessceAutoConfig.js', () => {
353
379
  coordinationSpace: {
354
380
  dataset: {
355
381
  A: 'A',
356
- B: 'B',
357
382
  },
358
383
  },
359
384
  layout: [
@@ -364,7 +389,7 @@ describe('src/VitessceAutoConfig.js', () => {
364
389
  },
365
390
  x: 0,
366
391
  y: 0,
367
- w: 4,
392
+ w: 6,
368
393
  h: 4,
369
394
  },
370
395
  {
@@ -372,9 +397,9 @@ describe('src/VitessceAutoConfig.js', () => {
372
397
  coordinationScopes: {
373
398
  dataset: 'A',
374
399
  },
375
- x: 4,
400
+ x: 6,
376
401
  y: 0,
377
- w: 4,
402
+ w: 6,
378
403
  h: 4,
379
404
  },
380
405
  {
@@ -382,9 +407,9 @@ describe('src/VitessceAutoConfig.js', () => {
382
407
  coordinationScopes: {
383
408
  dataset: 'A',
384
409
  },
385
- x: 8,
386
- y: 0,
387
- w: 4,
410
+ x: 0,
411
+ y: 4,
412
+ w: 6,
388
413
  h: 4,
389
414
  props: {
390
415
  disable3d: [],
@@ -394,52 +419,45 @@ describe('src/VitessceAutoConfig.js', () => {
394
419
  {
395
420
  component: 'description',
396
421
  coordinationScopes: {
397
- dataset: 'B',
422
+ dataset: 'A',
398
423
  },
399
- x: 0,
424
+ x: 6,
400
425
  y: 4,
401
- w: 4,
426
+ w: 6,
402
427
  h: 4,
403
428
  },
404
429
  {
405
430
  component: 'spatial',
406
431
  coordinationScopes: {
407
- dataset: 'B',
432
+ dataset: 'A',
408
433
  },
409
- x: 4,
410
- y: 4,
411
- w: 4,
434
+ x: 0,
435
+ y: 8,
436
+ w: 6,
412
437
  h: 4,
413
438
  },
414
439
  {
415
440
  component: 'layerController',
416
441
  coordinationScopes: {
417
- dataset: 'B',
442
+ dataset: 'A',
418
443
  },
419
- x: 8,
420
- y: 4,
421
- w: 4,
422
- h: 4,
423
- },
424
- {
425
- component: 'status',
426
- coordinationScopes: {
427
- dataset: 'B',
444
+ props: {
445
+ disable3d: [],
446
+ disableChannelsIfRgbDetected: true,
428
447
  },
429
- x: 0,
448
+ x: 6,
430
449
  y: 8,
431
- w: 4,
450
+ w: 6,
432
451
  h: 4,
433
452
  },
434
453
  ],
435
454
  initStrategy: 'auto',
436
455
  };
437
- const config = await generateConfigs(urls);
456
+ const config = await generateConfig(urls);
438
457
  expect(config).toEqual(expectedConfig);
439
458
  });
440
459
  it('Does the parsing when .zmetadata file not present in folder', async () => {
441
460
  const urls = ['http://localhost:4204/@fixtures/zarr/anndata-0.8/anndata-csr.adata.zarr'];
442
- const expectedName = urls[0].split('/').at(-1);
443
461
  const expectedConfig = {
444
462
  version: '1.0.15',
445
463
  name: 'An automatically generated config. Adjust values and add layout components if needed.',
@@ -447,7 +465,7 @@ describe('src/VitessceAutoConfig.js', () => {
447
465
  datasets: [
448
466
  {
449
467
  uid: 'A',
450
- name: expectedName,
468
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
451
469
  files: [
452
470
  {
453
471
  url: urls[0],
@@ -470,9 +488,7 @@ describe('src/VitessceAutoConfig.js', () => {
470
488
  obsSets: [
471
489
  {
472
490
  name: 'Cell Type',
473
- path: [
474
- 'obs/leiden',
475
- ],
491
+ path: 'obs/leiden',
476
492
  },
477
493
  ],
478
494
  },
@@ -497,17 +513,458 @@ describe('src/VitessceAutoConfig.js', () => {
497
513
  },
498
514
  x: 0,
499
515
  y: 0,
500
- w: 12,
501
- h: 12,
516
+ w: 6,
517
+ h: 4,
518
+ },
519
+ {
520
+ component: 'obsSetSizes',
521
+ coordinationScopes: {
522
+ dataset: 'A',
523
+ },
524
+ h: 4,
525
+ w: 6,
526
+ x: 6,
527
+ y: 0,
528
+ },
529
+ {
530
+ component: 'obsSetFeatureValueDistribution',
531
+ coordinationScopes: {
532
+ dataset: 'A',
533
+ },
534
+ h: 4,
535
+ w: 6,
536
+ x: 0,
537
+ y: 4,
538
+ },
539
+ {
540
+ component: 'heatmap',
541
+ coordinationScopes: {
542
+ dataset: 'A',
543
+ },
544
+ h: 4,
545
+ props: {
546
+ transpose: true,
547
+ },
548
+ w: 6,
549
+ x: 6,
550
+ y: 4,
551
+ },
552
+ {
553
+ component: 'featureList',
554
+ coordinationScopes: {
555
+ dataset: 'A',
556
+ },
557
+ h: 4,
558
+ w: 6,
559
+ x: 0,
560
+ y: 8,
502
561
  },
503
562
  ],
504
563
  initStrategy: 'auto',
505
564
  };
506
- const config = await generateConfigs(urls);
565
+ const config = await generateConfig(urls);
507
566
  expect(config).toEqual(expectedConfig);
508
567
  });
509
568
  it('raises an error when URL with unsupported file format is passed', async () => {
510
569
  const urls = ['http://localhost:4204/@fixtures/zarr/anndata-0.7/somefile.zarr'];
511
- await generateConfigs(urls).catch(e => expect(e.message).toContain('This file type is not supported.'));
570
+ await generateConfig(urls, 'Transcriptomics / scRNA-seq (with heatmap)').catch(e => expect(e.message).toContain('One or more of the URLs provided point to unsupported file types.'));
571
+ });
572
+ // ********** TESTS WITH HINTS **********
573
+ it('generates config with hints for OME-TIFF dataset types correctly', async () => {
574
+ const urls = ['somefile.ome.tif'];
575
+ const expectedConfig = {
576
+ version: '1.0.15',
577
+ name: 'An automatically generated config. Adjust values and add layout components if needed.',
578
+ description: 'Populate with text relevant to this visualisation.',
579
+ datasets: [
580
+ {
581
+ uid: 'A',
582
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
583
+ files: [
584
+ {
585
+ fileType: 'raster.json',
586
+ options: {
587
+ images: [
588
+ {
589
+ metadata: {
590
+ isBitmask: false,
591
+ },
592
+ name: 'somefile.ome.tif',
593
+ type: 'ome-tiff',
594
+ url: urls[0],
595
+ },
596
+ ],
597
+ schemaVersion: '0.0.2',
598
+ usePhysicalSizeScaling: false,
599
+ },
600
+ },
601
+ ],
602
+ },
603
+ ],
604
+ coordinationSpace: {
605
+ dataset: {
606
+ A: 'A',
607
+ },
608
+ },
609
+ layout: [
610
+ {
611
+ component: 'spatial',
612
+ coordinationScopes: {
613
+ dataset: 'A',
614
+ },
615
+ x: 0,
616
+ y: 0,
617
+ w: 8,
618
+ h: 12,
619
+ },
620
+ {
621
+ component: 'layerController',
622
+ coordinationScopes: {
623
+ dataset: 'A',
624
+ },
625
+ x: 8,
626
+ y: 0,
627
+ w: 4,
628
+ h: 7,
629
+ props: {
630
+ disable3d: [],
631
+ disableChannelsIfRgbDetected: true,
632
+ },
633
+ },
634
+ {
635
+ component: 'description',
636
+ coordinationScopes: {
637
+ dataset: 'A',
638
+ },
639
+ h: 5,
640
+ w: 4,
641
+ x: 8,
642
+ y: 9,
643
+ },
644
+ ],
645
+ initStrategy: 'auto',
646
+ };
647
+ const viewConfig = await generateConfig(urls, 'Image');
648
+ expect(viewConfig).toEqual(expectedConfig);
649
+ });
650
+ it('generates config with hints for OME-ZARR dataset types correctly', async () => {
651
+ const urls = ['somefile.ome.zarr'];
652
+ const expectedConfig = {
653
+ version: '1.0.15',
654
+ name: 'An automatically generated config. Adjust values and add layout components if needed.',
655
+ description: 'Populate with text relevant to this visualisation.',
656
+ datasets: [
657
+ {
658
+ uid: 'A',
659
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
660
+ files: [
661
+ {
662
+ fileType: 'raster.ome-zarr',
663
+ url: 'somefile.ome.zarr',
664
+ },
665
+ ],
666
+ },
667
+ ],
668
+ coordinationSpace: {
669
+ dataset: {
670
+ A: 'A',
671
+ },
672
+ },
673
+ layout: [
674
+ {
675
+ component: 'spatial',
676
+ coordinationScopes: {
677
+ dataset: 'A',
678
+ },
679
+ x: 0,
680
+ y: 0,
681
+ w: 8,
682
+ h: 12,
683
+ },
684
+ {
685
+ component: 'layerController',
686
+ coordinationScopes: {
687
+ dataset: 'A',
688
+ },
689
+ x: 8,
690
+ y: 0,
691
+ w: 4,
692
+ h: 7,
693
+ props: {
694
+ disable3d: [],
695
+ disableChannelsIfRgbDetected: true,
696
+ },
697
+ },
698
+ {
699
+ component: 'description',
700
+ coordinationScopes: {
701
+ dataset: 'A',
702
+ },
703
+ h: 5,
704
+ w: 4,
705
+ x: 8,
706
+ y: 9,
707
+ },
708
+ ],
709
+ initStrategy: 'auto',
710
+ };
711
+ const viewConfig = await generateConfig(urls, 'Image');
712
+ expect(viewConfig).toEqual(expectedConfig);
713
+ });
714
+ it('generates config hints for Anndata-Zarr, OME-TIFF dataset types correctly', async () => {
715
+ const urls = ['somefile.ome.tif', 'http://localhost:4204/@fixtures/zarr/partials/.anndata.zarr'];
716
+ const expectedNames = [urls[0].split('/').at(-1), urls[1].split('/').at(-1)];
717
+ const expectedConfig = {
718
+ version: '1.0.15',
719
+ name: 'An automatically generated config. Adjust values and add layout components if needed.',
720
+ description: 'Populate with text relevant to this visualisation.',
721
+ datasets: [
722
+ {
723
+ uid: 'A',
724
+ name: 'An automatically generated view config for dataset. Adjust values and add layout components if needed.',
725
+ files: [
726
+ {
727
+ fileType: 'raster.json',
728
+ options: {
729
+ images: [
730
+ {
731
+ metadata: {
732
+ isBitmask: false,
733
+ },
734
+ name: expectedNames[0],
735
+ type: 'ome-tiff',
736
+ url: urls[0],
737
+ },
738
+ ],
739
+ schemaVersion: '0.0.2',
740
+ usePhysicalSizeScaling: false,
741
+ },
742
+ },
743
+ {
744
+ url: urls[1],
745
+ coordinationValues: {
746
+ featureType: 'gene',
747
+ featureValueType: 'expression',
748
+ obsType: 'cell',
749
+ },
750
+ fileType: 'anndata.zarr',
751
+ options: {
752
+ obsFeatureMatrix: {
753
+ path: 'X',
754
+ },
755
+ obsEmbedding: [
756
+ {
757
+ embeddingType: 'UMAP',
758
+ path: 'obsm/X_umap',
759
+ },
760
+ ],
761
+ obsSets: [
762
+ {
763
+ name: 'Cell Type',
764
+ path: [
765
+ 'obs/cell_type',
766
+ 'obs/disease',
767
+ 'obs/leiden',
768
+ 'obs/organism',
769
+ 'obs/self_reported_ethnicity',
770
+ 'obs/sex',
771
+ 'obs/tissue',
772
+ ],
773
+ },
774
+ ],
775
+ },
776
+ },
777
+ ],
778
+ },
779
+ ],
780
+ coordinationSpace: {
781
+ dataset: {
782
+ A: 'A',
783
+ },
784
+ spatialSegmentationLayer: {
785
+ A: {
786
+ radius: 65,
787
+ stroked: true,
788
+ visible: true,
789
+ opacity: 1,
790
+ },
791
+ },
792
+ spatialImageLayer: {
793
+ A: [
794
+ {
795
+ type: 'raster',
796
+ index: 0,
797
+ colormap: null,
798
+ transparentColor: null,
799
+ opacity: 1,
800
+ domainType: 'Min/Max',
801
+ channels: [
802
+ {
803
+ selection: {
804
+ c: 0,
805
+ },
806
+ color: [
807
+ 255,
808
+ 0,
809
+ 0,
810
+ ],
811
+ visible: true,
812
+ slider: [
813
+ 0,
814
+ 255,
815
+ ],
816
+ },
817
+ {
818
+ selection: {
819
+ c: 1,
820
+ },
821
+ color: [
822
+ 0,
823
+ 255,
824
+ 0,
825
+ ],
826
+ visible: true,
827
+ slider: [
828
+ 0,
829
+ 255,
830
+ ],
831
+ },
832
+ {
833
+ selection: {
834
+ c: 2,
835
+ },
836
+ color: [
837
+ 0,
838
+ 0,
839
+ 255,
840
+ ],
841
+ visible: true,
842
+ slider: [
843
+ 0,
844
+ 255,
845
+ ],
846
+ },
847
+ ],
848
+ },
849
+ ],
850
+ },
851
+ spatialZoom: {
852
+ A: null,
853
+ },
854
+ spatialTargetX: {
855
+ A: null,
856
+ },
857
+ spatialTargetY: {
858
+ A: null,
859
+ },
860
+ },
861
+ layout: [
862
+ {
863
+ component: 'spatial',
864
+ coordinationScopes: {
865
+ dataset: 'A',
866
+ spatialImageLayer: 'A',
867
+ spatialSegmentationLayer: 'A',
868
+ spatialTargetX: 'A',
869
+ spatialTargetY: 'A',
870
+ spatialZoom: 'A',
871
+ },
872
+ h: 6,
873
+ w: 6,
874
+ x: 0,
875
+ y: 0,
876
+ },
877
+ {
878
+ component: 'layerController',
879
+ coordinationScopes: {
880
+ dataset: 'A',
881
+ spatialImageLayer: 'A',
882
+ spatialSegmentationLayer: 'A',
883
+ spatialTargetX: 'A',
884
+ spatialTargetY: 'A',
885
+ spatialZoom: 'A',
886
+ },
887
+ h: 6,
888
+ props: {
889
+ disable3d: [],
890
+ disableChannelsIfRgbDetected: true,
891
+ },
892
+ w: 4,
893
+ x: 8,
894
+ y: 6,
895
+ },
896
+ {
897
+ component: 'heatmap',
898
+ coordinationScopes: {
899
+ dataset: 'A',
900
+ },
901
+ x: 0,
902
+ y: 6,
903
+ w: 8,
904
+ h: 6,
905
+ props: {
906
+ transpose: true,
907
+ },
908
+ },
909
+ {
910
+ component: 'obsSets',
911
+ coordinationScopes: {
912
+ dataset: 'A',
913
+ },
914
+ x: 9,
915
+ y: 0,
916
+ w: 3,
917
+ h: 6,
918
+ },
919
+ {
920
+ component: 'featureList',
921
+ coordinationScopes: {
922
+ dataset: 'A',
923
+ },
924
+ h: 6,
925
+ w: 3,
926
+ x: 6,
927
+ y: 0,
928
+ },
929
+ ],
930
+ initStrategy: 'auto',
931
+ };
932
+ const viewConfig = await generateConfig(urls, 'Spatial transcriptomics (with histology image and polygon cell segmentations)');
933
+ expect(viewConfig).toEqual(expectedConfig);
934
+ });
935
+ it('raises an error if the supplied dataset URLs and hint do not have any compatible views', async () => {
936
+ const urls = ['http://localhost:4204/@fixtures/zarr/partials/.anndata.zarr'];
937
+ const hint = 'Image';
938
+ await generateConfig(urls, hint).catch(e => expect(e.message).toContain('No views found that are compatible with the supplied dataset URLs and hint.'));
939
+ });
940
+ it('raises an error if no views are found for the supplied hint string', async () => {
941
+ const urls = ['http://localhost:4204/@fixtures/zarr/partials/.anndata.zarr'];
942
+ const hint = 'I do not exist';
943
+ await generateConfig(urls, hint).catch(e => expect(e.message).toContain('Hints config not found for the supplied hint: I do not exist'));
944
+ });
945
+ // ********** TESTS OF GET HINTS OPTIONS **********
946
+ it('returns a list of hints options for the supplied dataset URLs', async () => {
947
+ const urls = ['http://localhost:4204/@fixtures/zarr/partials/.anndata.zarr'];
948
+ const actualHintOptions = getHintOptions(urls);
949
+ expect(actualHintOptions).toEqual(HINT_TYPE_TO_FILE_TYPE_MAP['AnnData-Zarr']);
950
+ });
951
+ it('returns a list of hints options for the supplied dataset URLs', async () => {
952
+ const urls = [
953
+ 'http://localhost:4204/@fixtures/zarr/partials/.anndata.zarr',
954
+ 'somefile.ome.zarr',
955
+ 'http://localhost:4204/@fixtures/zarr/partials/.adata.zarr',
956
+ 'somefile.ome.tiff',
957
+ ];
958
+ const actualHintOptions = getHintOptions(urls);
959
+ expect(actualHintOptions).toEqual(HINT_TYPE_TO_FILE_TYPE_MAP['AnnData-Zarr,OME-TIFF']);
960
+ });
961
+ it('raises an error if no hints options are found for the supplied dataset URLs', async () => {
962
+ const urls = ['unsupportedfiletype.txt', 'unsupportedfiletype2.ome.tiff'];
963
+ try {
964
+ getHintOptions(urls);
965
+ }
966
+ catch (e) {
967
+ expect(e.message).toContain('One or more of the URLs provided point to unsupported file types.');
968
+ }
512
969
  });
513
970
  });