From 0ac1cdbaa2aa1a819b2c5f4e28ad26328451e667 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 19 Sep 2022 08:33:50 +0300 Subject: Check for file size before attempting parsing Empty files lead to json encoding errors; this commit checks whether the file is empty before attempting to parse the file. --- wqflask/wqflask/marker_regression/gemma_mapping.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 8adca6e5..3bf9fdd5 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -183,8 +183,12 @@ def gen_covariates_file(this_dataset, covariates, samples): def parse_loco_output(this_dataset, gwa_output_filename, loco="True"): + output_filename = f"{TEMPDIR}/gn2/{gwa_output_filename}.json" + if os.stat(output_filename).st_size == 0: + return {} + output_filelist = [] - with open(f"{TEMPDIR}/gn2/{gwa_output_filename}.json") as data_file: + with open(output_filename) as data_file: data = json.load(data_file) files = data['files'] -- cgit v1.2.3