From d723eb260bfd9c707f6e282037c4e42670bdf48e Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 16 Jun 2021 21:15:27 +0000 Subject: Changed views.py to call the correlation code using the GN3 API + a function in show_corr_results for setting other template vars (might change this later) --- wqflask/wqflask/views.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index b9181368..96f228af 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -65,7 +65,7 @@ from wqflask.comparison_bar_chart import comparison_bar_chart from wqflask.marker_regression import run_mapping from wqflask.marker_regression import display_mapping_results from wqflask.network_graph import network_graph -from wqflask.correlation import show_corr_results +from wqflask.correlation.show_corr_results import set_other_template_vars from wqflask.correlation.correlation_gn3_api import compute_correlation from wqflask.correlation_matrix import show_corr_matrix from wqflask.correlation import corr_scatter_plot @@ -1082,15 +1082,9 @@ def network_graph_page(): @app.route("/corr_compute", methods=('POST',)) def corr_compute_page(): - logger.info("In corr_compute, request.form is:", pf(request.form)) - logger.info(request.url) - template_vars = show_corr_results.CorrelationResults(request.form) - return render_template("correlation_page.html", **template_vars.__dict__) - - # to test/disable the new correlation api uncomment these lines - - # correlation_results = compute_correlation(request.form) - # return render_template("test_correlation_page.html", correlation_results=correlation_results) + correlation_results = compute_correlation(request.form, compute_all=True) + correlation_results = set_other_template_vars(request.form, correlation_results) + return render_template("correlation_page.html", **correlation_results) @app.route("/test_corr_compute", methods=["POST"]) -- cgit v1.2.3 From c327905af1ef1a0c66a453127ee8f5ba4a824573 Mon Sep 17 00:00:00 2001 From: zsloan Date: Wed, 16 Jun 2021 21:16:09 +0000 Subject: Changed correlation page template to account for differences in the output returned from the GN3 API correlation code --- wqflask/wqflask/templates/correlation_page.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/correlation_page.html b/wqflask/wqflask/templates/correlation_page.html index 4cad2749..f66eb4bd 100644 --- a/wqflask/wqflask/templates/correlation_page.html +++ b/wqflask/wqflask/templates/correlation_page.html @@ -17,9 +17,9 @@
-

Values of record {{ this_trait.name }} in the {{ dataset.fullname }} +

Values of record {{ this_trait.name }} in the {{ this_dataset.fullname }} dataset were compared to all records in the {{ target_dataset.fullname }} - dataset. The top {{ return_number }} correlations ranked by the {{ formatted_corr_type }} are displayed. + dataset. The top {{ return_results }} correlations ranked by the {{ formatted_corr_type }} are displayed. You can resort this list by clicking the headers. Select the Record ID to open the trait data and analysis page.

@@ -30,7 +30,7 @@ {% include 'tool_buttons.html' %} @@ -43,7 +43,7 @@ - + @@ -146,7 +146,7 @@ +{% endblock %} diff --git a/wqflask/wqflask/templates/edit_trait.html b/wqflask/wqflask/templates/edit_trait.html deleted file mode 100644 index 7d4c65f8..00000000 --- a/wqflask/wqflask/templates/edit_trait.html +++ /dev/null @@ -1,234 +0,0 @@ -{% extends "base.html" %} -{% block title %}Trait Submission{% endblock %} -{% block content %} - -Edit Trait for Published Database -Submit Trait | Reset - -{% if diff %} - -
-
- -

Update History

-
- - - - - - - - - {% set ns = namespace(display_cell=True) %} - - {% for timestamp, group in diff %} - {% set ns.display_cell = True %} - {% for i in group %} - - {% if ns.display_cell and i.timestamp == timestamp %} - - {% set author = i.author %} - {% set timestamp_ = i.timestamp %} - - {% else %} - - {% set author = "" %} - {% set timestamp_ = "" %} - - {% endif %} - - - - - {% set ns.display_cell = False %} - - {% endfor %} - {% endfor %} - -
TimestampEditorFieldDiff
{{ timestamp_ }}{{ author }}{{ i.diff.field }}
{{ i.diff.diff }}
-
- -
- -{% endif %} - -
-

Trait Information:

-
- - -
- - -
-
-
- -
- - -
- -
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- -
- - -
-
-
- - - - - - -
-
- -{%endblock%} - -{% block js %} - -{% endblock %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index da427bfe..595a0de7 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -428,9 +428,9 @@ def submit_trait_form(): version=GN_VERSION) -@app.route("/trait//edit/") +@app.route("/trait//edit/inbredset-id/") @admin_login_required -def edit_trait(name, inbred_set_id): +def edit_phenotype(name, inbred_set_id): conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"), user=current_app.config.get("DB_USER"), passwd=current_app.config.get("DB_PASS"), @@ -476,7 +476,7 @@ def edit_trait(name, inbred_set_id): if len(diff_data) > 0: diff_data_ = groupby(diff_data, lambda x: x.timestamp) return render_template( - "edit_trait.html", + "edit_phenotype.html", diff=diff_data_, publish_xref=publish_xref, phenotype=phenotype_, @@ -486,7 +486,7 @@ def edit_trait(name, inbred_set_id): @app.route("/trait/update", methods=["POST"]) -def update_trait(): +def update_phenotype(): conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"), user=current_app.config.get("DB_USER"), passwd=current_app.config.get("DB_PASS"), @@ -544,7 +544,8 @@ def update_trait(): data=MetadataAudit(dataset_id=data_.get("dataset-name"), editor=author.decode("utf-8"), json_data=json.dumps(diff_data))) - return redirect("/trait/10007/edit/1") + return redirect(f"/trait/{data_.get('dataset-name')}" + f"/edit/inbredset-id/{data_.get('inbred-set-id')}") @app.route("/create_temp_trait", methods=('POST',)) -- cgit v1.2.3 From ffa34cc70ad70ab39682e8bdda6b6eb0d46a577d Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 9 Jul 2021 13:42:22 +0300 Subject: wqflask: views: Add extra route showing probeset editing form * wqflask/wqflask/views.py (edit_probeset): New function/ route. --- wqflask/wqflask/views.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 595a0de7..e1f6dd71 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -34,8 +34,10 @@ from gn3.db import insert from gn3.db import update from gn3.db.metadata_audit import MetadataAudit from gn3.db.phenotypes import Phenotype +from gn3.db.phenotypes import Probeset from gn3.db.phenotypes import Publication from gn3.db.phenotypes import PublishXRef +from gn3.db.phenotypes import probeset_mapping from flask import current_app @@ -485,6 +487,23 @@ def edit_phenotype(name, inbred_set_id): ) +@app.route("/trait/edit/probeset-name/") +@admin_login_required +def edit_probeset(dataset_name): + conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"), + user=current_app.config.get("DB_USER"), + passwd=current_app.config.get("DB_PASS"), + host=current_app.config.get("DB_HOST")) + probeset_ = fetchone(conn=conn, + table="ProbeSet", + columns=list(probeset_mapping.values()), + where=Probeset(name=dataset_name)) + return render_template( + "edit_probeset.html", + probeset=probeset_ + ) + + @app.route("/trait/update", methods=["POST"]) def update_phenotype(): conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"), -- cgit v1.2.3 From 503ff72502d7bc440450c1c91ac2d5051ca446b9 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 9 Jul 2021 15:23:10 +0300 Subject: templates: edit_probeset: Add template for editing probeset data * wqflask/wqflask/templates/edit_probeset.html: New file(template). --- wqflask/wqflask/templates/edit_probeset.html | 239 +++++++++++++++++++++++++++ wqflask/wqflask/views.py | 31 +++- 2 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 wqflask/wqflask/templates/edit_probeset.html (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/edit_probeset.html b/wqflask/wqflask/templates/edit_probeset.html new file mode 100644 index 00000000..85d49561 --- /dev/null +++ b/wqflask/wqflask/templates/edit_probeset.html @@ -0,0 +1,239 @@ +{% extends "base.html" %} +{% block title %}Trait Submission{% endblock %} +{% block content %} + +Edit Trait for Probeset +Submit Trait | Reset + +{% if diff %} + +
+
+ +

Update History

+
+ + + + + + + + + {% set ns = namespace(display_cell=True) %} + + {% for timestamp, group in diff %} + {% set ns.display_cell = True %} + {% for i in group %} + + {% if ns.display_cell and i.timestamp == timestamp %} + + {% set author = i.author %} + {% set timestamp_ = i.timestamp %} + + {% else %} + + {% set author = "" %} + {% set timestamp_ = "" %} + + {% endif %} + + + + + {% set ns.display_cell = False %} + + {% endfor %} + {% endfor %} + +
TimestampEditorFieldDiff
{{ timestamp_ }}{{ author }}{{ i.diff.field }}
{{ i.diff.diff }}
+
+ +
+ +{% endif %} + +
+

Probeset Information:

+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ + + + + +
+
+ +{%endblock%} + +{% block js %} + +{% endblock %} diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index e1f6dd71..741861e6 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -498,13 +498,40 @@ def edit_probeset(dataset_name): table="ProbeSet", columns=list(probeset_mapping.values()), where=Probeset(name=dataset_name)) + json_data = fetchall( + conn, + "metadata_audit", + where=MetadataAudit(dataset_id=probeset_.id_)) + Edit = namedtuple("Edit", ["field", "old", "new", "diff"]) + Diff = namedtuple("Diff", ["author", "diff", "timestamp"]) + diff_data = [] + for data in json_data: + json_ = json.loads(data.json_data) + timestamp = json_.get("timestamp") + author = json_.get("author") + for key, value in json_.items(): + if isinstance(value, dict): + for field, data_ in value.items(): + diff_data.append( + Diff(author=author, + diff=Edit(field, + data_.get("old"), + data_.get("new"), + "\n".join(difflib.ndiff( + [data_.get("old")], + [data_.get("new")]))), + timestamp=timestamp)) + diff_data_ = None + if len(diff_data) > 0: + diff_data_ = groupby(diff_data, lambda x: x.timestamp) return render_template( "edit_probeset.html", - probeset=probeset_ - ) + diff=diff_data_, + probeset=probeset_) @app.route("/trait/update", methods=["POST"]) +@admin_login_required def update_phenotype(): conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"), user=current_app.config.get("DB_USER"), -- cgit v1.2.3 From 76b4cb3cfa945c0016fa083bb672e42816707572 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 9 Jul 2021 15:27:24 +0300 Subject: wqflask: views: Add route for updating the probeset --- wqflask/wqflask/views.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index 741861e6..731ca291 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -488,7 +488,7 @@ def edit_phenotype(name, inbred_set_id): @app.route("/trait/edit/probeset-name/") -@admin_login_required +# @admin_login_required def edit_probeset(dataset_name): conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"), user=current_app.config.get("DB_USER"), @@ -594,6 +594,63 @@ def update_phenotype(): f"/edit/inbredset-id/{data_.get('inbred-set-id')}") +@app.route("/probeset/update", methods=["POST"]) +@admin_login_required +def update_probeset(): + conn = MySQLdb.Connect(db=current_app.config.get("DB_NAME"), + user=current_app.config.get("DB_USER"), + passwd=current_app.config.get("DB_PASS"), + host=current_app.config.get("DB_HOST")) + data_ = request.form.to_dict() + probeset_ = { + "id_": data_.get("id"), + "symbol": data_.get("symbol"), + "description": data_.get("description"), + "probe_target_description": data_.get("probe_target_description"), + "chr_": data_.get("chr"), + "mb": data_.get("mb"), + "alias": data_.get("alias"), + "geneid": data_.get("geneid"), + "homologeneid": data_.get("homologeneid"), + "unigeneid": data_.get("unigeneid"), + "omim": data_.get("OMIM"), + "refseq_transcriptid": data_.get("refseq_transcriptid"), + "blatseq": data_.get("blatseq"), + "targetseq": data_.get("targetseq"), + "strand_probe": data_.get("Strand_Probe"), + "probe_set_target_region": data_.get("probe_set_target_region"), + "probe_set_specificity": data_.get("probe_set_specificity"), + "probe_set_blat_score": data_.get("probe_set_blat_score"), + "probe_set_blat_mb_start": data_.get("probe_set_blat_mb_start"), + "probe_set_blat_mb_end": data_.get("probe_set_blat_mb_end"), + "probe_set_strand": data_.get("probe_set_strand"), + "probe_set_note_by_rw": data_.get("probe_set_note_by_rw"), + "flag": data_.get("flag") + } + updated_probeset = update( + conn, "ProbeSet", + data=Probeset(**probeset_), + where=Probeset(id_=data_.get("id"))) + + diff_data = {} + author = g.user_session.record.get(b'user_name') + if updated_probeset: + diff_data.update({"Probeset": diff_from_dict(old={ + k: data_.get(f"old_{k}") for k, v in probeset_.items() + if v is not None}, new=probeset_)}) + if diff_data: + diff_data.update({"probeset_name": data_.get("probeset_name")}) + diff_data.update({"author": author.decode('utf-8')}) + diff_data.update({"timestamp": datetime.datetime.now().strftime( + "%Y-%m-%d %H:%M:%S")}) + insert(conn, + table="metadata_audit", + data=MetadataAudit(dataset_id=data_.get("id"), + editor=author.decode("utf-8"), + json_data=json.dumps(diff_data))) + return redirect(f"/trait/edit/probeset-name/{data_.get('probeset_name')}") + + @app.route("/create_temp_trait", methods=('POST',)) def create_temp_trait(): logger.info(request.url) -- cgit v1.2.3 From d01b1aadcd3604e4f592f64ce7d9eb010d4c7230 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Sat, 10 Jul 2021 09:55:12 +0300 Subject: templates: show_trait_details: Show edit buttons conditionally * wqflask/wqflask/templates/show_trait_details.html: Check the data type, and load different edit buttons. --- wqflask/wqflask/templates/show_trait_details.html | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'wqflask') diff --git a/wqflask/wqflask/templates/show_trait_details.html b/wqflask/wqflask/templates/show_trait_details.html index 83f7b0ac..bb30c54c 100644 --- a/wqflask/wqflask/templates/show_trait_details.html +++ b/wqflask/wqflask/templates/show_trait_details.html @@ -235,8 +235,14 @@ {% endif %} {% if admin_status == "owner" or admin_status == "edit-admins" or admin_status == "edit-access" %} + {% if this_trait.dataset.type == 'Publish' %} {% endif %} + + {% if this_trait.dataset.type == 'ProbeSet' %} + + {% endif %} + {% endif %}
-- cgit v1.2.3 From 344d6a86d2e468249ec7b583e8c0751f99cd6a5b Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 12 Jul 2021 11:40:40 +0300 Subject: tests: test_markdown_routes: Remove stubbed out tests --- wqflask/tests/integration/test_markdown_routes.py | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 wqflask/tests/integration/test_markdown_routes.py (limited to 'wqflask') diff --git a/wqflask/tests/integration/test_markdown_routes.py b/wqflask/tests/integration/test_markdown_routes.py deleted file mode 100644 index 5e3e5045..00000000 --- a/wqflask/tests/integration/test_markdown_routes.py +++ /dev/null @@ -1,21 +0,0 @@ -"Integration tests for markdown routes" -import unittest - -from bs4 import BeautifulSoup - -from wqflask import app - - -class TestGenMenu(unittest.TestCase): - """Tests for glossary""" - - def setUp(self): - self.app = app.test_client() - - def tearDown(self): - pass - - def test_glossary_page(self): - """Test that the glossary page is rendered properly""" - response = self.app.get('/glossary', follow_redirects=True) - pass -- cgit v1.2.3