From 40938962c325ae142d906b2ba3ac1bd845e670c5 Mon Sep 17 00:00:00 2001 From: zsloan Date: Thu, 17 Jan 2019 16:47:54 -0600 Subject: Redid gene global search to take JSON data input instead of converting an HTML table, and adding loading text Made some changes to make trait page SNPs link point to GN2 SNP Browser, as well as make other links open in new tabs/windows --- wqflask/wqflask/gsearch.py | 35 ++-- wqflask/wqflask/static/new/css/show_trait.css | 4 +- wqflask/wqflask/templates/gsearch_gene.html | 217 +++++++++++++--------- wqflask/wqflask/templates/show_trait_details.html | 12 +- wqflask/wqflask/templates/snp_browser.html | 2 +- 5 files changed, 163 insertions(+), 107 deletions(-) diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py index 94965507..99dd087d 100644 --- a/wqflask/wqflask/gsearch.py +++ b/wqflask/wqflask/gsearch.py @@ -7,6 +7,8 @@ from db import webqtlDatabaseFunction from base import webqtlConfig +from wqflask import user_manager + from utility.type_checking import is_float, is_int, is_str, get_float, get_int, get_string from utility.benchmark import Bench @@ -30,6 +32,7 @@ class GSearch(object): InbredSet.`Name` AS inbredset_name, Tissue.`Name` AS tissue_name, ProbeSetFreeze.Name AS probesetfreeze_name, + ProbeSetFreeze.FullName AS probesetfreeze_fullname, ProbeSet.Name AS probeset_name, ProbeSet.Symbol AS probeset_symbol, ProbeSet.`description` AS probeset_description, @@ -58,30 +61,38 @@ class GSearch(object): re = g.db.execute(sql).fetchall() self.trait_list = [] with Bench("Creating trait objects"): - for line in re: + for i, line in enumerate(re): this_trait = {} - this_trait['name'] = line[4] + this_trait['index'] = i + 1 + this_trait['name'] = line[5] this_trait['dataset'] = line[3] + this_trait['dataset_fullname'] = line[4] + this_trait['hmac'] = user_manager.data_hmac('{}:{}'.format(line[4], line[3])) this_trait['species'] = line[0] this_trait['group'] = line[1] this_trait['tissue'] = line[2] - this_trait['symbol'] = line[5] - this_trait['description'] = line[6] + this_trait['symbol'] = line[6] + this_trait['description'] = line[7] this_trait['location_repr'] = 'N/A' - if (line[7] != "NULL" and line[7] != "") and (line[8] != 0): - this_trait['location_repr'] = 'Chr%s: %.6f' % (line[7], float(line[8])) - this_trait['mean'] = line[9] + if (line[8] != "NULL" and line[8] != "") and (line[9] != 0): + this_trait['location_repr'] = 'Chr%s: %.6f' % (line[8], float(line[9])) + this_trait['mean'] = round(line[10], 3) this_trait['LRS_score_repr'] = "N/A" - if line[10] != "" and line[10] != None: - this_trait['LRS_score_repr'] = '%3.1f' % line[10] + if line[11] != "" and line[11] != None: + this_trait['LRS_score_repr'] = round(line[10], 1) this_trait['additive'] = "N/A" - if line[13] != "": - this_trait['additive'] = line[13] + if line[14] != "" and line[14] != None: + this_trait['additive'] = round(line[14], 3) #dataset = create_dataset(line[3], "ProbeSet", get_samplelist=False) #trait_id = line[4] #with Bench("Building trait object"): - #this_trait = GeneralTrait(dataset=dataset, name=trait_id, get_qtl_info=False, get_sample_info=False) + trait_ob = GeneralTrait(dataset_name=this_trait['dataset'], name=this_trait['name'], get_qtl_info=True, get_sample_info=False) + max_lrs_text = "N/A" + if trait_ob.locus_chr != "" and trait_ob.locus_mb != "": + max_lrs_text = "Chr" + str(trait_ob.locus_chr) + ": " + str(trait_ob.locus_mb) + this_trait['max_lrs_text'] = max_lrs_text + self.trait_list.append(this_trait) elif self.type == "phenotype": diff --git a/wqflask/wqflask/static/new/css/show_trait.css b/wqflask/wqflask/static/new/css/show_trait.css index 59901404..09d5e1e3 100644 --- a/wqflask/wqflask/static/new/css/show_trait.css +++ b/wqflask/wqflask/static/new/css/show_trait.css @@ -14,7 +14,7 @@ div.sample_group { left: 100px; } -table.dataTable thead th{ +table.dataTable thead th, table.dataTable tfoot th{ border-right: 1px solid white; color: white; background-color: #369; @@ -27,7 +27,7 @@ table.dataTable thead .sorting_desc { background-image: url("../packages/DataTables/images/sort_desc_disabled.png"); } -table.dataTable thead th { +table.dataTable thead th, table.dataTable tfoot { padding: 4px 18px 4px 10px; } diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index ff5c56f1..5433f2c5 100644 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -7,7 +7,7 @@ {% block content %} -
You searched for {{ terms }}.
To study a record, click on its Record ID below.
Check records below and click Add button to add to selection.
- | Index | -Record ID | -Species | -Group | -Tissue | -Dataset | -Symbol | -Description | -Location | -Mean | -Max LRS ? | -Additive Effect ? | -
---|---|---|---|---|---|---|---|---|---|---|---|---|
- | {{ loop.index }} | -{{ this_trait.name }} | -{{ this_trait.species }} | -{{ this_trait.group }} | -{{ this_trait.tissue }} | -{{ this_trait.dataset }} | -{{ this_trait.symbol }} | -{{ this_trait.description }} | -{{ this_trait.location_repr }} | -{{ '%0.3f' % this_trait.mean|float }} | -{% if this_trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % this_trait.LRS_score_repr|float }}{% else %}N/A{% endif %} | -{% if this_trait.additive != "" %}{{ '%0.3f' % this_trait.additive|float }}{% else %}N/A{% endif %} | -Loading... |
-
-
- | Index | -Record ID | -Species | -Group | -Tissue | -Dataset | -Symbol | -Description | -Location | -Mean | -Max LRS ? | -Additive Effect ? | -