aboutsummaryrefslogtreecommitdiff
path: root/gn3/db/traits.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-04-27 11:57:59 +0300
committerBonfaceKilz2021-05-08 19:19:47 +0300
commit46cee438cedc5d855676958d97bf67d127d5e3e3 (patch)
tree95657ae96ed4f4805cb5cacbaa35a2fa8f473e42 /gn3/db/traits.py
parente4487b7dbbb8e2c93417019b33b7f4fbd5de655e (diff)
downloadgenenetwork3-46cee438cedc5d855676958d97bf67d127d5e3e3.tar.gz
db: traits: Update method for inserting publication method
Diffstat (limited to 'gn3/db/traits.py')
-rw-r--r--gn3/db/traits.py24
1 files changed, 24 insertions, 0 deletions
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):