Commit 72590042 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Added default execution in tmp directory

parent 100b4c88
......@@ -79,8 +79,10 @@ def setup_execution_directory(execution):
os.symlink(execution['bin_path'], directory + '/bin')
def execute_analysis(execution):
old_cwd = os.getcwd()
os.chdir(execution['directory'])
os.system('nextflow run main.nf --fasta ' + execution['fasta'] + ' --output ' + execution['output'])
os.system('nextflow run ' + execution['directory'] + '/main.nf --fasta ' + execution['fasta'] + ' --output ' + execution['output'])
os.chdir(old_cwd)
def generate_nextflow_script(execution):
modules = execution['modules']
......
......@@ -3,7 +3,9 @@ import argparse
import os
from config import load_config
import copy
import shutil
from nextflow import setup_execution_directory, execute_analysis
import tempfile
def main():
parser = argparse.ArgumentParser(description='Make bioinformatic observations on aminoacid sequences')
......@@ -20,28 +22,40 @@ def main():
analyze_parser.add_argument('--profile', '-p', default='fast', help='The profile to use')
analyze_parser.add_argument('--live', '-l', action='store_true', help='Report results as they are computed, not only at the end of the computation')
analyze_parser.add_argument('--config', '-c', help='The config to use')
analyze_parser.add_argument('--debug', '-d', action='store_true', help='Debug mode, computation directory will not be removed after computation')
analyze_parser.add_argument('--execution_dir', '-e', help='Use the specified execution directory and do not delete it after the computation')
analyze_parser.set_defaults(func=analyze)
args = parser.parse_args()
config = load_config()
args.func(args, config)
def info(args, config):
show_analyses(config)
def analyze(args, config):
execution = generate_execution(config, args)
if args.debug:
print(execution)
setup_execution_directory(execution)
execute_analysis(execution)
cleanup(execution)
def cleanup(execution):
if not execution['debug']:
shutil.rmtree(execution['directory'])
def generate_execution(config, args):
execution = {}
execution['debug'] = args.debug
execution['mode'] = 'live' if args.live else 'complete'
execution['bin_path'] = config['app']['bin_path']
execution['fasta'] = os.path.abspath(args.fasta)
execution['output'] = os.path.abspath(args.output)
execution['directory'] = 'tmp' # TODO replace by random tmp directory or make it configurable (cli option)
if args.execution_dir:
execution['directory'] = args.execution_dir
else:
execution['directory'] = tempfile.mkdtemp()
execution['modules'] = generate_execution_modules_for_profile(config, args.profile)
return execution
......
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