about summary refs log tree commit diff
path: root/qc_app/db/datasets.py
diff options
context:
space:
mode:
Diffstat (limited to 'qc_app/db/datasets.py')
-rw-r--r--qc_app/db/datasets.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/qc_app/db/datasets.py b/qc_app/db/datasets.py
index 5f6a2d5..5816146 100644
--- a/qc_app/db/datasets.py
+++ b/qc_app/db/datasets.py
@@ -85,3 +85,36 @@ def probeset_create_study(conn: mdb.Connection,#pylint: disable=[too-many-argume
         cursor.execute("UPDATE ProbeFreeze SET ProbeFreezeId=%s",
                        (studyid,))
         return {**studydata, "studyid": studyid}
+
+def probeset_create_dataset(conn: mdb.Connection,#pylint: disable=[too-many-arguments]
+                            studyid: int,
+                            averageid: int,
+                            datasetname: str,
+                            datasetfullname: str,
+                            datasetshortname: str="",
+                            public: bool = True,
+                            datascale="log2") -> dict:
+    """Create a new ProbeSet dataset."""
+    with conn.cursor(cursorclass=DictCursor) as cursor:
+        dataset = {
+            "studyid": studyid,
+            "averageid": averageid,
+            "name2": datasetname,
+            "fname": datasetfullname,
+            "name": datasetshortname,
+            "sname": datasetshortname,
+            "today": date.today().isoformat(),
+            "public": 2 if public else 0,
+            "datascale": datascale
+        }
+        cursor.execute(
+            """
+            insert into ProbeSetFreeze(
+              ProbeFreezeId, AvgId, Name, Name2, FullName, ShortName,
+              CreateTime, public, DataScale)
+            VALUES(
+              %(studyid)s, %(averageid)s, %(name)s, %(name2)s, %(fname)s,
+              %(sname)s, %(today)s, %(public)s, %(datascale)s)
+            """,
+            dataset)
+        return {**dataset, "datasetid": cursor.lastrowid}