From 39f849889ed106bc11eb48e803201f31ffcdccd4 Mon Sep 17 00:00:00 2001 From: Alexander OSTROVSKY Date: Thu, 15 Jun 2023 14:21:46 -0700 Subject: [PATCH 1/2] Add Visium datatype for squidpy and spatialomics tools --- .../config/sample/datatypes_conf.xml.sample | 1 + lib/galaxy/datatypes/binary.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/galaxy/config/sample/datatypes_conf.xml.sample b/lib/galaxy/config/sample/datatypes_conf.xml.sample index cfd58ef2285..dd056fdca9e 100644 --- a/lib/galaxy/config/sample/datatypes_conf.xml.sample +++ b/lib/galaxy/config/sample/datatypes_conf.xml.sample @@ -185,6 +185,7 @@ + diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index b56c7bee39e..231ebba84ed 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -317,6 +317,28 @@ class Meryldb(CompressedArchive): log.warning("%s, sniff Exception: %s", self, e) return False +class Visium(CompressedArchive): + """Visium is a tar.gz archive with at least a 'Spatial' subfolder, a filtered h5 file and a raw h5 file.""" + + file_ext = "visium.tar.gz" + + def sniff(self, filename: str) -> bool: + """ + Check data structure: + Contains h5 files + Contains spatial folder + """ + try: + if filename and tarfile.is_tarfile(filename): + with tarfile.open(filename, "r") as temptar: + _tar_content = temptar.getnames() + if "spatial" in _tar_content: + if len([_ for _ in _tar_content if _.endswith("matrix.h5")]) == 2: + return True + except Exception as e: + log.warning("%s, sniff Exception: %s", self, e) + return False + class Bref3(Binary): """Bref3 format is a binary format for storing phased, non-missing genotypes for a list of samples.""" From 3be998011e0ffcbf5fbd6e9180f0e63632255a54 Mon Sep 17 00:00:00 2001 From: Alexander OSTROVSKY Date: Fri, 16 Jun 2023 09:01:16 -0700 Subject: [PATCH 2/2] formatting --- lib/galaxy/datatypes/binary.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index 231ebba84ed..de4565a58c3 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -317,6 +317,7 @@ class Meryldb(CompressedArchive): log.warning("%s, sniff Exception: %s", self, e) return False + class Visium(CompressedArchive): """Visium is a tar.gz archive with at least a 'Spatial' subfolder, a filtered h5 file and a raw h5 file.""" @@ -324,9 +325,9 @@ class Visium(CompressedArchive): def sniff(self, filename: str) -> bool: """ - Check data structure: - Contains h5 files - Contains spatial folder + Check data structure: + Contains h5 files + Contains spatial folder """ try: if filename and tarfile.is_tarfile(filename):