aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2022-08-30 20:20:51 +0000
committerzsloan2022-08-30 20:20:51 +0000
commit8a9af09df608c0afeb11c18eee8e5dba43e091e6 (patch)
tree413c3610b2f521b1a68c5dd39d6c6580f36f49da
parent25d589e6a96c617cbb2b09b7838a0a7b4bb9f988 (diff)
downloadgenenetwork2-8a9af09df608c0afeb11c18eee8e5dba43e091e6.tar.gz
Add genofile parameter to mapping API endpoint
-rw-r--r--wqflask/wqflask/api/mapping.py62
1 files changed, 48 insertions, 14 deletions
diff --git a/wqflask/wqflask/api/mapping.py b/wqflask/wqflask/api/mapping.py
index d1cc368e..5ffcbd55 100644
--- a/wqflask/wqflask/api/mapping.py
+++ b/wqflask/wqflask/api/mapping.py
@@ -23,26 +23,46 @@ def do_mapping_for_api(start_vars):
samples = []
vals = []
- for sample in dataset.group.samplelist:
- in_trait_data = False
- for item in this_trait.data:
- if this_trait.data[item].name == sample:
- value = str(this_trait.data[item].value)
- samples.append(item)
- vals.append(value)
- in_trait_data = True
- break
- if not in_trait_data:
- vals.append("x")
-
mapping_params = initialize_parameters(start_vars, dataset, this_trait)
- # ZS: It seems to take an empty string as default. This should probably be changed.
+ genofile_samplelist = []
+ if mapping_params['genofile']:
+ dataset.group.genofile = mapping_params['genofile']
+ genofile_samplelist = get_genofile_samplelist(dataset)
+
+ logger.debug("SAMPLES:", genofile_samplelist)
+
+ if (len(genofile_samplelist) > 0):
+ for sample in genofile_samplelist:
+ in_trait_data = False
+ for item in this_trait.data:
+ if this_trait.data[item].name == sample:
+ value = str(this_trait.data[item].value)
+ samples.append(item)
+ vals.append(value)
+ in_trait_data = True
+ break
+ if not in_trait_data:
+ vals.append("x")
+ else:
+ for sample in dataset.group.samplelist:
+ in_trait_data = False
+ for item in this_trait.data:
+ if this_trait.data[item].name == sample:
+ value = str(this_trait.data[item].value)
+ samples.append(item)
+ vals.append(value)
+ in_trait_data = True
+ break
+ if not in_trait_data:
+ vals.append("x")
+
+ # It seems to take an empty string as default. This should probably be changed.
covariates = ""
if mapping_params['mapping_method'] == "gemma":
header_row = ["name", "chr", "Mb", "lod_score", "p_value"]
- # ZS: gemma_mapping returns both results and the filename for LOCO, so need to only grab the former for api
+ # gemma_mapping returns both results and the filename for LOCO, so need to only grab the former for api
if mapping_params['use_loco'] == "True":
result_markers = gemma_mapping.run_gemma(
this_trait, dataset, samples, vals, covariates, mapping_params['use_loco'], mapping_params['maf'])[0]
@@ -138,4 +158,18 @@ def initialize_parameters(start_vars, dataset, this_trait):
except:
mapping_params['perm_check'] = False
+ mapping_params['genofile'] = False
+ if 'genofile' in start_vars:
+ mapping_params['genofile'] = start_vars['genofile']
+
return mapping_params
+
+def get_genofile_samplelist(dataset):
+ genofile_samplelist = []
+
+ genofile_json = dataset.group.get_genofiles()
+ for genofile in genofile_json:
+ if genofile['location'] == dataset.group.genofile and 'sample_list' in genofile:
+ genofile_samplelist = genofile['sample_list']
+
+ return genofile_samplelist