aboutsummaryrefslogtreecommitdiff
path: root/wqflask/wqflask
diff options
context:
space:
mode:
authorZachary Sloan2013-06-12 22:45:57 +0000
committerZachary Sloan2013-06-12 22:45:57 +0000
commit7938d8c6cbdfe866ebf9ec62dec0fe5c43cf2d6f (patch)
tree56480908785e871bcc82d47101d0d7b81afe7917 /wqflask/wqflask
parent43eb99c11d8ef371bba926a3a63bf599b56820ae (diff)
downloadgenenetwork2-7938d8c6cbdfe866ebf9ec62dec0fe5c43cf2d6f.tar.gz
Fixed a couple issues with the template that caused the
regular search results and show trait page to not display
Diffstat (limited to 'wqflask/wqflask')
-rw-r--r--wqflask/wqflask/search_results.py59
-rw-r--r--wqflask/wqflask/templates/index_page.html9
-rw-r--r--wqflask/wqflask/templates/quick_search.html146
-rw-r--r--wqflask/wqflask/templates/show_trait_details.html4
4 files changed, 162 insertions, 56 deletions
diff --git a/wqflask/wqflask/search_results.py b/wqflask/wqflask/search_results.py
index ad74f6cc..63aa481e 100644
--- a/wqflask/wqflask/search_results.py
+++ b/wqflask/wqflask/search_results.py
@@ -42,7 +42,7 @@ from utility import formatting
#def __init__(self, key, result_fields):
# self.key = key
# self.result_fields = result_fields
-
+
class SearchResultPage(object):
#maxReturn = 3000
@@ -73,6 +73,7 @@ class SearchResultPage(object):
self.quick = True
self.search_terms = kw['q']
print("self.search_terms is: ", self.search_terms)
+ self.trait_type = kw['trait_type']
self.quick_search()
else:
self.results = []
@@ -91,7 +92,7 @@ class SearchResultPage(object):
"""
self.trait_list = []
-
+
species = webqtlDatabaseFunction.retrieve_species(self.dataset.group.name)
# result_set represents the results for each search term; a search of
@@ -100,7 +101,7 @@ class SearchResultPage(object):
for result in self.results:
if not result:
continue
-
+
#### Excel file needs to be generated ####
print("foo locals are:", locals())
@@ -123,42 +124,46 @@ class SearchResultPage(object):
FROM QuickSearch
WHERE MATCH (terms)
AGAINST ('{}' IN BOOLEAN MODE) """.format(search_terms)
- #print("query is: ", query)
with Bench("Doing QuickSearch Query: "):
dbresults = g.db.execute(query, no_parameters=True).fetchall()
#print("results: ", pf(results))
-
+
self.results = collections.defaultdict(list)
-
+
type_dict = {'PublishXRef': 'phenotype',
'ProbeSetXRef': 'mrna_assay',
'GenoXRef': 'genotype'}
-
+
self.species_groups = {}
+
for dbresult in dbresults:
this_result = {}
this_result['table_name'] = dbresult.table_name
- this_result['key'] = dbresult.the_key
- this_result['result_fields'] = json.loads(dbresult.result_fields)
- this_species = this_result['result_fields']['species']
- this_group = this_result['result_fields']['group_name']
- if this_species not in self.species_groups:
- self.species_groups[this_species] = {}
- if type_dict[dbresult.table_name] not in self.species_groups[this_species]:
- self.species_groups[this_species][type_dict[dbresult.table_name]] = []
- if this_group not in self.species_groups[this_species][type_dict[dbresult.table_name]]:
- self.species_groups[this_species][type_dict[dbresult.table_name]].append(this_group)
- #if type_dict[dbresult.table_name] not in self.species_groups:
- # self.species_groups[type_dict[dbresult.table_name]] = {}
- #if this_species not in self.species_groups[type_dict[dbresult.table_name]]:
- # self.species_groups[type_dict[dbresult.table_name]][this_species] = []
- #if this_group not in self.species_groups[type_dict[dbresult.table_name]][this_species]:
- # self.species_groups[type_dict[dbresult.table_name]][this_species].append(this_group)
- self.results[type_dict[dbresult.table_name]].append(this_result)
-
- #print("results: ", pf(self.results['phenotype']))
-
+ if self.trait_type == type_dict[dbresult.table_name] or self.trait_type == 'all':
+ this_result['key'] = dbresult.the_key
+ this_result['result_fields'] = json.loads(dbresult.result_fields)
+ this_species = this_result['result_fields']['species']
+ this_group = this_result['result_fields']['group_name']
+ if this_species not in self.species_groups:
+ self.species_groups[this_species] = {}
+ if type_dict[dbresult.table_name] not in self.species_groups[this_species]:
+ self.species_groups[this_species][type_dict[dbresult.table_name]] = []
+ if this_group not in self.species_groups[this_species][type_dict[dbresult.table_name]]:
+ self.species_groups[this_species][type_dict[dbresult.table_name]].append(this_group)
+ #if type_dict[dbresult.table_name] not in self.species_groups:
+ # self.species_groups[type_dict[dbresult.table_name]] = {}
+ #if this_species not in self.species_groups[type_dict[dbresult.table_name]]:
+ # self.species_groups[type_dict[dbresult.table_name]][this_species] = []
+ #if this_group not in self.species_groups[type_dict[dbresult.table_name]][this_species]:
+ # self.species_groups[type_dict[dbresult.table_name]][this_species].append(this_group)
+ self.results[type_dict[dbresult.table_name]].append(this_result)
+
+ import redis
+ Redis = redis.Redis()
+
+
+
#def get_group_species_tree(self):
# self.species_groups = collections.default_dict(list)
# for key in self.results:
diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html
index b4376ce3..a9f2cb24 100644
--- a/wqflask/wqflask/templates/index_page.html
+++ b/wqflask/wqflask/templates/index_page.html
@@ -32,7 +32,14 @@
</div>
<form method="get" action="/search" name="SEARCHFORM">
<fieldset>
- <label for="quick">Search:</label>
+ <div class="input-prepend">
+ <select id="trait_type" name="trait_type" class="span2">
+ <option value="all">All</option>
+ <option value="mrna_assay">Molecular Assays</option>
+ <option value="phenotype">Phenotypes</option>
+ <option value="genotype">Genotypes</option>
+ </select>
+ </div>
<div class="input-append">
<input class="input-xlarge"
id="quick" name="q"
diff --git a/wqflask/wqflask/templates/quick_search.html b/wqflask/wqflask/templates/quick_search.html
index 01588924..b0e38708 100644
--- a/wqflask/wqflask/templates/quick_search.html
+++ b/wqflask/wqflask/templates/quick_search.html
@@ -26,7 +26,11 @@
{% endif %}
</ul>
- <div id="species_level" class="tabbable"> <!-- Only required for left/right tabs -->
+
+ <div class="tabbable"> <!-- Only required for left/right tabs -->
+ {% if trait_type == 'all' %}
+ {% include 'all_results.html' %}
+ {% else %}
<ul class="nav nav-tabs">
{% for species in species_groups %}
<li> <a href="#tab{{ loop.index }}" data-toggle="tab">{{ species }}</a></li>
@@ -34,11 +38,12 @@
</ul>
<div class="tab-content">
{% for species in species_groups %}
- <div class="tab-pane" id="tab{{ loop.index }}">
- <div id="trait_type_level" class="tabbable tabs-left">
+ <div class="tab-pane active" id="tab{{ loop.index }}">
+ <div>
+ {#
<ul class="nav nav-tabs">
{% if species_groups[species]['phenotype'] %}
- <li> <a href="#tab{{ loop.index }}_1" data-toggle="tab">Phenotype</a></li>
+ <li class="active"> <a href="#tab{{ loop.index }}_1" data-toggle="tab">Phenotype</a></li>
{% endif %}
{% if species_groups[species]['mrna_assay'] %}
<li> <a href="#tab{{ loop.index }}_2" data-toggle="tab">mRNA Assay</a></li>
@@ -47,9 +52,9 @@
<li> <a href="#tab{{ loop.index }}_3" data-toggle="tab">Genotype</a></li>
{% endif %}
</ul>
- <div class="tab-content">
- {% if species_groups[species]['phenotype'] %}
- <div class="tab-pane active" id="tab{{ loop.index }}_1">
+ #}
+ <div>
+ {% if trait_type == 'phenotype' and species_groups[species]['phenotype'] %}
<table id="pheno_results" class="table table-hover table-striped table-bordered">
<thead>
<tr>
@@ -82,10 +87,8 @@
{% endfor %}
</tbody>
</table>
- </div>
{% endif %}
- {% if species_groups[species]['mrna_assay'] %}
- <div class="tab-pane" id="tab{{ loop.index }}_2">
+ {% if trait_type == 'mrna_assay' and species_groups[species]['mrna_assay'] %}
<table id="mrna_assay_results" class="table table-hover table-striped table-bordered">
<thead>
<tr>
@@ -105,7 +108,7 @@
{% if result.result_fields['species'] == species %}
<tr>
<td>
- <a href="http://gn2python.genenetwork.org/show_trait?trait_id={{ result.result_fields['name'] }}&dataset={{ result.result_fields['dataset'] }}">
+ <a href="http://gn2python.genenetwork.org/show_trait?trait_id={{ result.result_fields['name'] }}&dataset={{ result.result_fields['dataset'] }}"
{{ result.result_fields['name'] }}
</a>
</td>
@@ -114,18 +117,16 @@
<td>{{ result.result_fields['dataset_name'] }}</td>
<td>{{ result.result_fields['symbol'] }}</td>
<td>{{ result.result_fields['description'] }}</td>
- <td>Chr {{ result.result_fields['chr'] }}: {{ result.result_fields['mb'] }}</td>
+ <td>{{ result.result_fields['chr'] }} : {{ result['mb'] }}</td>
<td>{{ result.result_fields['mean'] }}</td>
<td>{{ result.result_fields['lrs'] }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
- </table>
- </div>
+ </table>
{% endif %}
- {% if species_groups[species]['genotype'] %}
- <div class="tab-pane" id="tab{{ loop.index }}_3">
+ {% if trait_type == 'genotype' and species_groups[species]['genotype'] %}
<table id="geno_results" class="table table-hover table-striped table-bordered">
<thead>
<tr>
@@ -153,14 +154,14 @@
{% endif %}
{% endfor %}
</tbody>
- </table>
- </div>
+ </table>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
+ {% endif %}
</div>
</div>
@@ -168,6 +169,105 @@
{% endblock %}
+ {#
+ <table id="pheno_results" class="table table-hover table-striped table-bordered">
+ <thead>
+ <tr>
+ <th>Id</th>
+ <th>Species</th>
+ <th>Group</th>
+ <th>Description</th>
+ <th>LRS</th>
+ <th>Year</th>
+ <th>Authors</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for result in results.phenotype %}
+ <tr>
+ <td>{{ result.result_fields['phenotype_id'] }}</td>
+ <td>{{ result.result_fields['species'] }}</td>
+ <td>{{ result.result_fields['group_name'] }}</td>
+ <td>{{ result.result_fields['description'] }}</td>
+ <td>{{ result.result_fields['lrs'] }}</td>
+ <td>
+ <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=PubMed&list_uids={{ result.result_fields['pubmed_id'] }}&dopt=Abstract">
+ {{ result.result_fields['year'] }}
+ </a>
+ </td>
+ <td>{{ result.result_fields['authors'] }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ <div class="tab-pane" id="tab2">
+ <table id="mrna_assay_results" class="table table-hover table-striped table-bordered">
+ <thead>
+ <tr>
+ <th>Record ID</th>
+ <th>Species</th>
+ <th>Group</th>
+ <th>Data Set</th>
+ <th>Symbol</th>
+ <th>Description</th>
+ <th>Location</th>
+ <th>Mean Expr</th>
+ <th>Max LRS</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for result in results.mrna_assay %}
+ <tr>
+ <td>
+ <a href="http://gn2python.genenetwork.org/show_trait?trait_id={{ result.result_fields['name'] }}&dataset={{ result.result_fields['dataset'] }}"
+ {{ result.result_fields['name'] }}
+ </a>
+ </td>
+ <td>{{ result.result_fields['species'] }}</td>
+ <td>{{ result.result_fields['group_name'] }}</td>
+ <td>{{ result.result_fields['dataset_name'] }}</td>
+ <td>{{ result.result_fields['symbol'] }}</td>
+ <td>{{ result.result_fields['description'] }}</td>
+ <td>{{ result.result_fields['chr'] }} : {{ result['mb'] }}</td>
+ <td>{{ result.result_fields['mean'] }}</td>
+ <td>{{ result.result_fields['lrs'] }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ <div class="tab-pane" id="tab3">
+ <table id="geno_results" class="table table-hover table-striped table-bordered">
+ <thead>
+ <tr>
+ <th>Marker</th>
+ <th>Species</th>
+ <th>Group</th>
+ <th>Data Set</th>
+ <th>Location</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for result in results.genotype %}
+ <tr>
+ <td>
+ <a href="http://gn2python.genenetwork.org/show_trait?trait_id={{ result.result_fields['marker_name'] }}&dataset={{ result.result_fields['dataset'] }}">
+ {{ result.result_fields['marker_name'] }}
+ </a>
+ </td>
+ <td>{{ result.result_fields['species'] }}</td>
+ <td>{{ result.result_fields['group_name'] }}</td>
+ <td>{{ result.result_fields['dataset_name'] }}</td>
+ <td>{{ result.result_fields['chr'] }} : {{ result.result_fields['mb'] }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ #}
+
+
{% block js %}
<script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/js/jquery.dataTables.min.js"></script>
@@ -175,16 +275,9 @@
<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>
+
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {
-
- $("div[id^='tab'").bind('click', function(){
- tab_id = $(this).attr('id');
- $("a[href^='"+tab_id+"']").first().trigger('click');
- });
-
- $('#species_level ul li:first').addClass('active');
- $('#trait_type_level ul li:first').addClass('active');
console.time("Creating table");
$('#pheno_results, #mrna_assay_results, #geno_results').dataTable( {
//"sDom": "<<'span3'l><'span3'T><'span4'f>'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>",
@@ -210,3 +303,4 @@
});
</script>
{% endblock %}
+
diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html
index c3abfc9f..b57c3c21 100644
--- a/wqflask/wqflask/templates/show_trait_details.html
+++ b/wqflask/wqflask/templates/show_trait_details.html
@@ -19,11 +19,11 @@
BLAT Specifity
</a>
</dt>
- <dd>{{ "%.1f" % (this_trait.probe_set_specificity) }}</dd>
+ <dd>{{ "%s" % (this_trait.probe_set_specificity) }}</dd>
{% endif %}
{% if this_trait.probe_set_blat_score %}
<dt>BLAT Score</dt>
- <dd>{{ "%i" % (this_trait.probe_set_blat_score) }}</dd>
+ <dd>{{ "%s" % (this_trait.probe_set_blat_score) }}</dd>
{% endif %}
</dl>