diff options
author | Frederick Muriuki Muriithi | 2022-09-19 08:33:50 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-09-19 08:33:50 +0300 |
commit | 0ac1cdbaa2aa1a819b2c5f4e28ad26328451e667 (patch) | |
tree | f13d55ac834c3141983f6f575008bae758cd7b6b | |
parent | 870e1b3f899ba8142ab8c8835d11ac2b2bd203ee (diff) | |
download | genenetwork2-0ac1cdbaa2aa1a819b2c5f4e28ad26328451e667.tar.gz |
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.
-rw-r--r-- | wqflask/wqflask/marker_regression/gemma_mapping.py | 6 |
1 files changed, 5 insertions, 1 deletions
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'] |