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

updated files for bigg tool

parent 3f0c2d0d
Pipeline #481 canceled with stages
......@@ -4,9 +4,6 @@ COPY ./code /home
WORKDIR /workdir
ADD ./requirements/system /workdir/system
ADD ./requirements/scraper /workdir/scraper
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install ncbi-blast+
......
File added
No preview for this file type
import subprocess as sp
import os
import hashlib
import sys
from zipfile import ZipFile
import shutil
import logging
def blast(processingPath, resultsPath):
logger.info('Blast process is Starting')
# 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)
runBlast(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 runBlast(output_path, processingPath):
# The following code will run Blast and check whether the software has run correctly or not.
logger.info('Run blast is starting')
logging.info(output_path)
child = sp.Popen(["java", "-jar", "-Djavax.xml.accessExternalDTD=all", "-Dworkdir=/workdir", "/home/Blast.jar"])
exit_code = child.wait()
if exit_code != 0:
removeFromProcessingAndResults(output_path, processingPath, exit_code)
else:
logger.info("Blast ran well and the GPRsResults.txt 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[0]
resultsPath = sys.argv[1]
logger.info('Calling blast method with these parameters: 'processingPath + ' ' + resultsPath)
blast(processingPath, resultsPath)
......@@ -25,11 +25,9 @@ logger.setLevel(logging.DEBUG)
#####
PROCESS_PATH = '/home/transyt.py'
PROCESS_PATH = '/home/blast.py'
SUBMISSIONS_PATH = '/workdir/workerSubmissions/'
RESULTS_PATH = '/workdir/resultsWorker/'
#RESULTS_PATH = "C:\\Users\\BioSystems\\Desktop\\testFolder\\resultsWorker\\"
#SUBMISSIONS_PATH = "C:\\Users\\BioSystems\\Desktop\\testFolder\\workerSubmissions\\"
if not os.path.exists(SUBMISSIONS_PATH):
os.makedirs(SUBMISSIONS_PATH)
......@@ -69,7 +67,7 @@ def start():
logger.debug("directories reset complete")
try:
try:
for file in request.files.values():
destination = "/".join([SUBMISSIONS_PATH, file.filename])
logger.info("saving file " + destination)
......
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