aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-10-16 14:45:22 +0300
committerFrederick Muriuki Muriithi2023-10-16 14:45:22 +0300
commit1d3f877aadcf89f82746e4dccc8d8cf767928419 (patch)
treec480d037f75f5fe0bf6122d7105bfeb7709b20f1 /scripts
parent9e7c5761a1f9ba089ac700ee1a7a02d7c17683e1 (diff)
downloadgn-uploader-1d3f877aadcf89f82746e4dccc8d8cf767928419.tar.gz
Fix bug: Insert ProbeSets if they do not exist.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/insert_data.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/scripts/insert_data.py b/scripts/insert_data.py
index 7e27f93..f8b73f6 100644
--- a/scripts/insert_data.py
+++ b/scripts/insert_data.py
@@ -131,27 +131,33 @@ def insert_means(
"Insert the means/averages data into the database"
headings = read_file_headings(filepath)
strains = strains_info(dbconn, headings[1:], speciesid)
- check_strains(headings[1:], strains)
+ check_strains(headings[1:], strains),
+ probeset_query = (
+ "INSERT IGNORE INTO ProbeSet(ChipId, Name) "
+ "VALUES (%(ChipId)s, %(ProbeSetId)s) ")
means_query = (
"INSERT INTO ProbeSetData "
"VALUES(%(ProbeSetDataId)s, %(StrainId)s, %(DataValue)s)")
xref_query = (
"INSERT INTO ProbeSetXRef(ProbeSetFreezeId, ProbeSetId, DataId) "
"VALUES(%(ProbeSetFreezeId)s, %(ProbeSetId)s, %(ProbeSetDataId)s)")
- the_means = (
- {"ProbeSetFreezeId": datasetid, "ProbeSetDataId": data_id, **mean}
- for data_id, mean in
- enumerate(
- read_datavalues(filepath, headings, strains),
- start=(last_data_id(dbconn)+1)))
+ the_means = ({
+ "ProbeSetFreezeId": datasetid, "ProbeSetDataId": data_id,
+ "ChipId": platform_id, **mean
+ } for data_id, mean in enumerate(
+ read_datavalues(filepath, headings, strains),
+ start=(last_data_id(dbconn)+1)))
with dbconn.cursor(cursorclass=DictCursor) as cursor:
while True:
means = tuple(take(the_means, 1000))
if not bool(means):
break
+ print(__format_query__(probeset_query, means))
+ print()
print(__format_query__(means_query, means))
print()
print(__format_query__(xref_query, means))
+ cursor.executemany(probeset_query, means)
cursor.executemany(means_query, means)
cursor.executemany(xref_query, means)
return 0