Commit 28a0c8eb authored by Davide Lagoa's avatar Davide Lagoa
Browse files

database queries integration to website

parent a56634d7
......@@ -3,5 +3,6 @@ RUN mkdir /configs
COPY ./configs /configs
COPY ./code /home
WORKDIR /workdir
RUN pip install neo4j-driver==1.3.1
EXPOSE 80
CMD ["python", "/home/workersManager.py"]
......@@ -10,6 +10,7 @@ import logging
import re
import time
import requests
from transyt_request import database_retriever_by_id
CONFIGURATIONS = FilesUtilities.read_conf_file('/configs/docker_config.conf')
......@@ -29,7 +30,6 @@ logger = logging.getLogger(__name__)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.info("Docker configurations: " + str(CONFIGURATIONS))
logger.info('Starting server')
......@@ -46,6 +46,7 @@ last_submission_ID = 0
print('SERVER WORKING')
@app.after_request
def after_request(response):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, public, max-age=0"
......@@ -53,6 +54,7 @@ def after_request(response):
response.headers["Pragma"] = "no-cache"
return response
@app.route("/")
def index():
logger.info('Welcome page rendering...')
......@@ -93,20 +95,6 @@ def submitMerlinPlugin(taxonomyId):
return run(files, taxonomyId, True)
@app.route("/reaction/<reactionId>", methods=["GET"])
def getReactionInfo(reactionId):
pattern = re.compile("^TR\d{6}")
patternFound = bool(pattern.match(reactionId))
if patternFound:
return jsonify({"Result": "Success",
"Purpose": "Future page for transyt reaction " + reactionId}), 200
else:
logger.info('Bad request to get reaction. Request done: ' + reactionId)
return jsonify({"Result": "Bad request, page does not exist!"}), 400
def run(files, taxonomyId, isRest):
logger.debug('New submission in progress...')
......@@ -266,8 +254,9 @@ def display_msg(submissionID, isRest):
def download(submissionID):
logger.debug("Request to download submission " + submissionID + " results")
timestr = time.strftime("%Y%m%d_%H%M%S")
return send_file(RESULTS_PATH + submissionID + "/results" + timestr + ".zip", as_attachment=True,
attachment_filename='results.zip')
return send_file(RESULTS_PATH + submissionID + "/results.zip", as_attachment=True,
attachment_filename='results' + timestr + '.zip')
@app.route("/debug/logs/<level>")
def logsRetriever(level):
......@@ -287,7 +276,7 @@ def logsRetriever(level):
os.makedirs(saveFilesPath)
#implement service here when running
# implement service here when running
if level == 'manager':
logger.info("Collecting manager logs.")
......@@ -340,6 +329,52 @@ def getWorkersLogs(savePath):
logger.debug("Worker " + host + " not alive!")
@app.route('/reactions/<reactionId>')
def reactions(reactionId):
pattern = re.compile("^T[A-Z]\d{7}")
patternFound = bool(pattern.match(reactionId))
if patternFound:
results_dict = result_parser(reactionId)
if results_dict:
return render_template("record.html", subId=reactionId, dictt=results_dict), 200
return render_template("noresutls.html", subId=reactionId), 200
@app.template_filter('enumerate_items')
def enumerate_items(*args, **kwargs):
return enumerate(*args, **kwargs)
def result_parser(id):
databases, tc_systems, reactionID, metaID, reaction, metabolites = database_retriever_by_id(id)
if not metabolites:
return None
tc_systems2 = {}
for tc in tc_systems:
tc_elements = tc.split('@')
if tc_elements[0] in tc_systems2:
tc_systems2[tc_elements[0]].append(tc_elements[1])
else:
tc_systems2[tc_elements[0]] = [tc_elements[1]]
res_dict = {'databases': databases,
'tc_systems': tc_systems2,
'reactionID': reactionID,
'metaID': metaID,
'reaction': reaction,
'metabolites': metabolites}
return res_dict
def countEntriesBelow(l, id):
id = int(id)
res = 0
......
from neo4j.v1 import GraphDatabase
class neo4jPythonDriver:
###### CONSTRUCTOR ######
def __init__(self, uri, user, password):
self.__uri = uri
self.__user = user
self.__password = password
self.__driver = self.__initDriver()
def __initDriver(self):
return GraphDatabase.driver(self.__getUri(), auth=(self.__getUser(), self.__getPassword()))
def initSession(self):
return self.__driver.session()
def __getUri(self):
return self.__uri
def __getUser(self):
return self.__user
def __getPassword(self):
return self.__password
def __getDriver(self):
return self.__driver
def __setUri(self, value):
self.__uri = value
def __setUser(self, value):
self.__user = value
def __setPassword(self, value):
self.__password = value
def __setDriver(self, value):
self.__driver = value
#aspect-content {
margin: 10px 10px 0px 10px;
font-family: 'Oxygen';
}
.tab-element {
position: relative;
width: 90%;
margin: 0 auto 10px;
border-radius: 4px;
background-color: #ffffff;
box-shadow: 3px -1px 5px 3px #bdc3c7;
opacity: 1;
transition: box-shadow .2s, opacity .4s;
}
.tab-element:hover {
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, .11);
}
.inner-tab-element {
position: relative;
width: 100%;
border-radius: 4px;
background-color: #34495e;
box-shadow: 3px -1px 5px 3px #bdc3c7;
opacity: 1;
transition: box-shadow .2s, opacity .4s;
}
.inner-tab-element:hover {
box-shadow: 0 4px 10px 0 rgba(0, 0, 0, .11);
}
.outer-input {
display: none;
}
.inner-input {
display: none;
}
.outer-input:checked ~ .outer-label-content + .dropdown-content-outer-wrapper {
max-height: 8000px;
}
.outer-input:checked ~ .outer-label-content:after {
transform: rotate(0);
}
.inner-input:checked ~ .outer-label-content + .dropdown-content-outer-wrapper {
max-height: 8000px;
}
.inner-input:checked ~ .outer-label-content:after {
transform: rotate(0);
}
.outer-input:checked ~ .inner-label-content + .dropdown-content-outer-wrapper {
max-height: 8000px;
}
.outer-input:checked ~ .inner-label-content:after {
transform: rotate(0);
}
.inner-input:checked ~ .inner-label-content + .dropdown-content-outer-wrapper {
max-height: 8000px;
}
.inner-input:checked ~ .inner-label-content:after {
transform: rotate(0);
}
.outer-label {
position: absolute;
top: 0;
left: 0;
height: 100%;
max-height: 50px;
width: 100%;
margin: 0;
padding: 0;
font-size: 0;
z-index: 1;
cursor: pointer;
}
.inner-label {
position: absolute;
top: 0;
left: 0;
height: 100%;
max-height: 50px;
width: 100%;
margin: 0;
padding: 0;
font-size: 0;
z-index: 1;
cursor: pointer;
}
.outer-label-content {
position: relative;
display: block;
height: 50px;
margin: 0;
padding: 0;
font-size: 0;
white-space: nowrap;
cursor: pointer;
}
.outer-label-content:before {
content: '';
display: inline-block;
vertical-align: middle;
height: 100%;
}
.outer-label-content:after {
content: '';
display: inline-block;
vertical-align: middle;
position: absolute;
width: 24px;
height: 100%;
right: 30px;
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPHBhdGggZD0iTTI0IDI0SDBWMGgyNHoiIG9wYWNpdHk9Ii44NyIvPgogICAgICAgIDxwYXRoIGZpbGw9IiNBOUFDQUYiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTE1Ljg4IDE1LjI5TDEyIDExLjQxbC0zLjg4IDMuODhhLjk5Ni45OTYgMCAxIDEtMS40MS0xLjQxbDQuNTktNC41OWEuOTk2Ljk5NiAwIDAgMSAxLjQxIDBsNC41OSA0LjU5Yy4zOS4zOS4zOSAxLjAyIDAgMS40MS0uMzkuMzgtMS4wMy4zOS0xLjQyIDB6Ii8+CiAgICA8L2c+Cjwvc3ZnPgo=');
background-repeat: no-repeat;
background-position: center;
transform: rotate(180deg);
}
.outer-label-content + .dropdown-content-outer-wrapper {
max-height: 0;
overflow: hidden;
transition: max-height .3s;
}
.outer-label-content > div {
display: inline-block;
vertical-align: middle;
}
.inner-label-content {
position: relative;
display: block;
height: 50px;
margin: 0;
padding: 0;
font-size: 0;
white-space: nowrap;
cursor: pointer;
}
.inner-label-content:before {
content: '';
display: inline-block;
vertical-align: middle;
height: 100%;
}
.inner-label-content:after {
content: '';
display: inline-block;
vertical-align: middle;
position: absolute;
width: 24px;
height: 100%;
right: 30px;
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPHBhdGggZD0iTTI0IDI0SDBWMGgyNHoiIG9wYWNpdHk9Ii44NyIvPgogICAgICAgIDxwYXRoIGZpbGw9IiNBOUFDQUYiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTE1Ljg4IDE1LjI5TDEyIDExLjQxbC0zLjg4IDMuODhhLjk5Ni45OTYgMCAxIDEtMS40MS0xLjQxbDQuNTktNC41OWEuOTk2Ljk5NiAwIDAgMSAxLjQxIDBsNC41OSA0LjU5Yy4zOS4zOS4zOSAxLjAyIDAgMS40MS0uMzkuMzgtMS4wMy4zOS0xLjQyIDB6Ii8+CiAgICA8L2c+Cjwvc3ZnPgo=');
background-repeat: no-repeat;
background-position: center;
transform: rotate(180deg);
}
.inner-label-content + .dropdown-content-outer-wrapper {
max-height: 0;
overflow: hidden;
transition: max-height .3s;
}
.inner-label-content > div {
display: inline-block;
vertical-align: middle;
}
.aspect-info {
width: 100%;
white-space: nowrap;
font-size: 0;
}
.aspect-info:before {
content: '';
display: inline-block;
vertical-align: middle;
}
.aspect-name {
display: inline-block;
width: 33%;
max-height: 22px;
color: #000000;
text-align: left;
vertical-align: middle;
font-size: 16px;
margin: 0 0 0 20px;
}
.aspect-name > p {
display: inline-block;
font-size: 16px;
}
.aspect-name > a {
display: inline-block;
}
.dropdown-content-outer-wrapper {
background-color: #ecf0f1;
font-size: 0;
text-align: justify;
}
.inner-tab-element-wrapper {
padding: 10px 10px 10px 10px;
}
.inner-inner-tab-element-wrapper {
padding: 10px 10px 10px 10px;
display: flex;
flex-wrap: wrap;
}
.inner-inner-tab-element-wrapper > div {
display: inline-block;
width: 100%;
height: 100%;
flex: 0 0 20%
}
.inner-inner-tab-element-wrapper > div > div {
width: 100%;
height: 100%;
padding: 10px 10px 10px 10px;
background-color: #ecf0f1;
text-align: left;
}
.content {
position: relative;
width: 100%;
font-size: 13px;
color: #2c3e50;
}
.external-links-button {
display: inline-block;
background: none;
padding: 10px;
margin: 10px;
cursor:pointer;
border: 2px solid #2c3e50;
border-radius: 10px;
}
.external-links-button:hover {
display: inline-block;
background: #2c3e50;
transition: 0.5s;
}
.external-links-button >p {
margin: 0;
color: #2c3e50;
}
.external-links-button:hover >p {
margin: 0;
color: #ffffff;
transition: 0.5s;
}
.inner-external-links-title {
padding-bottom: 15px;
}
.inner-external-links-title >a {
font-size: 16px;
color: #2980b9;
}
.inner-external-links-title:hover >a {
text-decoration: underline;
cursor: pointer;
color: #95a5a6;
}
.inner-external-links {
display: inline-block;
background: none;
padding: 10px;
margin: 10px;
border: 1px solid #95a5a6;
border-radius: 10px;
width: 90%;
}
.inner-external-links >div{
vertical-align: middle;
display: flex;
flex-wrap: wrap;
margin-left: 5%;
width: 80%;
}
.inner-external-links >div >div {
flex: 0 0 33%;
vertical-align: middle;
}
.par-inner-external-links {
vertical-align: middle;
margin: 10px;
font-size: 14px;
color: #95a5a6;
display: inline-block;
}
.external-links-button-close {
padding:10px 0 10px 50%;
margin: 0;
cursor: pointer;
align-content: center;
}
......@@ -2,7 +2,6 @@
.center {
margin: auto;
width: 60%;
border: 3px solid #000066;
padding: 10px;
word-wrap: break-word;
font-family: 'Oxygen';
......@@ -22,6 +21,14 @@
font-size: 20px;
}
.center h4 {
color: black;
font-family: 'Oxygen';
font-size: 18px;
}
.center p {
......@@ -35,3 +42,47 @@
font-family: 'Oxygen';
}
.center-download {
margin: auto;
width: 90%;
padding: 20px;
word-wrap: break-word;
font-family: 'Oxygen';
}
.center-download h1 {
color: black;
font-family: 'Oxygen';
font-size: 28px;
}
.center-download h3 {
color: black;
font-family: 'Oxygen';
font-size: 20px;
}
.center-download h4 {
color: black;
font-family: 'Oxygen';
font-size: 18px;