aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kabui2022-02-01 00:42:41 +0300
committerBonfaceKilz2022-02-09 08:49:56 +0300
commit6d3f48d3fa257e5fc22e874b3e0746b809a278a4 (patch)
tree899e9b6a3fe7c1ec1eeba2c8141470cbd1402122
parentd082c40370e45187994e90b146ae6a5e15a2c9c9 (diff)
downloadgenenetwork2-6d3f48d3fa257e5fc22e874b3e0746b809a278a4.tar.gz
handle exceptions
-rw-r--r--wqflask/wqflask/ctl/gn3_ctl_analysis.py28
-rw-r--r--wqflask/wqflask/templates/gn3_ctl_results.html14
2 files changed, 32 insertions, 10 deletions
diff --git a/wqflask/wqflask/ctl/gn3_ctl_analysis.py b/wqflask/wqflask/ctl/gn3_ctl_analysis.py
index 67f76a30..7af0013f 100644
--- a/wqflask/wqflask/ctl/gn3_ctl_analysis.py
+++ b/wqflask/wqflask/ctl/gn3_ctl_analysis.py
@@ -96,18 +96,28 @@ def run_ctl(requestform):
pheno_data = parse_phenotype_data(
trait_db_list, dataset, geno_data["individuals"])
- response = requests.post(ctl_api, json={
+ # todo refactor this chunk;;similar to wgcna check
- "genoData": geno_data,
- "phenoData": pheno_data,
+ try:
- **form_data,
+ response = requests.post(ctl_api, json={
- }).json()["results"]
+ "genoData": geno_data,
+ "phenoData": pheno_data,
+ **form_data,
- response["significance_data"] = process_significance_data(
- response["significance_data"])
+ })
+ if response.status_code != 200:
+ return {"error": response.json()}
+ response = response.json()["results"]
+ response["significance_data"] = process_significance_data(
+ response["significance_data"])
+
+ return response
+
+ except requests.exceptions.ConnectionError:
+ return {
+ "error": "A connection error to perform computation occurred"
+ }
- # todo check for errors
- return response
diff --git a/wqflask/wqflask/templates/gn3_ctl_results.html b/wqflask/wqflask/templates/gn3_ctl_results.html
index fedddc40..c42707f6 100644
--- a/wqflask/wqflask/templates/gn3_ctl_results.html
+++ b/wqflask/wqflask/templates/gn3_ctl_results.html
@@ -14,6 +14,14 @@
}
</style>
<div style="margin-top:10px">
+
+{% if error %}
+ <div>
+ <h4 style="text-align:center;color:red">{{error}}</h4>
+ </div>
+
+{% else %}
+ <div>
<div>
<div style="text-align: center;">
<h3>CTL/QTL Plots for Individual Traits</h3>
@@ -68,7 +76,11 @@
</div>
</div>
-<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
+{% endif %}
+</div>
+
+<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> -->
+<script src="{{ url_for('js', filename='bootstrap/js/bootstrap.min.js') }}" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTables/js/jquery.dataTables.min.js') }}"></script>
<script language="javascript" type="text/javascript" src="{{ url_for('js', filename='DataTablesExtensions/scroller/js/dataTables.scroller.min.js') }}"></script>