From 6ca2c1520b1fc6e1472fbc74994e3e136cacdc71 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 30 Sep 2024 16:54:28 -0500 Subject: BugFix: Ensure all data items show up. --- uploader/phenotypes/models.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py index eb5a189..be970ac 100644 --- a/uploader/phenotypes/models.py +++ b/uploader/phenotypes/models.py @@ -78,7 +78,7 @@ def __phenotype_se__(cursor: Cursor, xref_id: str) -> dict: """Fetch standard-error values (if they exist) for a phenotype.""" _sequery = ( - "SELECT pxr.Id AS xref_id, pxr.DataId, pse.error, nst.count " + "SELECT pxr.Id AS xref_id, pxr.DataId, str.Id AS StrainId, pse.error, nst.count " "FROM Phenotype AS pheno " "INNER JOIN PublishXRef AS pxr ON pheno.Id=pxr.PhenotypeId " "INNER JOIN PublishSE AS pse ON pxr.DataId=pse.DataId " @@ -90,7 +90,12 @@ def __phenotype_se__(cursor: Cursor, "WHERE (str.SpeciesId, pxr.InbredSetId, pf.Id, pxr.Id)=(%s, %s, %s, %s)") cursor.execute(_sequery, (species_id, population_id, dataset_id, xref_id)) - return {row["xref_id"]: dict(row) for row in cursor.fetchall()} + return {(row["DataId"], row["StrainId"]): { + "xref_id": row["xref_id"], + "DataId": row["DataId"], + "error": row["error"], + "count": row["count"] + } for row in cursor.fetchall()} def __organise_by_phenotype__(pheno, row): """Organise disparate data rows into phenotype 'objects'.""" @@ -105,11 +110,10 @@ def __organise_by_phenotype__(pheno, row): "Units": row["Units"], "Pre_publication_abbreviation": row["Pre_publication_abbreviation"], "Post_publication_abbreviation": row["Post_publication_abbreviation"], + "xref_id": row["pxr.Id"], "data": { - #TOD0: organise these by DataId and StrainId **(_pheno["data"] if bool(_pheno) else {}), - row["pxr.Id"]: { - "xref_id": row["pxr.Id"], + (row["DataId"], row["StrainId"]): { "DataId": row["DataId"], "mean": row["mean"], "Locus": row["Locus"], @@ -168,7 +172,7 @@ def phenotype_by_id( species_id, population_id, dataset_id, - xref_id)).items()) + xref_id)).values()) } if bool(_pheno) and len(_pheno.keys()) > 1: raise Exception( -- cgit v1.2.3