diff options
-rw-r--r-- | wqflask/base/trait.py | 22 | ||||
-rw-r--r-- | wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py | 13 | ||||
-rw-r--r-- | wqflask/wqflask/markdown_routes.py | 10 | ||||
-rw-r--r-- | wqflask/wqflask/marker_regression/gemma_mapping.py | 8 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/css/markdown.css | 7 | ||||
-rw-r--r-- | wqflask/wqflask/templates/correlation_page.html | 39 | ||||
-rw-r--r-- | wqflask/wqflask/templates/environment.html | 10 | ||||
-rw-r--r-- | wqflask/wqflask/templates/facilities.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/glossary.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/links.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/policies.html | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/references.html | 2 |
12 files changed, 80 insertions, 39 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index ec8c40a0..50bd8874 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -25,19 +25,19 @@ def create_trait(**kw): assert bool(kw.get('dataset')) != bool( kw.get('dataset_name')), "Needs dataset ob. or name" - if kw.get('name'): - if kw.get('dataset_name'): - if kw.get('dataset_name') != "Temp": - dataset = create_dataset(kw.get('dataset_name')) - else: - dataset = kw.get('dataset') + assert bool(kw.get('name')), "Needs trait name" + if kw.get('dataset_name'): if kw.get('dataset_name') != "Temp": - if dataset.type == 'Publish': - permissions = check_resource_availability( - dataset, kw.get('name')) - else: - permissions = check_resource_availability(dataset) + dataset = create_dataset(kw.get('dataset_name')) + else: + dataset = kw.get('dataset') + + if dataset.type == 'Publish': + permissions = check_resource_availability( + dataset, kw.get('name')) + else: + permissions = check_resource_availability(dataset) if "view" in permissions['data']: the_trait = GeneralTrait(**kw) diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py index 5b621264..b8c13ab4 100644 --- a/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py +++ b/wqflask/tests/unit/wqflask/marker_regression/test_gemma_mapping.py @@ -43,22 +43,22 @@ class TestGemmaMapping(unittest.TestCase): @mock.patch("wqflask.marker_regression.gemma_mapping.GEMMA_WRAPPER_COMMAND", "ghc") @mock.patch("wqflask.marker_regression.gemma_mapping.TEMPDIR", "/home/user/data/") @mock.patch("wqflask.marker_regression.gemma_mapping.parse_loco_output") - @mock.patch("wqflask.marker_regression.gemma_mapping.logger") @mock.patch("wqflask.marker_regression.gemma_mapping.flat_files") @mock.patch("wqflask.marker_regression.gemma_mapping.gen_covariates_file") @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_firstrun_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_parse_loco): """add tests for run_gemma where first run is set to true""" - chromosomes = [] + this_chromosomes={} for i in range(1, 5): - chromosomes.append(AttributeSetter({"name": f"CH{i}"})) - chromo = AttributeSetter({"chromosomes": chromosomes}) + this_chromosomes[f'CH{i}']=(AttributeSetter({"name": f"CH{i}"})) + chromosomes = AttributeSetter({"chromosomes": this_chromosomes}) + dataset_group = MockGroup( {"name": "GP1", "genofile": "file_geno"}) dataset = AttributeSetter({"group": dataset_group, "name": "dataset1_name", - "species": AttributeSetter({"chromosomes": chromo})}) + "species": AttributeSetter({"chromosomes": chromosomes})}) trait = AttributeSetter({"name": "trait1"}) samples = [] mock_gen_pheno_txt.return_value = None @@ -76,7 +76,6 @@ class TestGemmaMapping(unittest.TestCase): mock_parse_loco.assert_called_once_with(dataset, "GP1_GWA_RRRRRR") mock_os.path.isfile.assert_called_once_with( ('/home/user/imgfile_output.assoc.txt')) - self.assertEqual(mock_logger.debug.call_count, 2) self.assertEqual(mock_flat_files.call_count, 4) self.assertEqual(results, ([], "GP1_GWA_RRRRRR")) diff --git a/wqflask/wqflask/markdown_routes.py b/wqflask/wqflask/markdown_routes.py index 183f4caa..ebf75807 100644 --- a/wqflask/wqflask/markdown_routes.py +++ b/wqflask/wqflask/markdown_routes.py @@ -9,6 +9,7 @@ import sys from bs4 import BeautifulSoup +from flask import send_from_directory from flask import Blueprint from flask import render_template @@ -99,6 +100,13 @@ def environments(): 200) +@environments_blueprint.route('/svg-dependency-graph') +def svg_graph(): + directory, file_name, _ = get_file_from_python_search_path( + "wqflask/dependency-graph.svg").partition("dependency-graph.svg") + return send_from_directory(directory, file_name) + + @links_blueprint.route("/") def links(): return render_template( @@ -109,7 +117,7 @@ def links(): @policies_blueprint.route("/") def policies(): return render_template( - "links.html", + "policies.html", rendered_markdown=render_markdown("general/policies/policies.md")), 200 diff --git a/wqflask/wqflask/marker_regression/gemma_mapping.py b/wqflask/wqflask/marker_regression/gemma_mapping.py index 02f91a32..61e4897c 100644 --- a/wqflask/wqflask/marker_regression/gemma_mapping.py +++ b/wqflask/wqflask/marker_regression/gemma_mapping.py @@ -31,7 +31,8 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf gwa_output_filename = this_dataset.group.name + "_GWA_" + ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(6)) this_chromosomes = this_dataset.species.chromosomes.chromosomes - this_chromosomes_name=[chromosome.name for chromosome in this_chromosomes] + this_chromosomes_name=[this_chromosomes[chromosome].name for chromosome in this_chromosomes] + chr_list_string=",".join(this_chromosomes_name) if covariates != "": @@ -45,7 +46,7 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf genofile_name, TEMPDIR, k_output_filename) - logger.debug("k_command:" + generate_k_command) + os.system(generate_k_command) gemma_command = GEMMA_WRAPPER_COMMAND + ' --json --loco --input %s/gn2/%s.json -- ' % (TEMPDIR, k_output_filename) + GEMMAOPTS + ' -g %s/%s_geno.txt -p %s/gn2/%s.txt' % (flat_files('genotype/bimbam'), @@ -77,7 +78,6 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf TEMPDIR, k_output_filename) - logger.debug("k_command:" + generate_k_command) os.system(generate_k_command) 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'), @@ -93,8 +93,6 @@ def run_gemma(this_trait, this_dataset, samples, vals, covariates, use_loco, maf else: gemma_command += ' > %s/gn2/%s.json' % (TEMPDIR, gwa_output_filename) - - logger.debug("gemma_command:" + gemma_command) os.system(gemma_command) else: gwa_output_filename = output_files diff --git a/wqflask/wqflask/static/new/css/markdown.css b/wqflask/wqflask/static/new/css/markdown.css index 38d664e2..859fe7fc 100644 --- a/wqflask/wqflask/static/new/css/markdown.css +++ b/wqflask/wqflask/static/new/css/markdown.css @@ -62,7 +62,8 @@ } .graph-legend, -#guix-graph { +#guix-graph, +#guix-svg-graph{ width: 90%; margin: 10px auto; } @@ -71,6 +72,10 @@ border: solid 2px black; } +#guix-svg-graph img { + width: 100%; +} + #markdown table { width: 100%; } diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 06ee9056..68566ee5 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -345,8 +345,15 @@ 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", 'type': "natural-minus-na", 'width': "40px", - 'data': "sample_r", - 'orderSequence': [ "desc", "asc"] + 'data': null, + 'orderSequence': [ "desc", "asc"], + 'render': function(data, type, row, meta) { + if (data.sample_r != "N/A") { + return "<a target\"_blank\" href=\"corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" + } else { + return data.sample_r + } + } }, { 'title': "N", @@ -357,7 +364,7 @@ }, { 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", - 'type': "natural-minus-na", + 'type': "scientific", 'width': "65px", 'data': "sample_p", 'orderSequence': [ "desc", "asc"] @@ -459,8 +466,15 @@ 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", 'type': "natural-minus-na", 'width': "40px", - 'data': "sample_r", - 'orderSequence': [ "desc", "asc"] + 'data': null, + 'orderSequence': [ "desc", "asc"], + 'render': function(data, type, row, meta) { + if (data.sample_r != "N/A") { + return "<a target\"_blank\" href=\"corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" + } else { + return data.sample_r + } + } }, { 'title': "N", @@ -471,7 +485,7 @@ }, { 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", - 'type': "natural-minus-na", + 'type': "scientific", 'width': "65px", 'data': "sample_p", 'orderSequence': [ "desc", "asc"] @@ -506,8 +520,15 @@ 'title': "Sample {% if corr_method == 'pearson' %}r{% else %}rho{% endif %}", 'type': "natural-minus-na", 'width': "40px", - 'data': "sample_r", - 'orderSequence': [ "desc", "asc"] + 'data': null, + 'orderSequence': [ "desc", "asc"], + 'render': function(data, type, row, meta) { + if (data.sample_r != "N/A") { + return "<a target\"_blank\" href=\"corr_scatter_plot?dataset_1={% if dataset.name == 'Temp' %}Temp_{{ dataset.group.name }}{% else %}{{ dataset.name }}{% endif %}&dataset_2=" + data.dataset + "&trait_1={{ this_trait.name }}&trait_2=" + data.trait_id + "\">" + data.sample_r + "</a>" + } else { + return data.sample_r + } + } }, { 'title': "N", @@ -518,7 +539,7 @@ }, { 'title': "Sample p({% if corr_method == 'pearson' %}r{% else %}rho{% endif %})", - 'type': "natural-minus-na", + 'type': "scientific", 'width': "65px", 'data': "sample_p", 'orderSequence': [ "desc", "asc"] diff --git a/wqflask/wqflask/templates/environment.html b/wqflask/wqflask/templates/environment.html index 5fe01dad..89e805ce 100644 --- a/wqflask/wqflask/templates/environment.html +++ b/wqflask/wqflask/templates/environment.html @@ -21,6 +21,16 @@ </div> <div id="guix-graph"></div> + +<!-- Display the svg graph --> + +<div id="guix-svg-graph"> + <h1>The dependency graph is shown below</h1> + + <p>To explore this image SVG you may want to open it in new browser page and zoom in. Or use an SVG viewing application.</p> + + <img alt="Dependency graph of the tools needed to build python3-genenetwork2" src="{{url_for('environments_blueprint.svg_graph')}}"/> +</div> {% endif %} {% endblock %} diff --git a/wqflask/wqflask/templates/facilities.html b/wqflask/wqflask/templates/facilities.html index a022b657..56b127f9 100644 --- a/wqflask/wqflask/templates/facilities.html +++ b/wqflask/wqflask/templates/facilities.html @@ -10,7 +10,7 @@ <div class="github-btn-container"> <div class="github-btn"> - <a href="https://github.com/genenetwork/gn-docs"> + <a href="https://github.com/genenetwork/gn-docs/blob/master/general/help/facilities.md"> Edit Text <img src="/static/images/edit.png"> </a> diff --git a/wqflask/wqflask/templates/glossary.html b/wqflask/wqflask/templates/glossary.html index 752c4b12..aaee7c5a 100644 --- a/wqflask/wqflask/templates/glossary.html +++ b/wqflask/wqflask/templates/glossary.html @@ -10,7 +10,7 @@ <div class="github-btn-container"> <div class="github-btn"> - <a href="https://github.com/genenetwork/gn-docs"> + <a href="https://github.com/genenetwork/gn-docs/blob/master/general/glossary/glossary.md"> Edit Text <img src="/static/images/edit.png"> </a> diff --git a/wqflask/wqflask/templates/links.html b/wqflask/wqflask/templates/links.html index 072e8429..6e91adae 100644 --- a/wqflask/wqflask/templates/links.html +++ b/wqflask/wqflask/templates/links.html @@ -10,7 +10,7 @@ <div class="github-btn-container"> <div class="github-btn "> - <a href="https://github.com/genenetwork/gn-docs"> + <a href="https://github.com/genenetwork/gn-docs/blob/master/general/links/links.md"> Edit Text <img src="/static/images/edit.png"> </a> diff --git a/wqflask/wqflask/templates/policies.html b/wqflask/wqflask/templates/policies.html index 4e0985d3..e36c9e08 100644 --- a/wqflask/wqflask/templates/policies.html +++ b/wqflask/wqflask/templates/policies.html @@ -10,7 +10,7 @@ <div class="github-btn-container"> <div class="github-btn "> - <a href="https://github.com/genenetwork/gn-docs"> + <a href="https://github.com/genenetwork/gn-docs/blob/master/general/policies/policies.md"> Edit Text <img src="/static/images/edit.png"> </a> diff --git a/wqflask/wqflask/templates/references.html b/wqflask/wqflask/templates/references.html index f723a1e8..04e60361 100644 --- a/wqflask/wqflask/templates/references.html +++ b/wqflask/wqflask/templates/references.html @@ -6,7 +6,7 @@ {% block content %} <div class="github-btn-container"> <div class="github-btn"> - <a href="https://github.com/genenetwork/gn-docs"> + <a href="https://github.com/genenetwork/gn-docs/blob/master/general/references/references.md"> Edit Text <img src="/static/images/edit.png"> </a> |