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,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
|
||||
Reference in New Issue
Block a user