Build branch allow-compressed-output-bundles with version allow-compressed-output-bundles (2cc934c)
Build pipeline: openpipelines-bio.openpipeline-spatial.allow-compressed-ou59m5k
Source commit: 2cc934cef9
Source message: wip
This commit is contained in:
@@ -173,23 +173,23 @@ def retrieve_input_data(cells2stats_output_bundle):
|
||||
# │ └── RawCellStats.parquet
|
||||
# └── Panel.json
|
||||
|
||||
required_files = [
|
||||
"Panel.json",
|
||||
"Cytoprofiling/Instrument/RawCellStats.parquet"
|
||||
]
|
||||
required_files = ["Panel.json", "Cytoprofiling/Instrument/RawCellStats.parquet"]
|
||||
|
||||
if zipfile.is_zipfile(cells2stats_output_bundle):
|
||||
cells2stats_output_bundle = extract_selected_files_from_zip(
|
||||
cells2stats_output_bundle,
|
||||
members=required_files
|
||||
cells2stats_output_bundle, members=required_files
|
||||
)
|
||||
|
||||
assert os.path.isdir(cells2stats_output_bundle), "Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(cells2stats_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
input_dir = Path(cells2stats_output_bundle)
|
||||
input_data = dict(zip(
|
||||
["target_panel", "count_matrix"],
|
||||
[input_dir / file for file in required_files]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["target_panel", "count_matrix"],
|
||||
[input_dir / file for file in required_files],
|
||||
)
|
||||
)
|
||||
|
||||
assert all([file.exists() for file in input_data.values()]), (
|
||||
f"Not all required input files are found. Make sure that {par['input']} contains {input_data.values()}."
|
||||
@@ -199,7 +199,6 @@ def retrieve_input_data(cells2stats_output_bundle):
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
logger.info("Reading input data...")
|
||||
input_data = retrieve_input_data(par["input"])
|
||||
with open(input_data["target_panel"], "r") as f:
|
||||
|
||||
@@ -56,15 +56,18 @@ def test_compressed_input(run_component, tmp_path):
|
||||
output = tmp_path / "aviti.h5mu"
|
||||
zipped_input = tmp_path / "aviti.zip"
|
||||
|
||||
subprocess.run(
|
||||
["zip", "-r", str(zipped_input), "."],
|
||||
cwd=input,
|
||||
check=True
|
||||
)
|
||||
subprocess.run(["zip", "-r", str(zipped_input), "."], cwd=input, check=True)
|
||||
|
||||
# run component
|
||||
run_component(
|
||||
["--input", zipped_input, "--output", str(output), "--output_compression", "gzip"]
|
||||
[
|
||||
"--input",
|
||||
zipped_input,
|
||||
"--output",
|
||||
str(output),
|
||||
"--output_compression",
|
||||
"gzip",
|
||||
]
|
||||
)
|
||||
|
||||
assert output.is_file(), "output file was not created"
|
||||
|
||||
@@ -4,7 +4,6 @@ import squidpy as sq
|
||||
import mudata as mu
|
||||
import glob
|
||||
import zipfile
|
||||
import os
|
||||
|
||||
## VIASH START
|
||||
par = {
|
||||
@@ -38,19 +37,29 @@ def retrieve_input_data(cosmx_output_bundle):
|
||||
# ├── *_fov_positions_file.csv
|
||||
# └── *_metadata_file.csv
|
||||
|
||||
expected_file_patterns = ["exprMat_file.csv", "fov_positions_file.csv", "metadata_file.csv"]
|
||||
expected_file_patterns = [
|
||||
"exprMat_file.csv",
|
||||
"fov_positions_file.csv",
|
||||
"metadata_file.csv",
|
||||
]
|
||||
if zipfile.is_zipfile(cosmx_output_bundle):
|
||||
cosmx_output_bundle = extract_selected_files_from_zip(
|
||||
cosmx_output_bundle,
|
||||
members=["*" + file for file in expected_file_patterns]
|
||||
cosmx_output_bundle, members=["*" + file for file in expected_file_patterns]
|
||||
)
|
||||
|
||||
assert os.path.isdir(cosmx_output_bundle), "Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(cosmx_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
|
||||
input_data = dict(zip(
|
||||
["counts_file", "fov_file", "meta_file"],
|
||||
[find_cosmx_files(cosmx_output_bundle, glob_pattern) for glob_pattern in expected_file_patterns]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["counts_file", "fov_file", "meta_file"],
|
||||
[
|
||||
find_cosmx_files(cosmx_output_bundle, glob_pattern)
|
||||
for glob_pattern in expected_file_patterns
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
return input_data
|
||||
|
||||
@@ -63,7 +72,7 @@ def main():
|
||||
path=par["input"],
|
||||
counts_file=input_data["counts_file"],
|
||||
meta_file=input_data["meta_file"],
|
||||
fov_file=input_data["fov_file"]
|
||||
fov_file=input_data["fov_file"],
|
||||
)
|
||||
|
||||
logger.info("Writing output MuData object...")
|
||||
|
||||
@@ -3,6 +3,7 @@ import sys
|
||||
import mudata as mu
|
||||
import subprocess
|
||||
|
||||
|
||||
def test_simple_execution(run_component, tmp_path):
|
||||
output = tmp_path / "cosmx_tiny.h5mu"
|
||||
|
||||
@@ -57,13 +58,9 @@ def test_compressed_input(run_component, tmp_path):
|
||||
output = tmp_path / "cosmx_tiny.h5mu"
|
||||
zipped_input = tmp_path / "xenium_tiny.zip"
|
||||
input = meta["resources_dir"] + "/Lung5_Rep2_tiny"
|
||||
|
||||
subprocess.run(
|
||||
["zip", "-r", str(zipped_input), "."],
|
||||
cwd=input,
|
||||
check=True
|
||||
)
|
||||
|
||||
|
||||
subprocess.run(["zip", "-r", str(zipped_input), "."], cwd=input, check=True)
|
||||
|
||||
run_component(
|
||||
[
|
||||
"--input",
|
||||
|
||||
@@ -37,22 +37,25 @@ def _retrieve_input_data(xenium_output_bundle):
|
||||
"cell_feature_matrix.h5",
|
||||
"cells.parquet",
|
||||
"experiment.xenium",
|
||||
"metrics_summary.csv"
|
||||
"metrics_summary.csv",
|
||||
]
|
||||
|
||||
if zipfile.is_zipfile(xenium_output_bundle):
|
||||
xenium_output_bundle = extract_selected_files_from_zip(
|
||||
xenium_output_bundle,
|
||||
members=required_files
|
||||
xenium_output_bundle, members=required_files
|
||||
)
|
||||
|
||||
assert os.path.isdir(xenium_output_bundle), f"Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(xenium_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
input_dir = Path(xenium_output_bundle)
|
||||
|
||||
input_data = dict(zip(
|
||||
["count_matrix", "cells_metadata", "experiment", "metrics_summary"],
|
||||
[input_dir / file for file in required_files]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["count_matrix", "cells_metadata", "experiment", "metrics_summary"],
|
||||
[input_dir / file for file in required_files],
|
||||
)
|
||||
)
|
||||
|
||||
assert all([file.exists() for file in input_data.values()]), (
|
||||
f"Not all required input files are found. Make sure that {par['input']} contains {input_data.values()}."
|
||||
|
||||
@@ -67,15 +67,18 @@ def test_compressed_input(run_component, tmp_path):
|
||||
output = tmp_path / "xenium.h5mu"
|
||||
zipped_input = tmp_path / "xenium_tiny.zip"
|
||||
|
||||
subprocess.run(
|
||||
["zip", "-r", str(zipped_input), "."],
|
||||
cwd=input,
|
||||
check=True
|
||||
)
|
||||
subprocess.run(["zip", "-r", str(zipped_input), "."], cwd=input, check=True)
|
||||
|
||||
# run component
|
||||
run_component(
|
||||
["--input", zipped_input, "--output", str(output), "--output_compression", "gzip"]
|
||||
[
|
||||
"--input",
|
||||
zipped_input,
|
||||
"--output",
|
||||
str(output),
|
||||
"--output_compression",
|
||||
"gzip",
|
||||
]
|
||||
)
|
||||
|
||||
assert output.is_file(), "output file was not created"
|
||||
|
||||
@@ -78,6 +78,7 @@ resources:
|
||||
- type: python_script
|
||||
path: script.py
|
||||
- path: /src/utils/setup_logger.py
|
||||
- path: /src/utils/unzip_archived_folder.py
|
||||
test_resources:
|
||||
- type: python_script
|
||||
path: test.py
|
||||
@@ -91,6 +92,10 @@ engines:
|
||||
- procps
|
||||
- type: python
|
||||
__merge__: [ /src/base/requirements/spatialdata-io.yaml ]
|
||||
test_setup:
|
||||
- type: apt
|
||||
packages:
|
||||
- zip
|
||||
__merge__: [ /src/base/requirements/python_test_setup.yaml, .]
|
||||
runners:
|
||||
- type: executable
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from spatialdata_io import xenium
|
||||
import zipfile
|
||||
|
||||
## VIASH START
|
||||
par = {
|
||||
@@ -22,10 +23,14 @@ meta = {"resources_dir": "src/utils"}
|
||||
|
||||
sys.path.append(meta["resources_dir"])
|
||||
from setup_logger import setup_logger
|
||||
from unzip_archived_folder import unzip_archived_folder
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
logger.info("Reading in Xenium data...")
|
||||
if zipfile.is_zipfile(par["input"]):
|
||||
par["input"] = unzip_archived_folder(par["input"])
|
||||
|
||||
sdata = xenium(
|
||||
par["input"],
|
||||
cells_boundaries=par["cells_boundaries"],
|
||||
|
||||
@@ -2,6 +2,7 @@ import pytest
|
||||
import os
|
||||
import sys
|
||||
import spatialdata as sd
|
||||
import subprocess
|
||||
|
||||
|
||||
def test_simple_execution(run_component, tmp_path):
|
||||
@@ -31,5 +32,35 @@ def test_simple_execution(run_component, tmp_path):
|
||||
assert (output_sd_path / "zmetadata").is_file(), "zmetadata file was not created"
|
||||
|
||||
|
||||
def test_compressed_input(run_component, tmp_path):
|
||||
output_sd_path = tmp_path / "sd"
|
||||
input = meta["resources_dir"] + "/xenium_tiny"
|
||||
zipped_input = tmp_path / "xenium_tiny.zip"
|
||||
|
||||
subprocess.run(["zip", "-r", str(zipped_input), "."], cwd=input, check=True)
|
||||
run_component(
|
||||
[
|
||||
"--input",
|
||||
zipped_input,
|
||||
"--output",
|
||||
output_sd_path,
|
||||
]
|
||||
)
|
||||
|
||||
assert os.path.exists(output_sd_path), "Output zarr folder was not created"
|
||||
|
||||
sdata = sd.read_zarr(output_sd_path)
|
||||
assert isinstance(sdata, sd.SpatialData), (
|
||||
"the generated output is not a SpatialData object"
|
||||
)
|
||||
|
||||
assert os.path.exists(output_sd_path / "images"), "images folder was not created"
|
||||
assert os.path.exists(output_sd_path / "labels"), "labels folder was not created"
|
||||
assert os.path.exists(output_sd_path / "points"), "images folder was not created"
|
||||
assert os.path.exists(output_sd_path / "shapes"), "shapes folder was not created"
|
||||
assert os.path.exists(output_sd_path / "tables"), "tables folder was not created"
|
||||
assert (output_sd_path / "zmetadata").is_file(), "zmetadata file was not created"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(pytest.main([__file__]))
|
||||
|
||||
@@ -5,9 +5,7 @@ from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(
|
||||
archived_folder: Union[str, Path]
|
||||
) -> Union[str, Path]:
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
@@ -26,8 +24,7 @@ def unzip_archived_folder(
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path],
|
||||
members: list[Union[str, Path]]
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
@@ -296,7 +296,7 @@ build_info:
|
||||
output: "target/executable/convert/from_cells2stats_to_h5mu"
|
||||
executable: "target/executable/convert/from_cells2stats_to_h5mu/from_cells2stats_to_h5mu"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_cells2stats_to_h5mu"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:44Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
@@ -1433,23 +1433,23 @@ def retrieve_input_data(cells2stats_output_bundle):
|
||||
# │ └── RawCellStats.parquet
|
||||
# └── Panel.json
|
||||
|
||||
required_files = [
|
||||
"Panel.json",
|
||||
"Cytoprofiling/Instrument/RawCellStats.parquet"
|
||||
]
|
||||
required_files = ["Panel.json", "Cytoprofiling/Instrument/RawCellStats.parquet"]
|
||||
|
||||
if zipfile.is_zipfile(cells2stats_output_bundle):
|
||||
cells2stats_output_bundle = extract_selected_files_from_zip(
|
||||
cells2stats_output_bundle,
|
||||
members=required_files
|
||||
cells2stats_output_bundle, members=required_files
|
||||
)
|
||||
|
||||
assert os.path.isdir(cells2stats_output_bundle), "Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(cells2stats_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
input_dir = Path(cells2stats_output_bundle)
|
||||
input_data = dict(zip(
|
||||
["target_panel", "count_matrix"],
|
||||
[input_dir / file for file in required_files]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["target_panel", "count_matrix"],
|
||||
[input_dir / file for file in required_files],
|
||||
)
|
||||
)
|
||||
|
||||
assert all([file.exists() for file in input_data.values()]), (
|
||||
f"Not all required input files are found. Make sure that {par['input']} contains {input_data.values()}."
|
||||
@@ -1459,7 +1459,6 @@ def retrieve_input_data(cells2stats_output_bundle):
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
logger.info("Reading input data...")
|
||||
input_data = retrieve_input_data(par["input"])
|
||||
with open(input_data["target_panel"], "r") as f:
|
||||
|
||||
@@ -5,9 +5,7 @@ from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(
|
||||
archived_folder: Union[str, Path]
|
||||
) -> Union[str, Path]:
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
@@ -26,8 +24,7 @@ def unzip_archived_folder(
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path],
|
||||
members: list[Union[str, Path]]
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
@@ -231,7 +231,7 @@ build_info:
|
||||
output: "target/executable/convert/from_cosmx_to_h5mu"
|
||||
executable: "target/executable/convert/from_cosmx_to_h5mu/from_cosmx_to_h5mu"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -459,9 +459,9 @@ RUN pip install --upgrade pip && \
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_cosmx_to_h5mu"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:45Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
@@ -1115,7 +1115,6 @@ import squidpy as sq
|
||||
import mudata as mu
|
||||
import glob
|
||||
import zipfile
|
||||
import os
|
||||
|
||||
## VIASH START
|
||||
# The following code has been auto-generated by Viash.
|
||||
@@ -1173,19 +1172,29 @@ def retrieve_input_data(cosmx_output_bundle):
|
||||
# ├── *_fov_positions_file.csv
|
||||
# └── *_metadata_file.csv
|
||||
|
||||
expected_file_patterns = ["exprMat_file.csv", "fov_positions_file.csv", "metadata_file.csv"]
|
||||
expected_file_patterns = [
|
||||
"exprMat_file.csv",
|
||||
"fov_positions_file.csv",
|
||||
"metadata_file.csv",
|
||||
]
|
||||
if zipfile.is_zipfile(cosmx_output_bundle):
|
||||
cosmx_output_bundle = extract_selected_files_from_zip(
|
||||
cosmx_output_bundle,
|
||||
members=["*" + file for file in expected_file_patterns]
|
||||
cosmx_output_bundle, members=["*" + file for file in expected_file_patterns]
|
||||
)
|
||||
|
||||
assert os.path.isdir(cosmx_output_bundle), "Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(cosmx_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
|
||||
input_data = dict(zip(
|
||||
["counts_file", "fov_file", "meta_file"],
|
||||
[find_cosmx_files(cosmx_output_bundle, glob_pattern) for glob_pattern in expected_file_patterns]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["counts_file", "fov_file", "meta_file"],
|
||||
[
|
||||
find_cosmx_files(cosmx_output_bundle, glob_pattern)
|
||||
for glob_pattern in expected_file_patterns
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
return input_data
|
||||
|
||||
@@ -1198,7 +1207,7 @@ def main():
|
||||
path=par["input"],
|
||||
counts_file=input_data["counts_file"],
|
||||
meta_file=input_data["meta_file"],
|
||||
fov_file=input_data["fov_file"]
|
||||
fov_file=input_data["fov_file"],
|
||||
)
|
||||
|
||||
logger.info("Writing output MuData object...")
|
||||
|
||||
@@ -5,9 +5,7 @@ from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(
|
||||
archived_folder: Union[str, Path]
|
||||
) -> Union[str, Path]:
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
@@ -26,8 +24,7 @@ def unzip_archived_folder(
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path],
|
||||
members: list[Union[str, Path]]
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
@@ -232,7 +232,7 @@ build_info:
|
||||
output: "target/executable/convert/from_cosmx_to_spatialexperiment"
|
||||
executable: "target/executable/convert/from_cosmx_to_spatialexperiment/from_cosmx_to_spatialexperiment"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -457,9 +457,9 @@ RUN Rscript -e 'options(warn = 2); if (!requireNamespace("BiocManager", quietly
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_cosmx_to_spatialexperiment"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:44Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
|
||||
@@ -224,7 +224,7 @@ build_info:
|
||||
output: "target/executable/convert/from_h5mu_to_spatialexperiment"
|
||||
executable: "target/executable/convert/from_h5mu_to_spatialexperiment/from_h5mu_to_spatialexperiment"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -458,9 +458,9 @@ RUN Rscript -e 'options(warn = 2); if (!requireNamespace("remotes", quietly = TR
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_h5mu_to_spatialexperiment"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:44Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
|
||||
@@ -220,7 +220,7 @@ build_info:
|
||||
output: "target/executable/convert/from_spatialdata_to_h5mu"
|
||||
executable: "target/executable/convert/from_spatialdata_to_h5mu/from_spatialdata_to_h5mu"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -459,9 +459,9 @@ RUN pip install --upgrade pip && \
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_spatialdata_to_h5mu"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:44Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
|
||||
@@ -239,7 +239,7 @@ build_info:
|
||||
output: "target/executable/convert/from_xenium_to_h5mu"
|
||||
executable: "target/executable/convert/from_xenium_to_h5mu/from_xenium_to_h5mu"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_xenium_to_h5mu"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:44Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
@@ -1212,22 +1212,25 @@ def _retrieve_input_data(xenium_output_bundle):
|
||||
"cell_feature_matrix.h5",
|
||||
"cells.parquet",
|
||||
"experiment.xenium",
|
||||
"metrics_summary.csv"
|
||||
"metrics_summary.csv",
|
||||
]
|
||||
|
||||
if zipfile.is_zipfile(xenium_output_bundle):
|
||||
xenium_output_bundle = extract_selected_files_from_zip(
|
||||
xenium_output_bundle,
|
||||
members=required_files
|
||||
xenium_output_bundle, members=required_files
|
||||
)
|
||||
|
||||
assert os.path.isdir(xenium_output_bundle), f"Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(xenium_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
input_dir = Path(xenium_output_bundle)
|
||||
|
||||
input_data = dict(zip(
|
||||
["count_matrix", "cells_metadata", "experiment", "metrics_summary"],
|
||||
[input_dir / file for file in required_files]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["count_matrix", "cells_metadata", "experiment", "metrics_summary"],
|
||||
[input_dir / file for file in required_files],
|
||||
)
|
||||
)
|
||||
|
||||
assert all([file.exists() for file in input_data.values()]), (
|
||||
f"Not all required input files are found. Make sure that {par['input']} contains {input_data.values()}."
|
||||
|
||||
@@ -5,9 +5,7 @@ from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(
|
||||
archived_folder: Union[str, Path]
|
||||
) -> Union[str, Path]:
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
@@ -26,8 +24,7 @@ def unzip_archived_folder(
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path],
|
||||
members: list[Union[str, Path]]
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
@@ -173,6 +173,8 @@ resources:
|
||||
is_executable: true
|
||||
- type: "file"
|
||||
path: "setup_logger.py"
|
||||
- type: "file"
|
||||
path: "unzip_archived_folder.py"
|
||||
- type: "file"
|
||||
path: "nextflow_labels.config"
|
||||
dest: "nextflow_labels.config"
|
||||
@@ -303,6 +305,10 @@ engines:
|
||||
github:
|
||||
- "openpipelines-bio/core#subdirectory=packages/python/openpipeline_testutils"
|
||||
upgrade: true
|
||||
- type: "apt"
|
||||
packages:
|
||||
- "zip"
|
||||
interactive: false
|
||||
entrypoint: []
|
||||
cmd: null
|
||||
- type: "native"
|
||||
@@ -314,7 +320,7 @@ build_info:
|
||||
output: "target/executable/convert/from_xenium_to_spatialdata"
|
||||
executable: "target/executable/convert/from_xenium_to_spatialdata/from_xenium_to_spatialdata"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_xenium_to_spatialdata"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:44Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:38Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
@@ -1340,6 +1340,7 @@ trap interrupt INT SIGINT
|
||||
cat > "\$tempscript" << 'VIASHMAIN'
|
||||
import sys
|
||||
from spatialdata_io import xenium
|
||||
import zipfile
|
||||
|
||||
## VIASH START
|
||||
# The following code has been auto-generated by Viash.
|
||||
@@ -1386,10 +1387,14 @@ dep = {
|
||||
|
||||
sys.path.append(meta["resources_dir"])
|
||||
from setup_logger import setup_logger
|
||||
from unzip_archived_folder import unzip_archived_folder
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
logger.info("Reading in Xenium data...")
|
||||
if zipfile.is_zipfile(par["input"]):
|
||||
par["input"] = unzip_archived_folder(par["input"])
|
||||
|
||||
sdata = xenium(
|
||||
par["input"],
|
||||
cells_boundaries=par["cells_boundaries"],
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import fnmatch
|
||||
import zipfile
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
Args:
|
||||
zip_path (Union[str, Path]): Path to the ZIP archive.
|
||||
|
||||
Returns:
|
||||
extracted_path (Union[str, Path]): Path to the extracted folder inside the temporary directory.
|
||||
"""
|
||||
|
||||
temp_dir = Path(tempfile.TemporaryDirectory().name)
|
||||
with zipfile.ZipFile(archived_folder, "r") as archive:
|
||||
archive.extractall(temp_dir)
|
||||
|
||||
return temp_dir
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
Args:
|
||||
zip_path (Union[str, Path]): Path to the ZIP archive.
|
||||
members (list[str]): List of file paths within the archive to extract.
|
||||
|
||||
Returns:
|
||||
Path: Path to the extraction directory.
|
||||
"""
|
||||
|
||||
temp_dir = Path(tempfile.TemporaryDirectory().name)
|
||||
|
||||
with zipfile.ZipFile(zip_path, "r") as archive:
|
||||
all_files = archive.namelist()
|
||||
selected = set()
|
||||
for pattern in members:
|
||||
selected.update(fnmatch.filter(all_files, str(pattern)))
|
||||
for member in selected:
|
||||
archive.extract(member, temp_dir)
|
||||
|
||||
return temp_dir
|
||||
@@ -222,7 +222,7 @@ build_info:
|
||||
output: "target/executable/convert/from_xenium_to_spatialexperiment"
|
||||
executable: "target/executable/convert/from_xenium_to_spatialexperiment/from_xenium_to_spatialexperiment"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -457,9 +457,9 @@ RUN Rscript -e 'options(warn = 2); if (!requireNamespace("BiocManager", quietly
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component convert from_xenium_to_spatialexperiment"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:43Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
|
||||
@@ -227,7 +227,7 @@ build_info:
|
||||
output: "target/executable/filter/subset_cosmx"
|
||||
executable: "target/executable/filter/subset_cosmx/subset_cosmx"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -458,9 +458,9 @@ RUN pip install --upgrade pip && \
|
||||
|
||||
LABEL org.opencontainers.image.authors="Dorien Roosen, Weiwei Schultz"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component filter subset_cosmx"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:43Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
|
||||
@@ -426,7 +426,7 @@ build_info:
|
||||
output: "target/executable/mapping/spaceranger_count"
|
||||
executable: "target/executable/mapping/spaceranger_count/spaceranger_count"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -453,9 +453,9 @@ apt upgrade -y && apt install -y procps && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
LABEL org.opencontainers.image.authors="Jakub Majercik"
|
||||
LABEL org.opencontainers.image.description="Companion container for running component mapping spaceranger_count"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T10:55:43Z"
|
||||
LABEL org.opencontainers.image.created="2025-08-27T13:23:37Z"
|
||||
LABEL org.opencontainers.image.source="https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
LABEL org.opencontainers.image.revision="b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
LABEL org.opencontainers.image.revision="2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
LABEL org.opencontainers.image.version="allow-compressed-output-bundles"
|
||||
|
||||
VIASHDOCKER
|
||||
|
||||
@@ -296,7 +296,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_cells2stats_to_h5mu"
|
||||
executable: "target/nextflow/convert/from_cells2stats_to_h5mu/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3393,7 +3393,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_cells2stats_to_h5mu",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
@@ -3642,23 +3642,23 @@ def retrieve_input_data(cells2stats_output_bundle):
|
||||
# │ └── RawCellStats.parquet
|
||||
# └── Panel.json
|
||||
|
||||
required_files = [
|
||||
"Panel.json",
|
||||
"Cytoprofiling/Instrument/RawCellStats.parquet"
|
||||
]
|
||||
required_files = ["Panel.json", "Cytoprofiling/Instrument/RawCellStats.parquet"]
|
||||
|
||||
if zipfile.is_zipfile(cells2stats_output_bundle):
|
||||
cells2stats_output_bundle = extract_selected_files_from_zip(
|
||||
cells2stats_output_bundle,
|
||||
members=required_files
|
||||
cells2stats_output_bundle, members=required_files
|
||||
)
|
||||
|
||||
assert os.path.isdir(cells2stats_output_bundle), "Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(cells2stats_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
input_dir = Path(cells2stats_output_bundle)
|
||||
input_data = dict(zip(
|
||||
["target_panel", "count_matrix"],
|
||||
[input_dir / file for file in required_files]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["target_panel", "count_matrix"],
|
||||
[input_dir / file for file in required_files],
|
||||
)
|
||||
)
|
||||
|
||||
assert all([file.exists() for file in input_data.values()]), (
|
||||
f"Not all required input files are found. Make sure that {par['input']} contains {input_data.values()}."
|
||||
@@ -3668,7 +3668,6 @@ def retrieve_input_data(cells2stats_output_bundle):
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
logger.info("Reading input data...")
|
||||
input_data = retrieve_input_data(par["input"])
|
||||
with open(input_data["target_panel"], "r") as f:
|
||||
|
||||
@@ -5,9 +5,7 @@ from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(
|
||||
archived_folder: Union[str, Path]
|
||||
) -> Union[str, Path]:
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
@@ -26,8 +24,7 @@ def unzip_archived_folder(
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path],
|
||||
members: list[Union[str, Path]]
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
@@ -231,7 +231,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_cosmx_to_h5mu"
|
||||
executable: "target/nextflow/convert/from_cosmx_to_h5mu/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3342,7 +3342,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_cosmx_to_h5mu",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
@@ -3398,7 +3398,6 @@ import squidpy as sq
|
||||
import mudata as mu
|
||||
import glob
|
||||
import zipfile
|
||||
import os
|
||||
|
||||
## VIASH START
|
||||
# The following code has been auto-generated by Viash.
|
||||
@@ -3456,19 +3455,29 @@ def retrieve_input_data(cosmx_output_bundle):
|
||||
# ├── *_fov_positions_file.csv
|
||||
# └── *_metadata_file.csv
|
||||
|
||||
expected_file_patterns = ["exprMat_file.csv", "fov_positions_file.csv", "metadata_file.csv"]
|
||||
expected_file_patterns = [
|
||||
"exprMat_file.csv",
|
||||
"fov_positions_file.csv",
|
||||
"metadata_file.csv",
|
||||
]
|
||||
if zipfile.is_zipfile(cosmx_output_bundle):
|
||||
cosmx_output_bundle = extract_selected_files_from_zip(
|
||||
cosmx_output_bundle,
|
||||
members=["*" + file for file in expected_file_patterns]
|
||||
cosmx_output_bundle, members=["*" + file for file in expected_file_patterns]
|
||||
)
|
||||
|
||||
assert os.path.isdir(cosmx_output_bundle), "Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(cosmx_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
|
||||
input_data = dict(zip(
|
||||
["counts_file", "fov_file", "meta_file"],
|
||||
[find_cosmx_files(cosmx_output_bundle, glob_pattern) for glob_pattern in expected_file_patterns]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["counts_file", "fov_file", "meta_file"],
|
||||
[
|
||||
find_cosmx_files(cosmx_output_bundle, glob_pattern)
|
||||
for glob_pattern in expected_file_patterns
|
||||
],
|
||||
)
|
||||
)
|
||||
|
||||
return input_data
|
||||
|
||||
@@ -3481,7 +3490,7 @@ def main():
|
||||
path=par["input"],
|
||||
counts_file=input_data["counts_file"],
|
||||
meta_file=input_data["meta_file"],
|
||||
fov_file=input_data["fov_file"]
|
||||
fov_file=input_data["fov_file"],
|
||||
)
|
||||
|
||||
logger.info("Writing output MuData object...")
|
||||
|
||||
@@ -5,9 +5,7 @@ from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(
|
||||
archived_folder: Union[str, Path]
|
||||
) -> Union[str, Path]:
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
@@ -26,8 +24,7 @@ def unzip_archived_folder(
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path],
|
||||
members: list[Union[str, Path]]
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
@@ -232,7 +232,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_cosmx_to_spatialexperiment"
|
||||
executable: "target/nextflow/convert/from_cosmx_to_spatialexperiment/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3322,7 +3322,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_cosmx_to_spatialexperiment",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
@@ -224,7 +224,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_h5mu_to_spatialexperiment"
|
||||
executable: "target/nextflow/convert/from_h5mu_to_spatialexperiment/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3332,7 +3332,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_h5mu_to_spatialexperiment",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
@@ -220,7 +220,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_spatialdata_to_h5mu"
|
||||
executable: "target/nextflow/convert/from_spatialdata_to_h5mu/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3330,7 +3330,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_spatialdata_to_h5mu",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
@@ -239,7 +239,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_xenium_to_h5mu"
|
||||
executable: "target/nextflow/convert/from_xenium_to_h5mu/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3342,7 +3342,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_xenium_to_h5mu",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
@@ -3455,22 +3455,25 @@ def _retrieve_input_data(xenium_output_bundle):
|
||||
"cell_feature_matrix.h5",
|
||||
"cells.parquet",
|
||||
"experiment.xenium",
|
||||
"metrics_summary.csv"
|
||||
"metrics_summary.csv",
|
||||
]
|
||||
|
||||
if zipfile.is_zipfile(xenium_output_bundle):
|
||||
xenium_output_bundle = extract_selected_files_from_zip(
|
||||
xenium_output_bundle,
|
||||
members=required_files
|
||||
xenium_output_bundle, members=required_files
|
||||
)
|
||||
|
||||
assert os.path.isdir(xenium_output_bundle), f"Input is expected to be a (compressed) directory."
|
||||
assert os.path.isdir(xenium_output_bundle), (
|
||||
"Input is expected to be a (compressed) directory."
|
||||
)
|
||||
input_dir = Path(xenium_output_bundle)
|
||||
|
||||
input_data = dict(zip(
|
||||
["count_matrix", "cells_metadata", "experiment", "metrics_summary"],
|
||||
[input_dir / file for file in required_files]
|
||||
))
|
||||
input_data = dict(
|
||||
zip(
|
||||
["count_matrix", "cells_metadata", "experiment", "metrics_summary"],
|
||||
[input_dir / file for file in required_files],
|
||||
)
|
||||
)
|
||||
|
||||
assert all([file.exists() for file in input_data.values()]), (
|
||||
f"Not all required input files are found. Make sure that {par['input']} contains {input_data.values()}."
|
||||
|
||||
@@ -5,9 +5,7 @@ from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(
|
||||
archived_folder: Union[str, Path]
|
||||
) -> Union[str, Path]:
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
@@ -26,8 +24,7 @@ def unzip_archived_folder(
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path],
|
||||
members: list[Union[str, Path]]
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
@@ -173,6 +173,8 @@ resources:
|
||||
is_executable: true
|
||||
- type: "file"
|
||||
path: "setup_logger.py"
|
||||
- type: "file"
|
||||
path: "unzip_archived_folder.py"
|
||||
- type: "file"
|
||||
path: "nextflow_labels.config"
|
||||
dest: "nextflow_labels.config"
|
||||
@@ -303,6 +305,10 @@ engines:
|
||||
github:
|
||||
- "openpipelines-bio/core#subdirectory=packages/python/openpipeline_testutils"
|
||||
upgrade: true
|
||||
- type: "apt"
|
||||
packages:
|
||||
- "zip"
|
||||
interactive: false
|
||||
entrypoint: []
|
||||
cmd: null
|
||||
- type: "native"
|
||||
@@ -314,7 +320,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_xenium_to_spatialdata"
|
||||
executable: "target/nextflow/convert/from_xenium_to_spatialdata/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3251,6 +3251,10 @@ meta = [
|
||||
"type" : "file",
|
||||
"path" : "/src/utils/setup_logger.py"
|
||||
},
|
||||
{
|
||||
"type" : "file",
|
||||
"path" : "/src/utils/unzip_archived_folder.py"
|
||||
},
|
||||
{
|
||||
"type" : "file",
|
||||
"path" : "/src/workflows/utils/labels.config",
|
||||
@@ -3411,6 +3415,13 @@ meta = [
|
||||
"openpipelines-bio/core#subdirectory=packages/python/openpipeline_testutils"
|
||||
],
|
||||
"upgrade" : true
|
||||
},
|
||||
{
|
||||
"type" : "apt",
|
||||
"packages" : [
|
||||
"zip"
|
||||
],
|
||||
"interactive" : false
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -3425,7 +3436,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_xenium_to_spatialdata",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
@@ -3477,6 +3488,7 @@ tempscript=".viash_script.py"
|
||||
cat > "$tempscript" << VIASHMAIN
|
||||
import sys
|
||||
from spatialdata_io import xenium
|
||||
import zipfile
|
||||
|
||||
## VIASH START
|
||||
# The following code has been auto-generated by Viash.
|
||||
@@ -3523,10 +3535,14 @@ dep = {
|
||||
|
||||
sys.path.append(meta["resources_dir"])
|
||||
from setup_logger import setup_logger
|
||||
from unzip_archived_folder import unzip_archived_folder
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
logger.info("Reading in Xenium data...")
|
||||
if zipfile.is_zipfile(par["input"]):
|
||||
par["input"] = unzip_archived_folder(par["input"])
|
||||
|
||||
sdata = xenium(
|
||||
par["input"],
|
||||
cells_boundaries=par["cells_boundaries"],
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import fnmatch
|
||||
import zipfile
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
def unzip_archived_folder(archived_folder: Union[str, Path]) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts a ZIP archive to a temporary directory and returns the path to the extracted folder.
|
||||
|
||||
Args:
|
||||
zip_path (Union[str, Path]): Path to the ZIP archive.
|
||||
|
||||
Returns:
|
||||
extracted_path (Union[str, Path]): Path to the extracted folder inside the temporary directory.
|
||||
"""
|
||||
|
||||
temp_dir = Path(tempfile.TemporaryDirectory().name)
|
||||
with zipfile.ZipFile(archived_folder, "r") as archive:
|
||||
archive.extractall(temp_dir)
|
||||
|
||||
return temp_dir
|
||||
|
||||
|
||||
def extract_selected_files_from_zip(
|
||||
zip_path: Union[str, Path], members: list[Union[str, Path]]
|
||||
) -> Union[str, Path]:
|
||||
"""
|
||||
Extracts selected files (supports glob patterns) from a ZIP archive to a temporary directory.
|
||||
|
||||
Args:
|
||||
zip_path (Union[str, Path]): Path to the ZIP archive.
|
||||
members (list[str]): List of file paths within the archive to extract.
|
||||
|
||||
Returns:
|
||||
Path: Path to the extraction directory.
|
||||
"""
|
||||
|
||||
temp_dir = Path(tempfile.TemporaryDirectory().name)
|
||||
|
||||
with zipfile.ZipFile(zip_path, "r") as archive:
|
||||
all_files = archive.namelist()
|
||||
selected = set()
|
||||
for pattern in members:
|
||||
selected.update(fnmatch.filter(all_files, str(pattern)))
|
||||
for member in selected:
|
||||
archive.extract(member, temp_dir)
|
||||
|
||||
return temp_dir
|
||||
@@ -222,7 +222,7 @@ build_info:
|
||||
output: "target/nextflow/convert/from_xenium_to_spatialexperiment"
|
||||
executable: "target/nextflow/convert/from_xenium_to_spatialexperiment/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3311,7 +3311,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/convert/from_xenium_to_spatialexperiment",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
@@ -227,7 +227,7 @@ build_info:
|
||||
output: "target/nextflow/filter/subset_cosmx"
|
||||
executable: "target/nextflow/filter/subset_cosmx/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3333,7 +3333,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/filter/subset_cosmx",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
@@ -426,7 +426,7 @@ build_info:
|
||||
output: "target/nextflow/mapping/spaceranger_count"
|
||||
executable: "target/nextflow/mapping/spaceranger_count/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
package_config:
|
||||
name: "openpipeline_spatial"
|
||||
|
||||
@@ -3548,7 +3548,7 @@ meta = [
|
||||
"engine" : "docker|native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/mapping/spaceranger_count",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
@@ -640,7 +640,7 @@ build_info:
|
||||
output: "target/nextflow/workflows/multiomics/spatial_process_samples"
|
||||
executable: "target/nextflow/workflows/multiomics/spatial_process_samples/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
dependencies:
|
||||
- "target/dependencies/vsh/vsh/openpipeline/v3.0.0/nextflow/workflows/multiomics/process_samples"
|
||||
|
||||
@@ -3807,7 +3807,7 @@ meta = [
|
||||
"engine" : "native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/workflows/multiomics/spatial_process_samples",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
@@ -387,7 +387,7 @@ build_info:
|
||||
output: "target/nextflow/workflows/qc/spatial_qc"
|
||||
executable: "target/nextflow/workflows/qc/spatial_qc/main.nf"
|
||||
viash_version: "0.9.4"
|
||||
git_commit: "b1bfccbd0edea3f1692c489d0f174f7e494a7341"
|
||||
git_commit: "2cc934cef9746e6befa3e91c82080bc071294628"
|
||||
git_remote: "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
dependencies:
|
||||
- "target/dependencies/vsh/vsh/openpipeline/v3.0.0/nextflow/workflows/qc/qc"
|
||||
|
||||
@@ -3505,7 +3505,7 @@ meta = [
|
||||
"engine" : "native",
|
||||
"output" : "/workdir/root/repo/target/nextflow/workflows/qc/spatial_qc",
|
||||
"viash_version" : "0.9.4",
|
||||
"git_commit" : "b1bfccbd0edea3f1692c489d0f174f7e494a7341",
|
||||
"git_commit" : "2cc934cef9746e6befa3e91c82080bc071294628",
|
||||
"git_remote" : "https://github.com/openpipelines-bio/openpipeline_spatial"
|
||||
},
|
||||
"package_config" : {
|
||||
|
||||
Reference in New Issue
Block a user