From 46cee438cedc5d855676958d97bf67d127d5e3e3 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 27 Apr 2021 11:57:59 +0300 Subject: db: traits: Update method for inserting publication method --- gn3/db/traits.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'gn3') diff --git a/gn3/db/traits.py b/gn3/db/traits.py index fc1463c..3134d31 100644 --- a/gn3/db/traits.py +++ b/gn3/db/traits.py @@ -88,8 +88,32 @@ def insert_publication_data(riset_id: int, strains: List, conn: Any): "%s AND Name in (%s)" % (riset_id, ", ".join(f"'{strain}'" for strain in strains))) strain_ids = cursor.fetchall() + data_id, *_ = cursor.execute("SELECT max(Id) " + "from PublishData").fetchone() + if strain_ids: strain_ids = list(chain(*strain_ids)) + for strain, strain_id in zip(strains, strain_ids): + # TODO: Fetch this values correctly using sql + value, variance, trait_np = 1, 1, 1 + if value: + cursor.execute( + "INSERT INTO PublishData values (%d, %d, %s)" % + (data_id, strain_id, value)) + if variance: + cursor.execute( + "INSERT INTO PublishSE values (%d, %d, %s)" % + (data_id, strain_id, variance)) + if trait_np: + cursor.execute( + "INSERT INTO NStrain values (%d, %d, %s)" % + (data_id, strain_id, trait_np)) + inbred_set_id = lookup_webqtldataset_name(riset_name="", + conn=conn) + cursor.execute( + "SELECT max(Sequence) FROM PublishXRef where " + "InbredSetId = %d and PhenotypeId = %d and PublicationId = %d" % + (inbred_set_id, phenotype_id, publication_id)) def insert_phenotype(phenotype: Optional[Dict], conn: Any): -- cgit v1.2.3