From 0d52804f6144eb9d3d01dae254c85806d05dd484 Mon Sep 17 00:00:00 2001 From: zsloan Date: Mon, 17 Oct 2016 17:48:55 +0000 Subject: Fixed issue where period sometimes appeared incorrectly in search results text. Changed formatting of a couple things in search results text (capitalizing/underlining "terms" and bolding the search term) Changed "Gene" label on trait page to "NCBI" and removed GenBank link --- wqflask/wqflask/templates/search_result_page.html | 2 +- wqflask/wqflask/templates/show_trait_details.html | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 523037f8..708c83eb 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -41,7 +41,7 @@ {% elif word.key|lower == "position" %} with target genes on chromosome {% if word.search_term[0].split('chr')|length > 1 %}{{ word.search_term[0].split('chr')[1] }}{% elif word.search_term[0].split('CHR')|length > 1 %}{{ word.search_term[0].split('CHR')[1] }}{% else %}{{ word.search_term[0] }}{% endif %} between {{ word.search_term[1] }} and {{ word.search_term[2] }} Mb{% if loop.last %}.{% else %} and {% endif %} {% else %} - that match the term {{ word.search_term[0] }}. + that match the TERM {{ word.search_term[0] }}{% if loop.last %}.{% else %} and {% endif %} {% endif %} {% endfor %}

diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html index d5fb0cf2..017a88ae 100644 --- a/wqflask/wqflask/templates/show_trait_details.html +++ b/wqflask/wqflask/templates/show_trait_details.html @@ -51,7 +51,7 @@ {% if this_trait.geneid != None %} - Gene + NCBI    {% endif %} @@ -61,12 +61,6 @@    {% endif %} - {% if this_trait.genbankid != None %} - - GenBank - -    - {% endif %} {% if this_trait.symbol != None %} Genotation -- cgit v1.2.3 From 921726b7bf2ced0cbb348f366d8a2955400567c3 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 19 Oct 2016 22:11:20 +0000 Subject: Rewrote export CSV in python Still need to add metadata and change it to where only selected traits are exported --- wqflask/wqflask/export_traits.py | 28 ++++++++ .../static/new/javascript/search_results.js | 38 ++++++++++ wqflask/wqflask/templates/search_result_page.html | 84 +++++++--------------- wqflask/wqflask/views.py | 12 ++++ 4 files changed, 105 insertions(+), 57 deletions(-) create mode 100644 wqflask/wqflask/export_traits.py (limited to 'wqflask') diff --git a/wqflask/wqflask/export_traits.py b/wqflask/wqflask/export_traits.py new file mode 100644 index 00000000..280566d7 --- /dev/null +++ b/wqflask/wqflask/export_traits.py @@ -0,0 +1,28 @@ +from __future__ import print_function, division + +import operator +import csv +import xlsxwriter +import StringIO + +import simplejson as json + +from pprint import pformat as pf + +def export_search_results_csv(targs): + + table_data = json.loads(targs['export_data']) + table_headers = table_data['headers'] + table_rows = table_data['rows'] + + buff = StringIO.StringIO() + writer = csv.writer(buff) + + writer.writerow(table_headers) + for trait_info in table_rows: + writer.writerow(trait_info) + + csv_data = buff.getvalue() + buff.close() + + return csv_data \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index 746564fd..54a61a45 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -155,10 +155,48 @@ $(function() { }); } }; + + export_traits = function() { + trait_data = get_traits_from_table("trait_table") + }; + + get_traits_from_table = function(table_name) { + trait_table = $('#'+table_name); + table_dict = {}; + + headers = []; + trait_table.find('th').each(function () { + if ($(this).data('export')){ + headers.push($(this).data('export')) + } + }); + table_dict['headers'] = headers; + + rows = []; + trait_table.find('tbody tr').each(function (i, tr) { + this_row = []; + $(tr).find('td').each(function(j, td){ + if ($(td).data('export')){ + this_row.push($(td).data('export')); + } + }); + rows.push(this_row); + }); + table_dict['rows'] = rows; + console.log("TABLEDICT:", table_dict); + + json_table_dict = JSON.stringify(table_dict); + $('input[name=export_data]').val(json_table_dict); + + $('#export_form').attr('action', '/export_traits_csv'); + $('#export_form').submit(); + }; + $("#select_all").click(select_all); $("#deselect_all").click(deselect_all); $("#invert").click(invert); $("#add").click(add); $("#remove").click(remove); + $("#export_traits").click(export_traits); $('.trait_checkbox, .btn').click(change_buttons); }); \ No newline at end of file diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index 708c83eb..13993e83 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -13,7 +13,6 @@ 'GeneNetwork found {}.'.format(numify(results|count, "record", "records"))) }}
- @@ -54,12 +53,16 @@ -

+
+ + +
+
@@ -74,20 +73,26 @@

+
+ + + +
+
- - - - - - - - - + + + + + + + + + @@ -98,9 +103,9 @@ - - - + + + + + + + {% endfor %} @@ -132,9 +137,6 @@ {% block js %} - - - @@ -170,18 +172,7 @@ "width": "15%" }, { "type": "natural" } ], - "buttons": [ - { - extend: 'csvHtml5', - text: 'Download CSV', - title: 'collection', - fieldBoundary: '"', - exportOptions: { - columns: [1, 2, 3, 4, 5, 6, 7, 8, 9] - } - } - ], - "sDom": "ZRBtir", + "sDom": "ZRtir", "iDisplayLength": -1, "autoWidth": true, "bDeferRender": true, diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index 776b8d07..8b8a9057 100644 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -2,7 +2,6 @@ {% block title %}Search Results{% endblock %} {% block css %} - {% endblock %} {% block content %} @@ -99,9 +98,6 @@ - - - diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html index 9aad7568..2f7dcaf6 100644 --- a/wqflask/wqflask/templates/gsearch_pheno.html +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -4,7 +4,6 @@ - {% endblock %} @@ -93,9 +92,6 @@ - - - diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index b6aab101..0f5e68d7 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -5,7 +5,6 @@ - {% endblock %} {% block content %} @@ -166,9 +165,6 @@ - - - -- cgit v1.2.3 From 684f461b815e3920419874fccb036c359cae35d8 Mon Sep 17 00:00:00 2001 From: zsloan Date: Tue, 25 Oct 2016 16:48:54 +0000 Subject: Just removed some extraneous spaces in trait.py --- wqflask/base/trait.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wqflask') diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py index 358138f5..276c624a 100644 --- a/wqflask/base/trait.py +++ b/wqflask/base/trait.py @@ -78,7 +78,7 @@ class GeneralTrait(object): """Return a dict suitable for using as json Actual turning into json doesn't happen here though""" - + if self.dataset.type == "ProbeSet": return dict(name=self.name, symbol=self.symbol, @@ -108,7 +108,7 @@ class GeneralTrait(object): ) else: return dict() - + def get_name(self): stringy = "" -- cgit v1.2.3
IndexDatasetRecordDescriptionLocationMeanMax LRS ?Max LRS LocationAdditive Effect ?IndexDatasetRecordDescriptionLocationMeanMax LRS ?Max LRS LocationAdditive Effect ?
{{ loop.index }}{{ this_trait.dataset.name }} + {{ loop.index }}{{ this_trait.dataset.name }} {{ this_trait.description_display }}{{ this_trait.location_repr }}{{ '%0.3f' % this_trait.mean|float }}{{ '%0.3f' % this_trait.LRS_score_repr|float }}{{ this_trait.LRS_location_repr }}{{ '%0.3f' % this_trait.additive|float }}