From de5a77cb18401c761760a0dc4af6104c0b2be9dd Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Wed, 3 Apr 2024 13:31:43 +0200 Subject: From gn3 only use TMPDIR/gn3 paths --- gn3/computations/gemma.py | 13 +++++++------ gn3/computations/rqtl.py | 6 ------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/gn3/computations/gemma.py b/gn3/computations/gemma.py index 2c367ff..577d8e8 100644 --- a/gn3/computations/gemma.py +++ b/gn3/computations/gemma.py @@ -22,23 +22,24 @@ def generate_pheno_txt_file(trait_filename: str, values: List, tmpdir: str = "/tmp") -> str: """Given VALUES, and TMPDIR, generate a valid traits file""" - if not os.path.isdir(f"{tmpdir}/gn2/"): - os.mkdir(f"{tmpdir}/gn2/") + + if not os.path.isdir(f"{tmpdir}/gn3/"): + os.mkdir(f"{tmpdir}/gn3/") ext = trait_filename.partition(".")[-1] if ext: trait_filename = trait_filename.replace(f".{ext}", "") ext = f".{ext}" trait_filename += f"_{generate_hash_of_string(''.join(values))}{ext}" # Early return if this already exists! - if os.path.isfile(f"{tmpdir}/gn2/{trait_filename}"): - return f"{tmpdir}/gn2/{trait_filename}" - with open(f"{tmpdir}/gn2/{trait_filename}", "w", encoding="utf-8") as _file: + if os.path.isfile(f"{tmpdir}/gn3/{trait_filename}"): + return f"{tmpdir}/gn3/{trait_filename}" + with open(f"{tmpdir}/gn3/{trait_filename}", "w", encoding="utf-8") as _file: for value in values: if value == "x": _file.write("NA\n") else: _file.write(f"{value}\n") - return f"{tmpdir}/gn2/{trait_filename}" + return f"{tmpdir}/gn3/{trait_filename}" # pylint: disable=R0913 diff --git a/gn3/computations/rqtl.py b/gn3/computations/rqtl.py index 589caa4..0b8c23d 100644 --- a/gn3/computations/rqtl.py +++ b/gn3/computations/rqtl.py @@ -69,8 +69,6 @@ def process_rqtl_mapping(file_name: str) -> List: # Later I should probably redo this using csv.read to avoid the # awkwardness with removing quotes with [1:-1] outdir = os.path.join(get_tmpdir(),"gn3") - if not os.path.isdir(outdir): - os.mkdir(outdir) with open( os.path.join(outdir,file_name),"r",encoding="utf-8") as the_file: for line in the_file: @@ -114,8 +112,6 @@ def pairscan_for_figure(file_name: str) -> Dict: # Open the file with the actual results, written as a list of lists outdir = os.path.join(get_tmpdir(),"gn3") - if not os.path.isdir(outdir): - os.mkdir(outdir) with open( os.path.join(outdir,file_name),"r",encoding="utf-8") as the_file: lod_results = [] @@ -319,8 +315,6 @@ def process_perm_output(file_name: str) -> Tuple[List, float, float]: perm_results = [] outdir = os.path.join(get_tmpdir(),"gn3") - if not os.path.isdir(outdir): - os.mkdir(outdir) with open( os.path.join(outdir,file_name),"r",encoding="utf-8") as the_file: for i, line in enumerate(the_file): -- cgit v1.2.3