diff options
author | GN2 | 2020-04-01 16:05:47 -0500 |
---|---|---|
committer | GN2 | 2020-04-01 16:05:47 -0500 |
commit | ef67ab4470e2c578a36c80a5cce4cd0c122ccf54 (patch) | |
tree | 820484b46fe4f76209b463ebda711a9313c339df /wqflask | |
parent | c1574aa8ca2fcab06fd127aa8c301fa10b60c21c (diff) | |
parent | bba892fc0ec1ecba21d5a6ba54392c247cbc2518 (diff) | |
download | genenetwork2-ef67ab4470e2c578a36c80a5cce4cd0c122ccf54.tar.gz |
Merge branch 'testing' of https://github.com/genenetwork/genenetwork2 into HEAD
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/export_traits.py | 13 | ||||
-rw-r--r-- | wqflask/wqflask/show_trait/SampleList.py | 6 | ||||
-rw-r--r-- | wqflask/wqflask/static/new/javascript/search_results.js | 1 | ||||
-rw-r--r-- | wqflask/wqflask/templates/collections/view.html | 26 | ||||
-rw-r--r-- | wqflask/wqflask/templates/correlation_page.html | 83 | ||||
-rw-r--r-- | wqflask/wqflask/templates/search_result_page.html | 1 | ||||
-rw-r--r-- | wqflask/wqflask/templates/show_trait_mapping_tools.html | 4 | ||||
-rw-r--r-- | wqflask/wqflask/views.py | 4 |
8 files changed, 72 insertions, 66 deletions
diff --git a/wqflask/wqflask/export_traits.py b/wqflask/wqflask/export_traits.py index bc029965..2d96c05a 100644 --- a/wqflask/wqflask/export_traits.py +++ b/wqflask/wqflask/export_traits.py @@ -12,12 +12,17 @@ from pprint import pformat as pf def export_search_results_csv(targs): table_data = json.loads(targs['export_data']) - table_headers = targs['headers'].split(",") + table_headers = table_data['headers'] table_rows = table_data['rows'] buff = StringIO.StringIO() writer = csv.writer(buff) + if 'file_name' in targs: + file_name = targs['file_name'] + else: + file_name = "table_export.csv" + metadata = [] if 'database_name' in targs: @@ -39,15 +44,15 @@ def export_search_results_csv(targs): for metadata_row in metadata: writer.writerow(metadata_row) - writer.writerow([""]) + writer.writerow([]) writer.writerow(table_headers) for trait_info in table_rows: writer.writerow(trait_info) - writer.writerow([""]) + writer.writerow([]) writer.writerow(["Funding for The GeneNetwork: NIAAA (U01AA13499, U24AA13513), NIDA, NIMH, and NIAAA (P20-DA21131), NCI MMHCC (U01CA105417), and NCRR (U01NR 105417)"]) csv_data = buff.getvalue() buff.close() - return csv_data
\ No newline at end of file + return csv_data, file_name
\ No newline at end of file diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index aa6ada5a..451be50b 100644 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -55,7 +55,7 @@ class SampleList(object): try: sample = self.this_trait.data[sample_name] except KeyError: - logger.debug("No sample %s, let's create it now" % sample_name) + #logger.debug("No sample %s, let's create it now" % sample_name) sample = webqtlCaseData.webqtlCaseData(name=sample_name) sample.extra_info = {} @@ -106,7 +106,7 @@ class SampleList(object): self.attributes = {} for attr, values in itertools.groupby(results.fetchall(), lambda row: (row.Id, row.Name)): key, name = attr - logger.debug("radish: %s - %s" % (key, name)) + #logger.debug("radish: %s - %s" % (key, name)) self.attributes[key] = Bunch() self.attributes[key].name = name self.attributes[key].distinct_values = [item.Value for item in values] @@ -195,7 +195,7 @@ def get_transform_vals(dataset, trait): for sample in samples: sample_dict[sample['name']] = sample['qnorm'] - logger.info("SAMPLE DICT:", sample_dict) + #logger.info("SAMPLE DICT:", sample_dict) return sample_dict else: return None diff --git a/wqflask/wqflask/static/new/javascript/search_results.js b/wqflask/wqflask/static/new/javascript/search_results.js index 0331a141..8fa698b4 100644 --- a/wqflask/wqflask/static/new/javascript/search_results.js +++ b/wqflask/wqflask/static/new/javascript/search_results.js @@ -215,7 +215,6 @@ $(function() { } }); table_dict['rows'] = rows; - console.log("TABLEDICT:", table_dict); json_table_dict = JSON.stringify(table_dict); $('input[name=export_data]').val(json_table_dict); diff --git a/wqflask/wqflask/templates/collections/view.html b/wqflask/wqflask/templates/collections/view.html index 1be6539d..1085e432 100644 --- a/wqflask/wqflask/templates/collections/view.html +++ b/wqflask/wqflask/templates/collections/view.html @@ -70,30 +70,26 @@ BNW </button> - <button id="delete" class="btn btn-danger submit_special" style="margin-left: 15px;" data-url="/collections/delete" title="Delete this collection" > - Delete Collection - </button> - </form> </div> <div> <br /> + <form id="export_form" method="POST" action="/export_traits_csv"> <button class="btn btn-default" id="select_all"><span class="glyphicon glyphicon-ok"></span> Select All</button> - <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" id="add" disabled="disabled"><i class="icon-plus-sign"></i> Copy</button> + <input type="hidden" name="database_name" id="database_name" value="None"> + <input type="hidden" name="export_data" id="export_data" value=""> + <input type="hidden" name="file_name" id="file_name" value="collection_table"> + <button class="btn btn-default" id="export_traits">Download CSV</button> + <input type="text" id="searchbox" class="form-control" style="width: 200px; display: inline; padding-bottom: 9px;" placeholder="Search Table For ..."> + <input type="text" id="select_top" class="form-control" style="width: 200px; display: inline; padding-bottom: 9px;" placeholder="Select Top ..."> + <button class="btn btn-default" id="deselect_all"><span class="glyphicon glyphicon-remove"></span> Deselect</button> <button class="btn btn-danger" id="remove" disabled="disabled"><i class="icon-minus-sign"></i> Delete Rows</button> - <button class="btn" id="add" disabled="disabled"><i class="icon-plus-sign"></i> Copy to Other Collection</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="None"> - <input type="hidden" name="export_data" id="export_data" value=""> - <button class="btn btn-default" id="export_traits">Download CSV</button> + <button id="delete" class="btn btn-danger submit_special" data-url="/collections/delete" title="Delete this collection" > Delete Collection</button> </form> <br /> + <br /> <div> <table class="table-hover table-striped cell-border" id='trait_table' style="float: left;"> <thead> diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index f52f20e1..829c5c29 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -73,13 +73,18 @@ </div> <br /> <div> - <button class="btn btn-default" id="select_all"><span class="glyphicon glyphicon-ok"></span> Select All</button> - <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 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 ..."> + <form id="export_form" method="POST" action="/export_traits_csv"> + <button class="btn btn-default" id="select_all"><span class="glyphicon glyphicon-ok"></span> Select All</button> + <button class="btn btn-default" id="add" disabled><span class="glyphicon glyphicon-plus-sign"></span> Add</button> + <input type="hidden" name="database_name" id="database_name" value="None"> + <input type="hidden" name="export_data" id="export_data" value=""> + <input type="hidden" name="file_name" id="file_name" value="{{ this_trait.name }}_{{ dataset.name }}_correlation.csv"> + <button class="btn btn-default" id="export_traits">Download CSV</button> + <input type="text" id="searchbox" class="form-control" style="width: 200px; display: inline;" placeholder="Search Table For ..."> + <input type="text" id="select_top" class="form-control" style="width: 200px; display: inline;" placeholder="Select Top ..."> + <button class="btn btn-default" id="deselect_all"><span class="glyphicon glyphicon-remove"></span> Deselect</button> + <button id="redraw" class="btn btn-default">Reset Columns</button> + </form> <br /> <br /> <button id="more_options" class="btn btn-primary">More Options...</button> @@ -116,7 +121,7 @@ <tr> <th></th> {% for header in header_fields %} - <th>{{header}}</th> + <th {% if header != "" %}data-export="{{ header }}"{% endif %}>{{header}}</th> {% endfor %} </tr> </thead> @@ -125,8 +130,8 @@ {% for trait in correlation_results %} <tr> <td><INPUT TYPE="checkbox" NAME="searchResult" class="checkbox trait_checkbox" style="padding-right: 0px;" VALUE="{{ data_hmac('{}:{}'.format(trait.name, trait.dataset.name)) }}"></td> - <td style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;">{{ loop.index }}</td> - <td> + <td data-export="{{ loop.index }}" style="padding-left: 8px; padding-right: 0px; padding-top: 4px; align: center;">{{ loop.index }}</td> + <td data-export="{{ trait.name }}"> <a href="{{ url_for('show_trait_page', trait_id = trait.name, dataset = trait.dataset.name @@ -135,47 +140,47 @@ </a> </td> {% if target_dataset.type == 'ProbeSet' %} - <td>{{ trait.symbol }}</td> - <td>{{ trait.description_display }}</TD> - <td style="white-space: nowrap;">{{ trait.location_repr }}</td> - <td align="right">{{ '%0.3f' % trait.mean|float }}</td> - <td align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{'%0.3f'|format(trait.sample_r)}}</a></td> - <td align="right">{{ trait.num_overlap }}</td> - <td align="right">{{'%0.3e'|format(trait.sample_p)}}</td> + <td data-export="{{ trait.symbol }}">{{ trait.symbol }}</td> + <td data-export="{{ trait.description_display }}">{{ trait.description_display }}</TD> + <td data-export="{{ trait.location_repr }}" style="white-space: nowrap;">{{ trait.location_repr }}</td> + <td data-export="{{ '%0.3f' % trait.mean|float }}" align="right">{{ '%0.3f' % trait.mean|float }}</td> + <td data-export="{{ '%0.3f'|format(trait.sample_r) }} align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> + <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> + <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> {% if trait.lit_corr == "" or trait.lit_corr == 0.000 %} - <td align="right">--</td> + <td data-export="--" align="right">--</td> {% else %} - <td align="right">{{'%0.3f'|format(trait.lit_corr)}}</td> + <td data-export="{{ '%0.3f'|format(trait.lit_corr) }}" align="right">{{ '%0.3f'|format(trait.lit_corr) }}</td> {% endif %} {% if trait.tissue_corr == "" or trait.tissue_corr == 0.000 %} - <td align="right">--</td> - <td align="right">--</td> + <td data-export="--" align="right">--</td> + <td data-export="--" align="right">--</td> {% else %} - <td align="right">{{'%0.3f'|format(trait.tissue_corr)}}</td> - <td align="right">{{'%0.3e'|format(trait.tissue_pvalue)}}</td> + <td data-export="{{ '%0.3f'|format(trait.tissue_corr) }}" align="right">{{ '%0.3f'|format(trait.tissue_corr) }}</td> + <td data-export="{{ '%0.3e'|format(trait.tissue_pvalue) }}" align="right">{{ '%0.3e'|format(trait.tissue_pvalue) }}</td> {% endif %} - <td align="right">{% if trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % trait.LRS_score_repr|float }}{% else %}N/A{% endif %}</td> - <td align="right">{{ trait.LRS_location_repr }}</td> - <td align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> + <td data-export={% if trait.LRS_score_repr != "N/A" %}"{{ '%0.1f' % trait.LRS_score_repr|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % trait.LRS_score_repr|float }}{% else %}N/A{% endif %}</td> + <td data-export="{{ trait.LRS_location_repr }}" align="right">{{ trait.LRS_location_repr }}</td> + <td data-export={% if trait.additive != "" %}"{{ '%0.3f' % trait.additive|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> {% elif target_dataset.type == "Publish" %} - <td>{{ trait.description_display }}</td> - <td>{{ trait.authors }}</td> - <td> + <td data-export="{{ trait.description_display }}">{{ trait.description_display }}</td> + <td data-export="{{ trait.authors }}">{{ trait.authors }}</td> + <td data-export="{{ trait.pubmed_text }}"> <a href="{{ trait.pubmed_link }}"> {{ trait.pubmed_text }} </a> </td> - <td align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{'%0.3f'|format(trait.sample_r)}}</a></td> - <td align="right">{{ trait.num_overlap }}</td> - <td align="right">{{'%0.3e'|format(trait.sample_p)}}</td> - <td align="right">{{ trait.LRS_score_repr }}</td> - <td align="right">{{ trait.LRS_location_repr }}</td> - <td align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> + <td data-export="{{ '%0.3f'|format(trait.sample_r) }}" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> + <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> + <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> + <td data-export="{{ trait.LRS_score_repr }}" align="right">{{ trait.LRS_score_repr }}</td> + <td data-export="{{ trait.LRS_location_repr }}" align="right">{{ trait.LRS_location_repr }}</td> + <td data-export={% if trait.additive != "" %}"{{ '%0.3f' % trait.additive|float }}"{% else %}"N/A"{% endif %} align="right">{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}</td> {% elif target_dataset.type == "Geno" %} - <td align="right">{{ trait.location_repr }}</TD> - <td align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{'%0.3f'|format(trait.sample_r)}}</a></td> - <td align="right">{{ trait.num_overlap }}</td> - <td align="right">{{'%0.3e'|format(trait.sample_p)}}</td> + <td data-export="{{ trait.location_repr }}" align="right">{{ trait.location_repr }}</TD> + <td data-export="{{ '%0.3f'|format(trait.sample_r) }}" align="right"><a target="_blank" href="corr_scatter_plot?dataset_1={{dataset.name}}&dataset_2={{trait.dataset.name}}&trait_1={{this_trait.name}}&trait_2={{trait.name}}">{{ '%0.3f'|format(trait.sample_r) }}</a></td> + <td data-export="{{ trait.num_overlap }}" align="right">{{ trait.num_overlap }}</td> + <td data-export="{{ '%0.3e'|format(trait.sample_p) }}" align="right">{{ '%0.3e'|format(trait.sample_p) }}</td> {% endif %} </tr> {% endfor %} diff --git a/wqflask/wqflask/templates/search_result_page.html b/wqflask/wqflask/templates/search_result_page.html index c11b2533..6fc19be1 100644 --- a/wqflask/wqflask/templates/search_result_page.html +++ b/wqflask/wqflask/templates/search_result_page.html @@ -122,6 +122,7 @@ <input type="hidden" name="headers" id="headers" value="{% for field in header_fields %}{{ field }},{% endfor %}"> <input type="hidden" name="search_string" id="search_string" value="{{ original_search_string }}"> <input type="hidden" name="database_name" id="database_name" value="{{ dataset.fullname }}"> + <input type="hidden" name="file_name" id="file_name" value="search_results"> <input type="hidden" name="filter_term" id="filter_term" value="None"> {% if dataset.accession_id is defined %} <input type="hidden" name="accession_id" id="accession_id" value="{{ dataset.accession_id }}"> diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index ad7412b2..6da25a5d 100644 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -6,7 +6,7 @@ <ul class="nav nav-pills"> {% for mapping_method in dataset.group.mapping_names %} {% if mapping_method == "GEMMA" %} - <li class="gemma_tab mapping_tab {% if dataset.group.mapping_id == '1' %}active{% endif %}"> + <li class="gemma_tab mapping_tab {% if dataset.group.mapping_id == '1' or dataset.group.mapping_id == '2' %}active{% endif %}"> <a href="#gemma" data-toggle="tab">GEMMA</a> </li> {% elif mapping_method == "R/qtl" %} @@ -27,7 +27,7 @@ <div class="tab-content"> {% for mapping_method in dataset.group.mapping_names %} {% if mapping_method == "GEMMA" %} - <div class="tab-pane {% if dataset.group.mapping_id == '1' %}active{% endif %}" id="gemma"> + <div class="tab-pane {% if dataset.group.mapping_id == '1' or dataset.group.mapping_id == '2' %}active{% endif %}" id="gemma"> <div style="padding-top: 20px;" class="form-horizontal"> <div class="mapping_method_fields form-group"> <label for="chr_select" style="text-align: right;" class="col-xs-3 control-label">Chromosome</label> diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 8a80c26c..c4a1b85c 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -377,11 +377,11 @@ def export_traits_csv(): logger.info("In export_traits_csv") logger.info("request.form:", request.form) logger.info(request.url) - csv_data = export_traits.export_search_results_csv(request.form) + csv_data, file_name = export_traits.export_search_results_csv(request.form) return Response(csv_data, mimetype='text/csv', - headers={"Content-Disposition":"attachment;filename=trait_list.csv"}) + headers={"Content-Disposition":"attachment;filename=" + file_name}) @app.route('/export_perm_data', methods=('POST',)) def export_perm_data(): |