about summary refs log tree commit diff
path: root/uploader/phenotypes/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'uploader/phenotypes/models.py')
-rw-r--r--uploader/phenotypes/models.py42
1 files changed, 7 insertions, 35 deletions
diff --git a/uploader/phenotypes/models.py b/uploader/phenotypes/models.py
index e962e62..a22497c 100644
--- a/uploader/phenotypes/models.py
+++ b/uploader/phenotypes/models.py
@@ -255,9 +255,9 @@ def phenotypes_vector_data(# pylint: disable=[too-many-arguments, too-many-posit
         xref_ids: tuple[int, ...] = tuple(),
         offset: int = 0,
         limit: Optional[int] = None
-) -> dict[tuple[int, int, int]: dict[str, Union[int,float]]]:
+) -> dict[tuple[int, int, int], dict[str, Union[int,float]]]:
     """Retrieve the vector data values for traits in the database."""
-    _params = (species_id, population_id)
+    _params: tuple[int, ...] = (species_id, population_id)
     _query = ("SELECT "
               "Species.Id AS SpeciesId, iset.Id AS InbredSetId, "
               "pxr.Id AS xref_id, pdata.*, Strain.Id AS StrainId, "
@@ -328,35 +328,6 @@ def save_new_dataset(cursor: Cursor,
     return {**params, "Id": cursor.lastrowid}
 
 
-def phenotypes_data_by_ids(
-        conn: mdb.Connection,
-        inbred_pheno_xref: dict[str, int]
-) -> tuple[dict, ...]:
-    """Fetch all phenotype data, filtered by the `inbred_pheno_xref` mapping."""
-    _paramstr = ",".join(["(%s, %s, %s)"] * len(inbred_pheno_xref))
-    _query = ("SELECT "
-              "pub.PubMed_ID, pheno.*, pxr.*, pd.*, str.*, iset.InbredSetCode "
-              "FROM Publication AS pub "
-              "RIGHT JOIN PublishXRef AS pxr0 ON pub.Id=pxr0.PublicationId "
-              "INNER JOIN Phenotype AS pheno ON pxr0.PhenotypeId=pheno.id "
-              "INNER JOIN PublishXRef AS pxr ON pheno.Id=pxr.PhenotypeId "
-              "INNER JOIN PublishData AS pd ON pxr.DataId=pd.Id "
-              "INNER JOIN Strain AS str ON pd.StrainId=str.Id "
-              "INNER JOIN StrainXRef AS sxr ON str.Id=sxr.StrainId "
-              "INNER JOIN PublishFreeze AS pf ON sxr.InbredSetId=pf.InbredSetId "
-              "INNER JOIN InbredSet AS iset ON pf.InbredSetId=iset.InbredSetId "
-              f"WHERE (pxr.InbredSetId, pheno.Id, pxr.Id) IN ({_paramstr}) "
-              "ORDER BY pheno.Id")
-    with conn.cursor(cursorclass=DictCursor) as cursor:
-        cursor.execute(_query, tuple(item for row in inbred_pheno_xref
-                                     for item in (row["population_id"],
-                                                  row["phenoid"],
-                                                  row["xref_id"])))
-        debug_query(cursor, logger)
-        return tuple(
-            reduce(__organise_by_phenotype__, cursor.fetchall(), {}).values())
-
-
 def __pre_process_phenotype_data__(row):
     _desc = row.get("description", "")
     _pre_pub_desc = row.get("pre_publication_description", _desc)
@@ -381,7 +352,7 @@ def create_new_phenotypes(# pylint: disable=[too-many-locals]
         phenotypes: Iterable[dict]
 ) -> tuple[dict, ...]:
     """Add entirely new phenotypes to the database. WARNING: Not thread-safe."""
-    _phenos = tuple()
+    _phenos: tuple[dict, ...] = tuple()
     with conn.cursor(cursorclass=DictCursor) as cursor:
         def make_next_id(idcol, table):
             cursor.execute(f"SELECT MAX({idcol}) AS last_id FROM {table}")
@@ -430,9 +401,10 @@ def create_new_phenotypes(# pylint: disable=[too-many-locals]
             if len(batch) == 0:
                 break
 
-            params, abbrevs = reduce(__build_params_and_prepubabbrevs__,
-                                     batch,
-                                     (tuple(), tuple()))
+            params, abbrevs = reduce(#type: ignore[var-annotated]
+                __build_params_and_prepubabbrevs__,
+                batch,
+                (tuple(), tuple()))
             # Check for uniqueness for all "Pre_publication_description" values
             abbrevs_paramsstr = ", ".join(["%s"] * len(abbrevs))
             _query = ("SELECT PublishXRef.PhenotypeId, Phenotype.* "