From ab71b34b97f3f1eee52b5688f41644541535f281 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 5 Feb 2024 07:00:01 +0300 Subject: Do general bundle validation and show errors * Display any and all errors on the UI * Move `validate_bundle` to QC module and refactor to use `missing_files` --- r_qtl/r_qtl2_qc.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'r_qtl/r_qtl2_qc.py') diff --git a/r_qtl/r_qtl2_qc.py b/r_qtl/r_qtl2_qc.py index f666f40..261d300 100644 --- a/r_qtl/r_qtl2_qc.py +++ b/r_qtl/r_qtl2_qc.py @@ -3,6 +3,7 @@ from zipfile import ZipFile from functools import reduce from typing import Union, Sequence +from r_qtl import errors as rqe from r_qtl import r_qtl2 as rqtl2 from r_qtl.r_qtl2 import __FILE_TYPES__ @@ -45,3 +46,11 @@ def missing_files(zfile: ZipFile) -> tuple[str]: return tuple(filter(__missing_p__, bundle_files_list(zfile, rqtl2.control_data(zfile)))) + +def validate_bundle(zfile: ZipFile): + """Ensure the R/qtl2 bundle is valid.""" + missing = missing_files(zfile) + if len(missing) > 0: + raise rqe.MissingFileError( + "The following files do not exist in the bundle: " + + ", ".join(missing)) -- cgit v1.2.3