aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gn2/utility/Plot.py6
-rw-r--r--gn2/wqflask/templates/base.html23
-rw-r--r--gn2/wqflask/templates/gnqa_errors.html31
-rw-r--r--gn2/wqflask/templates/metadata/dataset.html13
-rw-r--r--gn2/wqflask/views.py27
5 files changed, 73 insertions, 27 deletions
diff --git a/gn2/utility/Plot.py b/gn2/utility/Plot.py
index ace954e4..b494a4a4 100644
--- a/gn2/utility/Plot.py
+++ b/gn2/utility/Plot.py
@@ -41,9 +41,9 @@ BLACK = ImageColor.getrgb("black")
# ---- END: Define common colours ---- #
# ---- FONT FILES ---- #
-VERDANA_FILE = "./wqflask/static/fonts/verdana.ttf"
-COUR_FILE = "./wqflask/static/fonts/courbd.ttf"
-TAHOMA_FILE = "./wqflask/static/fonts/tahoma.ttf"
+VERDANA_FILE = "./gn2/wqflask/static/fonts/verdana.ttf"
+COUR_FILE = "./gn2/wqflask/static/fonts/courbd.ttf"
+TAHOMA_FILE = "./gn2/wqflask/static/fonts/tahoma.ttf"
# ---- END: FONT FILES ---- #
diff --git a/gn2/wqflask/templates/base.html b/gn2/wqflask/templates/base.html
index 4c4308a3..0009e4d8 100644
--- a/gn2/wqflask/templates/base.html
+++ b/gn2/wqflask/templates/base.html
@@ -22,7 +22,7 @@
<link rel="stylesheet" href="/static/new/css/autocomplete.css" />
<link rel="stylesheet" type="text/css" href="{{ url_for('css', filename='fontawesome/css/font-awesome.min.css') }}" />
- {% block css %}
+ {% block css %}
{% endblock %}
<style>
.form-rounded {
@@ -224,16 +224,18 @@
</div>
<div class="container-fluid" style="width: 100%; min-width: 650px; position: relative;background-color: #d5d5d5; height: 100px;">
<form id="gnqna_search_home" method="POST" action="/gnqna" style="display:none;width: 100%;">
- <div >
- <input id="gnqna_search_home_input" style="width:45vw" type="text" autocomplete="off"
+
+ <!--- init gnqa codebase here -->
+ <div style="width: 100%; display: flex;justify-content: space-evenly;">
+
+ <input id="gnqna_search_home_input" style="width:50vw" type="text" autocomplete="off"
required placeholder="Ask More Questions or Topics (E.g Genes) " value='' name="querygnqa">
- </div>
- <!-- Large modal -->
-<button type="button" data-toggle="modal" data-target=".bd-example-modal-lg" style="border:none;outline: none;padding:5px;margin-left:25px"> GNQA-History</button>
-
-
-
+
+ <button type="button" data-toggle="modal" data-target=".bd-example-modal-lg" style="border:none;text-decoration:underline;outline: none;padding:5px;margin-left:25px;background-color: #d5d5d5;">
+ GNQA Search History
+ </button>
+ </div>
<div class="modal fade bd-example-modal-lg " id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
@@ -277,7 +279,7 @@ required placeholder="Ask More Questions or Topics (E.g Genes) " value='' name="
</div>
</div>
-
+
</form>
<form method="get" action="/gsearch" id="globalsearchform">
<div class="form-group">
@@ -309,6 +311,7 @@ required placeholder="Ask More Questions or Topics (E.g Genes) " value='' name="
</div>
</div>
+
</form>
</div>
diff --git a/gn2/wqflask/templates/gnqa_errors.html b/gn2/wqflask/templates/gnqa_errors.html
new file mode 100644
index 00000000..3a0e0bf7
--- /dev/null
+++ b/gn2/wqflask/templates/gnqa_errors.html
@@ -0,0 +1,31 @@
+{% extends "base.html" %}
+{% block title %}GNQNA{% endblock %}
+
+{% block content %} <!-- Start of body -->
+
+
+{% block css %}
+<link rel="stylesheet" type="text/css" href="/static/new/css/llm.css">
+{% endblock %}
+
+
+<style type="text/css">
+
+</style>
+
+<div style="min-height: 50vh;width: 100vw;text-align: center;display:flex;justify-content: center;align-items: center;">
+ <div>
+ <h2 style="color:red;text-decoration: underline;font-weight: bold;">Error:
+ {{error}} </h2>
+ </div>
+
+</div>
+
+
+<script src="{{ url_for('js', filename='jquery/jquery.min.js') }}" type="text/javascript"></script>
+
+<script type="text/javascript">
+</script>
+
+{% endblock %}
+
diff --git a/gn2/wqflask/templates/metadata/dataset.html b/gn2/wqflask/templates/metadata/dataset.html
index 06df6a68..23ceb3b5 100644
--- a/gn2/wqflask/templates/metadata/dataset.html
+++ b/gn2/wqflask/templates/metadata/dataset.html
@@ -98,6 +98,11 @@
<div>{{ dataset.description|safe }}</div>
{% endif %}
+ {% if dataset.experimentType %}
+ <h3><strong>Experiment Type</strong></h3>
+ <div>{{ dataset.experimentType|safe }}</div>
+ {% endif %}
+
{% if dataset.specificity %}
<h2><strong>Specifics of this Dataset</strong></h2>
<div>{{ dataset.specificity }}</div>
@@ -113,16 +118,16 @@
<div>{{ dataset.caseInfo|safe }}</div>
{% endif %}
- {% if dataset.tissue %}
+ {% if dataset.tissue and dataset.tissueInfo %}
<h3><strong>About the Tissue
{%if dataset.tissue and dataset.tissue.label %}({{ dataset.tissue.label }})
{% endif %}Used to Generate this Dataset</strong></h3>
- <div>{{ dataset.tissue.tissueInfo|safe }}</div>
+ <div>{{ dataset.tissueInfo|safe }}</div>
{% endif %}
- {% if dataset.platform %}
+ {% if dataset.platform and dataset.platformInfo %}
<h3 title="{{ dataset.platform.label }}"><strong>About the Array Platform</strong></h3>
- <div>{{ dataset.platform.platformInfo|safe }}</div>
+ <div>{{ dataset.platformInfo|safe }}</div>
{% endif %}
{% if dataset.processingInfo %}
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index 9e82cc64..cc212980 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -264,30 +264,40 @@ def gsearchtable():
@app.route("/gnqna", methods=["POST", "GET"])
def gnqna():
+
if request.method == "POST":
try:
def __error__(resp):
return resp.json()
+ def error_page(error_msg):
+ return render_template("gnqa_errors.html", error=error_msg)
+
def __success__(resp):
- return render_template("gnqa_answer.html", **{"gn_server_url":GN3_LOCAL_URL,**(resp.json())})
+ return render_template("gnqa_answer.html", **{"gn_server_url": GN3_LOCAL_URL, **(resp.json())})
+ if not user_logged_in():
+ return error_page("Please Login/Register to Genenetwork to access this Service")
+ token = session_info()["user"]["token"].either(
+ lambda err: err, lambda tok: tok["access_token"])
return monad_requests.post(
urljoin(GN3_LOCAL_URL,
"/api/llm/gnqna"),
json=dict(request.form),
+ headers={
+ "Authorization": f"Bearer {token}"
+ }
).then(
lambda resp: resp
).either(
__error__, __success__)
except Exception as error:
return flask.jsonify({"error": str(error)})
-
- prev_queries = monad_requests.get(
+ prev_queries = (monad_requests.get(
urljoin(GN3_LOCAL_URL,
"/api/llm/get_hist_names")
).then(
lambda resp: resp
- ).either(lambda x: [], lambda x: x.json()["prev_queries"])
+ ).either(lambda x: [], lambda x: x.json()["prev_queries"]))
return render_template("gnqa.html", prev_queries=prev_queries)
@@ -296,12 +306,9 @@ def gnqna():
def gnqna_hist(search_term):
# todo add token validation
- response = monad_requests.get(urljoin(GN3_LOCAL_URL,f"/api/llm/historys/{search_term}")).then(lambda resp :resp).either(
- lambda x: x.json(),lambda x : x.json())
- return render_template("gnqa_answer.html",**{"gn_server_url":GN3_LOCAL_URL,**response})
-
-
-
+ response = monad_requests.get(urljoin(GN3_LOCAL_URL, f"/api/llm/historys/{search_term}")).then(lambda resp: resp).either(
+ lambda x: x.json(), lambda x: x.json())
+ return render_template("gnqa_answer.html", **{"gn_server_url": GN3_LOCAL_URL, **response})
@app.route("/gsearch_updating", methods=('POST',))