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

Delete transyt.py

parent baafc3c1
Pipeline #482 canceled with stages
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)
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