aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander_Kabui2022-07-08 13:23:10 +0300
committerBonfaceKilz2022-07-22 14:52:08 +0300
commit3b6b25ab0c0410db9cb32c787b87e1a60dc02803 (patch)
tree65bbf9539c81ac21288d008a7c1cfbaa0529b72f
parent7b95327210c45e289e0a2420228aeac02feb216b (diff)
downloadgenenetwork3-3b6b25ab0c0410db9cb32c787b87e1a60dc02803.tar.gz
minor fixes for parsing data
-rw-r--r--gn3/computations/rust_correlation.py42
1 files changed, 23 insertions, 19 deletions
diff --git a/gn3/computations/rust_correlation.py b/gn3/computations/rust_correlation.py
index 9f991b2..d206065 100644
--- a/gn3/computations/rust_correlation.py
+++ b/gn3/computations/rust_correlation.py
@@ -57,7 +57,7 @@ def generate_json_file(tmp_dir, tmp_file,
def run_correlation(dataset, trait_vals:
- list[str],
+ str,
method: str,
delimiter: str):
"""entry function to call rust correlation"""
@@ -84,6 +84,10 @@ def parse_correlation_output(result_file: str, top_n: int = 500) -> list[dict]:
corr_results = []
+ breakpoint()
+
+
+
with open(result_file, "r", encoding="utf-8") as file_reader:
lines = [next(file_reader) for x in range(top_n)]
@@ -120,7 +124,7 @@ def get_samples(all_samples: dict[str, str],
return data
- return({key: float(val) for (key, val) in all_samples.items()
+ return({key: float(val.strip()) for (key, val) in all_samples.items()
if key not in excluded and val.lower().strip() != "x"})
@@ -145,26 +149,26 @@ def get_sample_corr_data(sample_type: str,
return data
-def parse_tissue_corr_data(tt_symbol: list[dict[str, str]],
- symbols_dict: [str, str],
- dataset_dict):
- """get the correct datatype"""
+def parse_tissue_corr_data(symbol_name: str,
+ symbol_dict: dict[list[str, list[str]]],
+ dataset_symbols: dict[str, str],
+ dataset_vals: dict[str, list[str, str]]):
+
+ if symbol_name and symbol_name.lower() in symbol_dict:
+ x_vals = ",".join([str(val)
+ for val in symbol_dict[symbol_name.lower()]])
- data = []
+ data = []
- if not (tt_symbol):
- return [[], []]
+ for (trait, symbol) in dataset_symbols.items():
+ try:
+ corr_vals = dataset_vals.get(symbol.lower())
- for (name, symbol) in symbols_dict.items():
- try:
- exists = dataset_dict.get(symbol.lower())
- if exists:
- corr_values = insert(0, name)
- ",".join([str(dt) for dt in data])
+ corr_vals.insert(0, trait)
- data.append(corr_values)
+ data.append(",".join([str(val) for val in corr_vals]))
- except Exception as e:
- pass
+ except Exception as e:
+ pass
- return [symbol[0], data]
+ return (x_vals, data)