aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/oauth2/data.py46
-rw-r--r--wqflask/wqflask/templates/oauth2/data-list-genotype.html2
-rw-r--r--wqflask/wqflask/templates/oauth2/data-list-mrna.html166
3 files changed, 207 insertions, 7 deletions
diff --git a/wqflask/wqflask/oauth2/data.py b/wqflask/wqflask/oauth2/data.py
index 03fde15f..6804dafa 100644
--- a/wqflask/wqflask/oauth2/data.py
+++ b/wqflask/wqflask/oauth2/data.py
@@ -20,7 +20,20 @@ def __render_template__(templatepath, **kwargs):
templatepath, **kwargs, user_privileges=user_privileges)
def __search_mrna__(query, template, **kwargs):
- return __render_template__(template, **kwargs)
+ species_name = kwargs["species_name"]
+ search_uri = urljoin(app.config["GN_SERVER_URL"], "oauth2/data/search")
+ print(f"SEARCHING FOR mrna")
+ datasets = oauth2_get(
+ "oauth2/data/search",
+ json = {
+ "query": query,
+ "dataset_type": "mrna",
+ "species_name": species_name,
+ "selected": __selected_datasets__()
+ }).either(
+ lambda err: {"datasets_error": process_error(err)},
+ lambda datasets: {"datasets": datasets})
+ return __render_template__(template, search_uri=search_uri, **datasets, **kwargs)
def __selected_datasets__():
if bool(request.json):
@@ -70,12 +83,7 @@ def __search_phenotypes__(query, template, **kwargs):
def json_search_genotypes() -> Response:
def __handle_error__(err):
error = process_error(err)
- print(f"THE ERROR: {error}")
return jsonify(error), error["status_code"]
-
- print(f"===============================================")
- print(request.json)
- print(f"===============================================")
return oauth2_get(
"oauth2/data/search",
@@ -213,3 +221,29 @@ def link_genotype_data():
"selected": tuple(json.loads(dataset) for dataset
in form.getlist("selected"))
}).either(lambda err: __link_error__(process_error(err)), __link_success__)
+
+
+@data.route("/link/mrna", methods=["POST"])
+def link_mrna_data():
+ """Link mrna data to a group."""
+ form = request.form
+ link_source_url = redirect(url_for("oauth2.data.list_data"))
+ if bool(form.get("species_name")):
+ link_source_url = redirect(url_for(
+ "oauth2.data.list_data_by_species_and_dataset",
+ species_name=form["species_name"], dataset_type="mrna"))
+
+ def __link_error__(err):
+ flash(f"{err['error']}: {err['error_description']}", "alert-danger")
+ return link_source_url
+
+ def __link_success__(success):
+ flash(success["description"], "alert-success")
+ return link_source_url
+
+ return oauth2_post("oauth2/data/link/mrna", json={
+ "species_name": form.get("species_name"),
+ "group_id": form.get("group_id"),
+ "selected": tuple(json.loads(dataset) for dataset
+ in form.getlist("selected"))
+ }).either(lambda err: __link_error__(process_error(err)), __link_success__)
diff --git a/wqflask/wqflask/templates/oauth2/data-list-genotype.html b/wqflask/wqflask/templates/oauth2/data-list-genotype.html
index 47c21079..30ee0d27 100644
--- a/wqflask/wqflask/templates/oauth2/data-list-genotype.html
+++ b/wqflask/wqflask/templates/oauth2/data-list-genotype.html
@@ -25,7 +25,7 @@
<div class="row">
<form id="frm-link-genotypes" method="POST"
action="{{url_for('oauth2.data.link_genotype_data')}}">
- <legend>Link Genotype Traits to Group</legend>
+ <legend>Link Genotype Datasets to Group</legend>
<input type="hidden" name="species_name" value="{{species_name}}" />
diff --git a/wqflask/wqflask/templates/oauth2/data-list-mrna.html b/wqflask/wqflask/templates/oauth2/data-list-mrna.html
new file mode 100644
index 00000000..1c22f65c
--- /dev/null
+++ b/wqflask/wqflask/templates/oauth2/data-list-mrna.html
@@ -0,0 +1,166 @@
+{%extends "base.html"%}
+{%from "oauth2/profile_nav.html" import profile_nav%}
+{%from "oauth2/display_error.html" import display_error%}
+
+{%block title%}Link Data: Genotype{%endblock%}
+
+{%block css%}
+<link rel="stylesheet" type="text/css"
+ href="/css/DataTables/css/jquery.dataTables.css" />
+<link rel="stylesheet" type="text/css"
+ href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
+<link rel="stylesheet" type="text/css" href="/static/new/css/show_trait.css" />
+{%endblock%}
+
+{%block content%}
+<div class="container" style="width: 98%;">
+ {{profile_nav("data", user_privileges)}}
+
+ {{flash_me()}}
+
+ <div class="row">
+ <noscript>This page needs javascript to work correctly</noscript>
+ </div>
+
+ <div class="row">
+ <form id="frm-link-mrna" method="POST"
+ action="{{url_for('oauth2.data.link_mrna_data')}}">
+ <legend>Link mRNA Assay Datasets to Group</legend>
+
+ <input type="hidden" name="species_name" value="{{species_name}}" />
+
+ <div class="form-group">
+ <label for="select-group">Group</label>
+ <select id="select-group" name="group_id" required="required"
+ class="form-control">
+ <option value="">Select group</option>
+ {%for group in groups%}
+ <option value="{{group.group_id}}">{{group.group_name}}</option>
+ {%endfor%}
+ </select>
+ </div>
+
+ <div class="form-group">
+ <table id="tbl-link-mrna"
+ class="table-hover table-striped cell-border dataTable no-footer"
+ data-selected-datasets='{{selected_datasets | list | tojson}}'>
+ <thead>
+ <tr>
+ <th>Deselect</th>
+ <th>Group</th>
+ <th>Dataset Name</th>
+ <th>Dataset FullName</th>
+ <th>Dataset ShortName</th>
+ </tr>
+ </thead>
+ <tbody>
+ {%for dataset in selected_datasets%}
+ <tr>
+ <td>
+ <input type="checkbox" class="checkbox checkbox-selected"
+ name="selected"
+ value='{{dataset | tojson}}' />
+ </td>
+ <td>{{dataset.dataset_name}}</td>
+ <td>{{dataset.dataset_fullname}}</td>
+ <td>{{dataset.dataset_shortname}}</td>
+ </tr>
+ {%else%}
+ <tr>
+ <td colspan="100%" align="center">
+ <span class="glyphicon glyphicon-info-sign text-info"></span>
+ &nbsp
+ No datasets selected for linking.
+ </td>
+ </tr>
+ {%endfor%}
+ </tbody>
+ </table>
+ </div>
+
+ <div class="form-group text-center">
+ <input type="submit" value="Link Selected"
+ class="btn btn-primary"
+ style="border-top: 0.3em;"
+ {%if groups | length <= 0 or selected_datasets | length <= 0%}
+ disabled="disabled"
+ {%endif%} />
+ </div>
+ </form>
+ </div>
+
+ <div class="row">
+ <span id="search-messages" class="alert-danger" style="display:none"></span>
+ <form id="frm-search"
+ action="{{search_uri}}"
+ method="POST">
+ <legend>Search: mRNA Assay</legend>
+ <input type="hidden" value="{{species_name}}" name="species"
+ id="txt-species-name" />
+ <input type="hidden" value="{{dataset_type}}" name="dataset_type"
+ id="txt-dataset-type" />
+ <input type="hidden" value="{{per_page}}" name="per_page"
+ id="txt-per-page" />
+
+ <div class="form-group">
+ <label for="txt-query">Dataset Search String</label>
+ <input type="text" id="txt-query" name="query" class="form-control"
+ value="{{query}}"/>
+ </div>
+ </form>
+ </div>
+
+ <div class="row">
+ <div id="search-error" class="text-danger" style="display: none;">
+ <span class="glyphicon glyphicon-exclamation-sign"></span>
+ &nbsp
+ <span id="search-error-text"></span>
+ </div>
+ <table id="tbl-search"
+ class="table-hover table-striped cell-border dataTable no-footer"
+ data-datasets='{{datasets | list | tojson}}'>
+ <thead>
+ <tr>
+ <th>Select</th>
+ <th>Group</th>
+ <th>Study Name</th>
+ <th>Dataset Name</th>
+ <th>Dataset FullName</th>
+ <th>Dataset ShortName</th>
+ </tr>
+ </thead>
+ <tbody>
+ {%for dataset in datasets:%}
+ <tr>
+ <td>
+ <input type="checkbox" class="checkbox checkbox-search"
+ name="search_datasets"
+ value='{{dataset | tojson}}' />
+ </td>
+ <td>{{dataset.InbredSetName}}</td>
+ <td>{{dataset.StudyName}}</td>
+ <td>{{dataset.dataset_name}}</td>
+ <td>{{dataset.dataset_fullname}}</td>
+ <td>{{dataset.dataset_shortname}}</td>
+ </tr>
+ {%else%}
+ <tr>
+ <td colspan="100%" align="center">
+ <span class="glyphicon glyphicon-info-sign text-info"></span>
+ &nbsp
+ No datasets available for selection.
+ </td>
+ </tr>
+ {%endfor%}
+ </tbody>
+ </table>
+ </div>
+
+
+</div>
+{%endblock%}
+
+{%block js%}
+<script src="/static/new/javascript/auth/search_mrna.js"
+ language="javascript" type="text/javascript"></script>
+{%endblock%}