aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kabui2022-01-19 13:27:41 +0300
committerBonfaceKilz2022-02-09 08:49:56 +0300
commit9d7e616e1924173499395047ba011262f704fc78 (patch)
treefb8f85b358f548806056a4753293f5a64414e5a4
parent1d34c15ddafc516dfaf6064f4fad2bf09795d5ed (diff)
downloadgenenetwork2-9d7e616e1924173499395047ba011262f704fc78.tar.gz
parse geno input data
-rw-r--r--wqflask/wqflask/ctl/gn3_ctl_analysis.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/wqflask/wqflask/ctl/gn3_ctl_analysis.py b/wqflask/wqflask/ctl/gn3_ctl_analysis.py
index 2b5c0f0b..9ee85d3d 100644
--- a/wqflask/wqflask/ctl/gn3_ctl_analysis.py
+++ b/wqflask/wqflask/ctl/gn3_ctl_analysis.py
@@ -1,8 +1,45 @@
import requests
-
+from dataclasses import dataclass
from utility.tools import GN3_LOCAL_URL
+@dataclass
+class CtlDatabase:
+ """class for keeping track of ctl db data"""
+
+ dataset: dict
+
+ trait_db_list: list
+
+
+def parse_geno_data(dataset_group_name) ->dict:
+ """function to parse geno file data"""
+ genofile_location = locate(dataset.group.name + ".geno", "genotype")
+ parser = genofile_parser.ConvertGenoFile(genofilelocation)
+
+ parser.process_csv()
+
+ # get marker and marker names
+
+ markers = []
+ markernames = []
+ for marker in parser.markers:
+ markernames.append(marker["name"])
+ markers.append(marker["genotypes"])
+
+ return {
+
+ "genotypes":list(itertools.chain(*markers)),
+ "markernames":markernames
+ "individuals":parser.individuals,
+
+
+ }
+
+
+
+
+
def parse_form_data(form_data: dict):
"""function to parse/validate form data
input: dict containing required data
@@ -10,6 +47,10 @@ def parse_form_data(form_data: dict):
"""
+ trait_db_list = [trait.strip()
+ for trait in requestform['trait_list'].split(',')]
+ form_data["trait_db_list"] = [x for x in trait_db_list if x]
+
form_data["nperm"] = int(form_data["nperm"])
form_data["significance"] = float(int(form_data["significance"]))
form_data["strategy"] = form_data["strategy"].capitalize()
@@ -21,6 +62,8 @@ def run_ctl():
"""function to make an api call
to gn3 and run ctl"""
+ CtlObj = CtlDatabase()
+
ctl_api = f"{GN3_LOCAL_URL}/api/wgcna/run_wgcna"
response = requests.post(ctl_api, json={