diff --git a/src/methods/geneformer/config.vsh.yaml b/src/methods/geneformer/config.vsh.yaml index d571a4ad..9624fa07 100644 --- a/src/methods/geneformer/config.vsh.yaml +++ b/src/methods/geneformer/config.vsh.yaml @@ -40,6 +40,7 @@ resources: - type: python_script path: script.py - path: /src/utils/read_anndata_partial.py + - path: /src/utils/exit_codes.py engines: - type: docker diff --git a/src/methods/geneformer/script.py b/src/methods/geneformer/script.py index 01067377..521b8f5c 100644 --- a/src/methods/geneformer/script.py +++ b/src/methods/geneformer/script.py @@ -24,13 +24,14 @@ print(">>> Reading input...", flush=True) sys.path.append(meta["resources_dir"]) from read_anndata_partial import read_anndata +from exit_codes import exit_non_applicable adata = read_anndata(par["input"], X="layers/counts", obs="obs", var="var", uns="uns") if adata.uns["dataset_organism"] != "homo_sapiens": - raise ValueError( + exit_non_applicable( f"Geneformer can only be used with human data " - f"(dataset_organism == '{adata.uns['dataset_organism']}')" + f"(dataset_organism == \"{adata.uns['dataset_organism']}\")" ) # Set adata.var_names to gene IDs diff --git a/src/methods/scgpt/config.vsh.yaml b/src/methods/scgpt/config.vsh.yaml index 263a490b..ad6825c6 100644 --- a/src/methods/scgpt/config.vsh.yaml +++ b/src/methods/scgpt/config.vsh.yaml @@ -45,6 +45,7 @@ resources: - type: python_script path: script.py - path: /src/utils/read_anndata_partial.py + - path: /src/utils/exit_codes.py engines: - type: docker diff --git a/src/methods/scgpt/script.py b/src/methods/scgpt/script.py index dda48777..c6d29ee1 100644 --- a/src/methods/scgpt/script.py +++ b/src/methods/scgpt/script.py @@ -22,17 +22,18 @@ meta = {"name": "scgpt"} ## VIASH END -print(f"====== scGPT version {scgpt.__version__} ======", flush=True) - sys.path.append(meta["resources_dir"]) from read_anndata_partial import read_anndata +from exit_codes import exit_non_applicable + +print(f"====== scGPT version {scgpt.__version__} ======", flush=True) print("\n>>> Reading input files...", flush=True) print(f"Input H5AD file: '{par['input']}'", flush=True) adata = read_anndata(par["input"], X="layers/counts", obs="obs", var="var", uns="uns") if adata.uns["dataset_organism"] != "homo_sapiens": - raise ValueError( + exit_non_applicable( f"scGPT can only be used with human data " f"(dataset_organism == \"{adata.uns['dataset_organism']}\")" ) diff --git a/src/methods/scimilarity/config.vsh.yaml b/src/methods/scimilarity/config.vsh.yaml index 02b6527c..e2f29613 100644 --- a/src/methods/scimilarity/config.vsh.yaml +++ b/src/methods/scimilarity/config.vsh.yaml @@ -21,6 +21,7 @@ resources: - type: python_script path: script.py - path: /src/utils/read_anndata_partial.py + - path: /src/utils/exit_codes.py engines: - type: docker image: openproblems/base_pytorch_nvidia:1.0.0 diff --git a/src/methods/scimilarity/script.py b/src/methods/scimilarity/script.py index 761d59a5..7dd9c57c 100644 --- a/src/methods/scimilarity/script.py +++ b/src/methods/scimilarity/script.py @@ -20,12 +20,13 @@ sys.path.append(meta["resources_dir"]) from read_anndata_partial import read_anndata +from exit_codes import exit_non_applicable print("Read input", flush=True) adata = read_anndata(par["input"], X="layers/counts", obs="obs", var="var", uns="uns") if adata.uns["dataset_organism"] != "homo_sapiens": - raise ValueError( + exit_non_applicable( f"SCimilarity can only be used with human data " f"(dataset_organism == \"{adata.uns['dataset_organism']}\")" ) diff --git a/src/methods/scprint/config.vsh.yaml b/src/methods/scprint/config.vsh.yaml index 12100dfb..ac94288a 100644 --- a/src/methods/scprint/config.vsh.yaml +++ b/src/methods/scprint/config.vsh.yaml @@ -54,6 +54,7 @@ resources: - type: python_script path: script.py - path: /src/utils/read_anndata_partial.py + - path: /src/utils/exit_codes.py engines: - type: docker diff --git a/src/methods/scprint/script.py b/src/methods/scprint/script.py index 6c1d6b96..555776b1 100644 --- a/src/methods/scprint/script.py +++ b/src/methods/scprint/script.py @@ -20,6 +20,7 @@ sys.path.append(meta["resources_dir"]) from read_anndata_partial import read_anndata +from exit_codes import exit_non_applicable print(f"====== scPRINT version {scprint.__version__} ======", flush=True) @@ -30,7 +31,7 @@ elif input.uns["dataset_organism"] == "mus_musculus": input.obs["organism_ontology_term_id"] = "NCBITaxon:10090" else: - raise ValueError( + exit_non_applicable( f"scPRINT requires human or mouse data, not '{input.uns['dataset_organism']}'" ) adata = input.copy() diff --git a/src/methods/uce/config.vsh.yaml b/src/methods/uce/config.vsh.yaml index 2301ef51..3b3a3206 100644 --- a/src/methods/uce/config.vsh.yaml +++ b/src/methods/uce/config.vsh.yaml @@ -28,6 +28,7 @@ resources: - type: python_script path: script.py - path: /src/utils/read_anndata_partial.py + - path: /src/utils/exit_codes.py engines: - type: docker diff --git a/src/methods/uce/script.py b/src/methods/uce/script.py index 24108a94..3cae8459 100644 --- a/src/methods/uce/script.py +++ b/src/methods/uce/script.py @@ -46,6 +46,7 @@ print(">>> Reading input...", flush=True) sys.path.append(meta["resources_dir"]) from read_anndata_partial import read_anndata +from exit_codes import exit_non_applicable adata = read_anndata(par["input"], X="layers/counts", obs="obs", var="var", uns="uns") @@ -54,7 +55,7 @@ elif adata.uns["dataset_organism"] == "mus_musculus": species = "mouse" else: - raise ValueError(f"Species '{adata.uns['dataset_organism']}' not yet implemented") + exit_non_applicable(f"Species '{adata.uns['dataset_organism']}' not yet implemented") print("\n>>> Creating working directory...", flush=True) work_dir = tempfile.TemporaryDirectory() diff --git a/src/utils/exit_codes.py b/src/utils/exit_codes.py new file mode 100644 index 00000000..03f270c3 --- /dev/null +++ b/src/utils/exit_codes.py @@ -0,0 +1,6 @@ +import sys + + +def exit_non_applicable(msg): + print(f"NON-APPLICABLE ERROR: {msg}", flush=True) + sys.exit(99)