aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-29 04:27:20 +0300
committerFrederick Muriuki Muriithi2022-09-29 04:27:20 +0300
commit0d365ddd4e579674faefe17ce2e0fc372e6aeeee (patch)
tree95803cfde1e54afbe15af942977a0c1121ee5261 /gn3
parent1e1c9d8178141469af2ca88a971a13233e88f3a8 (diff)
downloadgenenetwork3-0d365ddd4e579674faefe17ce2e0fc372e6aeeee.tar.gz
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.
Diffstat (limited to 'gn3')
-rw-r--r--gn3/computations/rust_correlation.py8
1 files 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)