From bba892fc0ec1ecba21d5a6ba54392c247cbc2518 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 1 Apr 2020 16:04:44 -0500 Subject: Adding export option to correlation page Added ability to control in code the export file name Reorganized View Collection options --- wqflask/wqflask/export_traits.py | 13 ++-- wqflask/wqflask/show_trait/SampleList.py | 6 +- .../static/new/javascript/search_results.js | 1 - wqflask/wqflask/templates/collections/view.html | 26 +++---- wqflask/wqflask/templates/correlation_page.html | 83 ++++++++++++---------- wqflask/wqflask/templates/search_result_page.html | 1 + .../templates/show_trait_mapping_tools.html | 4 +- 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 - -

+
- - + + + + + + + + - - - -
-
- - - - +

+
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 @@
- - - - - - - +
+ + + + + + + + + + +

@@ -116,7 +121,7 @@
{% for header in header_fields %} - + {% endfor %} @@ -125,8 +130,8 @@ {% for trait in correlation_results %} - - + - - - - + + + + + + + {% if trait.lit_corr == "" or trait.lit_corr == 0.000 %} - + {% else %} - + {% endif %} {% if trait.tissue_corr == "" or trait.tissue_corr == 0.000 %} - - + + {% else %} - - + + {% endif %} - - - + + + {% elif target_dataset.type == "Publish" %} - - - + + - - - - - - + + + + + + {% elif target_dataset.type == "Geno" %} - - - - + + + + {% endif %} {% 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 @@ + {% if dataset.accession_id is defined %} 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 @@
{{header}}{{header}}
{{ loop.index }} + {{ loop.index }} {{ trait.location_repr }}{{ '%0.3f' % trait.mean|float }}{{'%0.3f'|format(trait.sample_r)}}{{ trait.num_overlap }}{{'%0.3e'|format(trait.sample_p)}}{{ trait.symbol }}{{ trait.description_display }}{{ trait.location_repr }}{{ '%0.3f' % trait.mean|float }}{{ '%0.3f'|format(trait.sample_r) }}{{ trait.num_overlap }}{{ '%0.3e'|format(trait.sample_p) }}----{{'%0.3f'|format(trait.lit_corr)}}{{ '%0.3f'|format(trait.lit_corr) }}--------{{'%0.3f'|format(trait.tissue_corr)}}{{'%0.3e'|format(trait.tissue_pvalue)}}{{ '%0.3f'|format(trait.tissue_corr) }}{{ '%0.3e'|format(trait.tissue_pvalue) }}{% if trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % trait.LRS_score_repr|float }}{% else %}N/A{% endif %}{{ trait.LRS_location_repr }}{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}{% if trait.LRS_score_repr != "N/A" %}{{ '%0.1f' % trait.LRS_score_repr|float }}{% else %}N/A{% endif %}{{ trait.LRS_location_repr }}{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}{{ trait.description_display }}{{ trait.authors }} + {{ trait.description_display }}{{ trait.authors }} {{ trait.pubmed_text }} {{'%0.3f'|format(trait.sample_r)}}{{ trait.num_overlap }}{{'%0.3e'|format(trait.sample_p)}}{{ trait.LRS_score_repr }}{{ trait.LRS_location_repr }}{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}{{ '%0.3f'|format(trait.sample_r) }}{{ trait.num_overlap }}{{ '%0.3e'|format(trait.sample_p) }}{{ trait.LRS_score_repr }}{{ trait.LRS_location_repr }}{% if trait.additive != "" %}{{ '%0.3f' % trait.additive|float }}{% else %}N/A{% endif %}{{ trait.location_repr }}{{'%0.3f'|format(trait.sample_r)}}{{ trait.num_overlap }}{{'%0.3e'|format(trait.sample_p)}}{{ trait.location_repr }}{{ '%0.3f'|format(trait.sample_r) }}{{ trait.num_overlap }}{{ '%0.3e'|format(trait.sample_p) }}