aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorAlexander Kabui2021-10-09 22:11:50 +0300
committerAlexander Kabui2021-10-09 22:11:50 +0300
commit585cd45c56ae4bc444336815cbde791b0c0d2e7b (patch)
treed34a62baceed54185fa818864d4c43a823a09c70 /wqflask
parentc9ae69a30a972f47232f8457e9e1b8cd514f9832 (diff)
downloadgenenetwork2-585cd45c56ae4bc444336815cbde791b0c0d2e7b.tar.gz
add function to call wgcna api
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/wgcna/gn3_wgcna.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/wqflask/wqflask/wgcna/gn3_wgcna.py b/wqflask/wqflask/wgcna/gn3_wgcna.py
index 9ab6b3e0..520f3d04 100644
--- a/wqflask/wqflask/wgcna/gn3_wgcna.py
+++ b/wqflask/wqflask/wgcna/gn3_wgcna.py
@@ -1,6 +1,7 @@
"""module contains code to consume gn3-wgcna api
and process data to be rendered by datatables
"""
+from typing import SimpleNamespace
from utility.helper_functions import get_trait_db_obs
@@ -85,3 +86,33 @@ def process_image(response):
} if image_data else {
"image_generated": False
})
+
+
+def run_wgcna(form_data):
+ """function to run wgcna"""
+
+ wgcna_api = f"{GN3_URL}/api/wgcna/run_wgcna"
+
+ # parse form data
+
+ trait_dataset = fetch_trait_data(form_data)
+
+ response = requests.post(wgcna_api, {
+ "socket_id": form_data.get("socket_id"), # streaming disabled
+ "sample_names": list(set(strains)),
+ "trait_names": form_traits,
+ "trait_sample_data": form_strains,
+ "TOMtype": form_data["TOMtype"],
+ "minModuleSize": int(form_data["MinModuleSize"]),
+ "corType": form_data["corType"]
+
+ }
+ ).json()
+
+ if response.status_code == 200:
+ return {
+ {"results": response,
+ "data": process_wgcna_data(response),
+ "image": process_image(response)
+ }
+ }