diff options
author | Alexander | 2022-05-28 20:15:39 +0300 |
---|---|---|
committer | BonfaceKilz | 2022-06-29 17:41:16 +0300 |
commit | 5d78eddfe974958bb90b3cc84bf8f8a78b568b01 (patch) | |
tree | f03d31d356ed59ff73fc2f72e9521ac9f06f1a22 /gn3/computations | |
parent | 01f1af8f0c7149d8454b68d3cca25b9af50011da (diff) | |
download | genenetwork3-5d78eddfe974958bb90b3cc84bf8f8a78b568b01.tar.gz |
parse output data
Diffstat (limited to 'gn3/computations')
-rw-r--r-- | gn3/computations/rust_correlation.py | 22 |
1 files changed, 21 insertions, 1 deletions
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 |