aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2022-03-01 12:21:17 +0300
committerBonfaceKilz2022-03-12 15:33:09 +0300
commit967eefd5c22281cb53d055f9304993fa988e2eb2 (patch)
tree97f3386a2650e9cbf9b3350fcd14ef5e32a6dbcc
parenta31bf0e5d1178cb2e3b2d95c6df0d34054a872dd (diff)
downloadgenenetwork3-967eefd5c22281cb53d055f9304993fa988e2eb2.tar.gz
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.
-rw-r--r--gn3/db/sample_data.py17
1 files changed, 9 insertions, 8 deletions
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)