diff options
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/marker_regression/gemma_mapping.py | 35 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 60 |
2 files changed, 37 insertions, 58 deletions
diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 895d4ac6..1d9bbb43 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -73,14 +73,6 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf gwa_output_filename) else: - # generate_k_command = GEMMA_COMMAND + ' ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -gk -outdir %s/gn2/ -o %s' % (flat_files('genotype/bimbam'), - # genofile_name, - # TEMPDIR, - # trait_filename, - # flat_files('genotype/bimbam'), - # genofile_name, - # TEMPDIR, - # k_output_filename) generate_k_command = GEMMA_WRAPPER_COMMAND + ' --json -- ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -gk > %s/gn2/%s.json' % (flat_files('genotype/bimbam'), genofile_name, TEMPDIR, @@ -93,31 +85,18 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf logger.debug("k_command:" + generate_k_command) os.system(generate_k_command) - # gemma_command = GEMMA_COMMAND + ' ' + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt -a %s/%s_snps.txt -k %s/gn2/%s.cXX.txt -lmm 2 -maf %s' % (flat_files('genotype/bimbam'), - # genofile_name, - # TEMPDIR, - # trait_filename, - # flat_files('genotype/bimbam'), - # genofile_name, - # TEMPDIR, - # k_output_filename, - # maf) - - gemma_command = GEMMA_WRAPPER_COMMAND + ' --json --input %s/gn2/%s.json -- ' % (TEMPDIR, k_output_filename) + GEMMAOPTS + ' -lmm 2 -g %s/%s_geno.txt -p %s/gn2/%s.txt' % (flat_files('genotype/bimbam'), + gemma_command = GEMMA_WRAPPER_COMMAND + ' --json --input %s/gn2/%s.json -- ' % (TEMPDIR, k_output_filename) + GEMMAOPTS + ' -a %s/%s_snps.txt -lmm 2 -g %s/%s_geno.txt -p %s/gn2/%s.txt' % (flat_files('genotype/bimbam'), + genofile_name, + flat_files('genotype/bimbam'), genofile_name, TEMPDIR, trait_filename) if covariates != "": - gemma_command += ' -c %s/%s_covariates.txt' % (flat_files('mapping'), this_dataset.group.name) - # gemma_command += ' -c %s/%s_covariates.txt -outdir %s -o %s_output' % (flat_files('mapping'), - # this_dataset.group.name, - # webqtlConfig.GENERATED_IMAGE_DIR, - # genofile_name) - # else: - # gemma_command += ' -outdir %s -o %s_output' % (webqtlConfig.GENERATED_IMAGE_DIR, - # genofile_name) + gemma_command += ' -c %s/%s_covariates.txt > %s/gn2/%s.json' % (flat_files('mapping'), this_dataset.group.name, TEMPDIR, gwa_output_filename) + else: + gemma_command += ' > %s/gn2/%s.json' % (TEMPDIR, gwa_output_filename) logger.debug("gemma_command:" + gemma_command) @@ -127,7 +106,7 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf marker_obs = parse_loco_output(this_dataset, gwa_output_filename) return marker_obs, gwa_output_filename else: - marker_obs = parse_gemma_output(genofile_name) + marker_obs = parse_loco_output(this_dataset, gwa_output_filename) return marker_obs def gen_pheno_txt_file(this_dataset, genofile_name, vals, trait_filename): diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index aa64a910..fbcaefc1 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -671,36 +671,36 @@ def mapping_results_page(): if template_vars.no_results: rendered_template = render_template("mapping_error.html") else: - #if template_vars.mapping_method != "gemma" and template_vars.mapping_method != "plink": - template_vars.js_data = json.dumps(template_vars.js_data, - default=json_default_handler, - indent=" ") - - result = template_vars.__dict__ - - if result['pair_scan']: - with Bench("Rendering template"): - img_path = result['pair_scan_filename'] - logger.info("img_path:", img_path) - initial_start_vars = request.form - logger.info("initial_start_vars:", initial_start_vars) - imgfile = open(TEMPDIR + img_path, 'rb') - imgdata = imgfile.read() - imgB64 = imgdata.encode("base64") - bytesarray = array.array('B', imgB64) - result['pair_scan_array'] = bytesarray - rendered_template = render_template("pair_scan_results.html", **result) - else: - gn1_template_vars = display_mapping_results.DisplayMappingResults(result).__dict__ - #pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL) - #logger.info("pickled result length:", len(pickled_result)) - #Redis.set(key, pickled_result) - #Redis.expire(key, 1*60) - - with Bench("Rendering template"): - if (gn1_template_vars['mapping_method'] == "gemma") or (gn1_template_vars['mapping_method'] == "plink"): - gn1_template_vars.pop('qtlresults', None) - rendered_template = render_template("mapping_results.html", **gn1_template_vars) + #if template_vars.mapping_method != "gemma" and template_vars.mapping_method != "plink": + template_vars.js_data = json.dumps(template_vars.js_data, + default=json_default_handler, + indent=" ") + + result = template_vars.__dict__ + + if result['pair_scan']: + with Bench("Rendering template"): + img_path = result['pair_scan_filename'] + logger.info("img_path:", img_path) + initial_start_vars = request.form + logger.info("initial_start_vars:", initial_start_vars) + imgfile = open(TEMPDIR + img_path, 'rb') + imgdata = imgfile.read() + imgB64 = imgdata.encode("base64") + bytesarray = array.array('B', imgB64) + result['pair_scan_array'] = bytesarray + rendered_template = render_template("pair_scan_results.html", **result) + else: + gn1_template_vars = display_mapping_results.DisplayMappingResults(result).__dict__ + #pickled_result = pickle.dumps(result, pickle.HIGHEST_PROTOCOL) + #logger.info("pickled result length:", len(pickled_result)) + #Redis.set(key, pickled_result) + #Redis.expire(key, 1*60) + + with Bench("Rendering template"): + if (gn1_template_vars['mapping_method'] == "gemma") or (gn1_template_vars['mapping_method'] == "plink"): + gn1_template_vars.pop('qtlresults', None) + rendered_template = render_template("mapping_results.html", **gn1_template_vars) return rendered_template |