Git Lab CI for docker build enabled! You can enable it using .gitlab-ci.yml in your project. Check file template at https://gitlab.bio.di.uminho.pt/snippets/5

Commit 19ac3a7a authored by Davide Lagoa's avatar Davide Lagoa
Browse files

Initial commit

parents
Pipeline #264 canceled with stages
File added
FROM openjdk:10-slim
COPY . /usr/src/app/
WORKDIR /workdir
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install ncbi-blast+
RUN apt-get install -y python-pip python-dev build-essential
RUN pip install Flask
RUN pip install requests
RUN apt-get install -y procps
RUN apt-get -y autoclean
RUN apt-get -y clean
ENTRYPOINT [ "python" ]
CMD ["/home/worker.py"]
import subprocess as sp
import os
import hashlib
import sys
from zipfile import ZipFile
import shutil
import logging
def transyt(processingPath, resultsPath):
# Create a directory whose name is the submission ID, if it hasn't been created already
if not os.path.exists(resultsPath):
os.makedirs(resultsPath)
logPath = resultsPath + "/trace_errors.log"
logging.basicConfig(filename=logPath, level=logging.DEBUG, format='%(asctime)s: %(levelname)s: >>>%(message)s')
output_path = resultsPath + "/" # + "/results_biocoiso.json"
logging.info("The results path is " + output_path)
runTransyt(output_path, processingPath+"/" )
file_paths = get_all_file_paths(resultsPath + "/")
with ZipFile(resultsPath + '/results.zip', 'w') as zip:
# writing each file one by one
for file in file_paths:
new_file = file.split("/")[-1]
zip.write(file, arcname=new_file)
logging.info("The zip file was generated successfully.")
with open(resultsPath + "/processComplete", "w") as f:
f.write("Process complete: ")
def runTransyt(output_path, processingPath):
# The following code will run BioCoISO and check whether the software has run correctly or not.
#logging.info(protein)
logging.info(output_path)
child = sp.Popen(["java", "-Xmx8192m", "-Dworkdir=/workdir", "-jar", "/home/runClassification.jar", "3", processingPath, output_path])
exit_code = child.wait()
if exit_code != 0:
removeFromProcessingAndResults(output_path, processingPath, exit_code)
else:
logging.info("TranSyT run well and the zip file and the md5 file is going to be created.")
if os.path.exists(processingPath):
shutil.rmtree(processingPath)
logging.info("The processing directory was removed succefully.")
def get_all_file_paths(directory):
# initializing empty file paths list
file_paths = []
# crawling through directory and subdirectories
for root, directories, files in os.walk(directory):
for filename in files:
# join the two strings in order to form the full filepath.
filepath = os.path.join(root, filename)
file_paths.append(filepath)
# returning all file paths
return file_paths
def removeFromProcessingAndResults(output_path, processingPath, exit_code):
logging.info("TranSyT didn't run well.")
if output_path is not None and os.path.exists(output_path):
os.remove(output_path)
with open(resultsPath + "/" + str(exit_code), "w") as f:
f.write("A error was found while running TranSyT. The exit code was: " + str(exit_code))
if os.path.exists(processingPath):
shutil.rmtree(processingPath)
if __name__ == "__main__":
processingPath = sys.argv[1]
resultsPath = sys.argv[2]
transyt(processingPath, resultsPath)
from flask import Flask
import subprocess
import os
app = Flask(__name__)
PROCESS_PATH = '/home/transyt.py'
@app.route("/start/<processingPath>/<resultsPath>")
def start(processingPath, resultsPath):
try:
resultsPath = resultsPath.replace('$', '/')
processingPath = processingPath.replace('$', '/')
subprocess.Popen(["python", PROCESS_PATH, processingPath, resultsPath])
return ('processing', 102)
except IndexError:
print('An error occurred while processing the submission')
return ('error', 500)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, threaded=False, debug=True)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Done
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Complete!!!!!!
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body class="body">
<div class="container" align="left">
<a href="/return-file" target="blank"><button class='btn btn-default'> Download</button></a>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Upload</title>
</head>
<body>
<h1>TranSyT's Files Uploader</h1>
<p>The submissions will only be valid if the following files are submitted:</p>
<p>Genome as 'genome.faa'</p>
<p>Taxonomy identifier (write the number inside a simple txt file) as taxID.txt</p>
<p>Model as 'model.xml'!!</p>
<p></p>
<p>Please submit the files with the names above!</p>
<form id="upload-form" action="{{url_for('upload')}}" method="POST" enctype="multipart/form-data">
<input type="file" name="file" multiple>
<input type="submit" name="send">
</form>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Upload</title>
</head>
<body>
<h1>TranSyT's NEW Files Uploader</h1>
<p>The submissions will only be valid if the following files are submitted:</p>
<p>Genome as 'genome.faa'</p>
<p>Taxonomy identifier (write the number inside a simple txt file) as taxID.txt</p>
<p>Model as 'model.xml'!!</p>
<p></p>
<p>Please submit the files with the names above!</p>
<form id="upload-form" action="{{url_for('submit)}}" method="POST" enctype="multipart/form-data">
<input type="file" name="file" multiple>
<input type="submit" name="send">
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Waiting...
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment