From a63b5b1f694f3f4624f791c534502a9451394d16 Mon Sep 17 00:00:00 2001 From: Kevin Mo Date: Fri, 19 Apr 2024 16:59:42 -0400 Subject: [PATCH] Fix bug with adding primers to database --- src/primer-design/web/ajaxCalls/addPrimers.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/primer-design/web/ajaxCalls/addPrimers.py b/src/primer-design/web/ajaxCalls/addPrimers.py index 95ee7b3..2372d17 100755 --- a/src/primer-design/web/ajaxCalls/addPrimers.py +++ b/src/primer-design/web/ajaxCalls/addPrimers.py @@ -43,21 +43,25 @@ def addToDatabase(dbConnection, geneName, release, primerPairs): """ import fetchEnsemblRelease + release_num = release ens_release_num = fetchEnsemblRelease.getRelease() - fileFound = False - while not fileFound: - if int(release) > int(ens_release_num): - print("Unable to find " + primerType + " file") - return - json_filename = geneName + "_" + release + "_" - path = os.path.join( + path = None + + while int(release_num) <= int(ens_release_num): + json_filename = geneName + "_" + release_num + "_" + release_path = os.path.join( jsonDir, (json_filename + primerType + "-" + str(primerPairs[key]) + ".json"), ) - if os.path.isfile(path): - fileFound = True - else: - release = str(int(release) + 1) + + if os.path.isfile(release_path): + path = release_path + + release_num = str(int(release_num) + 1) + + if not path: + print("Unable to find " + primerType + " file") + return with open((path), "r") as primerJSON: primerRecord = json.load(primerJSON)