diff options
23 files changed, 539 insertions, 217 deletions
diff --git a/test/requests/link_checker.py b/test/requests/link_checker.py index fa70747d..5e16a5cd 100644 --- a/test/requests/link_checker.py +++ b/test/requests/link_checker.py @@ -76,3 +76,26 @@ def check_links(args_obj, parser): check_page( host, host+"/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P") + + +def check_packaged_js_files(args_obj, parser): + host = args_obj.host + js_files = [ + # Datatables Extensions: + "/DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css", + "/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", + "/DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css", + "/DataTablesExtensions/buttons/js/dataTables.buttons.min.js", + "/DataTablesExtensions/colResize/dataTables.colResize.js", + "/DataTablesExtensions/colReorder/js/dataTables.colReorder.js", + "/DataTablesExtensions/buttons/js/buttons.colVis.min.js", + "/DataTables/js/jquery.dataTables.js", + "/DataTablesExtensions/scroller/css/scroller.dataTables.min.css", + # Datatables plugins: + "/DataTablesExtensions/plugins/sorting/natural.js", + "/DataTablesExtensions/plugins/sorting/scientific.js", + ] + + print("Checking links") + for link in js_files: + verify_link(host+link) diff --git a/test/requests/test-website.py b/test/requests/test-website.py index 74057e7f..f90d1843 100755 --- a/test/requests/test-website.py +++ b/test/requests/test-website.py @@ -6,6 +6,7 @@ from __future__ import print_function import argparse from link_checker import check_links +from link_checker import check_packaged_js_files from mapping_tests import check_mapping from navigation_tests import check_navigation from main_web_functionality import check_main_web_functionality @@ -30,6 +31,7 @@ def run_all(args_obj, parser): link_checker.DO_FAIL = args_obj.fail check_main_web_functionality(args_obj, parser) check_links(args_obj, parser) + check_packaged_js_files(args_obj, parser) check_mapping(args_obj, parser) # TODO: Add other functions as they are created. diff --git a/wqflask/tests/wqflask/api/test_gen_menu.py b/wqflask/tests/wqflask/api/test_gen_menu.py index 79c77fec..239484aa 100644 --- a/wqflask/tests/wqflask/api/test_gen_menu.py +++ b/wqflask/tests/wqflask/api/test_gen_menu.py @@ -255,9 +255,9 @@ class TestGenMenu(unittest.TestCase): ('Mouse Tissue'), ('Human Tissue'), ('Rat Tissue') ) self.assertEqual(build_types('mouse', 'random group'), - [['M', 'M', 'Molecular Trait Datasets'], - ['H', 'H', 'Molecular Trait Datasets'], - ['R', 'R', 'Molecular Trait Datasets']]) + [['M', 'M', 'Molecular Traits'], + ['H', 'H', 'Molecular Traits'], + ['R', 'R', 'Molecular Traits']]) db_mock.db.execute.assert_called_once_with( "SELECT DISTINCT Tissue.Name " + "FROM ProbeFreeze, ProbeSetFreeze, InbredSet, " + diff --git a/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py new file mode 100644 index 00000000..6f791df1 --- /dev/null +++ b/wqflask/tests/wqflask/marker_regression/test_display_mapping_results.py @@ -0,0 +1,151 @@ +import unittest + +from htmlgen import HTMLgen2 as HT +from wqflask.marker_regression.display_mapping_results import ( + DisplayMappingResults, + HtmlGenWrapper +) + + +class TestDisplayMappingResults(unittest.TestCase): + """Basic Methods to test Mapping Results""" + def test_pil_colors(self): + """Test that colors use PILLOW color format""" + self.assertEqual(DisplayMappingResults.CLICKABLE_WEBQTL_REGION_COLOR, + (245, 211, 211)) + + +class TestHtmlGenWrapper(unittest.TestCase): + """Test Wrapper around HTMLGen""" + def test_create_image(self): + """Test HT.Image method""" + self.assertEqual( + str(HtmlGenWrapper.create_image_tag(src="test.png", + alt="random", + border="0", + width="10", + height="13", + usemap="#webqtlmap")), + ("""<IMG src="test.png" height="13" width="10" """ + """alt="random" border="0" """ + """usemap="#webqtlmap">""") + ) + + def test_create_form(self): + """Test HT.Form method""" + test_form = HtmlGenWrapper.create_form_tag( + cgi="/testing/", + enctype='multipart/form-data', + name="formName", + submit=HT.Input(type='hidden') + ) + test_image = HtmlGenWrapper.create_image_tag( + src="test.png", + alt="random", + border="0", + width="10", + height="13", + usemap="#webqtlmap" + ) + self.assertEqual( + str(test_form).replace("\n", ""), + ("""<FORM METHOD="POST" ACTION="/testing/" """ + """ENCTYPE="multipart/form-data" """ + """NAME="formName"><INPUT TYPE="hidden" """ + """NAME="Default_Name"></FORM>""")) + hddn = { + 'FormID': 'showDatabase', + 'ProbeSetID': '_', + 'database': "TestGeno", + 'CellID': '_', + 'RISet': "Test", + 'incparentsf1': 'ON' + } + for key in hddn.keys(): + test_form.append(HT.Input(name=key, value=hddn[key], + type='hidden')) + test_form.append(test_image) + self.assertEqual(str(test_form).replace("\n", ""), ( + """<FORM METHOD="POST" ACTION="/testing/" """ + """ENCTYPE="multipart/form-data" NAME="formName">""" + """<INPUT TYPE="hidden" NAME="database" VALUE="TestGeno">""" + """<INPUT TYPE="hidden" NAME="incparentsf1" VALUE="ON">""" + """<INPUT TYPE="hidden" NAME="FormID" VALUE="showDatabase">""" + """<INPUT TYPE="hidden" NAME="ProbeSetID" VALUE="_">""" + """<INPUT TYPE="hidden" NAME="RISet" VALUE="Test">""" + """<INPUT TYPE="hidden" NAME="CellID" VALUE="_">""" + """<IMG src="test.png" height="13" width="10" alt="random" """ + """border="0" usemap="#webqtlmap">""" + """<INPUT TYPE="hidden" NAME="Default_Name"></FORM>""")) + + def test_create_paragraph(self): + """Test HT.Paragraph method""" + test_p_element = HtmlGenWrapper.create_p_tag(id="smallSize") + par_text = ( + "Mapping using genotype data as " + "a trait will result in infinity LRS at one locus. " + "In order to display the result properly, all LRSs " + "higher than 100 are capped at 100." + ) + self.assertEqual( + str(test_p_element), + """<P id="smallSize"></P>""" + ) + test_p_element.append(HT.BR()) + test_p_element.append(par_text) + self.assertEqual( + str(test_p_element), + """<P id="smallSize"><BR>{}</P>""".format(par_text) + ) + + def test_create_br_tag(self): + """Test HT.BR() method""" + self.assertEqual(str(HtmlGenWrapper.create_br_tag()), + "<BR>") + + def test_create_input_tag(self): + """Test HT.Input method""" + self.assertEqual( + str(HtmlGenWrapper.create_input_tag( + type="hidden", + name="name", + value="key", + Class="trait trait_")).replace("\n", ""), + ("""<INPUT TYPE="hidden" NAME="name" """ + """class="trait trait_" VALUE="key">""")) + + def test_create_map_tag(self): + """Test HT.Map method""" + self.assertEqual(str(HtmlGenWrapper.create_map_tag( + name="WebqTLImageMap")).replace("\n", ""), + """<MAP NAME="WebqTLImageMap"></MAP>""") + gifmap = HtmlGenWrapper.create_map_tag(areas=[]) + gifmap.areas.append(HT.Area(shape="rect", + coords='1 2 3', href='#area1')) + gifmap.areas.append(HT.Area(shape="rect", + coords='1 2 3', href='#area2')) + self.assertEqual( + str(gifmap).replace("\n", ""), + ("""<MAP NAME="">""" + """<AREA coords="1 2 3" """ + """href="#area1" shape="rect">""" + """<AREA coords="1 2 3" href="#area2" shape="rect">""" + """</MAP>""")) + + def test_create_area_tag(self): + """Test HT.Area method""" + self.assertEqual( + str(HtmlGenWrapper.create_area_tag( + shape="rect", + coords="1 2", + href="http://test.com", + title="Some Title")).replace("\n", ""), + ("""<AREA coords="1 2" href="http://test.com" """ + """shape="rect" title="Some Title">""")) + + def test_create_link_tag(self): + """Test HT.HREF method""" + self.assertEqual( + str(HtmlGenWrapper.create_link_tag( + "www.test.com", "test", target="_blank")).replace("\n", ""), + """<A HREF="www.test.com" TARGET="_blank">test</A>""") diff --git a/wqflask/tests/wqflask/marker_regression/test_display_marking_results.py b/wqflask/tests/wqflask/marker_regression/test_display_marking_results.py deleted file mode 100644 index 67da508b..00000000 --- a/wqflask/tests/wqflask/marker_regression/test_display_marking_results.py +++ /dev/null @@ -1,9 +0,0 @@ -import unittest - -from wqflask.marker_regression.display_mapping_results import DisplayMappingResults - -class TestDisplayMappingResults(unittest.TestCase): - def test_pil_colors(self): - """Test that colors use PILLOW color format""" - self.assertEqual(DisplayMappingResults.CLICKABLE_WEBQTL_REGION_COLOR, - (245, 211, 211)) diff --git a/wqflask/utility/Plot.py b/wqflask/utility/Plot.py index 4f6e694e..7d9d7649 100644 --- a/wqflask/utility/Plot.py +++ b/wqflask/utility/Plot.py @@ -26,16 +26,12 @@ from __future__ import print_function -from PIL import (Image, ImageColor, ImageDraw, ImageFont) -from pprint import pformat as pf +from PIL import ImageColor +from PIL import ImageDraw +from PIL import ImageFont from math import * -import random -import sys, os -from numarray import linear_algebra as la -from numarray import ones, array, dot, swapaxes -import webqtlUtil import corestats from base import webqtlConfig from utility.pillow_utils import draw_rotated_text diff --git a/wqflask/utility/pillow_utils.py b/wqflask/utility/pillow_utils.py index 1e2ed075..c486abba 100644 --- a/wqflask/utility/pillow_utils.py +++ b/wqflask/utility/pillow_utils.py @@ -1,5 +1,7 @@ from PIL import Image, ImageColor, ImageDraw, ImageFont +from utility.tools import TEMPDIR + import utility.logger logger = utility.logger.getLogger(__name__ ) @@ -14,7 +16,7 @@ def draw_rotated_text(canvas, text, font, xy, fill=BLACK, angle=-90): draw_text = ImageDraw.Draw(tmp_img) draw_text.text(text=text, xy=(0, 0), font=font, fill=fill) tmp_img2 = tmp_img.rotate(angle, expand=1) - tmp_img2.save("/tmp/{}.png".format(text), format="png") + tmp_img2.save("/{0}/{1}.png".format(TEMPDIR, text), format="png") canvas.paste(im=tmp_img2, box=tuple([int(i) for i in xy])) # def draw_open_polygon(canvas: Image, xy: tuple, fill: ImageColor=WHITE, outline: ImageColor=BLACK): diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py index 71d9ee03..41966f78 100644 --- a/wqflask/wqflask/api/gen_menu.py +++ b/wqflask/wqflask/api/gen_menu.py @@ -128,7 +128,7 @@ def build_types(species, group): these_datasets = build_datasets(species, group, result[0]) if len(these_datasets) > 0: results.append([str(result[0]), str(result[0]), - "Molecular Trait Datasets"]) + "Molecular Traits"]) return results diff --git a/wqflask/wqflask/marker_regression/display_mapping_results.py b/wqflask/wqflask/marker_regression/display_mapping_results.py index f06db5d5..255e3b74 100644 --- a/wqflask/wqflask/marker_regression/display_mapping_results.py +++ b/wqflask/wqflask/marker_regression/display_mapping_results.py @@ -24,13 +24,13 @@ # # Last updated by Zach 12/14/2010 -import datetime import string from math import * -from PIL import (Image, ImageDraw, ImageFont, ImageColor) -import sys, os -import pickle -import http.client +from PIL import Image +from PIL import ImageDraw +from PIL import ImageFont +from PIL import ImageColor +import os import json from flask import Flask, g @@ -40,11 +40,10 @@ from htmlgen import HTMLgen2 as HT from base import webqtlConfig from base.GeneralObject import GeneralObject from utility import webqtlUtil -from utility import helper_functions from utility import Plot from utility.benchmark import Bench from wqflask.interval_analyst import GeneUtil -from base.webqtlConfig import TMPDIR, GENERATED_TEXT_DIR, GENERATED_IMAGE_DIR +from base.webqtlConfig import GENERATED_IMAGE_DIR from utility.pillow_utils import draw_rotated_text, draw_open_polygon import utility.logger @@ -84,22 +83,53 @@ ARIAL_FILE = "./wqflask/static/fonts/arial.ttf" assert(os.path.isfile(VERDANA_FILE)) -# ---- END: FONT FILES ---- # -######################################### -# Inteval Mapping Plot Page -######################################### +class HtmlGenWrapper: + """Wrapper Methods for HTML gen""" + @staticmethod + def create_image_tag(**kwargs): + return HT.Image(**kwargs) + + @staticmethod + def create_form_tag(**kwargs): + return HT.Form(**kwargs) + + @staticmethod + def create_p_tag(**kwargs): + return HT.Paragraph(**kwargs) + + @staticmethod + def create_br_tag(): + return HT.BR() + + @staticmethod + def create_input_tag(**kwargs): + return HT.Input(**kwargs) + + @staticmethod + def create_area_tag(**kwargs): + return HT.Area(**kwargs) + + @staticmethod + def create_link_tag(href, content, **kwargs): + return HT.Href(href, content, **kwargs) + + @staticmethod + def create_map_tag(**kwargs): + return HT.Map(**kwargs) + + class DisplayMappingResults(object): + """Inteval Mapping Plot Page""" cMGraphInterval = 5 GRAPH_MIN_WIDTH = 900 - GRAPH_MAX_WIDTH = 10000 # Don't set this too high + GRAPH_MAX_WIDTH = 10000 # Don't set this too high GRAPH_DEFAULT_WIDTH = 1280 MULT_GRAPH_DEFAULT_WIDTH = 2000 MULT_GRAPH_MIN_WIDTH = 1400 MULT_GRAPH_DEFAULT_WIDTH = 1600 GRAPH_DEFAULT_HEIGHT = 600 - # Display order: # UCSC BAND ========= # ENSEMBL BAND -=-=-= @@ -110,22 +140,27 @@ class DisplayMappingResults(object): BAND_HEIGHT = 10 BAND_HEIGHT = 10 - NUM_GENE_ROWS = 10 - EACH_GENE_HEIGHT = 6 # number of pixels tall, for each gene to display + NUM_GENE_ROWS = 10 + EACH_GENE_HEIGHT = 6 # number of pixels tall, for each gene to display EACH_GENE_ARROW_WIDTH = 5 EACH_GENE_ARROW_SPACING = 14 DRAW_DETAIL_MB = 4 DRAW_UTR_LABELS_MB = 4 - qmarkImg = HT.Image('/images/qmarkBoxBlue.gif', width=10, height=13, border=0, alt='Glossary') - # Note that "qmark.gif" is a similar, smaller, rounded-edges question mark. It doesn't look - # like the ones on the image, though, which is why we don't use it here. + qmarkImg = HtmlGenWrapper.create_image_tag( + src='/images/qmarkBoxBlue.gif', + width="10", height="13", border="0", alt='Glossary' + ) + + # Note that "qmark.gif" is a similar, smaller, rounded-edges + # question mark. It doesn't look like the ones on the image, + # though, which is why we don't use it here. HELP_WINDOW_NAME = 'helpWind' - ## BEGIN HaplotypeAnalyst + # BEGIN HaplotypeAnalyst NR_INDIVIDUALS = 0 - ## END HaplotypeAnalyst + # END HaplotypeAnalyst ALEX_DEBUG_BOOL_PRINT_GENE_LIST = 1 @@ -133,13 +168,13 @@ class DisplayMappingResults(object): LODFACTOR = 4.61 - SNP_COLOR = ORANGE # Color for the SNP "seismograph" + SNP_COLOR = ORANGE # Color for the SNP "seismograph" TRANSCRIPT_LOCATION_COLOR = MEDIUMPURPLE BOOTSTRAP_BOX_COLOR = YELLOW - LRS_COLOR = ImageColor.getrgb("#0000FF") - SIGNIFICANT_COLOR = ImageColor.getrgb("#EBC7C7") - SUGGESTIVE_COLOR = GAINSBORO + LRS_COLOR = ImageColor.getrgb("#0000FF") + SIGNIFICANT_COLOR = ImageColor.getrgb("#EBC7C7") + SUGGESTIVE_COLOR = GAINSBORO SIGNIFICANT_WIDTH = 5 SUGGESTIVE_WIDTH = 5 ADDITIVE_COLOR_POSITIVE = GREEN @@ -147,33 +182,33 @@ class DisplayMappingResults(object): DOMINANCE_COLOR_POSITIVE = DARKVIOLET DOMINANCE_COLOR_NEGATIVE = RED - ## BEGIN HaplotypeAnalyst + # BEGIN HaplotypeAnalyst HAPLOTYPE_POSITIVE = GREEN HAPLOTYPE_NEGATIVE = RED HAPLOTYPE_HETEROZYGOUS = BLUE HAPLOTYPE_RECOMBINATION = DARKGRAY - ## END HaplotypeAnalyst + # END HaplotypeAnalyst TOP_RIGHT_INFO_COLOR = BLACK - CLICKABLE_WEBQTL_REGION_COLOR = ImageColor.getrgb("#F5D3D3") + CLICKABLE_WEBQTL_REGION_COLOR = ImageColor.getrgb("#F5D3D3") CLICKABLE_WEBQTL_REGION_OUTLINE_COLOR = ImageColor.getrgb("#FCE9E9") - CLICKABLE_WEBQTL_TEXT_COLOR = ImageColor.getrgb("#912828") + CLICKABLE_WEBQTL_TEXT_COLOR = ImageColor.getrgb("#912828") - CLICKABLE_PHENOGEN_REGION_COLOR = ImageColor.getrgb("#A2FB94") + CLICKABLE_PHENOGEN_REGION_COLOR = ImageColor.getrgb("#A2FB94") CLICKABLE_PHENOGEN_REGION_OUTLINE_COLOR = ImageColor.getrgb("#CEFEC7") - CLICKABLE_PHENOGEN_TEXT_COLOR = ImageColor.getrgb("#1FD504") + CLICKABLE_PHENOGEN_TEXT_COLOR = ImageColor.getrgb("#1FD504") - CLICKABLE_UCSC_REGION_COLOR = ImageColor.getrgb("#DDDDEE") + CLICKABLE_UCSC_REGION_COLOR = ImageColor.getrgb("#DDDDEE") CLICKABLE_UCSC_REGION_OUTLINE_COLOR = ImageColor.getrgb("#EDEDFF") - CLICKABLE_UCSC_TEXT_COLOR = ImageColor.getrgb("#333366") + CLICKABLE_UCSC_TEXT_COLOR = ImageColor.getrgb("#333366") - CLICKABLE_ENSEMBL_REGION_COLOR = ImageColor.getrgb("#EEEEDD") + CLICKABLE_ENSEMBL_REGION_COLOR = ImageColor.getrgb("#EEEEDD") CLICKABLE_ENSEMBL_REGION_OUTLINE_COLOR = ImageColor.getrgb("#FEFEEE") - CLICKABLE_ENSEMBL_TEXT_COLOR = ImageColor.getrgb("#555500") + CLICKABLE_ENSEMBL_TEXT_COLOR = ImageColor.getrgb("#555500") GRAPH_BACK_LIGHT_COLOR = ImageColor.getrgb("#FBFBFF") - GRAPH_BACK_DARK_COLOR = ImageColor.getrgb("#F1F1F9") + GRAPH_BACK_DARK_COLOR = ImageColor.getrgb("#F1F1F9") HELP_PAGE_REF = '/glossary.html' @@ -200,7 +235,8 @@ class DisplayMappingResults(object): self.temp_trait = "True" self.group = start_vars['group'] - #Needing for form submission when doing single chr mapping or remapping after changing options + # Needing for form submission when doing single chr + # mapping or remapping after changing options self.samples = start_vars['samples'] self.vals = start_vars['vals'] self.transform = start_vars['transform'] @@ -211,9 +247,9 @@ class DisplayMappingResults(object): self.mapmodel_rqtl_geno = start_vars['model'] self.pair_scan = start_vars['pair_scan'] - #if self.mapping_method != "gemma" and self.mapping_method != "plink": self.js_data = start_vars['js_data'] - self.trimmed_markers = start_vars['trimmed_markers'] #Top markers to display in table + # Top markers to display in table + self.trimmed_markers = start_vars['trimmed_markers'] if self.dataset.group.species == "rat": self._ucscDb = "rn6" @@ -225,7 +261,7 @@ class DisplayMappingResults(object): ##################################### # Options ##################################### - #Mapping options + # Mapping options if start_vars['mapping_scale'] != "": self.plotScale = start_vars['mapping_scale'] else: @@ -514,7 +550,11 @@ class DisplayMappingResults(object): "{}.png".format( os.path.join(webqtlConfig.GENERATED_IMAGE_DIR, self.filename)), format='png') - intImg=HT.Image('/image/'+self.filename+'.png', border=0, usemap='#WebQTLImageMap') + intImg = HtmlGenWrapper.create_image_tag( + src="/image/{}.png".format(self.filename), + border="0", usemap='#WebQTLImageMap' + ) + self.intImg = intImg #Scales plot differently for high resolution if self.draw2X: @@ -531,11 +571,16 @@ class DisplayMappingResults(object): ################################################################ #this form is used for opening Locus page or trait page, only available for genetic mapping if showLocusForm: - showLocusForm = HT.Form(cgi= os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), enctype='multipart/form-data', - name=showLocusForm, submit=HT.Input(type='hidden')) + showLocusForm = HtmlGenWrapper.create_form_tag( + cgi=os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE), + enctype='multipart/form-data', + name=showLocusForm, + submit=HtmlGenWrapper.create_input_tag(type='hidden')) + hddn = {'FormID':'showDatabase', 'ProbeSetID':'_','database':fd.RISet+"Geno",'CellID':'_', 'RISet':fd.RISet, 'incparentsf1':'ON'} - for key in list(hddn.keys()): - showLocusForm.append(HT.Input(name=key, value=hddn[key], type='hidden')) + for key in hddn.keys(): + showLocusForm.append(HtmlGenWrapper.create_input_tag( + name=key, value=hddn[key], type='hidden')) showLocusForm.append(intImg) else: showLocusForm = intImg @@ -546,10 +591,12 @@ class DisplayMappingResults(object): ################################################################ # footnote goes here ################################################################ - btminfo = HT.Paragraph(Id="smallsize") #Small('More information about this graph is available here.') + # Small('More information about this graph is available here.') + btminfo = HtmlGenWrapper.create_p_tag(id="smallsize") if self.traitList and self.traitList[0].dataset and self.traitList[0].dataset.type == 'Geno': - btminfo.append(HT.BR(), 'Mapping using genotype data as a trait will result in infinity LRS at one locus. In order to display the result properly, all LRSs higher than 100 are capped at 100.') + btminfo.append(HtmlGenWrapper.create_br_tag()) + btminfo.append('Mapping using genotype data as a trait will result in infinity LRS at one locus. In order to display the result properly, all LRSs higher than 100 are capped at 100.') def plotIntMapping(self, canvas, offset= (80, 120, 20, 100), zoom = 1, startMb = None, endMb = None, showLocusForm = ""): im_drawer = ImageDraw.Draw(canvas) @@ -605,8 +652,8 @@ class DisplayMappingResults(object): if zoom == 2: drawAreaHeight -= 60 - #Image map - gifmap = HT.Map(name = "WebQTLImageMap") + # Image map + gifmap = HtmlGenWrapper.create_map_tag(name="WebQTLImageMap") newoffset = (xLeftOffset, xRightOffset, yTopOffset, yBottomOffset) # Draw the alternating-color background first and get plotXScale @@ -954,8 +1001,8 @@ class DisplayMappingResults(object): if thisTrait.db: COORDS = "%d,%d,%d,%d" %(rectWidth+2+rightShift, yPaddingTop+kstep*15, rectWidth+2+rightShift+nameWidth, yPaddingTop+10+kstep*15,) HREF= "javascript:showDatabase3('%s','%s','%s','');" % (showLocusForm, thisTrait.db.name, thisTrait.name) - Areas = HT.Area(shape='rect', coords=COORDS, href=HREF) - gifmap.areas.append(Areas) + Areas = HtmlGenWrapper.create_area_tag(shape='rect', coords=COORDS, href=HREF) + gifmap.areas.append(Areas) ### TODO def drawLegendPanel(self, canvas, offset= (40, 120, 80, 10), zoom = 1): im_drawer = ImageDraw.Draw(canvas) @@ -1357,7 +1404,13 @@ class DisplayMappingResults(object): COORDS = "%d, %d, %d, %d" %(geneStartPix, geneYLocation, geneEndPix, (geneYLocation + self.EACH_GENE_HEIGHT)) # NL: 06-02-2011 Rob required to display NCBI info in a new window - gifmap.areas.append(HT.Area(shape='rect', coords=COORDS, href=HREF, title=TITLE, target="_blank")) + gifmap.areas.append( + HtmlGenWrapper.create_area_tag( + shape='rect', + coords=COORDS, + href=HREF, + title=TITLE, + target="_blank")) ## BEGIN HaplotypeAnalyst def drawHaplotypeBand(self, canvas, gifmap, plotXScale, offset= (40, 120, 80, 10), zoom = 1, startMb = None, endMb = None): @@ -1389,6 +1442,8 @@ class DisplayMappingResults(object): #Initializing plotRight, error before plotRight = xRightOffset + im_drawer = ImageDraw.Draw(canvas) + #### find out PlotRight for _chr in self.genotype: if _chr.name == self.ChrList[self.selectedChr][0]: @@ -1523,7 +1578,12 @@ class DisplayMappingResults(object): COORDS = "%d, %d, %d, %d" %(geneStartPix, geneYLocation+ind*self.EACH_GENE_HEIGHT, geneEndPix+1, (geneYLocation + ind*self.EACH_GENE_HEIGHT)) TITLE = "Strain: %s, marker (%s) \n Position %2.3f Mb." % (samplelist[k], _chr[j].name, float(txStart)) HREF = '' - gifmap.areas.append(HT.Area(shape='rect', coords=COORDS, href=HREF, title=TITLE)) + gifmap.areas.append( + HtmlGenWrapper.create_area_tag( + shape='rect', + coords=COORDS, + href=HREF, + title=TITLE)) # if there are no more markers in a chromosome, the plotRight value calculated above will be before the plotWidth # resulting in some empty space on the right side of the plot area. This draws an "unknown" bar from plotRight to the edge. @@ -1642,7 +1702,12 @@ class DisplayMappingResults(object): WEBQTL_HREF = "javascript:rangeView('%s', %f, %f)" % (self.selectedChr - 1, max(0, (calBase-webqtlZoomWidth))/1000000.0, (calBase+webqtlZoomWidth)/1000000.0) WEBQTL_TITLE = "Click to view this section of the genome in WebQTL" - gifmap.areas.append(HT.Area(shape='rect', coords=WEBQTL_COORDS, href=WEBQTL_HREF, title=WEBQTL_TITLE)) + gifmap.areas.append( + HtmlGenWrapper.create_area_tag( + shape='rect', + coords=WEBQTL_COORDS, + href=WEBQTL_HREF, + title=WEBQTL_TITLE)) im_drawer.rectangle( xy=((xBrowse1, paddingTop), (xBrowse2, (paddingTop + self.BAND_HEIGHT))), @@ -1659,7 +1724,12 @@ class DisplayMappingResults(object): else: PHENOGEN_HREF = "https://phenogen.org/gene.jsp?speciesCB=Mm&auto=Y&geneTxt=chr%s:%d-%d&genomeVer=mm10" % (self.selectedChr, max(0, calBase-flankingWidthInBases), calBase+flankingWidthInBases) PHENOGEN_TITLE = "Click to view this section of the genome in PhenoGen" - gifmap.areas.append(HT.Area(shape='rect', coords=PHENOGEN_COORDS, href=PHENOGEN_HREF, title=PHENOGEN_TITLE)) + gifmap.areas.append( + HtmlGenWrapper.create_area_tag( + shape='rect', + coords=PHENOGEN_COORDS, + href=PHENOGEN_HREF, + title=PHENOGEN_TITLE)) im_drawer.rectangle( xy=((xBrowse1, phenogenPaddingTop), (xBrowse2, (phenogenPaddingTop+self.BAND_HEIGHT))), @@ -1675,7 +1745,12 @@ class DisplayMappingResults(object): else: UCSC_HREF = "http://genome.ucsc.edu/cgi-bin/hgTracks?db=%s&position=chr%s:%d-%d" % (self._ucscDb, self.selectedChr, max(0, calBase-flankingWidthInBases), calBase+flankingWidthInBases) UCSC_TITLE = "Click to view this section of the genome in the UCSC Genome Browser" - gifmap.areas.append(HT.Area(shape='rect', coords=UCSC_COORDS, href=UCSC_HREF, title=UCSC_TITLE)) + gifmap.areas.append( + HtmlGenWrapper.create_area_tag( + shape='rect', + coords=UCSC_COORDS, + href=UCSC_HREF, + title=UCSC_TITLE)) im_drawer.rectangle( xy=((xBrowse1, ucscPaddingTop), (xBrowse2, (ucscPaddingTop+self.BAND_HEIGHT))), @@ -1692,7 +1767,11 @@ class DisplayMappingResults(object): else: ENSEMBL_HREF = "http://www.ensembl.org/Rattus_norvegicus/contigview?chr=%s&start=%d&end=%d" % (self.selectedChr, max(0, calBase-flankingWidthInBases), calBase+flankingWidthInBases) ENSEMBL_TITLE = "Click to view this section of the genome in the Ensembl Genome Browser" - gifmap.areas.append(HT.Area(shape='rect', coords=ENSEMBL_COORDS, href=ENSEMBL_HREF, title=ENSEMBL_TITLE)) + gifmap.areas.append(HtmlGenWrapper.create_area_tag( + shape='rect', + coords=ENSEMBL_COORDS, + href=ENSEMBL_HREF, + title=ENSEMBL_TITLE)) im_drawer.rectangle( xy=((xBrowse1, ensemblPaddingTop), (xBrowse2, (ensemblPaddingTop+self.BAND_HEIGHT))), @@ -1923,10 +2002,15 @@ class DisplayMappingResults(object): yZero+40+Zorder*(LRectWidth+3)+LRectWidth)), outline=rectColor, fill=rectColor, width = 0) COORDS="%d,%d,%d,%d"%(xLeftOffset+offsetA-LRectHeight, yZero+40+Zorder*(LRectWidth+3),\ - xLeftOffset+offsetA, yZero+40+Zorder*(LRectWidth+3)+LRectWidth) - HREF="/show_trait?trait_id=%s&dataset=%s" % (Lname, self.dataset.group.name+"Geno") + xLeftOffset+offsetA,yZero+40+Zorder*(LRectWidth+3)+LRectWidth) + HREF = "/show_trait?trait_id=%s&dataset=%s" % (Lname, self.dataset.group.name+"Geno") #HREF="javascript:showDatabase3('%s','%s','%s','');" % (showLocusForm,fd.RISet+"Geno", Lname) - Areas=HT.Area(shape='rect', coords=COORDS, href=HREF, target="_blank", title="Locus : " + Lname) + Areas = HtmlGenWrapper.create_area_tag( + shape='rect', + coords=COORDS, + href=HREF, + target="_blank", + title="Locus : {}".format(Lname)) gifmap.areas.append(Areas) ##piddle bug if j == 0: @@ -2017,9 +2101,17 @@ class DisplayMappingResults(object): LRSLODFont=ImageFont.truetype(font=VERDANA_FILE, size=int(18*zoom*1.5)) yZero = yTopOffset + plotHeight - LRSHeightThresh = drawAreaHeight - AdditiveHeightThresh = drawAreaHeight/2 - DominanceHeightThresh = drawAreaHeight/2 + # LRSHeightThresh = drawAreaHeight + # AdditiveHeightThresh = drawAreaHeight/2 + # DominanceHeightThresh = drawAreaHeight/2 + if self.selectedChr == 1: + LRSHeightThresh = drawAreaHeight - yTopOffset + 30*(zoom - 1) + AdditiveHeightThresh = LRSHeightThresh/2 + DominanceHeightThresh = LRSHeightThresh/2 + else: + LRSHeightThresh = drawAreaHeight + AdditiveHeightThresh = drawAreaHeight/2 + DominanceHeightThresh = drawAreaHeight/2 # LRSHeightThresh = (yZero - yTopOffset + 30*(zoom - 1)) # AdditiveHeightThresh = LRSHeightThresh/2 # DominanceHeightThresh = LRSHeightThresh/2 @@ -2127,8 +2219,14 @@ class DisplayMappingResults(object): else: sugg_title = "Suggestive LOD = %0.2f" % (self.suggestive/4.61) sig_title = "Significant LOD = %0.2f" % (self.significant/4.61) - Areas1 = HT.Area(shape='rect', coords=sugg_coords, title=sugg_title) - Areas2 = HT.Area(shape='rect', coords=sig_coords, title=sig_title) + Areas1 = HtmlGenWrapper.create_area_tag( + shape='rect', + coords=sugg_coords, + title=sugg_title) + Areas2 = HtmlGenWrapper.create_area_tag( + shape='rect', + coords=sig_coords, + title=sig_title) gifmap.areas.append(Areas1) gifmap.areas.append(Areas2) @@ -2255,7 +2353,7 @@ class DisplayMappingResults(object): startPosX += newStartPosX oldStartPosX = newStartPosX - #ZS: This is beause the chromosome value stored in qtlresult['chr'] can be (for example) either X or 20 depending upon the mapping method/scale used + #ZS: This is because the chromosome value stored in qtlresult['chr'] can be (for example) either X or 20 depending upon the mapping method/scale used this_chr = str(self.ChrList[self.selectedChr][0]) if self.plotScale != "physic": this_chr = str(self.ChrList[self.selectedChr][1]+1) @@ -2580,7 +2678,10 @@ class DisplayMappingResults(object): #add by NL 09-03-2010 HREF = "javascript:chrView(%d,%s);" % (i, self.ChrLengthMbList) #HREF = "javascript:changeView(%d,%s);" % (i,self.ChrLengthMbList) - Areas = HT.Area(shape='rect', coords=COORDS, href=HREF) + Areas = HtmlGenWrapper.create_area_tag( + shape='rect', + coords=COORDS, + href=HREF) gifmap.areas.append(Areas) startPosX += (self.ChrLengthDistList[i]+self.GraphInterval)*plotXScale @@ -2666,7 +2767,11 @@ class DisplayMappingResults(object): tableIterationsCnt = tableIterationsCnt + 1 this_row = [] #container for the cells of each row - selectCheck = HT.Input(type="checkbox", name="selectCheck", value=theGO["GeneSymbol"], Class="checkbox trait_checkbox") #checkbox for each row + selectCheck = HtmlGenWrapper.create_input_tag( + type="checkbox", + name="selectCheck", + value=theGO["GeneSymbol"], + Class="checkbox trait_checkbox") # checkbox for each row geneLength = (theGO["TxEnd"] - theGO["TxStart"])*1000.0 tenPercentLength = geneLength*0.0001 @@ -2724,41 +2829,77 @@ class DisplayMappingResults(object): this_row = [selectCheck.__str__(), str(tableIterationsCnt), - HT.Href(geneIdString, theGO["GeneSymbol"], target="_blank").__str__(), - HT.Href(mouseStartString, "%0.6f" % txStart, target="_blank").__str__(), - HT.Href("javascript:rangeView('%s', %f, %f)" % (str(chr_as_int), txStart-tenPercentLength, txEnd+tenPercentLength), "%0.3f" % geneLength).__str__(), + str(HtmlGenWrapper.create_link_tag( + geneIdString, + theGO["GeneSymbol"], + target="_blank") + ), + str(HtmlGenWrapper.create_link_tag( + mouseStartString, + "{:.6f}".format(txStart), + target="_blank") + ), + str(HtmlGenWrapper.create_link_tag( + "javascript:rangeView('{}', {:f}, {:f})".format( + str(chr_as_int), + txStart-tenPercentLength, + txEnd+tenPercentLength), + "{:.3f}".format(geneLength))), snpString, snpDensityStr, avgExpr, humanChr, - HT.Href(humanStartString, humanStartDisplay, target="_blank").__str__(), + str(HtmlGenWrapper.create_link_tag( + humanStartString, + humanStartDisplay, + target="_blank")), literatureCorrelationString, geneDescription] else: this_row = [selectCheck.__str__(), str(tableIterationsCnt), - HT.Href(geneIdString, theGO["GeneSymbol"], target="_blank").__str__(), - HT.Href(mouseStartString, "%0.6f" % txStart, target="_blank").__str__(), - HT.Href("javascript:rangeView('%s', %f, %f)" % (str(chr_as_int), txStart-tenPercentLength, txEnd+tenPercentLength), "%0.3f" % geneLength).__str__(), + str(HtmlGenWrapper.create_link_tag( + geneIdString, theGO["GeneSymbol"], + target="_blank")), + str(HtmlGenWrapper.create_link_tag( + mouseStartString, + "{:.6f}".format(txStart), + target="_blank")), + str(HtmlGenWrapper.create_link_tag( + "javascript:rangeView('{}', {:f}, {:f})".format( + str(chr_as_int), + txStart-tenPercentLength, + txEnd+tenPercentLength), + "{:.3f}".format(geneLength))), snpString, snpDensityStr, avgExpr, humanChr, - HT.Href(humanStartString, humanStartDisplay, target="_blank").__str__(), + str(HtmlGenWrapper.create_link_tag( + humanStartString, + humanStartDisplay, + target="_blank")), geneDescription] gene_table_body.append(this_row) elif self.dataset.group.species == 'rat': for gIndex, theGO in enumerate(geneCol): - this_row = [] #container for the cells of each row - selectCheck = HT.Input(type="checkbox", name="selectCheck", Class="checkbox trait_checkbox").__str__() #checkbox for each row + this_row = [] # container for the cells of each row + selectCheck = str(HtmlGenWrapper.create_input_tag( + type="checkbox", + name="selectCheck", + Class="checkbox trait_checkbox")) # checkbox for each row #ZS: May want to get this working again later #webqtlSearch = HT.Href(os.path.join(webqtlConfig.CGIDIR, webqtlConfig.SCRIPTFILE)+"?cmd=sch&gene=%s&alias=1&species=rat" % theGO["GeneSymbol"], ">>", target="_blank").__str__() if theGO["GeneID"] != "": - geneSymbolNCBI = HT.Href("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids=%s" % theGO["GeneID"], theGO["GeneSymbol"], Class="normalsize", target="_blank").__str__() + geneSymbolNCBI = str(HtmlGenWrapper.create_link_tag( + "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids={}".format(theGO["GeneID"]), + theGO["GeneSymbol"], + Class="normalsize", + target="_blank")) else: geneSymbolNCBI = theGO["GeneSymbol"] @@ -2798,7 +2939,9 @@ class DisplayMappingResults(object): str(gIndex+1), geneSymbolNCBI, "%0.6f" % theGO["TxStart"], - HT.Href(geneLengthURL, "%0.3f" % (geneLength*1000.0)).__str__(), + str(HtmlGenWrapper.create_link_tag( + geneLengthURL, + "{:.3f}".format(geneLength*1000.0))), avgExprVal, mouseChr, mouseTxStart, diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index b3ed06fc..16eff345 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -138,14 +138,14 @@ $(function() { }; submit_bnw = function() { - trait_data = get_traits_from_table("trait_table", "submit_bnw") + trait_data = submit_traits_to_export_or_bnw("trait_table", "submit_bnw") } export_traits = function() { - trait_data = get_traits_from_table("trait_table", "export_csv") + trait_data = submit_traits_to_export_or_bnw("trait_table", "export_csv") }; - get_traits_from_table = function(table_name, destination) { + submit_traits_to_export_or_bnw = function(table_name, destination) { trait_table = $('#'+table_name); table_dict = {}; @@ -181,55 +181,58 @@ $(function() { $('#export_form').submit(); }; - $("#corr_matrix").on("click", function() { - traits = $("#trait_table input:checked").map(function() { + get_traits_from_table = function(){ + traits = $("#trait_table input:checked").map(function() { + return $(this).val(); + }).get(); + if (traits.length == 0){ + num_traits = $("#trait_table input").length + if (num_traits <= 100){ + traits = $("#trait_table input").map(function() { return $(this).val(); - }).get(); + }).get(); + } + } + return traits + } + + $("#corr_matrix").on("click", function() { + traits = get_traits_from_table() $("#trait_list").val(traits) $("input[name=tool_used]").val("Correlation Matrix") $("input[name=form_url]").val($(this).data("url")) return submit_special("/loading") }); $("#network_graph").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); + traits = get_traits_from_table() $("#trait_list").val(traits) $("input[name=tool_used]").val("Network Graph") $("input[name=form_url]").val($(this).data("url")) return submit_special("/loading") }); $("#wgcna_setup").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); + traits = get_traits_from_table() $("#trait_list").val(traits) $("input[name=tool_used]").val("WGCNA Setup") $("input[name=form_url]").val($(this).data("url")) return submit_special("/loading") }); $("#ctl_setup").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); + traits = get_traits_from_table() $("#trait_list").val(traits) $("input[name=tool_used]").val("CTL Setup") $("input[name=form_url]").val($(this).data("url")) return submit_special("/loading") }); $("#heatmap").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); + traits = get_traits_from_table() $("#trait_list").val(traits) $("input[name=tool_used]").val("Heatmap") $("input[name=form_url]").val($(this).data("url")) return submit_special("/loading") }); $("#comp_bar_chart").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); + traits = get_traits_from_table() $("#trait_list").val(traits) $("input[name=tool_used]").val("Comparison Bar Chart") $("input[name=form_url]").val($(this).data("url")) @@ -237,9 +240,7 @@ $(function() { }); $("#send_to_webgestalt, #send_to_bnw, #send_to_geneweaver").on("click", function() { - traits = $("#trait_table input:checked").map(function() { - return $(this).val(); - }).get(); + traits = get_traits_from_table() $("#trait_list").val(traits) url = $(this).data("url") return submit_special(url) diff --git a/wqflask/wqflask/templates/collections/list.html b/wqflask/wqflask/templates/collections/list.html index 94e22c4d..9e0c0f07 100644 --- a/wqflask/wqflask/templates/collections/list.html +++ b/wqflask/wqflask/templates/collections/list.html @@ -2,7 +2,7 @@ {% block title %}Your Collections{% endblock %} {% block css %} <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> + <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css') }}" /> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> {% endblock %} {% block content %} @@ -70,8 +70,8 @@ <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.buttons.min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> <script> $('#trait_table').dataTable( { "drawCallback": function( settings ) { diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index b56a89da..5c8edab8 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -2,7 +2,7 @@ {% block title %}View Collection{% endblock %} {% block css %} <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.dataTables.css"> + <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}"> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> {% endblock %} {% block content %} @@ -72,6 +72,7 @@ <br /> <form id="export_form" method="POST" action="/export_traits_csv"> <button class="btn btn-default" id="select_all" type="button"><span class="glyphicon glyphicon-ok"></span> Select All</button> + <button class="btn btn-default" id="invert" type="button"><span class="glyphicon glyphicon-ok"></span> Invert</button> <button class="btn" id="add" disabled="disabled" type="button"><i class="icon-plus-sign"></i> Copy</button> <input type="hidden" name="database_name" id="database_name" value="None"> <input type="hidden" name="export_data" id="export_data" value=""> @@ -167,11 +168,11 @@ <script language="javascript" type="text/javascript" src="/static/new/js_external/md5.min.js"></script> <script type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colResize.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colReorder.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.buttons.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/buttons.colVis.min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colResize/dataTables.colResize.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colReorder/js/dataTables.colReorder.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.colVis.min.js') }}"></script> <script language="javascript" type="text/javascript"> diff --git a/wqflask/wqflask/templates/corr_scatterplot.html b/wqflask/wqflask/templates/corr_scatterplot.html index 5877e367..4739b467 100644 --- a/wqflask/wqflask/templates/corr_scatterplot.html +++ b/wqflask/wqflask/templates/corr_scatterplot.html @@ -132,44 +132,8 @@ <br> <div id="scatterplot2"></div> <br> - <div class="row" style="min-width: 700px; overflow: hidden;"> - <div style="float: left;"> - <table class="table table-hover table-striped table-bordered" style="width: 80%; margin-left: 60px; text-align: right;"> - <thead> - <tr><th style="text-align: right;">Statistic</th><th style="text-align: right;">Value</th></tr> - </thead> - <tbody> - <tr> - <td>Number</td> - <td>{{jsdata.num_overlap}}</td> - </tr> - <tr> - <td>Slope</td> - <td>{{ jsdata.slope_string }}</td> - </tr> - <tr> - <td>Intercept</td> - <td>{{'%0.3f' % jsdata.intercept}}</td> - </tr> - <tr> - <td>r value</td> - <td>{{'%0.3f' % jsdata.r_value}}</td> - </tr> - <tr> - <td>P value</td> - <td>{% if jsdata.p_value < 0.001 %}{{'%0.3e' % jsdata.p_value}}{% else %}{{'%0.3f' % jsdata.p_value}}{% endif %}</td> - </tr> - <tr> - <td style="text-align: left;" colspan="2"> - Regression Line - <br> - y = {{ jsdata.slope_string }} * x {% if jsdata.intercept < 0 %}- {{'%0.3f' % (jsdata.intercept * -1)}}{% else %}+ {{'%0.3f' % jsdata.intercept}}{% endif %} - </td> - </tr> - </tbody> - </table> - </div> - <div style="margin-left: 50px; min-width: 300px; float: left;"> + <div style="min-width: 700px; overflow: hidden;"> + <div style="margin-left: 50px; min-width: 300px;"> {% if trait_1.dataset.type == "ProbeSet" %} <div> X axis: @@ -240,15 +204,7 @@ </div> {% endif %} </div> - </div> - </div> - - <div class="tab-pane" id="tp2"> - <br> - <div id="srscatterplot2"></div> - <br> - <div class="row" style="min-width: 700px; overflow: hidden;"> - <div style="float: left;"> + <div style="float: left; margin-top:30px;"> <table class="table table-hover table-striped table-bordered" style="width: 80%; margin-left: 60px; text-align: right;"> <thead> <tr><th style="text-align: right;">Statistic</th><th style="text-align: right;">Value</th></tr> @@ -260,31 +216,39 @@ </tr> <tr> <td>Slope</td> - <td>{{ jsdata.srslope_string }}</td> + <td>{{ jsdata.slope_string }}</td> </tr> <tr> <td>Intercept</td> - <td>{{'%0.3f' % jsdata.srintercept}}</td> + <td>{{'%0.3f' % jsdata.intercept}}</td> </tr> <tr> <td>r value</td> - <td>{{'%0.3f' % jsdata.srr_value}}</td> + <td>{{'%0.3f' % jsdata.r_value}}</td> </tr> - <tr> + <tr> <td>P value</td> - <td>{% if jsdata.srp_value < 0.001 %}{{'%0.3e' % jsdata.srp_value}}{% else %}{{'%0.3f' % jsdata.srp_value}}{% endif %}</td> + <td>{% if jsdata.p_value < 0.001 %}{{'%0.3e' % jsdata.p_value}}{% else %}{{'%0.3f' % jsdata.p_value}}{% endif %}</td> </tr> <tr> <td style="text-align: left;" colspan="2"> Regression Line <br> - y = {{ jsdata.srslope_string }} * x {% if jsdata.srintercept < 0 %}- {{'%0.3f' % (jsdata.srintercept * -1)}}{% else %}+ {{'%0.3f' % jsdata.srintercept}}{% endif %} + y = {{ jsdata.slope_string }} * x {% if jsdata.intercept < 0 %}- {{'%0.3f' % (jsdata.intercept * -1)}}{% else %}+ {{'%0.3f' % jsdata.intercept}}{% endif %} </td> </tr> </tbody> </table> + </div> </div> - <div style="margin-left: 50px; min-width: 300px; float: left;"> + </div> + + <div class="tab-pane" id="tp2"> + <br> + <div id="srscatterplot2"></div> + <br> + <div class="row" style="min-width: 700px; overflow: hidden;"> + <div style="margin-left: 50px; min-width: 300px;"> {% if trait_1.dataset.type == "ProbeSet" %} <div> X axis: @@ -335,6 +299,42 @@ </div> {% endif %} </div> + <div style="float: left; margin-top: 30px;"> + <table class="table table-hover table-striped table-bordered" style="width: 80%; margin-left: 60px; text-align: right;"> + <thead> + <tr><th style="text-align: right;">Statistic</th><th style="text-align: right;">Value</th></tr> + </thead> + <tbody> + <tr> + <td>Number</td> + <td>{{jsdata.num_overlap}}</td> + </tr> + <tr> + <td>Slope</td> + <td>{{ jsdata.srslope_string }}</td> + </tr> + <tr> + <td>Intercept</td> + <td>{{'%0.3f' % jsdata.srintercept}}</td> + </tr> + <tr> + <td>r value</td> + <td>{{'%0.3f' % jsdata.srr_value}}</td> + </tr> + <tr> + <td>P value</td> + <td>{% if jsdata.srp_value < 0.001 %}{{'%0.3e' % jsdata.srp_value}}{% else %}{{'%0.3f' % jsdata.srp_value}}{% endif %}</td> + </tr> + <tr> + <td style="text-align: left;" colspan="2"> + Regression Line + <br> + y = {{ jsdata.srslope_string }} * x {% if jsdata.srintercept < 0 %}- {{'%0.3f' % (jsdata.srintercept * -1)}}{% else %}+ {{'%0.3f' % jsdata.srintercept}}{% endif %} + </td> + </tr> + </tbody> + </table> + </div> </div> </div> @@ -351,8 +351,8 @@ <script language="javascript" type="text/javascript" src="/static/new/js_external/d3-tip.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/js_external/jscolor.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/panelutil.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> <!--<script language="javascript" type="text/javascript" src="/static/new/javascript/get_traits_from_collection.js"></script>--> <script type="text/javascript" src="/static/new/js_external/plotly-latest.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/draw_corr_scatterplot.js"></script> diff --git a/wqflask/wqflask/templates/correlation_matrix.html b/wqflask/wqflask/templates/correlation_matrix.html index cb9fb815..4e17a0b2 100644 --- a/wqflask/wqflask/templates/correlation_matrix.html +++ b/wqflask/wqflask/templates/correlation_matrix.html @@ -36,7 +36,7 @@ <td align="center"><input type="checkbox" class="checkbox" style="margin-left: 3px; margin-right: 1px;"></td> <td align="right" style="padding-right: 4px;" > <a href="/show_trait?trait_id={{ trait.name }}&dataset={{ trait.dataset.name }}"><font style="font-size: 14px; font-style: Bold;"><b>Trait {{ loop.index }}: {{ trait.dataset.name }} {{ trait.name }}</b></font></a> - <div class="shortName" style="display:none">{% if trait.dataset.type == "ProbeSet" %}Gene Symbol: {{ trait.symbol }}{% elif trait.dataset.type == "Publish" %}Trait Symbol: {{ trait.post_publication_abbreviation }}{% elif trait.dataset.type == "Geno" %}Genotype{% endif %} </div> + <div class="shortName">{% if trait.dataset.type == "ProbeSet" %}Gene Symbol: {{ trait.symbol }}{% elif trait.dataset.type == "Publish" %}Trait Symbol: {{ trait.post_publication_abbreviation }}{% elif trait.dataset.type == "Geno" %}Genotype{% endif %} </div> <div class="verboseName" style="display: none;"> {% if trait.dataset.type == "ProbeSet" %} <div>{{ trait.symbol }} on Chr {{ trait.chr }} @ {{ trait.mb }} Mb</div><div>{{ trait.description }}</div><div>{{ trait.probe_target_description }}</div> diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index df3e43f1..afa19c4a 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -2,9 +2,9 @@ {% block title %}Correlation Results{% endblock %} {% block css %} <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.dataTables.css"> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> + <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css') }}" /> + <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}"> {% endblock %} {% block content %} <div class="container" style="min-width: 1250px;"> @@ -207,9 +207,9 @@ <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.buttons.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/buttons.colVis.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.colVis.min.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> <script type="text/javascript" charset="utf-8"> var table_json = {{ json_results | safe }} diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index 62ef1a7b..617bdc0f 100644 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -50,9 +50,9 @@ <script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colReorder.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colResize.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colReorder/js/dataTables.colReorder.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colResize/dataTables.colResize.js') }}"></script> <script type='text/javascript'> var the_rows = {{ trait_list|safe }}; diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html index f5058158..66995346 100644 --- a/wqflask/wqflask/templates/gsearch_pheno.html +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -50,9 +50,9 @@ <script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colReorder.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.colResize.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colReorder/js/dataTables.colReorder.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/colResize/dataTables.colResize.js') }}"></script> <script type='text/javascript'> var the_rows = {{ trait_list|safe }}; diff --git a/wqflask/wqflask/templates/mapping_results.html b/wqflask/wqflask/templates/mapping_results.html index 6348ca31..961c3b21 100644 --- a/wqflask/wqflask/templates/mapping_results.html +++ b/wqflask/wqflask/templates/mapping_results.html @@ -341,8 +341,8 @@ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/dataTables.buttons.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.scientific.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/scientific.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/packages/purescript_genome_browser/js/purescript-genetics-browser.js"></script> <script> diff --git a/wqflask/wqflask/templates/pair_scan_results.html b/wqflask/wqflask/templates/pair_scan_results.html index b13b393f..5c776fc1 100644 --- a/wqflask/wqflask/templates/pair_scan_results.html +++ b/wqflask/wqflask/templates/pair_scan_results.html @@ -66,7 +66,7 @@ <script language="javascript" type="text/javascript" src="/static/new/js_external/d3-tip.min.js"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script> <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.scientific.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/scientific.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/packages/DT_bootstrap/DT_bootstrap.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> <script language="javascript" type="text/javascript" src="/static/packages/underscore/underscore-min.js"></script> diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 1f76ea82..dbdca9f8 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -2,8 +2,8 @@ {% block title %}Search Results{% endblock %} {% block css %} <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/scroller.dataTables.min.css"> - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.dataTables.css"> + <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/scroller/css/scroller.dataTables.min.css') }}"> + <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonStyles/css/buttons.dataTables.min.css') }}"> <link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" /> {% endblock %} {% block content %} @@ -137,7 +137,7 @@ </div> {% endif %} <!--<div id="table_container" style="min-width: {% if dataset.type == 'ProbeSet' or dataset.type == 'Publish' %}2000{% else %}380{% endif %}px;">--> - <div id="table_container"> + <div id="table_container" {% if dataset.type == 'ProbeSet' or dataset.type == 'Publish' %}style="min-width: 1500px;"{% endif %}> <table class="table-hover table-striped cell-border" id='trait_table' style="float: left; width: {% if dataset.type == 'Geno' %}380px{% else %}100%{% endif %};"> <tbody> <td colspan="100%" align="center"><br><b><font size="15">Loading...</font></b><br></td> @@ -159,9 +159,9 @@ <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/js_external/jszip.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.buttons.min.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/buttons.colVis.min.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/dataTables.buttons.min.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/buttons/js/buttons.colVis.min.js') }}"></script> <script type='text/javascript'> var trait_list = {{ trait_list|safe }}; diff --git a/wqflask/wqflask/templates/show_trait.html b/wqflask/wqflask/templates/show_trait.html index acee6724..15442ca7 100644 --- a/wqflask/wqflask/templates/show_trait.html +++ b/wqflask/wqflask/templates/show_trait.html @@ -147,9 +147,9 @@ <script type="text/javascript" src="/static/new/javascript/show_trait.js"></script> <script type="text/javascript" src="/static/new/javascript/validation.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.scientific.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/scientific.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/packages/noUiSlider/nouislider.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/get_covariates_from_collection.js"></script> diff --git a/wqflask/wqflask/templates/snp_browser.html b/wqflask/wqflask/templates/snp_browser.html index 4537cd06..fb564b28 100644 --- a/wqflask/wqflask/templates/snp_browser.html +++ b/wqflask/wqflask/templates/snp_browser.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% block css %} <link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='DataTables/css/jquery.dataTables.css') }}" /> - <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" /> + <link rel="stylesheet" type="text/css" href="{{ url_for('js', filename='DataTablesExtensions/buttonsBootstrap/css/buttons.bootstrap.css') }}" /> <link rel="stylesheet" type="text/css" href="/static/new/css/typeahead-bootstrap.css" /> <link rel="stylesheet" type="text/css" href="/static/new/css/snp_browser.css" /> {% endblock %} @@ -215,8 +215,8 @@ {% endblock %} {% block js %} - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.js"></script> - <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/dataTables.naturalSort.js"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.js') }}"></script> + <script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/plugins/sorting/natural.js') }}"></script> <script language="javascript" type="text/javascript" src="/static/new/js_external/typeahead.bundle.js"></script> <script language="javascript" type="text/javascript" src="/static/new/javascript/typeahead_rn6.json"></script> diff --git a/wqflask/wqflask/user_session.py b/wqflask/wqflask/user_session.py index ba659fe5..3aa2c151 100644 --- a/wqflask/wqflask/user_session.py +++ b/wqflask/wqflask/user_session.py @@ -13,7 +13,7 @@ from wqflask import app from utility import hmac #from utility.elasticsearch_tools import get_elasticsearch_connection -from utility.redis_tools import get_redis_conn, get_user_id, get_user_collections, save_collections +from utility.redis_tools import get_redis_conn, get_user_id, get_user_by_unique_column, set_user_attribute, get_user_collections, save_collections Redis = get_redis_conn() from utility.logger import getLogger @@ -53,6 +53,18 @@ def create_signed_cookie(): logger.debug("uuid_signed:", uuid_signed) return the_uuid, uuid_signed +@app.route("/user/manage", methods=('GET','POST')) +def manage_user(): + params = request.form if request.form else request.args + if 'new_full_name' in params: + set_user_attribute(g.user_session.user_id, 'full_name', params['new_full_name']) + if 'new_organization' in params: + set_user_attribute(g.user_session.user_id, 'organization', params['new_organization']) + + user_details = get_user_by_unique_column("user_id", g.user_session.user_id) + + return render_template("admin/manage_user.html", user_details = user_details) + class UserSession(object): """Logged in user handling""" |