aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-19 08:33:50 +0300
committerFrederick Muriuki Muriithi2022-09-19 08:33:50 +0300
commit0ac1cdbaa2aa1a819b2c5f4e28ad26328451e667 (patch)
treef13d55ac834c3141983f6f575008bae758cd7b6b
parent870e1b3f899ba8142ab8c8835d11ac2b2bd203ee (diff)
downloadgenenetwork2-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.py6
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']