Skip to content

Commit

Permalink
update indel primer reports
Browse files Browse the repository at this point in the history
  • Loading branch information
samwachspress committed Apr 29, 2021
1 parent 097cce5 commit c32a619
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 63 deletions.
19 changes: 0 additions & 19 deletions base/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion base/templates/tools/h2_result_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="row">
<div class="col-md-12">

<table class='h2-calc-result-table table-striped table-hover table-compact'>
<table class='strain-table table-striped table-hover table-compact' style='width:100%'>

<thead>
<tr class="header">
Expand Down
12 changes: 11 additions & 1 deletion base/templates/tools/indel_primer.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
</p>
</div>
<div class='row'>
<div class='col-md-10'></div>
<div class='col-md-2'>
<a role="button" class="btn btn-primary btn-block" href='{{ url_for("indel_primer.indel_primer_result_list") }}' >
<span class="glyphicon glyphicon-list" aria-hidden="true"></span>
My Primers

</a>
</div>
</div>
<div class='row'>
<form id='form-submit' method="POST">
{{ form.csrf_token }}
Expand Down Expand Up @@ -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")
}
})
});
Expand Down
2 changes: 1 addition & 1 deletion base/templates/tools/indel_primer_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h4>No Results</h4>
<div class="row">
<div class='pull-left col-md-4'>
<a role="button" id="pdd" class="btn btn-default" onClick='getPDF("containerfluid")'>PDF</a>
<a role="button" class="btn btn-default" href="{{ url_for('indel_primer.pairwise_indel_query_results', data_hash=data_hash, filename=data['site'] + '.tsv') }}" class="col-sm-4" >TSV</a>
<a role="button" class="btn btn-default" href="{{ url_for('indel_primer.pairwise_indel_query_results', id=id, filename=data['site'] + '.tsv') }}" class="col-sm-4" >TSV</a>
</div>
</div>{# /row #}

Expand Down
52 changes: 52 additions & 0 deletions base/templates/tools/ip_result_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% extends "_layouts/default.html" %}

{% block content %}

<div class="row">
<div class="col-md-12">

<table class='strain-table table-striped table-hover table-compact' style='width:100%;table-layout:fixed;'>

<thead>
<tr class="header">
<th><strong> Site </strong></th>
<th></th>
<th><strong> Strain 1 </strong></th>
<th><strong> Strain 2 </strong></th>
<th><strong> Empty </strong></th>
<th><strong> Status </strong></th>
<th><strong> Date </strong></th>
<th></th>
</tr>
</thead>

<tbody>
{% for item in items %}
<tr>
{% if item %}
<td colspan="2"> {{ item.site }} </td>
<td> {{ item.strain1 }} </td>
<td> {{ item.strain2 }} </td>
<td> {{ item.empty }} </td>
<td>
{% if item.status == 'COMPLETE' %}
<a href="{{ url_for('indel_primer.pairwise_indel_query_results', id=item.key.name) }}">
{{ item.status }}
</a>
{% else %}
{{ item.status }}
{% endif %}
</td>
{% endif %}
<td colspan="2"> {{ item.created_on|date_format }} </td>
</tr>
{% endfor %}
</tbody>

</table>

</div> <!-- /col-md-12 -->
</div> <!-- /row -->


{% endblock %}
82 changes: 51 additions & 31 deletions base/templates/user/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,59 @@
{% block content %}

<div class="row">
<div class='col-md-3'>
</div> <!-- /col-md-3 -->
<div class='col-md-6'>
<table class='table table-striped table-condensed'>
<tr><td>Username</td><td>{{ user.username }}</td></tr>
<tr><td>Full Name</td><td>{{ user.full_name }}</td></tr>
<tr><td>Email</td><td>{{ user.email }}</td></tr>
<tr><td>Verified</td><td>{{ user.verified_email }}</td></tr>
<tr><td>Password</td><td>************</td></tr>
<tr><td>Roles</td><td>{{ user.roles }}</td></tr>
<tr><td>Registered</td><td>{{ user.created_on }}</td></tr>
<tr><td>Last Modified</td><td>{{ user.modified_on }}</td></tr>
<tr><td>Last Login</td><td>{{ user.last_login }}</td></tr>
</table>
</div> <!-- /col-md-6 -->
</div> <!-- /row -->
<div class='col-md-2'></div>
<div class='col-md-8' align="center">




<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="main active" ><a href="#main" role="tab" data-toggle="tab">Profile</a></li>
<li role="presentation" class="h2results" ><a href="{{ url_for('heritability.heritability_result_list') }}" role="tab">Heritability Results</a></li>
<li role="presentation" class="ip-results" ><a href="{{ url_for('indel_primer.indel_primer_result_list') }}" role="tab">Indel Primer Results</a></li>
</ul>

<!-- Tab panes -->
<div class="tab-content">

<div role="tabpanel" class="tab-pane active" id="main">
<table class='table table-striped table-condensed'>
<tr><td>Username</td><td>{{ user.username }}</td></tr>
<tr><td>Full Name</td><td>{{ user.full_name }}</td></tr>
<tr><td>Email</td><td>{{ user.email }}</td></tr>
<tr><td>Verified</td><td>{{ user.verified_email }}</td></tr>
<tr><td>Password</td><td>************</td></tr>
<tr><td>Roles</td><td>{{ user.roles }}</td></tr>
<tr><td>Registered</td><td>{{ user.created_on }}</td></tr>
<tr><td>Last Modified</td><td>{{ user.modified_on }}</td></tr>
<tr><td>Last Login</td><td>{{ user.last_login }}</td></tr>
</table>

<div class="row">
<div class='col-md-3'></div> {# /col-md-3 >#}
<div class='col-md-6' align="center">
<button id='edit-btn' type='submit' class="btn btn-primary btn-block"
onClick='window.location.href="{{ url_for( 'user.user_update') }}";'
{% if user['user_type'] != 'LOCAL' %}
disabled>
{% else %}
>
{% endif %}
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
Edit
</button>
</div> <!-- /col-md-6 -->
</div> <!-- /row -->

</div>

</div>{# Tab Set #}


<div class="row">
<div class='col-md-3'>
</div> <!-- /col-md-3 -->
<div class='col-md-6' align="center">
<button id='edit-btn' type='submit' class="btn btn-primary btn-block"
onClick="window.location.href='{{ url_for( 'user.user_update') }}';"
{% if user['user_type'] != 'LOCAL' %}
disabled>
{% else %}
>
{% endif %}
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
Edit
</button>
</div> <!-- /col-md-6 -->
</div> <!-- /row -->




{% endblock %}
54 changes: 44 additions & 10 deletions base/views/tools/indel_primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pandas as pd
from cyvcf2 import VCF
from flask import (Blueprint,
flash,
jsonify,
render_template,
request,
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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/<data_hash>")
@indel_primer_bp.route("/indel_primer/result/<data_hash>/tsv/<filename>")
@indel_primer_bp.route("/indel_primer/result/<id>")
@indel_primer_bp.route("/indel_primer/result/<id>/tsv/<filename>")
@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")
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions cloud_functions/indel_primer_run/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit c32a619

Please sign in to comment.