Skip to content

Commit

Permalink
Merge pull request #16255 from astrovsky01/visium_datatype
Browse files Browse the repository at this point in the history
Add Visium datatype for squidpy and spatialomics tools
  • Loading branch information
jdavcs authored Jun 20, 2023
2 parents 6224748 + 3be9980 commit d5920c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/galaxy/config/sample/datatypes_conf.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
<datatype extension="grib" type="galaxy.datatypes.binary:Grib" mimetype="application/octet-stream" display_in_upload="true"/>
<datatype extension="loom" type="galaxy.datatypes.binary:Loom" description="An HDF5-based Loom File" mimetype="application/octet-stream" display_in_upload="true"/>
<datatype extension="h5ad" type="galaxy.datatypes.binary:Anndata" description="An HDF5-based anndata File" mimetype="application/octet-stream" display_in_upload="true"/>
<datatype extension="visium.tar.gz" type="galaxy.datatypes.binary:Visium" subclass="true" display_in_upload="true" description="Visium is a tar.gz archive with at least a 'Spatial' subfolder, a filtered h5 file and a raw h5 file." />
<datatype extension="mz5" type="galaxy.datatypes.binary:H5" subclass="true" mimetype="application/octet-stream" display_in_upload="true"/>
<datatype extension="hyphy_results.json" type="galaxy.datatypes.text:Json" mimetype="application/json" subclass="true" display_in_upload="false"/>
<datatype extension="hivtrace" type="galaxy.datatypes.text:Json" mimetype="application/json" subclass="true" display_in_upload="false"/>
Expand Down
23 changes: 23 additions & 0 deletions lib/galaxy/datatypes/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,29 @@ def sniff(self, filename: str) -> bool:
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."""

Expand Down

0 comments on commit d5920c6

Please sign in to comment.