From 93aab0d9f4ff0aa21a46e657f3fa45633c254fa7 Mon Sep 17 00:00:00 2001 From: Nikolay Akhmetov Date: Wed, 20 May 2026 12:00:37 -0400 Subject: [PATCH] Add is_zip handling to multivec wrapper --- src/vitessce/constants.py | 1 + src/vitessce/wrappers.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/vitessce/constants.py b/src/vitessce/constants.py index 584d3699..9d362c36 100644 --- a/src/vitessce/constants.py +++ b/src/vitessce/constants.py @@ -191,6 +191,7 @@ class FileType(DocEnum): CLUSTERS_JSON = "clusters.json", "A JSON-based expression matrix file type (this file type is poorly named)." GENES_JSON = "genes.json", "A JSON-based expression matrix file type." GENOMIC_PROFILES_ZARR = "genomic-profiles.zarr", "The Zarr-based genomic profile (multivec) file type." + GENOMIC_PROFILES_ZARR_ZIP = "genomic-profiles.zarr.zip", "The Zarr-based genomic profile (multivec) file type, in a Zarr directory store that has been zipped." ANNDATA_CELLS_ZARR = "anndata-cells.zarr", "The Zarr-based cells file type from an anndata object." ANNDATA_CELL_SETS_ZARR = "anndata-cell-sets.zarr", "The Zarr-based cell-sets file type from an anndata object." ANNDATA_EXPRESSION_MATRIX_ZARR = "anndata-expression-matrix.zarr", "The Zarr-based expression matrix file type from an anndata object." diff --git a/src/vitessce/wrappers.py b/src/vitessce/wrappers.py index 77547e95..95311598 100644 --- a/src/vitessce/wrappers.py +++ b/src/vitessce/wrappers.py @@ -1583,7 +1583,7 @@ def generator(base_url): class MultivecZarrWrapper(AbstractWrapper): - def __init__(self, zarr_path=None, zarr_url=None, **kwargs): + def __init__(self, zarr_path=None, zarr_url=None, is_zip=None, **kwargs): super().__init__(**kwargs) self._repr = make_repr(locals()) if zarr_url is not None and zarr_path is not None: @@ -1594,11 +1594,18 @@ def __init__(self, zarr_path=None, zarr_url=None, **kwargs): "Expected either zarr_url or zarr_path to be provided") self._zarr_path = zarr_path self._zarr_url = zarr_url + self.is_zip = is_zip if self._zarr_path is not None: self.is_remote = False + if is_zip is None and '.zip' in str(zarr_path): + self.is_zip = True else: self.is_remote = True - self.local_dir_uid = make_unique_filename(".multivec.zarr") + if is_zip is None and '.zip' in str(zarr_url): + self.is_zip = True + if self.is_zip is None: + self.is_zip = False + self.local_dir_uid = make_unique_filename(".multivec.zarr.zip" if self.is_zip else ".multivec.zarr") def convert_and_save(self, dataset_uid, obj_i, base_dir=None): # Only create out-directory if needed @@ -1615,6 +1622,8 @@ def convert_and_save(self, dataset_uid, obj_i, base_dir=None): def make_genomic_profiles_routes(self, dataset_uid, obj_i): if self.is_remote: return [] + elif self.is_zip: + return self.get_local_file_route(dataset_uid, obj_i, self._zarr_path, self.local_dir_uid) else: return self.get_local_dir_route(dataset_uid, obj_i, self._zarr_path, self.local_dir_uid) @@ -1626,7 +1635,7 @@ def get_zarr_url(self, base_url="", dataset_uid="", obj_i=""): def make_genomic_profiles_file_def_creator(self, dataset_uid, obj_i): def genomic_profiles_file_def_creator(base_url): obj_file_def = { - "fileType": "genomic-profiles.zarr", + "fileType": ft.GENOMIC_PROFILES_ZARR_ZIP.value if self.is_zip else ft.GENOMIC_PROFILES_ZARR.value, "url": self.get_zarr_url(base_url, dataset_uid, obj_i) } if self._request_init is not None: