@vitessce/config 3.0.1 → 3.1.0

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