aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2021-11-26 11:52:37 +0300
committerFrederick Muriuki Muriithi2021-11-29 12:05:16 +0300
commit0f9247fffc7127bdb3c35492a37706a2db01a26c (patch)
tree129a5c70839e592b4750ed05621654b7521fe826
parentee200d60bd3065c4c9e69bcbb756715211b711d2 (diff)
downloadgenenetwork3-0f9247fffc7127bdb3c35492a37706a2db01a26c.tar.gz
Update return type
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/partial-correlations.gmi * Return the complete filename when found, or the boolean value False, when it is not found.
-rw-r--r--gn3/db/correlations.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/gn3/db/correlations.py b/gn3/db/correlations.py
index 05c0809..ab4dc2c 100644
--- a/gn3/db/correlations.py
+++ b/gn3/db/correlations.py
@@ -2,7 +2,7 @@
This module will hold functions that are used in the (partial) correlations
feature to access the database to retrieve data needed for computations.
"""
-
+import os
from functools import reduce
from typing import Any, Dict, Tuple, Union
@@ -28,11 +28,13 @@ def get_filename(conn: Any, target_db_name: str, text_files_dir: str) -> Union[
(target_db_name,))
result = cursor.fetchone()
if result:
- return "ProbeSetFreezeId_{tid}_FullName_{fname}.txt".format(
+ filename = "ProbeSetFreezeId_{tid}_FullName_{fname}.txt".format(
tid=result[0],
fname=result[1].replace(' ', '_').replace('/', '_'))
+ return ((filename in os.listdir(text_file_dir))
+ and f"{text_files_dir}/{filename}")
- return ""
+ return False
def build_temporary_literature_table(
conn: Any, species: str, gene_id: int, return_number: int) -> str: