From 5e3076c8e5a9945dec4256809af70b7644b35887 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 13 Aug 2024 15:02:15 -0500 Subject: Bug: cross reference with NULL cM when "gmap" file is absent The "gmap" file might not exist in some bundles. In those instances, cross-reference the data without including the genotypes' physical positions (cM). --- scripts/rqtl2/install_genotypes.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/rqtl2/install_genotypes.py b/scripts/rqtl2/install_genotypes.py index 966728f..08fc0ba 100644 --- a/scripts/rqtl2/install_genotypes.py +++ b/scripts/rqtl2/install_genotypes.py @@ -154,16 +154,19 @@ def cross_reference_genotypes( (tuple(), tuple(), {})) with dbconn.cursor(cursorclass=DictCursor) as cursor: - paramstr = ", ".join(["%s"] * len(markers)) - insertparams = (speciesid,) + markers - selectquery = ("SELECT Id, Name FROM Geno " - f"WHERE SpeciesId=%s AND Name IN ({paramstr})") - _logger.debug( - "The select query was\n\t%s\n\nwith the parameters\n\t%s", - selectquery, - (speciesid,) + markers) - cursor.execute(selectquery, insertparams) - markersdict = {row["Id"]: row["Name"] for row in cursor.fetchall()} + markersdict = {} + if len(markers) > 0: + paramstr = ", ".join(["%s"] * len(markers)) + insertparams = (speciesid,) + markers + selectquery = ("SELECT Id, Name FROM Geno " + f"WHERE SpeciesId=%s AND Name IN ({paramstr})") + _logger.debug( + "The select query was\n\t%s\n\nwith the parameters\n\t%s", + selectquery, + (speciesid,) + markers) + cursor.execute(selectquery, insertparams) + markersdict = {row["Id"]: row["Name"] for row in cursor.fetchall()} + insertquery = ( "INSERT INTO GenoXRef(GenoFreezeId, GenoId, DataId, cM) " "VALUES(%(datasetid)s, %(markerid)s, %(dataid)s, %(pos)s) " -- cgit v1.2.3