diff options
author | Frederick Muriuki Muriithi | 2024-09-24 15:36:21 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-09-24 15:36:21 -0500 |
commit | b2d3883bbb1b75b8a55aa26fafef7302a5781fd6 (patch) | |
tree | 1187f92cd32c5987fc4ad4ed41f3d4a9ba6b7d6d | |
parent | 779ae32ad811b39f38d4b5adf14c71a7a5c8c60e (diff) | |
download | gn-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.
-rw-r--r-- | uploader/expression_data/dbinsert.py | 11 |
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")), |