aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-01-05 09:43:41 +0300
committerFrederick Muriuki Muriithi2022-01-10 08:33:19 +0300
commita7f5d93bec04b9142c8a14fb17a5059f069c6326 (patch)
tree39475af40f2b2830cbb464bc234fc0b1b9d9fdc1
parent66310d955b2543c3f76ad2429b84c80bb9184f38 (diff)
downloadgenenetwork3-a7f5d93bec04b9142c8a14fb17a5059f069c6326.tar.gz
Check for path existence
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi
-rw-r--r--gn3/db/correlations.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/gn3/db/correlations.py b/gn3/db/correlations.py
index 5361a1e..d372607 100644
--- a/gn3/db/correlations.py
+++ b/gn3/db/correlations.py
@@ -29,8 +29,11 @@ def get_filename(conn: Any, target_db_name: str, text_files_dir: str) -> Union[
filename = "ProbeSetFreezeId_{tid}_FullName_{fname}.txt".format(
tid=result[0],
fname=result[1].replace(' ', '_').replace('/', '_'))
- return ((filename in os.listdir(text_files_dir))
- and f"{text_files_dir}/{filename}")
+ full_filename = f"{text_files_dir}/{filename}"
+ return (
+ os.path.exists(full_filename) and
+ (filename in os.listdir(text_files_dir)) and
+ full_filename)
return False