diff options
author | Pjotr Prins | 2024-04-03 13:31:43 +0200 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-09-12 07:42:03 -0500 |
commit | de5a77cb18401c761760a0dc4af6104c0b2be9dd (patch) | |
tree | 2fc2485833973cbc06353f9549aed4c83c62be73 /gn3 | |
parent | 4dd2ab8da310a34e598553ef951d3233ded9d1ab (diff) | |
download | genenetwork3-de5a77cb18401c761760a0dc4af6104c0b2be9dd.tar.gz |
From gn3 only use TMPDIR/gn3 paths
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/computations/gemma.py | 13 | ||||
-rw-r--r-- | 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): |