From cca68f27b363009493c498bfcc773490a3f8b176 Mon Sep 17 00:00:00 2001 From: Sam Wachspress Date: Wed, 28 Apr 2021 03:38:57 -0500 Subject: [PATCH 1/4] do not save output of vk primer --- cloud_functions/indel_primer_run/invoke.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloud_functions/indel_primer_run/invoke.go b/cloud_functions/indel_primer_run/invoke.go index 131c8422..ed297589 100644 --- a/cloud_functions/indel_primer_run/invoke.go +++ b/cloud_functions/indel_primer_run/invoke.go @@ -184,7 +184,7 @@ func runIndelPrimer(p Payload, i dsInfo) ([]byte, error) { resultBlob := fmt.Sprintf("reports/indel_primer/%s/%s", dataHash, resultName) copyBlob(bucketName, resultName, resultBlob, i) - return string(out), err + return out, err } @@ -234,7 +234,9 @@ func ipHandler(w http.ResponseWriter, r *http.Request) { setDatastoreStatus(p.Ds_kind, p.Ds_id, "RUNNING", "") result, err2 := runIndelPrimer(p, i) check(err2, i) - setDatastoreStatus(p.Ds_kind, p.Ds_id, "COMPLETE", string(result)) + log.Printf("result: %+v", result) + + setDatastoreStatus(p.Ds_kind, p.Ds_id, "COMPLETE", "") if err5 := json.NewEncoder(w).Encode("submitted indel-primer-2"); err5 != nil { log.Printf("Error sending response: %v", err5) From 054fac42351bbc7defb72bd2d02ed221be7f2aaa Mon Sep 17 00:00:00 2001 From: Sam Wachspress Date: Wed, 28 Apr 2021 17:31:53 -0500 Subject: [PATCH 2/4] do not save output of vk primer --- cloud_functions/indel_primer_run/invoke.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloud_functions/indel_primer_run/invoke.go b/cloud_functions/indel_primer_run/invoke.go index 131c8422..ed297589 100644 --- a/cloud_functions/indel_primer_run/invoke.go +++ b/cloud_functions/indel_primer_run/invoke.go @@ -184,7 +184,7 @@ func runIndelPrimer(p Payload, i dsInfo) ([]byte, error) { resultBlob := fmt.Sprintf("reports/indel_primer/%s/%s", dataHash, resultName) copyBlob(bucketName, resultName, resultBlob, i) - return string(out), err + return out, err } @@ -234,7 +234,9 @@ func ipHandler(w http.ResponseWriter, r *http.Request) { setDatastoreStatus(p.Ds_kind, p.Ds_id, "RUNNING", "") result, err2 := runIndelPrimer(p, i) check(err2, i) - setDatastoreStatus(p.Ds_kind, p.Ds_id, "COMPLETE", string(result)) + log.Printf("result: %+v", result) + + setDatastoreStatus(p.Ds_kind, p.Ds_id, "COMPLETE", "") if err5 := json.NewEncoder(w).Encode("submitted indel-primer-2"); err5 != nil { log.Printf("Error sending response: %v", err5) From c32a619b5ebc1d67113365899539b108042ede36 Mon Sep 17 00:00:00 2001 From: Sam Wachspress Date: Wed, 28 Apr 2021 20:21:47 -0500 Subject: [PATCH 3/4] update indel primer reports --- base/static/css/styles.css | 19 ----- base/templates/tools/h2_result_list.html | 2 +- base/templates/tools/indel_primer.html | 12 ++- .../templates/tools/indel_primer_results.html | 2 +- base/templates/tools/ip_result_list.html | 52 ++++++++++++ base/templates/user/profile.html | 82 ++++++++++++------- base/views/tools/indel_primer.py | 54 +++++++++--- cloud_functions/indel_primer_run/invoke.go | 4 + 8 files changed, 164 insertions(+), 63 deletions(-) create mode 100644 base/templates/tools/ip_result_list.html diff --git a/base/static/css/styles.css b/base/static/css/styles.css index 86d1d5e8..2466808c 100644 --- a/base/static/css/styles.css +++ b/base/static/css/styles.css @@ -628,23 +628,4 @@ article { padding:40px 0px; } -table.h2-calc-result-table { - width: 100%; -} - -table.h2-calc-result-table th { - padding-left: 15px; - padding-top: 5px; - padding-bottom: 5px; - padding-right: 0px; - text-align: left; - font-size: 20px; -} -table.h2-calc-result-table td { - padding-left: 15px; - padding-top: 5px; - padding-bottom: 5px; - padding-right: 0px; - text-align: left; -} diff --git a/base/templates/tools/h2_result_list.html b/base/templates/tools/h2_result_list.html index 725311e5..31a72f07 100644 --- a/base/templates/tools/h2_result_list.html +++ b/base/templates/tools/h2_result_list.html @@ -5,7 +5,7 @@
- +
diff --git a/base/templates/tools/indel_primer.html b/base/templates/tools/indel_primer.html index 5942504f..22c12e99 100644 --- a/base/templates/tools/indel_primer.html +++ b/base/templates/tools/indel_primer.html @@ -31,6 +31,16 @@ These regions should be avoided because indel calls are less reliable and high levels of variation will make primer searches more error-prone.

+
{{ form.csrf_token }} @@ -225,7 +235,7 @@ contentType: "application/json; charset=utf-8", dataType: 'json', success:function(result){ - window.open(`indel_primer/result/${result.data_hash}`, "_blank") + window.open(`indel_primer/result/${result.id}`, "_blank") } }) }); diff --git a/base/templates/tools/indel_primer_results.html b/base/templates/tools/indel_primer_results.html index 7d62afa5..5c855732 100644 --- a/base/templates/tools/indel_primer_results.html +++ b/base/templates/tools/indel_primer_results.html @@ -81,7 +81,7 @@

No Results

PDF - TSV + TSV
{# /row #} diff --git a/base/templates/tools/ip_result_list.html b/base/templates/tools/ip_result_list.html new file mode 100644 index 00000000..0f95562b --- /dev/null +++ b/base/templates/tools/ip_result_list.html @@ -0,0 +1,52 @@ +{% extends "_layouts/default.html" %} + +{% block content %} + +
+
+ +
+ + + + + + + + + + + + + + + + {% for item in items %} + + {% if item %} + + + + + + {% endif %} + + + {% endfor %} + + +
Site Strain 1 Strain 2 Empty Status Date
{{ item.site }} {{ item.strain1 }} {{ item.strain2 }} {{ item.empty }} + {% if item.status == 'COMPLETE' %} + + {{ item.status }} + + {% else %} + {{ item.status }} + {% endif %} + {{ item.created_on|date_format }}
+ +
+
+ + +{% endblock %} diff --git a/base/templates/user/profile.html b/base/templates/user/profile.html index e661916a..4a3eaf53 100644 --- a/base/templates/user/profile.html +++ b/base/templates/user/profile.html @@ -4,39 +4,59 @@ {% block content %}
-
-
-
- - - - - - - - - - -
Username{{ user.username }}
Full Name{{ user.full_name }}
Email{{ user.email }}
Verified{{ user.verified_email }}
Password************
Roles{{ user.roles }}
Registered{{ user.created_on }}
Last Modified{{ user.modified_on }}
Last Login{{ user.last_login }}
-
-
+
+
+ + + + + + + + +
+ +
+ + + + + + + + + + +
Username{{ user.username }}
Full Name{{ user.full_name }}
Email{{ user.email }}
Verified{{ user.verified_email }}
Password************
Roles{{ user.roles }}
Registered{{ user.created_on }}
Last Modified{{ user.modified_on }}
Last Login{{ user.last_login }}
+ +
+
{# /col-md-3 >#} +
+ +
+
+ +
+ +
{# Tab Set #} + -
-
-
-
- -
+ + {% endblock %} diff --git a/base/views/tools/indel_primer.py b/base/views/tools/indel_primer.py index 6a1761fc..3266cc16 100644 --- a/base/views/tools/indel_primer.py +++ b/base/views/tools/indel_primer.py @@ -8,6 +8,7 @@ import pandas as pd from cyvcf2 import VCF from flask import (Blueprint, + flash, jsonify, render_template, request, @@ -103,6 +104,17 @@ class pairwise_indel_form(Form): stop = FlexIntegerField('Stop', default="2,039,217", validators=[Required()]) + +@indel_primer_bp.route("/pairwise_indel_finder/ip/all") +@jwt_required() +def indel_primer_result_list(): + title = "Indel Primer Results" + user = get_current_user() + items = ip_calc_ds().query_by_username(user.name) + items = sorted(items, key=lambda x: x['created_on'], reverse=True) + return render_template('tools/ip_result_list.html', **locals()) + + @indel_primer_bp.route('/pairwise_indel_finder', methods=['GET']) @jwt_required() def indel_primer(): @@ -159,15 +171,15 @@ def pairwise_indel_finder_query(): return jsonify(results=[]) return jsonify({"errors": form.errors}) -def create_ip_task(data_hash, site, strain1, strain2, vcf_url, username): +def create_ip_task(id, data_hash, site, strain1, strain2, vcf_url): """ This is designed to be run in the background on the server. It will run a heritability analysis on google cloud run """ - id = unique_id() ip = ip_calc_ds(id) - ip.data_hash = data_hash - ip.username = username + ip.site = site + ip.strain1 = strain1 + ip.strain2 = strain2 ip.save() # Perform ip request @@ -197,32 +209,51 @@ def submit_indel_primer(): """ data = request.get_json() user = get_current_user() + id = unique_id() + ip = ip_calc_ds(id) + ip.username = user.name # Generate an ID for the data based on its hash data_hash = hash_it(data, length=32) data['date'] = str(arrow.utcnow()) + ip.data_hash = data_hash + ip.site = data.get('site') + ip.strain1 = data.get('strain_1') + ip.strain2 = data.get('strain_2') + ip.save() # Check whether analysis has previously been run and if so - skip result = check_blob(f"reports/indel_primer/{data_hash}/results.tsv") if result: return jsonify({'thread_name': 'done', 'started': True, - 'data_hash': data_hash}) + 'data_hash': data_hash, + 'id': id}) logger.debug("Submitting Indel Primer Job") # Upload query information data_blob = f"reports/indel_primer/{data_hash}/input.json" upload_file(data_blob, json.dumps(data), as_string=True) - create_ip_task(data_hash=data_hash, site=data.get('site'), strain1=data.get('strain_1'), strain2=data.get('strain_2'), vcf_url=SV_VCF_URL, username=user.name) + create_ip_task(id=id, data_hash=data_hash, site=data.get('site'), strain1=data.get('strain_1'), strain2=data.get('strain_2'), vcf_url=SV_VCF_URL) return jsonify({ 'started': True, - 'data_hash': data_hash }) + 'data_hash': data_hash, + 'id': id }) -@indel_primer_bp.route("/indel_primer/result/") -@indel_primer_bp.route("/indel_primer/result//tsv/") +@indel_primer_bp.route("/indel_primer/result/") +@indel_primer_bp.route("/indel_primer/result//tsv/") @jwt_required() -def pairwise_indel_query_results(data_hash, filename = None): +def pairwise_indel_query_results(id, filename = None): + user = get_current_user() + ip = ip_calc_ds(id) + + if (not ip._exists) or (ip.username != user.name): + flash('You do not have access to that report', 'danger') + abort(401) + + data_hash = ip.data_hash + title = "Indel Primer Results" data = check_blob(f"reports/indel_primer/{data_hash}/input.json") result = check_blob(f"reports/indel_primer/{data_hash}/results.tsv") @@ -248,6 +279,9 @@ def pairwise_indel_query_results(data_hash, filename = None): # Check for no results empty = True if len(result) == 0 else False ready = True + ip.status = 'COMPLETE' + ip.empty = empty + ip.save() if empty is False: # left primer result['left_primer_start'] = result.amplicon_region.apply(lambda x: x.split(":")[1].split("-")[0]).astype(int) diff --git a/cloud_functions/indel_primer_run/invoke.go b/cloud_functions/indel_primer_run/invoke.go index ed297589..39b2d498 100644 --- a/cloud_functions/indel_primer_run/invoke.go +++ b/cloud_functions/indel_primer_run/invoke.go @@ -45,6 +45,10 @@ type dsInfo struct { type dsEntry struct { Username string `datastore:"username"` Data_hash string `datastore:"data_hash"` + Site string `datastore:"site"` + Strain1 string `datastore:"strain1"` + Strain2 string `datastore:"strain2"` + Empty bool `datastore:"empty"` Status string `datastore:"status"` Status_msg string `datastore:"status_msg,noindex"` Modified_on time.Time `datastore:"modified_on"` From 67285b1a997f054601f1a84ee7d3d0a23b82ae8b Mon Sep 17 00:00:00 2001 From: Sam Wachspress Date: Wed, 28 Apr 2021 20:23:12 -0500 Subject: [PATCH 4/4] update text --- base/templates/tools/indel_primer.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/templates/tools/indel_primer.html b/base/templates/tools/indel_primer.html index 22c12e99..d7a31484 100644 --- a/base/templates/tools/indel_primer.html +++ b/base/templates/tools/indel_primer.html @@ -36,7 +36,7 @@