From 7932f962aff0ac35dd53b84e483f405de81c0612 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 5 Nov 2020 15:07:58 -0600 Subject: Imported Scroller and used it with correlation page table --- wqflask/wqflask/templates/correlation_page.html | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index bc0b592c..06499ec6 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -215,6 +215,7 @@ + + @@ -331,10 +333,10 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "High P ?", + 'title': "High P ", 'type': "natural-minus-na", 'data': "lrs_score", - 'width': "60px", + 'width': "65px", 'orderSequence': [ "desc", "asc"] }, { @@ -344,10 +346,10 @@ 'data': "lrs_location" }, { - 'title': "Effect Size ?", + 'title': "Effect Size ", 'type': "natural-minus-na", 'data': "additive", - 'width': "85px", + 'width': "90px", 'orderSequence': [ "desc", "asc"] }{% elif dataset.type == 'Publish' %}, { @@ -400,7 +402,7 @@ 'orderSequence': [ "desc", "asc"] }, { - 'title': "High P ?", + 'title': "High P ", 'type': "natural-minus-na", 'data': "lrs_score", 'width': "80px", @@ -413,7 +415,7 @@ 'data': "lrs_location" }, { - 'title': "Effect Size ?", + 'title': "Effect Size ", 'type': "natural-minus-na", 'width': "120px", 'data': "additive", -- cgit v1.2.3 From db0e80bef73eb163bfb747ec4d137d5c5069ade8 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 13:40:40 -0600 Subject: Added cdn imports for fontawesome to correlation page and changed superscript i's to fontawesome icons for the glossary links in column headers --- wqflask/wqflask/templates/correlation_page.html | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index bb7d3df6..6ea86609 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -4,6 +4,7 @@ + {% endblock %} {% block content %} @@ -145,7 +146,8 @@ - + + -- cgit v1.2.3 From 76d5b24b3d2e0b5e6be5b1cf4c125a9a812ff57a Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 15:25:32 -0600 Subject: Switched to using boolean casting to check if various trait attributes exist --- wqflask/wqflask/correlation/show_corr_results.py | 59 ++++++++++++------------ 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 17d3de54..87dd7597 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -494,61 +494,60 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['mean'] = "N/A" results_dict['lrs_score'] = "N/A" results_dict['additive'] = "N/A" - if trait.description_display: + if bool(trait.description_display): results_dict['description'] = trait.description_display - if trait.mean and trait.mean != "": + if bool(trait.mean): results_dict['mean'] = float(trait.mean) if trait.LRS_score_repr != "N/A": results_dict['lrs_score'] = "%.1f" % float(trait.LRS_score_repr) results_dict['lrs_location'] = trait.LRS_location_repr - if trait.additive and trait.additive != "": + if bool(trait.additive): results_dict['additive'] = "%0.3f" % float(trait.additive) results_dict['sample_r'] = "%0.3f" % float(trait.sample_r) results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) - if trait.lit_corr == "" or trait.lit_corr == 0: - results_dict['lit_corr'] = "--" - else: + results_dict['lit_corr'] = "--" + results_dict['tissue_corr'] = "--" + results_dict['tissue_pvalue'] = "--" + if bool(trait.lit_corr): results_dict['lit_corr'] = "%0.3f" % float(trait.lit_corr) - if trait.tissue_corr == "" or trait.tissue_corr == 0: - results_dict['tissue_corr'] = "--" - results_dict['tissue_pvalue'] = "--" - else: + if bool(trait.tissue_corr): results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) results_dict['tissue_pvalue'] = "%0.3e" % float(trait.tissue_pvalue) elif target_dataset.type == "Publish": results_dict['abbreviation_display'] = "N/A" - if trait.abbreviation: - results_dict['abbreviation_display'] = trait.abbreviation results_dict['description'] = "N/A" - if trait.description_display: - results_dict['description'] = trait.description_display - results_dict['authors'] = trait.authors - authors_list = trait.authors.split(',') - if len(authors_list) > 6: - results_dict['authors_display'] = ", ".join(authors_list[:6]) + ", et al." + results_dict['authors_display'] = "N/A" + results_dict['additive'] = "N/A" + if for_api: + results_dict['pubmed_id'] = "N/A" + results_dict['year'] = "N/A" else: - results_dict['authors_display'] = trait.authors - if trait.pubmed_id: + results_dict['pubmed_link'] = "N/A" + results_dict['pubmed_text'] = "N/A" + + if bool(trait.abbreviation): + results_dict['abbreviation_display'] = trait.abbreviation + if bool(trait.description_display): + results_dict['description'] = trait.description_display + if bool(trait.authors): + authors_list = trait.authors.split(',') + if len(authors_list) > 6: + results_dict['authors_display'] = ", ".join(authors_list[:6]) + ", et al." + else: + results_dict['authors_display'] = trait.authors + if bool(trait.pubmed_id): if for_api: results_dict['pubmed_id'] = trait.pubmed_id results_dict['year'] = trait.pubmed_text else: results_dict['pubmed_link'] = trait.pubmed_link results_dict['pubmed_text'] = trait.pubmed_text - else: - if for_api: - results_dict['pubmed_id'] = "N/A" - results_dict['year'] = "N/A" - else: - results_dict['pubmed_link'] = "N/A" - results_dict['pubmed_text'] = "N/A" + results_dict['lrs_score'] = trait.LRS_score_repr results_dict['lrs_location'] = trait.LRS_location_repr - if trait.additive and trait.additive != "": + if bool(trait.additive): results_dict['additive'] = "%0.3f" % float(trait.additive) - else: - results_dict['additive'] = "N/A" results_dict['sample_r'] = "%0.3f" % trait.sample_r results_dict['num_overlap'] = trait.num_overlap results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) -- cgit v1.2.3 From 678d9cd4e073c3936c34d3b9b54f1e6c590def27 Mon Sep 17 00:00:00 2001 From: zsloan Date: Fri, 13 Nov 2020 15:37:49 -0600 Subject: Switched to using f-strings instead of the older method of string formatting --- wqflask/wqflask/correlation/show_corr_results.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/wqflask/wqflask/correlation/show_corr_results.py b/wqflask/wqflask/correlation/show_corr_results.py index 87dd7597..1b801b1d 100644 --- a/wqflask/wqflask/correlation/show_corr_results.py +++ b/wqflask/wqflask/correlation/show_corr_results.py @@ -499,21 +499,21 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap if bool(trait.mean): results_dict['mean'] = float(trait.mean) if trait.LRS_score_repr != "N/A": - results_dict['lrs_score'] = "%.1f" % float(trait.LRS_score_repr) + results_dict['lrs_score'] = f"{float(trait.LRS_score_repr):.1f}" results_dict['lrs_location'] = trait.LRS_location_repr if bool(trait.additive): - results_dict['additive'] = "%0.3f" % float(trait.additive) - results_dict['sample_r'] = "%0.3f" % float(trait.sample_r) + results_dict['additive'] = f"{float(trait.additive):.3f}" + results_dict['sample_r'] = f"{float(trait.sample_r):.3f}" results_dict['num_overlap'] = trait.num_overlap - results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + results_dict['sample_p'] = f"{float(trait.sample_p):.3e}" results_dict['lit_corr'] = "--" results_dict['tissue_corr'] = "--" results_dict['tissue_pvalue'] = "--" if bool(trait.lit_corr): - results_dict['lit_corr'] = "%0.3f" % float(trait.lit_corr) + results_dict['lit_corr'] = f"{float(trait.lit_corr):.3f}" if bool(trait.tissue_corr): - results_dict['tissue_corr'] = "%0.3f" % float(trait.tissue_corr) - results_dict['tissue_pvalue'] = "%0.3e" % float(trait.tissue_pvalue) + results_dict['tissue_corr'] = f"{float(trait.tissue_corr):.3f}" + results_dict['tissue_pvalue'] = f"{float(trait.tissue_pvalue):.3e}" elif target_dataset.type == "Publish": results_dict['abbreviation_display'] = "N/A" results_dict['description'] = "N/A" @@ -547,15 +547,15 @@ def generate_corr_json(corr_results, this_trait, dataset, target_dataset, for_ap results_dict['lrs_score'] = trait.LRS_score_repr results_dict['lrs_location'] = trait.LRS_location_repr if bool(trait.additive): - results_dict['additive'] = "%0.3f" % float(trait.additive) - results_dict['sample_r'] = "%0.3f" % trait.sample_r + results_dict['additive'] = f"{float(trait.additive):.3f}" + results_dict['sample_r'] = f"{float(trait.sample_r):.3f}" results_dict['num_overlap'] = trait.num_overlap - results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + results_dict['sample_p'] = f"{float(trait.sample_p):.3e}" else: results_dict['location'] = trait.location_repr - results_dict['sample_r'] = "%0.3f" % trait.sample_r + results_dict['sample_r'] = f"{float(trait.sample_r):.3f}" results_dict['num_overlap'] = trait.num_overlap - results_dict['sample_p'] = "%0.3e" % float(trait.sample_p) + results_dict['sample_p'] = f"{float(trait.sample_p):.3e}" results_list.append(results_dict) -- cgit v1.2.3 From ceeae6fd087d91637c5007e0433ce347048fa96d Mon Sep 17 00:00:00 2001 From: Alexanderlacuna Date: Tue, 17 Nov 2020 22:31:10 +0300 Subject: use better function names --- .../tests/wqflask/marker_regression/test_gemma_mapping.py | 14 +++++++------- .../tests/wqflask/marker_regression/test_rqtl_mapping.py | 2 +- .../tests/wqflask/marker_regression/test_run_mapping.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py b/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py index af20c1b8..4fafd95a 100644 --- a/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py +++ b/wqflask/tests/wqflask/marker_regression/test_gemma_mapping.py @@ -23,7 +23,7 @@ class MockDatasetGroup(AttributeSetter): class TestGemmaMapping(unittest.TestCase): @mock.patch("wqflask.marker_regression.gemma_mapping.parse_loco_output") - def test_run_gemma_first_run_loco_set_false(self, mock_parse_loco): + def test_run_gemma_firstrun_set_false(self, mock_parse_loco): """add tests for gemma function where first run is set to false""" dataset = AttributeSetter( {"group": AttributeSetter({"genofile": "genofile.geno"})}) @@ -49,7 +49,7 @@ class TestGemmaMapping(unittest.TestCase): @mock.patch("wqflask.marker_regression.run_mapping.random.choice") @mock.patch("wqflask.marker_regression.gemma_mapping.os") @mock.patch("wqflask.marker_regression.gemma_mapping.gen_pheno_txt_file") - def test_run_gemma_first_run_set_true(self, mock_gen_pheno_txt, mock_os, mock_choice, mock_gen_covar, mock_flat_files, mock_logger, mock_parse_loco): + def test_run_gemma_firstrun_set_true(self, mock_gen_pheno_txt, mock_os, mock_choice, mock_gen_covar, mock_flat_files, mock_logger, mock_parse_loco): """add tests for run_gemma where first run is set to true""" chromosomes = [] for i in range(1, 5): @@ -140,7 +140,7 @@ class TestGemmaMapping(unittest.TestCase): '-9\t'), mock.call('-9\t'), mock.call('-9\t'), mock.call('-9\t'), mock.call('\n')]) @mock.patch("wqflask.marker_regression.gemma_mapping.webqtlConfig.GENERATED_IMAGE_DIR", "/home/user/img/") - def test_parse_gemma_output_obj_returned(self): + def test_parse_gemma_output(self): """add test for generating gemma output with obj returned""" file = """X/Y\t gn2\t21\tQ\tE\tA\tP\tMMB\tCDE\t0.5 X/Y\tgn2\t21322\tQ\tE\tA\tP\tMMB\tCDE\t0.5 @@ -157,7 +157,7 @@ X\tgn7\t2324424\tQ\tE\tA\tP\tMMB\tCDE\t0.4 self.assertEqual(results, expected) @mock.patch("wqflask.marker_regression.gemma_mapping.webqtlConfig.GENERATED_IMAGE_DIR", "/home/user/img") - def test_parse_gemma_output_empty_return(self): + def test_parse_gemma_output_with_empty_return(self): """add tests for parse gemma output where nothing returned""" output_file_results = """chr\t today""" with mock.patch("builtins.open", mock.mock_open(read_data=output_file_results)) as mock_open: @@ -167,7 +167,7 @@ X\tgn7\t2324424\tQ\tE\tA\tP\tMMB\tCDE\t0.4 @mock.patch("wqflask.marker_regression.gemma_mapping.TEMPDIR", "/home/tmp") @mock.patch("wqflask.marker_regression.gemma_mapping.os") @mock.patch("wqflask.marker_regression.gemma_mapping.json") - def test_parse_loco_output_file_found(self, mock_json, mock_os): + def test_parse_loco_outputfile_found(self, mock_json, mock_os): """add tests for parse loco output file found""" mock_json.load.return_value = { "files": [["file_name", "user", "~/file1"], @@ -193,8 +193,8 @@ chr\tL3\t12312\tQ\tE\tA\tP\tMMB\tCDE\t0.7""" @mock.patch("wqflask.marker_regression.gemma_mapping.TEMPDIR", "/home/tmp") @mock.patch("wqflask.marker_regression.gemma_mapping.os") - def test_parse_loco_output_file_not_found(self, mock_os): - """add tests for parse loco output file not found""" + def test_parse_loco_outputfile_not_found(self, mock_os): + """add tests for parse loco output where output file not found""" mock_os.path.isfile.return_value = False file_to_write = """{"files":["file_1","file_2"]}""" diff --git a/wqflask/tests/wqflask/marker_regression/test_rqtl_mapping.py b/wqflask/tests/wqflask/marker_regression/test_rqtl_mapping.py index 9fd32a30..69f53721 100644 --- a/wqflask/tests/wqflask/marker_regression/test_rqtl_mapping.py +++ b/wqflask/tests/wqflask/marker_regression/test_rqtl_mapping.py @@ -17,7 +17,7 @@ class TestRqtlMapping(unittest.TestCase): @mock.patch("wqflask.marker_regression.rqtl_mapping.g") @mock.patch("wqflask.marker_regression.rqtl_mapping.logger") - def test_get_trait_data_type_found(self,mock_logger,mock_db): + def test_get_trait_data(self,mock_logger,mock_db): """test for getting trait data_type return True""" caller_value="""SELECT value FROM TraitMetadata WHERE type='trait_data_type'""" mock_db.db.execute.return_value.fetchone.return_value=["""{"type":"trait_data_type","name":"T1","traid_id":"fer434f"}"""] diff --git a/wqflask/tests/wqflask/marker_regression/test_run_mapping.py b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py index 2af4c3e3..a134f551 100644 --- a/wqflask/tests/wqflask/marker_regression/test_run_mapping.py +++ b/wqflask/tests/wqflask/marker_regression/test_run_mapping.py @@ -62,7 +62,7 @@ class TestRunMapping(unittest.TestCase): self.assertEqual(result_2, []) @mock.patch("wqflask.marker_regression.run_mapping.data_set") - def test_geno_db_exists(self, mock_data_set): + def test_if_geno_db_exists(self, mock_data_set): mock_data_set.create_dataset.side_effect = [ AttributeSetter({}), Exception()] results_no_error = geno_db_exists(self.dataset) -- cgit v1.2.3 From 9d3493f2e8ee2d2185854b95d2b13a5d2b4e38e1 Mon Sep 17 00:00:00 2001 From: Alexanderlacuna Date: Wed, 18 Nov 2020 02:18:45 +0300 Subject: use f strings in marker_regression/plink_mapping --- wqflask/wqflask/marker_regression/plink_mapping.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wqflask/wqflask/marker_regression/plink_mapping.py b/wqflask/wqflask/marker_regression/plink_mapping.py index 8d57d556..5d675c38 100644 --- a/wqflask/wqflask/marker_regression/plink_mapping.py +++ b/wqflask/wqflask/marker_regression/plink_mapping.py @@ -9,11 +9,11 @@ import utility.logger logger = utility.logger.getLogger(__name__ ) def run_plink(this_trait, dataset, species, vals, maf): - plink_output_filename = webqtlUtil.genRandStr("%s_%s_"%(dataset.group.name, this_trait.name)) + plink_output_filename = webqtlUtil.genRandStr(f"{dataset.group.name}_{this_trait.name}_") gen_pheno_txt_file(dataset, vals) - plink_command = PLINK_COMMAND + ' --noweb --bfile %s/%s --no-pheno --no-fid --no-parents --no-sex --maf %s --out %s%s --assoc ' % ( - flat_files('mapping'), dataset.group.name, maf, TMPDIR, plink_output_filename) + + plink_command = f"{PLINK_COMMAND} --noweb --bfile {flat_files('mapping')}/{dataset.group.name} --no-pheno --no-fid --no-parents --no-sex --maf {maf} --out { TMPDIR}{plink_output_filename} --assoc " logger.debug("plink_command:", plink_command) os.system(plink_command) @@ -29,12 +29,12 @@ def gen_pheno_txt_file(this_dataset, vals): """Generates phenotype file for GEMMA/PLINK""" current_file_data = [] - with open("{}/{}.fam".format(flat_files('mapping'), this_dataset.group.name), "r") as outfile: + with open(f"{flat_files('mapping')}/{this_dataset.group.name}.fam", "r") as outfile: for i, line in enumerate(outfile): split_line = line.split() current_file_data.append(split_line) - with open("{}/{}.fam".format(flat_files('mapping'), this_dataset.group.name), "w") as outfile: + with open(f"{flat_files('mapping')}/{this_dataset.group.name}.fam","w") as outfile: for i, line in enumerate(current_file_data): if vals[i] == "x": this_val = -9 @@ -44,8 +44,8 @@ def gen_pheno_txt_file(this_dataset, vals): def gen_pheno_txt_file_plink(this_trait, dataset, vals, pheno_filename = ''): ped_sample_list = get_samples_from_ped_file(dataset) - output_file = open("%s%s.txt" % (TMPDIR, pheno_filename), "wb") - header = 'FID\tIID\t%s\n' % this_trait.name + output_file = open(f"{TMPDIR}{pheno_filename}.txt", "wb") + header = f"FID\tIID\t{this_trait.name}\n" output_file.write(header) new_value_list = [] @@ -65,7 +65,7 @@ def gen_pheno_txt_file_plink(this_trait, dataset, vals, pheno_filename = ''): for i, sample in enumerate(ped_sample_list): j = i+1 value = new_value_list[i] - new_line += '%s\t%s\t%s\n'%(sample, sample, value) + new_line += f"{sample}\t{sample}\t{value}\n" if j%1000 == 0: output_file.write(newLine) @@ -78,7 +78,7 @@ def gen_pheno_txt_file_plink(this_trait, dataset, vals, pheno_filename = ''): # get strain name from ped file in order def get_samples_from_ped_file(dataset): - ped_file= open("{}{}.ped".format(flat_files('mapping'), dataset.group.name), "r") + ped_file= open(f"{flat_files('mapping')}{dataset.group.name}.ped","r") line = ped_file.readline() sample_list=[] @@ -98,7 +98,7 @@ def parse_plink_output(output_filename, species): threshold_p_value = 1 - result_fp = open("%s%s.qassoc"% (TMPDIR, output_filename), "rb") + result_fp = open(f"{TMPDIR}{output_filename}.qassoc","rb") line = result_fp.readline() -- cgit v1.2.3 From 77dff447c83a4b0824fe6626d16484cfd826ca77 Mon Sep 17 00:00:00 2001 From: Alexanderlacuna Date: Wed, 18 Nov 2020 03:06:27 +0300 Subject: use f strings in marker_regression/qtlreaper_mapping.py --- .../wqflask/marker_regression/qtlreaper_mapping.py | 46 +++++++++++++--------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py index 78b1f7b0..505ae295 100644 --- a/wqflask/wqflask/marker_regression/qtlreaper_mapping.py +++ b/wqflask/wqflask/marker_regression/qtlreaper_mapping.py @@ -17,22 +17,29 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo else: genofile_name = this_dataset.group.name - trait_filename = str(this_trait.name) + "_" + str(this_dataset.name) + "_pheno" + trait_filename =f"{str(this_trait.name)}_{str(this_dataset.name)}_pheno" gen_pheno_txt_file(samples, vals, trait_filename) - output_filename = this_dataset.group.name + "_GWA_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) + output_filename = (f"{this_dataset.group.name}_GWA_"+ + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) + ) bootstrap_filename = None permu_filename = None opt_list = [] if boot_check and num_bootstrap > 0: - bootstrap_filename = this_dataset.group.name + "_BOOTSTRAP_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) + bootstrap_filename = (f"{this_dataset.group.name}_BOOTSTRAP_" + + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) + ) opt_list.append("-b") - opt_list.append("--n_bootstrap " + str(num_bootstrap)) - opt_list.append("--bootstrap_output " + webqtlConfig.GENERATED_IMAGE_DIR + bootstrap_filename + ".txt") + opt_list.append(f"--n_bootstrap{str(num_bootstrap)}") + opt_list.append(f"--bootstrap_output{webqtlConfig.GENERATED_IMAGE_DIR}{bootstrap_filename}.txt") if num_perm > 0: - permu_filename = this_dataset.group.name + "_PERM_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) + permu_filename =("{this_dataset.group.name}_PERM_" + + ''.join(random.choice(string.ascii_uppercase + + string.digits) for _ in range(6)) + ) opt_list.append("-n " + str(num_perm)) opt_list.append("--permu_output " + webqtlConfig.GENERATED_IMAGE_DIR + permu_filename + ".txt") if control_marker != "" and do_control == "true": @@ -40,13 +47,15 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo if manhattan_plot != True: opt_list.append("--interval 1") - reaper_command = REAPER_COMMAND + ' --geno {0}/{1}.geno --traits {2}/gn2/{3}.txt {4} -o {5}{6}.txt'.format(flat_files('genotype'), - genofile_name, - TEMPDIR, - trait_filename, - " ".join(opt_list), - webqtlConfig.GENERATED_IMAGE_DIR, - output_filename) + reaper_command = (REAPER_COMMAND + + ' --geno {0}/{1}.geno --traits {2}/gn2/{3}.txt {4} -o {5}{6}.txt'.format(flat_files('genotype'), + + genofile_name, + TEMPDIR, + trait_filename, + " ".join(opt_list), + webqtlConfig.GENERATED_IMAGE_DIR, + output_filename)) logger.debug("reaper_command:" + reaper_command) os.system(reaper_command) @@ -61,12 +70,13 @@ def run_reaper(this_trait, this_dataset, samples, vals, json_data, num_perm, boo suggestive = permu_vals[int(num_perm*0.37-1)] significant = permu_vals[int(num_perm*0.95-1)] - return marker_obs, permu_vals, suggestive, significant, bootstrap_vals, [output_filename, permu_filename, bootstrap_filename] + return (marker_obs, permu_vals, suggestive, significant, bootstrap_vals, + [output_filename, permu_filename, bootstrap_filename]) def gen_pheno_txt_file(samples, vals, trait_filename): """Generates phenotype file for GEMMA""" - with open("{}/gn2/{}.txt".format(TEMPDIR, trait_filename), "w") as outfile: + with open(f"{TEMPDIR}/gn2/{trait_filename}.txt","w") as outfile: outfile.write("Trait\t") filtered_sample_list = [] @@ -90,7 +100,7 @@ def parse_reaper_output(gwa_filename, permu_filename, bootstrap_filename): only_cm = False only_mb = False - with open("{}{}.txt".format(webqtlConfig.GENERATED_IMAGE_DIR, gwa_filename)) as output_file: + with open(f"{webqtlConfig.GENERATED_IMAGE_DIR}{gwa_filename}.txt") as output_file: for line in output_file: if line.startswith("ID\t"): if len(line.split("\t")) < 8: @@ -137,13 +147,13 @@ def parse_reaper_output(gwa_filename, permu_filename, bootstrap_filename): permu_vals = [] if permu_filename: - with open("{}{}.txt".format(webqtlConfig.GENERATED_IMAGE_DIR, permu_filename)) as permu_file: + with open(f"{webqtlConfig.GENERATED_IMAGE_DIR}{permu_filename}.txt") as permu_file: for line in permu_file: permu_vals.append(float(line)) bootstrap_vals = [] if bootstrap_filename: - with open("{}{}.txt".format(webqtlConfig.GENERATED_IMAGE_DIR, bootstrap_filename)) as bootstrap_file: + with open(f"{webqtlConfig.GENERATED_IMAGE_DIR}{bootstrap_filename}.txt") as bootstrap_file: for line in bootstrap_file: bootstrap_vals.append(int(line)) -- cgit v1.2.3 From cf4db5545efee6d9052153708fc05ca707ef1716 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 24 Nov 2020 12:51:17 -0600 Subject: Added html/css for new "Filter Samples by Value" feature and changed a couple class names to make more sense for being shared between both this feature and "Block Samples by Index" --- wqflask/wqflask/static/new/css/show_trait.css | 4 ++-- .../templates/show_trait_transform_and_filter.html | 23 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/wqflask/wqflask/static/new/css/show_trait.css b/wqflask/wqflask/static/new/css/show_trait.css index 5e1a279b..39c6ba53 100644 --- a/wqflask/wqflask/static/new/css/show_trait.css +++ b/wqflask/wqflask/static/new/css/show_trait.css @@ -145,11 +145,11 @@ input.corr-location { display: inline; } -div.block-by-index-div { +div.block-div { margin-bottom: 10px; } -div.block-by-attribute-div { +div.block-div-2 { margin-top:10px; margin-bottom:10px; } diff --git a/wqflask/wqflask/templates/show_trait_transform_and_filter.html b/wqflask/wqflask/templates/show_trait_transform_and_filter.html index 0418d972..22c52d8c 100644 --- a/wqflask/wqflask/templates/show_trait_transform_and_filter.html +++ b/wqflask/wqflask/templates/show_trait_transform_and_filter.html @@ -4,7 +4,7 @@ Reset option as needed.
-