From 0d365ddd4e579674faefe17ce2e0fc372e6aeeee Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 29 Sep 2022 04:27:20 +0300 Subject: Use the built-in csv module for file output Use the built-in csv module for file output in order to avoid subtle errors in the formats. --- gn3/computations/rust_correlation.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gn3/computations/rust_correlation.py b/gn3/computations/rust_correlation.py index 7176284..d34b3bc 100644 --- a/gn3/computations/rust_correlation.py +++ b/gn3/computations/rust_correlation.py @@ -6,6 +6,7 @@ https://github.com/Alexanderlacuna/correlation_rust import subprocess import json +import csv import os from gn3.computations.qtlreaper import create_output_directory @@ -20,8 +21,11 @@ def generate_input_files(dataset: list[str], tmp_dir = f"{output_dir}/correlation" create_output_directory(tmp_dir) tmp_file = os.path.join(tmp_dir, f"{random_string(10)}.txt") - with open(tmp_file, "w", encoding="utf-8") as file_writer: - file_writer.write("\n".join(dataset)) + with open(tmp_file, "w", encoding="utf-8") as op_file: + writer = csv.writer( + op_file, delimiter=",", dialect="unix", quotechar="", + quoting=csv.QUOTE_NONE) + writer.writerows(dataset) return (tmp_dir, tmp_file) -- cgit v1.2.3