From 0299241b0e6cd00fac38fdd0b0bb59f0386cfc44 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Thu, 13 May 2021 18:51:08 -0700 Subject: [PATCH 1/3] Allow obtaining a per sample summary --- microsetta_admin/server.py | 42 +++++++++++++ .../templates/per_sample_summary.html | 62 +++++++++++++++++++ microsetta_admin/templates/sitebase.html | 1 + 3 files changed, 105 insertions(+) create mode 100644 microsetta_admin/templates/per_sample_summary.html diff --git a/microsetta_admin/server.py b/microsetta_admin/server.py index 0f0afb1..f35bf04 100644 --- a/microsetta_admin/server.py +++ b/microsetta_admin/server.py @@ -326,6 +326,48 @@ def urlify_account_id(id_): projects=projects) +@app.route('/per_sample_summary', methods=['GET', 'POST']) +def per_sample_summary(): + if request.method == 'GET': + sample_barcode = request.args.get('sample_barcode') + if sample_barcode is None: + return render_template('per_sample_summary.html', + resource=None, + **build_login_variables()) + sample_barcodes = [sample_barcode, ] + elif request.method == 'POST': + sample_barcodes, upload_err = upload_util.parse_request_csv_col( + request, + 'file', + 'sample_name' + ) + if upload_err is not None: + return render_template('per_sample_summary.html', + resource=None, + **build_login_variables(), + search_error=[{'error': upload_err}]) + + payload = {'sample_barcodes': sample_barcodes} + status, result = APIRequest.post('/api/admin/account_barcode_summary', + json=payload) + if status != 200: + return render_template('per_sample_summary.html', + resource=None, + error_message=result, + **build_login_variables()) + else: + resource = pd.DataFrame(result) + order = ['sampleid', 'project', 'account-email', 'source-email', + 'source-type', 'site-sampled', 'sample-status', + 'sample-received', 'ffq-taken', 'ffq-complete', + 'vioscreen_username'] + order.extend(sorted(set(resource.columns) - set(order))) + resource = resource[order] + return render_template('per_sample_summary.html', + resource=resource, + **build_login_variables()) + + @app.route('/create_kits', methods=['GET', 'POST']) def new_kits(): _, result = _get_projects(include_stats=False, is_active=True) diff --git a/microsetta_admin/templates/per_sample_summary.html b/microsetta_admin/templates/per_sample_summary.html new file mode 100644 index 0000000..1422d99 --- /dev/null +++ b/microsetta_admin/templates/per_sample_summary.html @@ -0,0 +1,62 @@ +{% extends "sitebase.html" %} +{% block head %} + + + + + +{% endblock %} +{% block content %} +

Microsetta Per Sample Summary

+
+ {% if error_message %} +

+ {{ error_message |e }} +

+ {% endif %} +
+ + + + + + + +
+ +
+
+ Or upload a file ofbarcodes listed in the column "sample_name" (max: 100) +
+
+
+ +
+ {% if resource is not none %} +
+ {{resource.to_html(table_id="search_results", classes=["display"], render_links=True, escape=False) |safe}} +
+
+{% endif %} +{{blob}} +{% endblock %} diff --git a/microsetta_admin/templates/sitebase.html b/microsetta_admin/templates/sitebase.html index 38d4344..56309f7 100644 --- a/microsetta_admin/templates/sitebase.html +++ b/microsetta_admin/templates/sitebase.html @@ -49,6 +49,7 @@

Microsetta Utilities

  • Create Kit
  • Scan Barcode
  • Retrieve Metadata
  • +
  • Per sample summary
  • Submit Daklapack Order
  • Log Out
    ({{email |e}})
  • {% else %} From 2de08c7400c2512b443a32faa30f665ce339f1d4 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Fri, 14 May 2021 15:58:26 -0700 Subject: [PATCH 2/3] change max --- microsetta_admin/templates/per_sample_summary.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsetta_admin/templates/per_sample_summary.html b/microsetta_admin/templates/per_sample_summary.html index 1422d99..5cb7882 100644 --- a/microsetta_admin/templates/per_sample_summary.html +++ b/microsetta_admin/templates/per_sample_summary.html @@ -46,7 +46,7 @@

    Microsetta Per Sample Summary


    - Or upload a file ofbarcodes listed in the column "sample_name" (max: 100) + Or upload a file ofbarcodes listed in the column "sample_name" (max: 1000)

    From 1a09bcff4011180e076ea6274fa85d74d597aa85 Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Mon, 17 May 2021 10:55:50 -0700 Subject: [PATCH 3/3] strip sample IDs --- microsetta_admin/server.py | 6 +++++- microsetta_admin/templates/per_sample_summary.html | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/microsetta_admin/server.py b/microsetta_admin/server.py index f35bf04..a689bba 100644 --- a/microsetta_admin/server.py +++ b/microsetta_admin/server.py @@ -328,6 +328,9 @@ def urlify_account_id(id_): @app.route('/per_sample_summary', methods=['GET', 'POST']) def per_sample_summary(): + strip_sampleid = request.form.get('strip_sampleid', 'off') + strip_sampleid = strip_sampleid.lower() == 'on' + if request.method == 'GET': sample_barcode = request.args.get('sample_barcode') if sample_barcode is None: @@ -348,7 +351,8 @@ def per_sample_summary(): search_error=[{'error': upload_err}]) payload = {'sample_barcodes': sample_barcodes} - status, result = APIRequest.post('/api/admin/account_barcode_summary', + status, result = APIRequest.post('/api/admin/account_barcode_summary?' + 'strip_sampleid=%s' % str(strip_sampleid), json=payload) if status != 200: return render_template('per_sample_summary.html', diff --git a/microsetta_admin/templates/per_sample_summary.html b/microsetta_admin/templates/per_sample_summary.html index 5cb7882..a755e3a 100644 --- a/microsetta_admin/templates/per_sample_summary.html +++ b/microsetta_admin/templates/per_sample_summary.html @@ -46,9 +46,11 @@

    Microsetta Per Sample Summary


    - Or upload a file ofbarcodes listed in the column "sample_name" (max: 1000) + Or upload a file of barcodes listed in the column "sample_name" (max: 1000)
    + +