diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/ctl/gn3_ctl_analysis.py | 45 |
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={ |