aboutsummaryrefslogtreecommitdiff
path: root/gn3/csvcmp.py
diff options
context:
space:
mode:
authorBonfaceKilz2022-03-14 18:01:02 +0300
committerBonfaceKilz2022-03-14 18:01:02 +0300
commita4ffdf5caced76f720b44f2b3ccd13a9be6f7040 (patch)
tree36d770f59b1b2ffe237c4fb7a588c796371df516 /gn3/csvcmp.py
parent046f184c63c48c19e4d807032623e5a4bfaaac3b (diff)
downloadgenenetwork3-a4ffdf5caced76f720b44f2b3ccd13a9be6f7040.tar.gz
Get all permissible column data
* gn3/csvcmp.py: Import "Any" and "List". (get_allowable_sampledata_headers): New function. * tests/unit/test_csvcmp: Import "get_allowable_sampledata_headers". (test_get_allowable_csv_headers): Test case for the above.
Diffstat (limited to 'gn3/csvcmp.py')
-rw-r--r--gn3/csvcmp.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/gn3/csvcmp.py b/gn3/csvcmp.py
index 43b795d..aa057b7 100644
--- a/gn3/csvcmp.py
+++ b/gn3/csvcmp.py
@@ -1,5 +1,7 @@
"""This module contains functions for manipulating and working with csv
texts"""
+from typing import Any, List
+
import json
import os
import uuid
@@ -106,3 +108,13 @@ def fill_csv(csv_text, width, value="x"):
_n[i] = value
data.append(",".join(_n + [value] * (width - len(_n))))
return "\n".join(data)
+
+
+def get_allowable_sampledata_headers(conn: Any) -> List:
+ """Get a list of all the case-attributes stored in the database"""
+ attributes = ["Strain Name", "Value", "SE", "Count"]
+ with conn.cursor() as cursor:
+ cursor.execute("SELECT Name from CaseAttribute")
+ attributes += [attributes[0] for attributes in
+ cursor.fetchall()]
+ return attributes