From 967eefd5c22281cb53d055f9304993fa988e2eb2 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 1 Mar 2022 12:21:17 +0300 Subject: Fetch InbredSetId * gn3/db/sample_data.py (get_sample_data_ids): Extend to also fetch InbredSetId. (update_sample_data): Discard the returned value of InbredSetId. (delete_sample_data): Ditto. --- gn3/db/sample_data.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'gn3') diff --git a/gn3/db/sample_data.py b/gn3/db/sample_data.py index 49a04d3..a6caa8d 100644 --- a/gn3/db/sample_data.py +++ b/gn3/db/sample_data.py @@ -53,11 +53,12 @@ def get_trait_csv_sample_data(conn: Any, def get_sample_data_ids(conn: Any, publishxref_id: int, - phenotype_id: int, - strain_name: str) -> Tuple: - strain_id, publishdata_id = None, None + phenotype_id: int, + strain_name: str) -> Tuple: + strain_id, publishdata_id, inbredset_id = None, None, None with conn.cursor() as cursor: - cursor.execute("SELECT st.id, pd.Id FROM PublishData pd " + cursor.execute("SELECT st.id, pd.Id, pf.InbredSetId " + "FROM PublishData pd " "JOIN Strain st ON pd.StrainId = st.Id " "JOIN PublishXRef px ON px.DataId = pd.Id " "JOIN PublishFreeze pf ON pf.InbredSetId " @@ -65,8 +66,8 @@ def get_sample_data_ids(conn: Any, publishxref_id: int, "AND px.PhenotypeId = %s AND st.Name = %s", (publishxref_id, phenotype_id, strain_name)) if _result := cursor.fetchone(): - strain_id, publishdata_id = _result - return (strain_id, publishdata_id) + strain_id, publishdata_id, inbredset_id = _result + return (strain_id, publishdata_id, inbredset_id) def update_sample_data(conn: Any, # pylint: disable=[R0913] @@ -78,7 +79,7 @@ def update_sample_data(conn: Any, # pylint: disable=[R0913] count: Union[int, str]): """Given the right parameters, update sample-data from the relevant table.""" - strain_id, data_id = get_sample_data_ids( + strain_id, data_id, _ = get_sample_data_ids( conn=conn, publishxref_id=trait_name, phenotype_id=phenotype_id, strain_name=strain_name) @@ -166,7 +167,7 @@ def delete_sample_data(conn: Any, phenotype_id: int): """Given the right parameters, delete sample-data from the relevant table.""" - strain_id, data_id = get_sample_data_ids( + strain_id, data_id, _ = get_sample_data_ids( conn=conn, publishxref_id=trait_name, phenotype_id=phenotype_id, strain_name=strain_name) -- cgit v1.2.3