From 8a7ca520aa32e79d8cc001ab37290247a66843e0 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Sat, 14 Aug 2021 17:40:05 +0100 Subject: [PATCH] Fix setting metadata for some Loom files Loom files created by recent versions of LoomExperiment Bioconductor package encode the Loom version in an binary array, which breaks metadata setting in Galaxy. --- lib/galaxy/datatypes/binary.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index 8c4e255046db..ac816e7e4db1 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -16,6 +16,7 @@ from typing import Optional import h5py +import numpy as np import pysam import pysam.bcftools from bx.seq.twobit import TWOBIT_MAGIC_NUMBER, TWOBIT_MAGIC_NUMBER_SWAP @@ -928,7 +929,12 @@ def set_meta(self, dataset, overwrite=True, **kwd): dataset.metadata.description = loom_file.attrs.get('description') dataset.metadata.url = loom_file.attrs.get('url') dataset.metadata.doi = loom_file.attrs.get('doi') - dataset.metadata.loom_spec_version = loom_file.attrs.get('LOOM_SPEC_VERSION') + loom_spec_version = loom_file.attrs.get('LOOM_SPEC_VERSION') + if isinstance(loom_spec_version, np.ndarray): + loom_spec_version = loom_spec_version[0] + if isinstance(loom_spec_version, bytes): + loom_spec_version = loom_spec_version.decode() + dataset.metadata.loom_spec_version = loom_spec_version dataset.creation_date = loom_file.attrs.get('creation_date') dataset.metadata.shape = tuple(loom_file['matrix'].shape)