aboutsummaryrefslogtreecommitdiff
path: root/uploader/expression_data
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-09-24 15:36:21 -0500
committerFrederick Muriuki Muriithi2024-09-24 15:36:21 -0500
commitb2d3883bbb1b75b8a55aa26fafef7302a5781fd6 (patch)
tree1187f92cd32c5987fc4ad4ed41f3d4a9ba6b7d6d /uploader/expression_data
parent779ae32ad811b39f38d4b5adf14c71a7a5c8c60e (diff)
downloadgn-uploader-b2d3883bbb1b75b8a55aa26fafef7302a5781fd6.tar.gz
Use function from `uploader.platforms` package
Reuse the function from the `uploader.platforms.models` module. This reduces duplication, and also helps with ensuring robustness of the code — the function actually checks to ensure the platform relates to the selected species.
Diffstat (limited to 'uploader/expression_data')
-rw-r--r--uploader/expression_data/dbinsert.py11
1 files changed, 2 insertions, 9 deletions
diff --git a/uploader/expression_data/dbinsert.py b/uploader/expression_data/dbinsert.py
index b30f730..e746944 100644
--- a/uploader/expression_data/dbinsert.py
+++ b/uploader/expression_data/dbinsert.py
@@ -15,6 +15,7 @@ from uploader import jobs
from uploader.authorisation import require_login
from uploader.population.models import populations_by_species
from uploader.species.models import all_species, species_by_id
+from uploader.platforms.models import platform_by_species_and_id
from uploader.db_utils import with_db_connection, database_connection
dbinsertbp = Blueprint("dbinsert", __name__)
@@ -48,14 +49,6 @@ def genechips():
return {}
-def platform_by_id(genechipid:int) -> Union[dict, None]:
- "Retrieve the gene platform by id"
- with database_connection(app.config["SQL_URI"]) as conn:
- with conn.cursor(cursorclass=DictCursor) as cursor:
- cursor.execute(
- "SELECT * FROM GeneChip WHERE GeneChipId=%s",
- (genechipid,))
- return cursor.fetchone()
def studies_by_species_and_platform(speciesid:int, genechipid:int) -> tuple:
"Retrieve the studies by the related species and gene platform"
@@ -347,7 +340,7 @@ def final_confirmation():
with_db_connection(lambda conn: species_by_id(conn, speciesid)),
("SpeciesName", "Name", "MenuName")),
platform=selected_keys(
- platform_by_id(genechipid),
+ platform_by_species_and_id(speciesid, genechipid),
("GeneChipName", "Name", "GeoPlatform", "Title", "GO_tree_value")),
study=selected_keys(
study_by_id(studyid), ("Name", "FullName", "ShortName")),