aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-08-11 08:12:54 +0300
committerFrederick Muriuki Muriithi2022-08-11 08:12:54 +0300
commit8658545c99a576229f9263414f5557545500f4a1 (patch)
treec14312631d94e336146e9d81c0ac397221d4b03e /wqflask
parent90195f350758902cecbd184bfa500eac2a39a263 (diff)
downloadgenenetwork2-8658545c99a576229f9263414f5557545500f4a1.tar.gz
Check for keys before using them.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/correlation/show_corr_results.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py
index 1c391386..988910c3 100644
--- a/wqflask/wqflask/correlation/show_corr_results.py
+++ b/wqflask/wqflask/correlation/show_corr_results.py
@@ -121,9 +121,12 @@ def correlation_json_for_table(correlation_data, this_trait, this_dataset, targe
results_dict['dataset'] = target_dataset['name']
results_dict['hmac'] = hmac.data_hmac(
'{}:{}'.format(target_trait['name'], target_dataset['name']))
- results_dict['sample_r'] = f"{float(trait['corr_coefficient']):.3f}"
- results_dict['num_overlap'] = trait['num_overlap']
- results_dict['sample_p'] = f"{float(trait['p_value']):.3e}"
+ if "corr_coefficient" in trait:
+ results_dict['sample_r'] = f"{float(trait['corr_coefficient']):.3f}"
+ if "num_overlap" in trait:
+ results_dict['num_overlap'] = trait['num_overlap']
+ if "p_value" in trait:
+ results_dict['sample_p'] = f"{float(trait['p_value']):.3e}"
if target_dataset['type'] == "ProbeSet":
results_dict['symbol'] = target_trait['symbol']
results_dict['description'] = "N/A"