From 0f9247fffc7127bdb3c35492a37706a2db01a26c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Fri, 26 Nov 2021 11:52:37 +0300 Subject: 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. --- gn3/db/correlations.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gn3/db/correlations.py') 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: -- cgit v1.2.3