From 85f014695b7873941ad200051606635ff37b2c20 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 5 Feb 2019 10:42:46 -0600 Subject: Fixed issue with getting marker info that affected heatmap and possibly other functions Added the collection page features (correlation matrix, network graph, third party link-outs, etc) to the search result and correlation result pages --- wqflask/base/data_set.py | 38 +++++------ wqflask/wqflask/heatmap/heatmap.py | 4 ++ .../static/new/javascript/search_results.js | 59 +++++++++++++++++ wqflask/wqflask/templates/collections/view.html | 58 ----------------- wqflask/wqflask/templates/correlation_page.html | 75 ++++++++-------------- wqflask/wqflask/templates/search_result_page.html | 57 +++++++++++++++- 6 files changed, 161 insertions(+), 130 deletions(-) (limited to 'wqflask') diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 2acb3b61..79f72390 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -171,28 +171,22 @@ class Markers(object): def __init__(self, name): json_data_fh = open(locate(name + ".json",'genotype/json')) - try: - markers = [] - with open(locate(name + "_snps.txt", 'r')) as bimbam_fh: + markers = [] + with open("%s/%s_snps.txt" % (flat_files('genotype/bimbam'), name), 'r') as bimbam_fh: + if len(bimbam_fh.readline().split(", ")) > 2: + delimiter = ", " + elif len(bimbam_fh.readline().split(",")) > 2: + delimiter = "," + elif len(bimbam_fh.readline().split("\t")) > 2: + delimiter = "\t" + else: + delimiter = " " + for line in bimbam_fh: marker = {} - if len(bimbam_fh[0].split(", ")) > 2: - delimiter = ", " - elif len(bimbam_fh[0].split(",")) > 2: - delimiter = "," - elif len(bimbam_fh[0].split("\t")) > 2: - delimiter = "\t" - else: - delimiter = " " - for line in bimbam_fh: - marker['name'] = line.split(delimiter)[0] - marker['Mb'] - marker['chr'] = line.split(delimiter)[2] - marker['cM'] - markers.append(marker) - #try: - # markers = json.load(json_data_fh) - except: - markers = [] + marker['name'] = line.split(delimiter)[0].rstrip() + marker['Mb'] = float(line.split(delimiter)[1].rstrip())/1000000 + marker['chr'] = line.split(delimiter)[2].rstrip() + markers.append(marker) for marker in markers: if (marker['chr'] != "X") and (marker['chr'] != "Y"): @@ -334,8 +328,6 @@ class DatasetGroup(object): return mapping_id, mapping_names def get_markers(self): - logger.debug("self.species is:", self.species) - def check_plink_gemma(): if flat_file_exists("mapping"): MAPPING_PATH = flat_files("mapping")+"/" diff --git a/wqflask/wqflask/heatmap/heatmap.py b/wqflask/wqflask/heatmap/heatmap.py index 7b328cb5..ff589693 100644 --- a/wqflask/wqflask/heatmap/heatmap.py +++ b/wqflask/wqflask/heatmap/heatmap.py @@ -43,6 +43,9 @@ Redis = Redis() from flask import Flask, g +from utility.logger import getLogger +logger = getLogger(__name__ ) + class Heatmap(object): def __init__(self, start_vars, temp_uuid): @@ -96,6 +99,7 @@ class Heatmap(object): for trait in self.trait_results.keys(): lodnames.append(trait) + self.dataset.group.get_markers() for marker in self.dataset.group.markers.markers: chr_pos.append(marker['chr']) pos.append(marker['Mb']) diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index abcdf7e6..2277a157 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -223,6 +223,65 @@ $(function() { $('#export_form').submit(); }; + $("#corr_matrix").on("click", function() { + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + $("#trait_list").val(traits) + url = $(this).data("url") + return submit_special(url) + }); + $("#network_graph").on("click", function() { + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + $("#trait_list").val(traits) + url = $(this).data("url") + return submit_special(url) + }); + $("#wgcna_setup").on("click", function() { + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + $("#trait_list").val(traits) + url = $(this).data("url") + return submit_special(url) + }); + $("#ctl_setup").on("click", function() { + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + $("#trait_list").val(traits) + url = $(this).data("url") + return submit_special(url) + }); + $("#heatmap").on("click", function() { + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + $("#trait_list").val(traits) + url = $(this).data("url") + return submit_special(url) + }); + $("#comp_bar_chart").on("click", function() { + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + $("#trait_list").val(traits) + url = $(this).data("url") + return submit_special(url) + }); + + $("#send_to_webgestalt, #send_to_bnw").on("click", function() { + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + $("#trait_list").val(traits) + url = $(this).data("url") + return submit_special(url) + }); + + $("#select_all").click(select_all); $("#deselect_all").click(deselect_all); $("#invert").click(invert); diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index a2b63374..a219b868 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -220,64 +220,6 @@ url = $(this).data("url") return submit_special(url) }); - - $("#corr_matrix").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#network_graph").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#wgcna_setup").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#ctl_setup").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#heatmap").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#comp_bar_chart").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - - $("#send_to_webgestalt, #send_to_bnw").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); }); diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 2d4ed2a4..4786e379 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -20,31 +20,53 @@

-
- {% if uc %} - - {% endif %} - + + + + + + + + + + + + + + + +
@@ -465,49 +487,6 @@ url = $(this).data("url") return submit_special(url) }); - - $("#corr_matrix").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - console.log($("#trait_list").val(traits)) - url = $(this).data("url") - //return submit_special(url) - }); - $("#network_graph").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#wgcna_setup").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#ctl_setup").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - $("#heatmap").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); - $("#trait_list").val(traits) - url = $(this).data("url") - return submit_special(url) - }); - }); {% endblock %} diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 79a279f8..6fcbcb01 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -46,13 +46,63 @@

To study a record click on its ID below, and to view the whole description {% if dataset.type == "Publish" %}or list of authors {% endif %} hover over the table cell. Check records below and click Add button to add to selection.

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+

-
@@ -355,6 +405,11 @@ table.colReorder.reset() }); + submit_special = function(url) { + $("#trait_submission_form").attr("action", url); + return $("#trait_submission_form").submit(); + }; + }); {% endblock %} -- cgit v1.2.3