Skip to content

Commit

Permalink
test passed
Browse files Browse the repository at this point in the history
  • Loading branch information
nilchia committed Aug 7, 2024
1 parent bbfac35 commit 18f9c8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
8 changes: 4 additions & 4 deletions lib/galaxy/datatypes/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ def set_meta(self, dataset: DatasetProtocol, overwrite: bool = True, **kwd) -> N
dataset.metadata.url = anndata_file.attrs.get("url")
dataset.metadata.doi = anndata_file.attrs.get("doi")
dataset.metadata.creation_date = anndata_file.attrs.get("creation_date")
dataset.metadata.shape = anndata_file.attrs.get("shape", dataset.metadata.shape)
dataset.metadata.shape = anndata_file.attrs.get("shape")
# none of the above appear to work in any dataset tested, but could be useful for
# future AnnData datasets
dataset.metadata.layers_count = len(anndata_file)
Expand Down Expand Up @@ -1574,7 +1574,7 @@ def _layercountsize(tmp, lennames=0):
dataset.metadata.shape = (int(dataset.metadata.obs_size), int(dataset.metadata.var_size))

def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
if not dataset.dataset.purged:
if not dataset.file_name_ == None:
tmp = dataset.metadata

def _makelayerstrings(layer, count, names):
Expand All @@ -1596,7 +1596,7 @@ def _makelayerstrings(layer, count, names):
peekstr += _makelayerstrings("uns", tmp.uns_count, tmp.uns_layers)

dataset.peek = peekstr
dataset.blurb = f"Anndata file ({nice_size(dataset.get_size())})"
dataset.blurb = "Anndata file"
else:
dataset.peek = "file does not exist"
dataset.blurb = "file purged from disk"
Expand All @@ -1605,7 +1605,7 @@ def display_peek(self, dataset: DatasetProtocol) -> str:
try:
return dataset.peek
except Exception:
return f"Binary Anndata file ({nice_size(dataset.get_size())})"
return "Peek unavailable"


@build_sniff_from_prefix
Expand Down
Binary file modified lib/galaxy/datatypes/test/anndata.h5ad
Binary file not shown.
31 changes: 15 additions & 16 deletions test/unit/data/datatypes/test_h5ad_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ def test_h5ad_set_meta():

ann.set_meta(dataset)

assert dataset.metadata.layers_count == "9"
assert dataset.metadata.layers_names == "['X', 'layers', 'obs', 'obsm', 'obsp', 'uns', 'var', 'varm', 'varp']"

assert ann.set_meta._layercountsize(dataset) == "['X', 'layers', 'obs', 'obsm', 'obsp', 'uns', 'var', 'varm', 'varp'], 9, 0"

assert dataset.metadata.layers_count == 9
assert dataset.metadata.layers_names == ['X', 'layers', 'obs', 'obsm', 'obsp', 'uns', 'var', 'varm', 'varp']


def test_h5ad_set_peek():
Expand All @@ -42,15 +39,17 @@ def test_h5ad_set_peek():

assert (
dataset.peek
== """
[n_obs x n_vars]
640 x 11
[obs]: 2 layers
blobs, index
[var]: 1 layer
index
[obsm]: 0 layer
[varm]: 0 layer
[uns]: 0 layer
"""
==
"""[n_obs x n_vars]
640 x 11
[obs]: 2 layers
blobs, index
[var]: 1 layer
index
[obsm]: 2 layers
X_pca, X_umap
[varm]: 1 layer
PCs
[uns]: 1 layer
sample_data"""
)

0 comments on commit 18f9c8a

Please sign in to comment.