From aaff8b8ac968bce9821d6fef22b1296247a9df09 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 24 Feb 2022 13:46:34 +0530 Subject: gn3: Explicitly specify UTF-8 to be the file encoding. When the encoding is not specified explicitly, the system default encoding is used. This is not recommended. * gn3/computations/ctl.py (call_ctl_script), gn3/computations/gemma.py (generate_pheno_txt_file), gn3/computations/parsers.py (parse_genofile), gn3/computations/partial_correlations.py (partial_correlations_fast), gn3/computations/rqtl.py (process_rqtl_output, process_perm_output), gn3/computations/wgcna.py (dump_wgcna_data, call_wgcna_script), gn3/fs_helpers.py (jsonfile_to_dict): Explicitly specify UTF-8 to be the file encoding. * tests/unit/computations/test_gemma.py (TestGemma.test_generate_pheno_txt_file), tests/unit/computations/test_wgcna.py (TestWgcna.test_create_json_file): Test for call to open with encoding='utf-8' argument. --- gn3/computations/rqtl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gn3/computations/rqtl.py') diff --git a/gn3/computations/rqtl.py b/gn3/computations/rqtl.py index 0433b3f..b3539a9 100644 --- a/gn3/computations/rqtl.py +++ b/gn3/computations/rqtl.py @@ -56,7 +56,7 @@ def process_rqtl_output(file_name: str) -> List: # Later I should probably redo this using csv.read to avoid the # awkwardness with removing quotes with [1:-1] with open(os.path.join(current_app.config.get("TMPDIR", "/tmp"), - "output", file_name), "r") as the_file: + "output", file_name), "r", encoding="utf-8") as the_file: for line in the_file: line_items = line.split(",") if line_items[1][1:-1] == "chr" or not line_items: @@ -88,7 +88,7 @@ def process_perm_output(file_name: str): """ perm_results = [] with open(os.path.join(current_app.config.get("TMPDIR", "/tmp"), - "output", "PERM_" + file_name), "r") as the_file: + "output", "PERM_" + file_name), "r", encoding="utf-8") as the_file: for i, line in enumerate(the_file): if i == 0: # Skip header line -- cgit v1.2.3