diff options
-rw-r--r-- | wqflask/wqflask/export_traits.py | 3 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/search_results.js | 2 | ||||
-rw-r--r-- | wqflask/wqflask/templates/gsearch_gene.html | 97 | ||||
-rw-r--r-- | wqflask/wqflask/templates/gsearch_pheno.html | 106 | ||||
-rw-r--r-- | wqflask/wqflask/templates/search_result_page.html | 44 |
5 files changed, 85 insertions, 167 deletions
diff --git a/wqflask/wqflask/export_traits.py b/wqflask/wqflask/export_traits.py index eeed72f1..f8fce929 100644 --- a/wqflask/wqflask/export_traits.py +++ b/wqflask/wqflask/export_traits.py @@ -22,7 +22,8 @@ def export_search_results_csv(targs): metadata = [] metadata.append(["Citations: Please see www.genenetwork.org/reference.html"]) - metadata.append(["Database: " + targs['database_name']]) + if targs['database_name'] != "None": + metadata.append(["Database: " + targs['database_name']]) metadata.append(["Date: " + datetime.datetime.now().strftime("%B %d, %Y")]) metadata.append(["Time: " + datetime.datetime.now().strftime("%H:%M GMT")]) metadata.append(["Status of data ownership: Possibly unpublished data; please see www.genenetwork.org/statusandContact.html for details on sources, ownership, and usage of these data."]) diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index 5250523f..40fdff70 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -73,7 +73,6 @@ $(function() { }); $('.trait_checkbox:checkbox').change(function() { - console.log("CHANGED") change_buttons() if ($(this).is(":checked")) { @@ -108,7 +107,6 @@ $(function() { var button, buttons, item, num_checked, text, _i, _j, _k, _l, _len, _len2, _len3, _len4, _results, _results2; buttons = ["#add", "#remove"]; num_checked = $('.trait_checkbox:checked').length; - console.log("num_checked is:", num_checked); if (num_checked === 0) { for (_i = 0, _len = buttons.length; _i < _len; _i++) { button = buttons[_i]; diff --git a/wqflask/wqflask/templates/gsearch_gene.html b/wqflask/wqflask/templates/gsearch_gene.html index 2d970b36..776b8d07 100644 --- a/wqflask/wqflask/templates/gsearch_gene.html +++ b/wqflask/wqflask/templates/gsearch_gene.html @@ -20,46 +20,51 @@ <button class="btn btn-default" id="add" disabled ><span class="glyphicon glyphicon-plus-sign"></span> Add</button> <input type="text" id="searchbox" class="form-control" style="width: 180px; display: inline;" placeholder="Search This Table For ..."> <input type="text" id="select_top" class="form-control" style="width: 120px; display: inline;" placeholder="Select Top ..."> - <br /> <br /> + <form id="export_form" method="POST" action="/export_traits_csv"> + <input type="hidden" name="database_name" id="database_name" value="None"> + <input type="hidden" name="export_data" id="export_data" value=""> + <button class="btn btn-default" id="export_traits">Download CSV</button> + </form> + <br /> <div style="width: 2000px; background-color: #eeeeee; border: 1px solid black;"> <table width="2000px" id="trait_table" class="table table-hover table-striped" > <thead> <tr> <th style="background-color: #eeeeee;"></th> - <th style="background-color: #eeeeee;">Index</th> - <th style="background-color: #eeeeee;">Species</th> - <th style="background-color: #eeeeee;">Group</th> - <th style="background-color: #eeeeee;">Tissue</th> - <th style="background-color: #eeeeee;">Dataset</th> - <th style="background-color: #eeeeee;">Record</th> - <th style="background-color: #eeeeee;">Symbol</th> - <th style="background-color: #eeeeee;">Description</th> - <th style="background-color: #eeeeee;">Location</th> - <th style="background-color: #eeeeee;">Mean</th> - <th style="background-color: #eeeeee;">Max <br>LRS<a href="http://genenetwork.org/glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th> - <th style="background-color: #eeeeee;">Max LRS Location</th> - <th style="background-color: #eeeeee;">Additive<br>Effect<a href="http://genenetwork.org/glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th data-export="Index" style="background-color: #eeeeee;">Index</th> + <th data-export="Species" style="background-color: #eeeeee;">Species</th> + <th data-export="Group" style="background-color: #eeeeee;">Group</th> + <th data-export="Tissue" style="background-color: #eeeeee;">Tissue</th> + <th data-export="Dataset" style="background-color: #eeeeee;">Dataset</th> + <th data-export="Record" style="background-color: #eeeeee;">Record</th> + <th data-export="Symbol" style="background-color: #eeeeee;">Symbol</th> + <th data-export="Description" style="background-color: #eeeeee;">Description</th> + <th data-export="Location" style="background-color: #eeeeee;">Location</th> + <th data-export="Mean" style="background-color: #eeeeee;">Mean</th> + <th data-export="Max LRS" style="background-color: #eeeeee;">Max <br>LRS<a href="http://genenetwork.org/glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th data-export="Max LRS Location" style="background-color: #eeeeee;">Max LRS Location</th> + <th data-export="Additive Effect" style="background-color: #eeeeee;">Additive<br>Effect<a href="http://genenetwork.org/glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th> </tr> </thead> <tbody> {% for this_trait in trait_list %} <tr id="trait:{{ this_trait.name }}:{{ this_trait.dataset.name }}"> <td><input type="checkbox" name="searchResult" class="checkbox trait_checkbox" style="transform: scale(1.5);" value="{{ data_hmac('{}:{}'.format(this_trait.name, this_trait.dataset.name)) }}"></td> - <td>{{ loop.index }}</td> - <td>{{ this_trait.dataset.group.species }}</td> - <td>{{ this_trait.dataset.group.name }}</td> - <td>{{ this_trait.dataset.tissue }}</td> - <td>{{ this_trait.dataset.name }}</td> - <td><a href="{{ url_for('show_trait_page', trait_id = this_trait.name, dataset = this_trait.dataset.name)}}">{{ this_trait.name }}</a></td> - <td>{{ this_trait.symbol }}</td> - <td>{{ this_trait.description_display }}</td> - <td align="right">{{ this_trait.location_repr }}</td> - <td align="right">{{ '%0.3f' % this_trait.mean|float }}</td> - <td align="right">{% if this_trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % this_trait.LRS_score_repr|float }}{% else %}N/A{% endif %}</td> - <td align="right">{{ this_trait.LRS_location_repr }}</td> - <td align="right">{% if this_trait.additive != "" %}{{ '%0.3f' % this_trait.additive|float }}{% else %}N/A{% endif %}</td> + <td data-export="{{ loop.index }}">{{ loop.index }}</td> + <td data-export="{{ this_trait.dataset.group.species }}">{{ this_trait.dataset.group.species }}</td> + <td data-export="{{ this_trait.dataset.group.name }}">{{ this_trait.dataset.group.name }}</td> + <td data-export="{{ this_trait.dataset.tissue }}">{{ this_trait.dataset.tissue }}</td> + <td data-export="{{ this_trait.dataset.name }}">{{ this_trait.dataset.name }}</td> + <td data-export="{{ this_trait.name }}"><a href="{{ url_for('show_trait_page', trait_id = this_trait.name, dataset = this_trait.dataset.name)}}">{{ this_trait.name }}</a></td> + <td data-export="{{ this_trait.symbol }}">{{ this_trait.symbol }}</td> + <td data-export="{{ this_trait.description_display }}">{{ this_trait.description_display }}</td> + <td data-export="{{ this_trait.location_repr }}" align="right">{{ this_trait.location_repr }}</td> + <td data-export="{{ '%0.3f' % this_trait.mean|float }}" align="right">{{ '%0.3f' % this_trait.mean|float }}</td> + <td data-export="{% if this_trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % this_trait.LRS_score_repr|float }}{% else %}N/A{% endif %}" align="right">{% if this_trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % this_trait.LRS_score_repr|float }}{% else %}N/A{% endif %}</td> + <td data-export="{{ this_trait.LRS_location_repr }}" align="right">{{ this_trait.LRS_location_repr }}</td> + <td data-export="{% if this_trait.additive != "" %}{{ '%0.3f' % this_trait.additive|float }}{% else %}N/A{% endif %}" align="right">{% if this_trait.additive != "" %}{{ '%0.3f' % this_trait.additive|float }}{% else %}N/A{% endif %}</td> </tr> {% endfor %} </tbody> @@ -105,27 +110,12 @@ <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> <script type="text/javascript" charset="utf-8"> - function getValue(x) { - if (x.indexOf('input') >= 0) { - if ($(x).val() == 'x') { - return 0; - } - else { - return parseFloat($(x).val()); - } - } - else if (isNaN(x)) { - return x; - } - return parseFloat(x); - } - $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) { return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { return $('input', td).prop('checked') ? '1' : '0'; } ); - } + }; $(document).ready( function () { @@ -138,19 +128,8 @@ console.time("Creating table"); $('#trait_table').DataTable( { "paging": false, - "buttons": [ - { - extend: 'csvHtml5', - text: 'Download CSV', - title: 'search_results', - fieldBoundary: '"', - exportOptions: { - columns: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] - } - } - ], "columns": [ - { "type": "natural" }, + { "orderDataType": "dom-checkbox" }, { "type": "natural" }, { "type": "natural" }, { "type": "natural", "width": "8%" }, @@ -165,8 +144,14 @@ { "type": "natural", "width": "8%" }, { "type": "natural" } ], + "columnDefs": [ + { + "targets": 0, + "orderDataType": "dom-checkbox" + } + ], "order": [[1, "asc" ]], - "sDom": "Btir", + "sDom": "tir", "autoWidth": false, "bDeferRender": true, "scrollY": "800px", diff --git a/wqflask/wqflask/templates/gsearch_pheno.html b/wqflask/wqflask/templates/gsearch_pheno.html index be4981bb..9aad7568 100644 --- a/wqflask/wqflask/templates/gsearch_pheno.html +++ b/wqflask/wqflask/templates/gsearch_pheno.html @@ -25,37 +25,43 @@ <input type="text" id="select_top" class="form-control" style="width: 200px; display: inline;" placeholder="Select Top ..."> <br /> <br /> + <form id="export_form" method="POST" action="/export_traits_csv"> + <input type="hidden" name="database_name" id="database_name" value="None"> + <input type="hidden" name="export_data" id="export_data" value=""> + <button class="btn btn-default" id="export_traits">Download CSV</button> + </form> + <br /> <div style="width: 1500px; background-color: #eeeeee; border: 1px solid black;"> <table width="1500px" id="trait_table" class="table table-hover table-striped"> <thead> <tr> <th style="background-color: #eeeeee;"></th> - <th style="background-color: #eeeeee;">Index</th> - <th style="background-color: #eeeeee;">Species</th> - <th style="background-color: #eeeeee;">Group</th> - <th style="background-color: #eeeeee;">Record</th> - <th style="background-color: #eeeeee;">Description</th> - <th style="background-color: #eeeeee;">Authors</th> - <th style="background-color: #eeeeee;">Year</th> - <th style="background-color: #eeeeee; text-align: right;">Max <br>LRS<a href="http://genenetwork.org//glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th> - <th style="background-color: #eeeeee;">Max LRS Location</th> - <th style="background-color: #eeeeee; text-align: right;">Additive<br>Effect<a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th data-export="Index" style="background-color: #eeeeee;">Index</th> + <th data-export="Species" style="background-color: #eeeeee;">Species</th> + <th data-export="Group" style="background-color: #eeeeee;">Group</th> + <th data-export="Record" style="background-color: #eeeeee;">Record</th> + <th data-export="Description" style="background-color: #eeeeee;">Description</th> + <th data-export="Authors" style="background-color: #eeeeee;">Authors</th> + <th data-export="Year" style="background-color: #eeeeee;">Year</th> + <th data-export="LRS" style="background-color: #eeeeee; text-align: right;">Max <br>LRS<a href="http://genenetwork.org//glossary.html#L" target="_blank"><sup style="color:#f00"> ?</sup></a></th> + <th data-export="LRS Location" style="background-color: #eeeeee;">Max LRS Location</th> + <th data-export="Additive Effect" style="background-color: #eeeeee; text-align: right;">Additive<br>Effect<a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th> </tr> </thead> <tbody> {% for this_trait in trait_list %} <TR id="trait:{{ this_trait.name }}:{{ this_trait.dataset.name }}"> <td><INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="transform: scale(1.5);" VALUE="{{ data_hmac('{}:{}'.format(this_trait.name, this_trait.dataset.name)) }}"></td> - <td>{{ loop.index }}</td> - <td>{{ this_trait.dataset.group.species }}</td> - <td>{{ this_trait.dataset.group.name }}</td> - <td><a href="{{ url_for('show_trait_page', trait_id = this_trait.name, dataset = this_trait.dataset.name)}}">{{ this_trait.name }}</a></td> - <td>{{ this_trait.description_display }}</td> - <td>{{ this_trait.authors }}</td> - <td data-order="{{ this_trait.pubmed_text }}"><a href="{{ this_trait.pubmed_link }}">{{ this_trait.pubmed_text }}</a></td> - <td align="right">{% if this_trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % this_trait.LRS_score_repr|float }}{% else %}N/A{% endif %}</td> - <td align="right">{{ this_trait.LRS_location_repr }}</td> - <td align="right">{% if this_trait.additive != "" %}{{ this_trait.additive }}{% else %}N/A{% endif %}</td> + <td data-export="{{ loop.index }}">{{ loop.index }}</td> + <td data-export="{{ this_trait.dataset.group.species }}">{{ this_trait.dataset.group.species }}</td> + <td data-export="{{ this_trait.dataset.group.name }}">{{ this_trait.dataset.group.name }}</td> + <td data-export="{{ this_trait.name }}"><a href="{{ url_for('show_trait_page', trait_id = this_trait.name, dataset = this_trait.dataset.name)}}">{{ this_trait.name }}</a></td> + <td data-export="{{ this_trait.description_display }}">{{ this_trait.description_display }}</td> + <td data-export="{{ this_trait.authors }}">{{ this_trait.authors }}</td> + <td data-export="{{ this_trait.pubmed_text }}" data-order="{{ this_trait.pubmed_text }}"><a href="{{ this_trait.pubmed_link }}">{{ this_trait.pubmed_text }}</a></td> + <td data-export="{% if this_trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % this_trait.LRS_score_repr|float }}{% else %}N/A{% endif %}" align="right">{% if this_trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % this_trait.LRS_score_repr|float }}{% else %}N/A{% endif %}</td> + <td data-export="{{ this_trait.LRS_location_repr }}" align="right">{{ this_trait.LRS_location_repr }}</td> + <td data-export="{% if this_trait.additive != "" %}{{ this_trait.additive }}{% else %}N/A{% endif %}" align="right">{% if this_trait.additive != "" %}{{ this_trait.additive }}{% else %}N/A{% endif %}</td> </TR> {% endfor %} </tbody> @@ -98,40 +104,11 @@ <script language="javascript" type="text/javascript" src="/static/packages/TableTools/media/js/TableTools.min.js"></script> <script type="text/javascript" charset="utf-8"> - function getValue(x) { - if (x.indexOf('input') >= 0) { - if ($(x).val() == 'x') { - return 0; - } - else { - return parseFloat($(x).val()); - } - } - else if (isNaN(x)) { - return x; - } - return parseFloat(x); - } - - jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - - if (x == 'N/A' || x == '') { - return 1; - } - else if (y == 'N/A' || y == '') { - return -1; - } - else { - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); - } - }; - - jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); + $.fn.dataTable.ext.order['dom-checkbox'] = function ( settings, col ) + { + return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) { + return $('input', td).prop('checked') ? '1' : '0'; + } ); }; $(document).ready( function () { @@ -145,19 +122,8 @@ console.time("Creating table"); $('#trait_table').DataTable( { "paging": false, - "buttons": [ - { - extend: 'csvHtml5', - text: 'Download CSV', - title: 'search_results', - fieldBoundary: '"', - exportOptions: { - columns: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] - } - } - ], "columns": [ - { "type": "natural" }, + { "orderDataType": "dom-checkbox" }, { "type": "natural" }, { "type": "natural" }, { "type": "natural" }, @@ -169,8 +135,14 @@ { "type": "natural", "width": "12%"}, { "type": "natural" } ], + "columnDefs": [ + { + "targets": 0, + "orderDataType": "dom-checkbox" + } + ], "order": [[1, "asc" ]], - "sDom": "Btir", + "sDom": "tir", "autoWidth": false, "bDeferRender": true, "scrollY": "800px", diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index f44714f3..b6aab101 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -59,9 +59,9 @@ <br /> <br /> <form id="export_form" method="POST" action="/export_traits_csv"> - <input type="hidden" name="database_name" id="database_name" value="{{ dataset.fullname }}"> - <input type="hidden" name="export_data" id="export_data" value=""> - <button class="btn btn-default" id="export_traits">Download CSV</button> + <input type="hidden" name="database_name" id="database_name" value="{{ dataset.fullname }}"> + <input type="hidden" name="export_data" id="export_data" value=""> + <button class="btn btn-default" id="export_traits">Download CSV</button> </form> <br /> <!-- @@ -176,44 +176,6 @@ <script language="javascript" type="text/javascript" src="/static/new/packages/DataTables/extensions/dataTables.fixedHeader.min.js"></script> <script type="text/javascript" charset="utf-8"> - function getValue(x) { - if (x.indexOf('input') >= 0) { - if ($(x).val() == 'x') { - return 0; - } - else { - return parseFloat($(x).val()); - } - } - else if (isNaN(x)) { - return x; - } - return parseFloat(x); - } - - - jQuery.fn.dataTableExt.oSort['cust-txt-asc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - - if (x == 'N/A' || x == '') { - return 1; - } - else if (y == 'N/A' || y == '') { - return -1; - } - else { - return ((x < y) ? -1 : ((x > y) ? 1 : 0)); - } - }; - - jQuery.fn.dataTableExt.oSort['cust-txt-desc'] = function (a, b) { - var x = getValue(a); - var y = getValue(b); - return ((x < y) ? 1 : ((x > y) ? -1 : 0)); - }; - - $(document).ready( function () { $('#trait_table tr').click(function(event) { |