aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-29 04:22:29 +0300
committerFrederick Muriuki Muriithi2022-09-29 04:22:29 +0300
commit495e02be4e3264c07e4ae89ccd2bc747bf2b6b59 (patch)
treec48b9a845fe2df07786aceec51535fe77f28f991
parentec36837e51b33ce771f50ab8937d0fc3d189d556 (diff)
downloadgenenetwork2-495e02be4e3264c07e4ae89ccd2bc747bf2b6b59.tar.gz
Remove empty rows, and conversion for output
Remove any rows that do not have values since they are not useful to the computations and only lead to errors. Remove the conversion to output format here: only convert the values for output at the point of output, and not earlier.
-rw-r--r--wqflask/wqflask/correlation/rust_correlation.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/wqflask/wqflask/correlation/rust_correlation.py b/wqflask/wqflask/correlation/rust_correlation.py
index d9193459..8d32aaba 100644
--- a/wqflask/wqflask/correlation/rust_correlation.py
+++ b/wqflask/wqflask/correlation/rust_correlation.py
@@ -250,11 +250,15 @@ def __compute_sample_corr__(
target_dataset.get_trait_data(list(sample_data.keys()))
- target_data = []
- for (key, val) in target_dataset.trait_data.items():
- lts = [key] + [str(x) for x in val if x is not None]
- r = ",".join(lts)
- target_data.append(r)
+
+ def __merge_key_and_values__(rows, current):
+ wo_nones = [value for value in current[1] if value is not None]
+ if len(wo_nones) > 0:
+ return rows + [[current[0]] + wo_nones]
+ return rows
+
+ target_data = reduce(
+ __merge_key_and_values__, target_dataset.trait_data.items(), [])
if len(target_data) == 0:
return {}