From f5bc311907ede5e2cce9539554453f846debd9ae Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 1 Nov 2018 19:41:26 +0000 Subject: Updated the way snpbrowser initializes parameters, in preparation for drawing SNP density chart when results exceed a certain value, plus a couple minor fixes Changed the header bar to put a few items under the "Help" option, since previously the header was too long and would go to a second line when the browser window width was smaller Changed dataset info link on trait page to same as one on search page Changed the mapping default to non-LOCO for the time being, until it is faster --- wqflask/wqflask/snp_browser/snp_browser.py | 177 ++++++++++++--------- wqflask/wqflask/static/new/css/main.css | 45 ++++-- .../new/javascript/dataset_menu_structure.json | 111 ++++++------- .../new/javascript/dataset_select_menu_orig.js | 2 +- .../wqflask/static/new/javascript/show_trait.js | 6 +- wqflask/wqflask/templates/base.html | 35 ++-- wqflask/wqflask/templates/show_trait_details.html | 2 +- .../templates/show_trait_mapping_tools.html | 4 +- wqflask/wqflask/templates/snp_browser.html | 5 +- 9 files changed, 217 insertions(+), 170 deletions(-) diff --git a/wqflask/wqflask/snp_browser/snp_browser.py b/wqflask/wqflask/snp_browser/snp_browser.py index 393b8507..0e999ba2 100644 --- a/wqflask/wqflask/snp_browser/snp_browser.py +++ b/wqflask/wqflask/snp_browser/snp_browser.py @@ -1,8 +1,11 @@ from __future__ import absolute_import, print_function, division -from flask import Flask, g +from flask import Flask, g, url_for + +from htmlgen import HTMLgen2 as HT import string +import piddle as pid from utility.logger import getLogger logger = getLogger(__name__ ) @@ -31,99 +34,110 @@ class SnpBrowser(object): self.table_rows = [] def initialize_parameters(self, start_vars): - self.first_run = "true" - self.allele_list = [] - if 'variant' in start_vars: #ZS: Check if not first time loaded (if it has form input) + if 'first_run' in start_vars: self.first_run = "false" + else: + self.first_run = "true" + self.allele_list = [] + + self.variant_type = "SNP" + if 'variant' in start_vars: self.variant_type = start_vars['variant'] + + self.species_name = "Mouse" + self.species_id = 1 + if 'species' in start_vars: self.species_name = start_vars['species'] - if self.species_name.capitalize() == "Mouse": - self.species_id = 1 - elif self.species_name.capitalize() == "Rat": + if self.species_name.capitalize() == "Rat": self.species_id = 2 + + species_ob = species.TheSpecies(species_name=self.species_name) + + self.chr_list = [] + for key in species_ob.chromosomes.chromosomes: + self.chr_list.append(species_ob.chromosomes.chromosomes[key].name) + + if self.first_run == "true": + self.chr = "19" + self.start_mb = 30.1 + self.end_mb = 30.12 + else: + if 'gene_name' in start_vars: + if start_vars['gene_name'] != "": + self.gene_name = start_vars['gene_name'] + else: + self.gene_name = "" + self.chr = start_vars['chr'] + try: + self.start_mb = float(start_vars['start_mb']) + self.end_mb = float(start_vars['end_mb']) + except: + self.start_mb = 0.0 + self.end_mb = 0.0 else: - self.species_id = 0 #Using this to indicate "All Species" - - #ZS: Currently this is just assuming mouse for determining the chromosomes. - # This logic may have to change depending upon what other species are added - self.chr_list = [] - species_ob = species.TheSpecies(species_name="Mouse") - for key in species_ob.chromosomes.chromosomes: - self.chr_list.append(species_ob.chromosomes.chromosomes[key].name) - - if start_vars['gene_name'] != "": - self.gene_name = start_vars['gene_name'] - else: - self.gene_name = "" - self.chr = start_vars['chr'] try: + self.chr = start_vars['chr'] self.start_mb = float(start_vars['start_mb']) self.end_mb = float(start_vars['end_mb']) except: + self.chr = "1" self.start_mb = 0.0 self.end_mb = 0.0 - if 'limit_strains' in start_vars: - self.limit_strains = "true" - else: + self.limit_strains = "true" + if self.first_run == "false": + if 'limit_strains' not in start_vars: self.limit_strains = "false" + else: + if start_vars['limit_strains'] == "false": + self.limit_strains = "false" + + self.chosen_strains_mouse = ["C57BL/6J", + "DBA/2J", + "A/J", + "129S1/SvImJ", + "NOD/ShiLtJ", + "NZO/HlLtJ", + "WSB/EiJ", + "PWK/PhJ", + "CAST/EiJ"] + self.chosen_strains_rat = ["BN", "F344"] + if 'chosen_strains_mouse' in start_vars: self.chosen_strains_mouse = start_vars['chosen_strains_mouse'].split(",") + if 'chosen_strains_rat' in start_vars: self.chosen_strains_rat = start_vars['chosen_strains_rat'].split(",") - if self.species_id == 1: - self.chosen_strains = self.chosen_strains_mouse - elif self.species_id == 2: - self.chosen_strains = self.chosen_strains_rat + if self.species_id == 1: + self.chosen_strains = self.chosen_strains_mouse + else: + self.chosen_strains = self.chosen_strains_rat + self.domain = "All" + if 'domain' in start_vars: self.domain = start_vars['domain'] + self.function = "All" + if 'function' in start_vars: self.function = start_vars['function'] + self.source = "All" + if 'source' in start_vars: self.source = start_vars['source'] + self.criteria = ">=" + if 'criteria' in start_vars: self.criteria = start_vars['criteria'] + self.score = 0.0 + if 'score' in start_vars: self.score = start_vars['score'] - self.redundant = "false" - self.diff_alleles = "false" - if 'redundant' in start_vars: - self.redundant = "true" - if 'diff_alleles' in start_vars: - self.diff_alleles = "true" - - else: #ZS: Default values - self.variant_type = "SNP" - self.species_name = "Mouse" - species_ob = species.TheSpecies(species_name=self.species_name) - self.chr_list = [] - for key in species_ob.chromosomes.chromosomes: - self.chr_list.append(species_ob.chromosomes.chromosomes[key].name) - - self.chr = "19" - self.start_mb = 30.1 - self.end_mb = 30.12 - - self.limit_strains = "true" - - self.chosen_strains_mouse = ["C57BL/6J", - "DBA/2J", - "A/J", - "129S1/SvImJ", - "NOD/ShiLtJ", - "NZO/HlLtJ", - "WSB/EiJ", - "PWK/PhJ", - "CAST/EiJ"] - self.chosen_strains_rat = ["F344"] - self.chosen_strains_all = self.chosen_strains_mouse + self.chosen_strains_rat - - self.chosen_strains = self.chosen_strains_mouse - - self.domain = "All" - self.function = "All" - self.source = "All" - self.criteria = ">=" - self.score = 0.0 - - self.redundant = "false" - self.diff_alleles = "true" + self.redundant = "false" + if self.first_run == "false" and 'redundant' in start_vars: + self.redundant = "true" + self.diff_alleles = "true" + if self.first_run == "false": + if 'diff_alleles' not in start_vars: + self.diff_alleles = "false" + else: + if start_vars['diff_alleles'] == "false": + self.diff_alleles = "false" def get_browser_results(self): self.snp_list = None @@ -567,6 +581,27 @@ class SnpBrowser(object): return domain_satisfied and function_satisfied and source_satisfied and score_satisfied and different_alleles_satisfied + def snp_density_map(self, query, results): + + canvas_width = 900 + canvas_height = 200 + snp_canvas = pid.PILCanvas(size=(canvas_width, canvas_height)) + left_offset, right_offset, top_offset, bottom_offset = (30, 30, 40, 50) + plot_width = canvas_width - left_offset - right_offset + plot_height = canvas_height - top_offset - bottom_offset + y_zero = top_offset + plot_height/2 + + x_scale = plot_width/(self.end_mb - self.start_mb) + + #draw clickable image map + #gifmap = HT.Map + n_click = 80.0 + click_step = plot_width/n_click + click_mb_step = (self.end_mb - self.start_mb)/n_click + + #for i in range(n_click): + # href = url_for('snp_browser', first_run="false", chosen_strains_mouse=self.chosen_strains_mouse, chosen_strains_rat=self.chosen_strains_rat, variant=self.variant_type, species=self.species_name, gene_name=self.gene_name, chr=self.chr, start_mb=self.start_mb, end_mb=self.end_mb, limit_strains=self.limit_strains, domain=self.domain, function=self.function, criteria=self.criteria, score=self.score, diff_alleles=self.diff_alleles) + def get_browser_sample_lists(species_id=1): strain_lists = {} mouse_strain_list = [] diff --git a/wqflask/wqflask/static/new/css/main.css b/wqflask/wqflask/static/new/css/main.css index 880395a7..097cd997 100644 --- a/wqflask/wqflask/static/new/css/main.css +++ b/wqflask/wqflask/static/new/css/main.css @@ -1,11 +1,36 @@ -.security_box { - padding-left: 30px; - padding-right: 30px; -} - -ol { - font-family: Arial; - font-weight: bold; - font-size: 16px; - color: #000082 +@media (max-width: 10px) { + .navbar-header { + float: none; + } + .navbar-toggle { + display: block; + } + .navbar-collapse { + border-top: 1px solid transparent; + box-shadow: inset 0 1px 0 rgba(255,255,255,0.1); + } + .navbar-collapse.collapse { + display: none!important; + } + .navbar-nav { + float: none!important; + margin: 7.5px -15px; + } + .navbar-nav>li { + float: none; + } + .navbar-nav>li>a { + padding-top: 10px; + padding-bottom: 10px; + } + .navbar-text { + float: none; + margin: 15px 0; + } + .navbar-collapse.collapse.in { + display: block!important; + } + .collapsing { + overflow: hidden!important; + } } \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json index 1c6791c4..9c806a7f 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json +++ b/wqflask/wqflask/static/new/javascript/dataset_menu_structure.json @@ -2590,21 +2590,6 @@ ] ], "Liver mRNA": [ - [ - "858", - "EPFLMouseLiverHFDRMA0818", - "EPFL/LISP BXD HFD Liver Affy Mouse Gene 1.0 ST (Aug18) RMA" - ], - [ - "852", - "NIA-AgBXD-Liv_HFD-0818", - "NIA Aging BXD HFD Liver Affy Clariom S Gene Level (Aug18) RMA **" - ], - [ - "857", - "EPFLMouseLiverCDHFDRMA0818", - "EPFL/LISP BXD CD+HFD Liver Affy Mouse Gene 1.0 ST (Aug18) RMA" - ], [ "859", "EPFLMouseLiverCDRMA0818", @@ -2625,6 +2610,21 @@ "UCLA_BXD_Liv_Jan16", "UCLA BXD Liver Affy M430 2.0 (Jan16) RMA" ], + [ + "858", + "EPFLMouseLiverHFDRMA0818", + "EPFL/LISP BXD HFD Liver Affy Mouse Gene 1.0 ST (Aug18) RMA" + ], + [ + "852", + "NIA-AgBXD-Liv_HFD-0818", + "NIA Aging BXD HFD Liver Affy Clariom S Gene Level (Aug18) RMA **" + ], + [ + "857", + "EPFLMouseLiverCDHFDRMA0818", + "EPFL/LISP BXD CD+HFD Liver Affy Mouse Gene 1.0 ST (Aug18) RMA" + ], [ "430", "EPFLMouseLiverRMA0413", @@ -2640,6 +2640,11 @@ "EPFLMouseLiverCDRMA0413", "EPFL/LISP BXD CD Liver Affy Mouse Gene 1.0 ST (Apr13) RMA" ], + [ + "433", + "EPFLMouseLiverBothExRMA0413", + "EPFL/LISP BXD CD+HFD Liver Affy Mouse Gene 1.0 ST (Apr13) RMA Exon Level" + ], [ "849", "EPFLMouseLiverCDEx0413", @@ -2650,11 +2655,6 @@ "EPFLMouseLiverHFCEx0413", "EPFL/LISP BXD HFC Liver Affy Mouse Gene 1.0 ST (Apr13) RMA Exon Level" ], - [ - "433", - "EPFLMouseLiverBothExRMA0413", - "EPFL/LISP BXD CD+HFD Liver Affy Mouse Gene 1.0 ST (Apr13) RMA Exon Level" - ], [ "700", "UTHSC-VGX_MmBXDHepatocytesRMA1014", @@ -3671,6 +3671,11 @@ }, "Retina-RGC-Rheaume": { "Retina Single-cell RNA-Seq": [ + [ + "866", + "UConn-RGC-RSeq_log2-0918", + "UConn-Rheaume Retina RGC (Sep18) scRNA-Seq Log2" + ], [ "865", "UConn-RGC-RSeq_r-0918", @@ -3680,11 +3685,6 @@ "867", "UConn-RGC-RSeq_s-0918", "UConn-Rheaume Retina RGC (Sep18) scRNA-Seq Siamak" - ], - [ - "866", - "UConn-RGC-RSeq_log2-0918", - "UConn-Rheaume Retina RGC (Sep18) scRNA-Seq Log2" ] ] }, @@ -3712,16 +3712,18 @@ }, "rat": { "HSNIH-Palmer": { + "Infralimbic Cortex mRNA": [ + [ + "861", + "HSNIH-Rat-IL-RSeq-0818", + "HSNIH-Palmer Infralimbic Cortex RNA-Seq (Aug18) rlog" + ] + ], "Lateral Habenula mRNA": [ [ "862", "HSNIH-Rat-LHB-RSeq-0818", "HSNIH-Palmer Lateral Habenula RNA-Seq (Aug18) rlog" - ], - [ - "870", - "HSNIH-Rat-LHB-RSeqlog2-0818", - "HSNIH-Palmer Lateral Habenula RNA-Seq (Aug18) log2" ] ], "Nucleus Accumbens mRNA": [ @@ -3729,11 +3731,13 @@ "860", "HSNIH-Rat-Acbc-RSeq-0818", "HSNIH-Palmer Nucleus Accumbens Core RNA-Seq (Aug18) rlog" - ], + ] + ], + "Orbitofrontal Cortex mRNA": [ [ - "868", - "HSNIH-Rat-Acbc-RSeqlog2-0818", - "HSNIH-Palmer Nucleus Accumbens Core RNA-Seq (Aug18) log2" + "864", + "HSNIH-Rat-VoLo-RSeq-0818", + "HSNIH-Palmer Orbitofrontal Cortex RNA-Seq (Aug18) rlog" ] ], "Phenotypes": [ @@ -3743,32 +3747,7 @@ "HSNIH-Palmer Phenotypes" ] ], - "Prefrontal Cortex mRNA": [ - [ - "869", - "HSNIH-Rat-IL-RSeqlog2-0818", - "HSNIH-Palmer Infralimbic Cortex RNA-Seq (Aug18) log2" - ], - [ - "872", - "HSNIH-Rat-VoLo-RSeqlog2-0818", - "HSNIH-Palmer Orbitofrontal Cortex RNA-Seq (Aug18) log2" - ], - [ - "861", - "HSNIH-Rat-IL-RSeq-0818", - "HSNIH-Palmer Infralimbic Cortex RNA-Seq (Aug18) rlog" - ], - [ - "864", - "HSNIH-Rat-VoLo-RSeq-0818", - "HSNIH-Palmer Orbitofrontal Cortex RNA-Seq (Aug18) rlog" - ], - [ - "871", - "HSNIH-Rat-PL-RSeqlog2-0818", - "HSNIH-Palmer Prelimbic Cortex RNA-Seq (Aug18) log2" - ], + "Prelimbic Cortex mRNA": [ [ "863", "HSNIH-Rat-PL-RSeq-0818", @@ -5531,6 +5510,10 @@ "Phenotypes", "Phenotypes" ], + [ + "Infralimbic Cortex mRNA", + "Infralimbic Cortex mRNA" + ], [ "Lateral Habenula mRNA", "Lateral Habenula mRNA" @@ -5540,8 +5523,12 @@ "Nucleus Accumbens mRNA" ], [ - "Prefrontal Cortex mRNA", - "Prefrontal Cortex mRNA" + "Orbitofrontal Cortex mRNA", + "Orbitofrontal Cortex mRNA" + ], + [ + "Prelimbic Cortex mRNA", + "Prelimbic Cortex mRNA" ] ], "HSNIH-RGSMC": [ diff --git a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js index d5ce6f84..3f123d6f 100644 --- a/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js +++ b/wqflask/wqflask/static/new/javascript/dataset_select_menu_orig.js @@ -94,7 +94,7 @@ $(function() { })(this)); open_window = function(url, name) { var options; - options = "menubar=1,toolbar=1,location=1,resizable=1,status=1,scrollbars=1,directories=1,width=900"; + options = "menubar=yes,toolbar=yes,titlebar=yes,location=yes,resizable=yes,status=yes,scrollbars=yes,directories=yes,width=900"; return open(url, name, options).focus(); }; group_info = function() { diff --git a/wqflask/wqflask/static/new/javascript/show_trait.js b/wqflask/wqflask/static/new/javascript/show_trait.js index a3edd0e6..c1b0cef9 100644 --- a/wqflask/wqflask/static/new/javascript/show_trait.js +++ b/wqflask/wqflask/static/new/javascript/show_trait.js @@ -829,8 +829,10 @@ } } + root.chart_range = [range_bottom, range_top] + total_sample_count = 0 - for (i = 0, i < sample_lists.length; i++) { + for (i = 0, i < sample_lists.length; i++;) { total_sample_count += get_sample_vals(sample_lists[i]).length } @@ -839,7 +841,7 @@ var layout = { yaxis: { - range: [range_bottom, range_top], + range: root.chart_range, }, width: bar_chart_width, height: 600, diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 81c04db5..3d03f3b9 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -22,17 +22,22 @@
-