aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/rqtl2/install_genotypes.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/scripts/rqtl2/install_genotypes.py b/scripts/rqtl2/install_genotypes.py
index 63e6113..a555d46 100644
--- a/scripts/rqtl2/install_genotypes.py
+++ b/scripts/rqtl2/install_genotypes.py
@@ -106,6 +106,18 @@ def insert_genotype_data(dbconn: mdb.Connection,
"markerid": row["markerid"]
} for row in data)
+def cross_reference_genotypes(dbconn: mdb.Connection,
+ datasetid: int,
+ dataids: tuple[int, ...]) -> int:
+ """Cross-reference the data to the relevant dataset."""
+ with dbconn.cursor(cursorclass=DictCursor) as cursor:
+ cursor.execute(
+ "INSERT INTO GenoXRef(GenoFreezeId, GenoId, DataId) "
+ "VALUES(%(datasetid)s, %(markerid)s, %(dataid)s) "
+ "ON DUPLICATE KEY UPDATE GenoFreezeId=GenoFreezeId",
+ tuple({**row, "datasetid": datasetid} for row in dataids))
+ return cursor.rowcount
+
def install_genotypes(dbconn: mdb.Connection,
speciesid: int,
populationid: int,
@@ -141,8 +153,9 @@ def install_genotypes(dbconn: mdb.Connection,
insert_individuals(dbconn, speciesid, individuals)
cross_reference_individuals(
dbconn, speciesid, populationid, individuals)
- _num_rows, data_ids = insert_genotype_data(
+ _num_rows, dataids = insert_genotype_data(
dbconn, speciesid, batch, individuals)
+ cross_reference_genotypes(dbconn, datasetid, dataids)
count = count + len(batch)
if "gmap" in cdata: