aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/base/trait.py36
-rw-r--r--wqflask/wqflask/export_traits.py41
-rw-r--r--wqflask/wqflask/static/new/javascript/search_results.js53
-rw-r--r--wqflask/wqflask/templates/collections/view.html59
-rw-r--r--wqflask/wqflask/templates/gsearch_gene.html101
-rw-r--r--wqflask/wqflask/templates/gsearch_pheno.html110
-rw-r--r--wqflask/wqflask/templates/search_result_page.html129
-rw-r--r--wqflask/wqflask/templates/show_trait_details.html8
-rw-r--r--wqflask/wqflask/views.py12
9 files changed, 270 insertions, 279 deletions
diff --git a/wqflask/base/trait.py b/wqflask/base/trait.py
index 32032ba7..276c624a 100644
--- a/wqflask/base/trait.py
+++ b/wqflask/base/trait.py
@@ -78,11 +78,37 @@ class GeneralTrait(object):
"""Return a dict suitable for using as json
Actual turning into json doesn't happen here though"""
- return dict(name=self.name,
- dataset=self.dataset.name,
- description=self.description_display,
- mean=self.mean)
-
+
+ if self.dataset.type == "ProbeSet":
+ return dict(name=self.name,
+ symbol=self.symbol,
+ dataset=self.dataset.name,
+ description=self.description_display,
+ mean=self.mean,
+ location=self.location_repr,
+ lrs_score=self.LRS_score_repr,
+ lrs_location=self.LRS_location_repr,
+ additive=self.additive
+ )
+ elif self.dataset.type == "Publish":
+ return dict(name=self.name,
+ dataset=self.dataset.name,
+ description=self.description_display,
+ authors=self.authors,
+ pubmed_text=self.pubmed_text,
+ pubmed_link=self.pubmed_link,
+ lrs_score=self.LRS_score_repr,
+ lrs_location=self.LRS_location_repr,
+ additive=self.additive
+ )
+ elif self.dataset.type == "Geno":
+ return dict(name=self.name,
+ dataset=self.dataset.name,
+ location=self.location_repr
+ )
+ else:
+ return dict()
+
def get_name(self):
stringy = ""
diff --git a/wqflask/wqflask/export_traits.py b/wqflask/wqflask/export_traits.py
new file mode 100644
index 00000000..f8fce929
--- /dev/null
+++ b/wqflask/wqflask/export_traits.py
@@ -0,0 +1,41 @@
+from __future__ import print_function, division
+
+import operator
+import csv
+import xlsxwriter
+import StringIO
+import datetime
+
+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)
+
+ metadata = []
+
+ metadata.append(["Citations: Please see www.genenetwork.org/reference.html"])
+ 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."])
+
+ for metadata_row in metadata:
+ writer.writerow(metadata_row)
+
+ 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..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];
@@ -155,10 +153,61 @@ $(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) {
+ if (trait_table.find('input[name="searchResult"]:checked').length > 0) {
+ if ($(this).find('input[name="searchResult"]').is(':checked')){
+ this_row = [];
+ $(tr).find('td').each(function(j, td){
+ if ($(td).data('export')){
+ this_row.push($(td).data('export'));
+ }
+ });
+ rows.push(this_row);
+ }
+ }
+ else {
+ 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/collections/view.html b/wqflask/wqflask/templates/collections/view.html
index 8fc5f120..801266d3 100644
--- a/wqflask/wqflask/templates/collections/view.html
+++ b/wqflask/wqflask/templates/collections/view.html
@@ -4,7 +4,6 @@
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" />
<link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.css" />
- <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" />
{% endblock %}
{% block content %}
<!-- Start of body -->
@@ -74,20 +73,26 @@
<button class="btn" id="remove" disabled="disabled"><i class="icon-minus-sign"></i> Remove Record</button>
<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="background-color: #eeeeee; border: 1px solid black;">
<table 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;">Dataset</th>
- <th style="background-color: #eeeeee;">Record</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 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 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="Dataset" style="background-color: #eeeeee;">Dataset</th>
+ <th data-export="Record" style="background-color: #eeeeee;">Record</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 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 Effect<a href="http://genenetwork.org//glossary.html#A" target="_blank"><sup style="color:#f00"> ?</sup></a></th>
</tr>
</thead>
@@ -98,9 +103,9 @@
<INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox"
VALUE="{{ data_hmac('{}:{}'.format(this_trait.name, this_trait.dataset.name)) }}">
</TD>
- <TD>{{ loop.index }}</TD>
- <TD>{{ this_trait.dataset.name }}</TD>
- <TD>
+ <TD data-export="{{ loop.index }}">{{ loop.index }}</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
@@ -108,12 +113,12 @@
{{ this_trait.name }}
</a>
</TD>
- <TD>{{ this_trait.description_display }}</TD>
- <TD>{{ this_trait.location_repr }}</TD>
- <TD>{{ '%0.3f' % this_trait.mean|float }}</TD>
- <TD>{{ '%0.3f' % this_trait.LRS_score_repr|float }}</TD>
- <TD>{{ this_trait.LRS_location_repr }}</TD>
- <TD>{{ '%0.3f' % this_trait.additive|float }}</TD>
+ <TD data-export="{{ this_trait.description_display }}">{{ this_trait.description_display }}</TD>
+ <TD data-export="{{ this_trait.location_repr }}">{{ this_trait.location_repr }}</TD>
+ <TD data-export="{{ this_trait.mean }}">{{ '%0.3f' % this_trait.mean|float }}</TD>
+ <TD data-export="{{ this_trait.LRS_score_repr }}">{{ '%0.3f' % this_trait.LRS_score_repr|float }}</TD>
+ <TD data-export="{{ this_trait.LRS_location_repr }}">{{ this_trait.LRS_location_repr }}</TD>
+ <TD data-export="{{ this_trait.additive }}">{{ '%0.3f' % this_trait.additive|float }}</TD>
</TR>
{% endfor %}
@@ -132,9 +137,6 @@
{% block js %}
<script type="text/javascript" src="/static/new/javascript/search_results.js"></script>
<script language="javascript" type="text/javascript" src="/static/new/packages/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="https://cdn.datatables.net/buttons/1.0.0/js/buttons.html5.min.js"></script>
- <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.bootstrap.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.colResize.js"></script>
@@ -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 2d970b36..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 %}
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" />
- <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" />
{% endblock %}
{% block content %}
<!-- Start of body -->
@@ -20,46 +19,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&nbsp;&nbsp;<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&nbsp;&nbsp;<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>
@@ -94,9 +98,6 @@
<script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script>
<script language="javascript" type="text/javascript" src="https://cdn.datatables.net/1.10.12/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="https://cdn.datatables.net/buttons/1.0.0/js/buttons.html5.min.js"></script>
- <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.bootstrap.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>
@@ -105,27 +106,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 +124,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 +140,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..2f7dcaf6 100644
--- a/wqflask/wqflask/templates/gsearch_pheno.html
+++ b/wqflask/wqflask/templates/gsearch_pheno.html
@@ -4,7 +4,6 @@
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/css/jquery.dataTables.css" />
<link rel="stylesheet" type="text/css" href="/static/packages/DT_bootstrap/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css" href="/static/packages/TableTools/media/css/TableTools.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/dataTables.fixedHeader.css" >
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/fixedcolumns/3.0.4/css/dataTables.fixedColumns.css">
{% endblock %}
@@ -25,37 +24,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&nbsp;&nbsp;<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&nbsp;&nbsp;<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>
@@ -87,9 +92,6 @@
<script language="javascript" type="text/javascript" src="/static/new/javascript/search_results.js"></script>
<script language="javascript" type="text/javascript" src="https://cdn.datatables.net/1.10.12/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="https://cdn.datatables.net/buttons/1.0.0/js/buttons.html5.min.js"></script>
- <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.bootstrap.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>
@@ -98,40 +100,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 +118,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 +131,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 523037f8..0f5e68d7 100644
--- a/wqflask/wqflask/templates/search_result_page.html
+++ b/wqflask/wqflask/templates/search_result_page.html
@@ -5,7 +5,6 @@
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/scroller/1.4.1/css/scroller.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/dataTables.fixedHeader.css" >
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/fixedcolumns/3.0.4/css/dataTables.fixedColumns.css">
- <link rel="stylesheet" type="text/css" href="/static/new/packages/DataTables/extensions/buttons.bootstrap.css" />
{% endblock %}
{% block content %}
<!-- Start of body -->
@@ -13,7 +12,6 @@
'GeneNetwork found {}.'.format(numify(results|count, "record", "records"))) }}
<div class="container">
-
<input type="hidden" name="uc_id" id="uc_id" value="{{ uc_id }}">
<!-- Need to customize text more for other types of searches -->
@@ -41,7 +39,7 @@
{% elif word.key|lower == "position" %}
with <u>target genes</u> on chromosome <strong>{% 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 %}</strong> between <strong>{{ word.search_term[1] }}</strong> and <strong>{{ word.search_term[2] }}</strong> Mb{% if loop.last %}.{% else %} and {% endif %}
{% else %}
- that match the term {{ word.search_term[0] }}.
+ that match the <u>TERM</u> <b>{{ word.search_term[0] }}</b>{% if loop.last %}.{% else %} and {% endif %}
{% endif %}
{% endfor %}
</p>
@@ -54,12 +52,17 @@
<button class="btn btn-default" id="deselect_all"><span class="glyphicon glyphicon-remove"></span> Deselect All</button>
<button class="btn btn-default" id="invert"><span class="glyphicon glyphicon-resize-vertical"></span> Invert</button>
<button class="btn btn-default" id="add" disabled><span class="glyphicon glyphicon-plus-sign"></span> Add</button>
- <!--<button class="btn btn-default"><span class="glyphicon glyphicon-download"></span> Download Table</button>-->
<button id="redraw" class="btn btn-default">Reset Columns</button>
<input type="text" id="searchbox" class="form-control" style="width: 200px; display: inline;" placeholder="Search This Table For ...">
<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="{{ 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 />
<!--
Removing this until more options are added and work correctly
{% if dataset.type == 'ProbeSet' %}
@@ -82,11 +85,11 @@
<th style="background-color: #eeeeee;"></th>
{% for header in header_fields %}
{% if header == 'Max LRS' %}
- <th style="background-color: #eeeeee; text-align: right;">Max<br>LRS</th>
+ <th data-export="Max LRS" style="background-color: #eeeeee; text-align: right;">Max<br>LRS</th>
{% elif header == 'Additive Effect' %}
- <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="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>
{% else %}
- <th style="background-color: #eeeeee;">{{header}}</th>
+ <th data-export="{{header}}" style="background-color: #eeeeee;">{{header}}</th>
{% endif %}
{% endfor %}
</tr>
@@ -97,8 +100,8 @@
<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 align="right">{{ loop.index }}</TD>
- <TD>
+ <TD data-export="{{ loop.index }}" align="right">{{ loop.index }}</TD>
+ <TD data-export="{{ this_trait.name }}">
<a href="{{ url_for('show_trait_page',
trait_id = this_trait.name,
dataset = dataset.name
@@ -107,26 +110,26 @@
</a>
</TD>
{% if dataset.type == 'ProbeSet' %}
- <TD>{{ this_trait.symbol }}</TD>
- <TD>{{ this_trait.description_display }}</TD>
- <TD>{{ this_trait.location_repr }}</TD>
- <TD align="right">{{ '%0.3f' % this_trait.mean|float }}</TD>
- <TD align="right">{{ '%0.3f' % this_trait.LRS_score_repr|float }}</TD>
- <TD>{{ this_trait.LRS_location_repr }}</TD>
- <TD align="right">{{ '%0.3f' % this_trait.additive|float }}</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 }}">{{ 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="{{ '%0.3f' % this_trait.LRS_score_repr|float }}" align="right">{{ '%0.3f' % this_trait.LRS_score_repr|float }}</TD>
+ <TD data-export="{{ this_trait.LRS_location_repr }}">{{ this_trait.LRS_location_repr }}</TD>
+ <TD data-export="{{ '%0.3f' % this_trait.additive|float }}" align="right">{{ '%0.3f' % this_trait.additive|float }}</TD>
{% elif dataset.type == 'Publish' %}
- <TD>{{ this_trait.description_display }}</TD>
- <TD>{{ this_trait.authors }}</TD>
- <TD data-sort="{{ this_trait.pubmed_text }}">
+ <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-sort="{{ this_trait.pubmed_text }}">
<a href="{{ this_trait.pubmed_link }}">
{{ this_trait.pubmed_text }}
</a>
</TD>
- <TD>{{ '%0.3f' % this_trait.LRS_score_repr|float }}</TD>
- <TD>{{ this_trait.LRS_location_repr }}</TD>
- <TD>{{ '%0.3f' % this_trait.additive|float }}</TD>
+ <TD data-export="{{ '%0.3f' % this_trait.LRS_score_repr|float }}">{{ '%0.3f' % this_trait.LRS_score_repr|float }}</TD>
+ <TD data-export="{{ this_trait.LRS_location_repr }}">{{ this_trait.LRS_location_repr }}</TD>
+ <TD data-export="{{ '%0.3f' % this_trait.additive|float }}">{{ '%0.3f' % this_trait.additive|float }}</TD>
{% elif dataset.type == 'Geno' %}
- <TD>{{ this_trait.location_repr }}</TD>
+ <TD data-export="{{ this_trait.location_repr }}">{{ this_trait.location_repr }}</TD>
{% endif %}
</TR>
{% endfor %}
@@ -162,9 +165,6 @@
<script type="text/javascript" src="/static/new/javascript/search_results.js"></script>
<script language="javascript" type="text/javascript" src="https://cdn.datatables.net/1.10.12/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="https://cdn.datatables.net/buttons/1.0.0/js/buttons.html5.min.js"></script>
- <script language="javascript" type="text/javascript" src="https://cdn.datatables.net/buttons/1.0.0/js/buttons.bootstrap.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.colResize.js"></script>
@@ -172,44 +172,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) {
@@ -235,18 +197,7 @@
{ "type": "natural" }
],
"order": [[1, "asc" ]],
- "buttons": [
- {
- extend: 'csvHtml5',
- text: 'Download CSV',
- title: 'search_results',
- fieldBoundary: '"',
- exportOptions: {
- columns: [1, 2, 3, 4, 5, 6, 7, 8, 9]
- }
- }
- ],
- "sDom": "RZBtir",
+ "sDom": "RZtir",
"iDisplayLength": -1,
"bDeferRender": true,
"bSortClasses": false,
@@ -269,18 +220,7 @@
{ "type": "natural" }
],
"order": [[1, "asc" ]],
- "buttons": [
- {
- extend: 'csvHtml5',
- text: 'Download CSV',
- title: 'search_results',
- fieldBoundary: '"',
- exportOptions: {
- columns: [1, 2, 3, 4, 5, 6, 7]
- }
- }
- ],
- "sDom": "RZBtir",
+ "sDom": "RZtir",
"iDisplayLength": -1,
"autoWidth": false,
"bDeferRender": true,
@@ -298,18 +238,7 @@
{ "type": "natural", "width": "40%"}
],
"order": [[1, "asc" ]],
- "buttons": [
- {
- extend: 'csvHtml5',
- text: 'Download CSV',
- title: 'search_results',
- fieldBoundary: '"',
- exportOptions: {
- columns: [1, 2, 3]
- }
- }
- ],
- "sDom": "RZBtir",
+ "sDom": "RZtir",
"iDisplayLength": -1,
"autoWidth": true,
"bDeferRender": true,
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 @@
<td>
{% if this_trait.geneid != None %}
<a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=Graphics&list_uids={{ this_trait.geneid }}" title="Info from NCBI Entrez Gene">
- Gene
+ NCBI
</a>
&nbsp;&nbsp;
{% endif %}
@@ -61,12 +61,6 @@
</a>
&nbsp;&nbsp;
{% endif %}
- {% if this_trait.genbankid != None %}
- <a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=Nucleotide&cmd=search&doptcmdl=DocSum&term={{ this_trait.genbankid }}" title="Find the original GenBank sequence used to design the probes">
- GenBank
- </a>
- &nbsp;&nbsp;
- {% endif %}
{% if this_trait.symbol != None %}
<a href="http://www.genotation.org/Getd2g.pl?gene_list={{ this_trait.symbol }}" title="Related descriptive, genomic, clinical, functional and drug-therapy information">
Genotation
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 822bab9f..4f6725b3 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -33,6 +33,7 @@ import sqlalchemy
from wqflask import app
from flask import g, Response, request, make_response, render_template, send_from_directory, jsonify, redirect
from wqflask import search_results
+from wqflask import export_traits
from wqflask import gsearch
from wqflask import update_search_results
from wqflask import docs
@@ -338,6 +339,17 @@ def export_trait_csv():
mimetype='text/csv',
headers={"Content-Disposition":"attachment;filename=sample_data.csv"})
+@app.route('/export_traits_csv', methods=('POST',))
+def export_traits_csv():
+ """CSV file consisting of the traits from the search result page"""
+ logger.info("In export_traits_csv")
+ logger.info("request.form:", request.form)
+ csv_data = export_traits.export_search_results_csv(request.form)
+
+ return Response(csv_data,
+ mimetype='text/csv',
+ headers={"Content-Disposition":"attachment;filename=trait_list.csv"})
+
@app.route('/export_perm_data', methods=('POST',))
def export_perm_data():
"""CSV file consisting of the permutation data for the mapping results"""