From 5d78eddfe974958bb90b3cc84bf8f8a78b568b01 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 28 May 2022 20:15:39 +0300 Subject: parse output data --- gn3/computations/rust_correlation.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'gn3/computations') diff --git a/gn3/computations/rust_correlation.py b/gn3/computations/rust_correlation.py index a3802ae..e739382 100644 --- a/gn3/computations/rust_correlation.py +++ b/gn3/computations/rust_correlation.py @@ -4,10 +4,30 @@ from gn3.settings import CORRELATION_COMMAND from gn3.settings import TMPDIR -def run_correlation(file_name: & str, outputdir: str = TMPDIR): +def run_correlation(file_name: str, outputdir: str = TMPDIR): command_list = [CORRELATION_COMMAND, file_name, outputdir] results = subprocess.run(command_list, check=True) return results + + +def parse_correlation_output(result_file: str): + + corr_results = [] + + with open(result_file, "r") as file_reader: + + for line in file_reader: + + (trait_name, corr_coeff, p_val) = line.rstrip().split(",") + corr_data = { + "trait_name": trait_name, + "corr_coeff": corr_coeff, + "p_val": p_val + } + + corr_results.append(corr_data) + + return corr_results -- cgit v1.2.3