Commit c0ed69dc authored by Marc's avatar Marc
Browse files

add download_databases function to main.py,...

add download_databases function to main.py, download_databases_from_s3bucket.sh is run as subprocess
parent 8a66566f
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
import os import os
from psot.config import load_config import subprocess
import copy import copy
import shutil import shutil
from psot.nextflow import setup_execution_directory, execute_analysis
import tempfile import tempfile
import sys import sys
import json import json
from psot.config import load_config
from psot.nextflow import setup_execution_directory, execute_analysis
def main(): def main():
parser = argparse.ArgumentParser(description='Make bioinformatic observations on aminoacid sequences') parser = argparse.ArgumentParser(description='Make bioinformatic observations on aminoacid sequences')
...@@ -54,6 +56,7 @@ def analyze(args, config): ...@@ -54,6 +56,7 @@ def analyze(args, config):
execution = generate_execution(config, args) execution = generate_execution(config, args)
if args.debug: if args.debug:
print(json.dumps(execution, indent=2)) print(json.dumps(execution, indent=2))
download_databases(execution)
setup_execution_directory(execution) setup_execution_directory(execution)
error_code = execute_analysis(execution) error_code = execute_analysis(execution)
cleanup(execution) cleanup(execution)
...@@ -129,5 +132,19 @@ def show_analyses(config): ...@@ -129,5 +132,19 @@ def show_analyses(config):
module = config['modules'][key] module = config['modules'][key]
print(' {0:<20} - {1}'.format(module['name'], module['info'])) print(' {0:<20} - {1}'.format(module['name'], module['info']))
def download_databases(execution):
script = execution['helpers_path'] + '/download_databases_from_s3bucket.sh'
logfile = execution['install_path'] + '/database_paths.log'
database_path = execution['database_path']
retcode = 1
try:
run_download_script = subprocess.run([script, logfile, database_path])
retcode = run_download_script.returncode
except OSError as e:
print("Execution failed:", e, file=sys.stderr)
return retcode
if __name__ == "__main__": if __name__ == "__main__":
main() main()
...@@ -342,17 +342,17 @@ def generate_nextflow_config(execution): ...@@ -342,17 +342,17 @@ def generate_nextflow_config(execution):
fragments = [] fragments = []
if execution['docker']: if execution['docker']:
fragments.append('''docker { fragments.append('''docker {{
enabled = 'true' enabled = 'true'
fixOwnership = 'true' fixOwnership = 'true'
runOptions = '--volume={path}/databases' runOptions = '--volume={path}:/databases'
} }}
'''.format(path=database_path)) '''.format(path=database_path))
elif execution['singularity']: elif execution['singularity']:
fragments.append('''singularity { fragments.append('''singularity {{
enabled = 'true' enabled = 'true'
runOptions = '--bind {path}:/databases' runOptions = '--bind {path}:/databases'
} }}
'''.format(path=database_path)) '''.format(path=database_path))
fragments.append('''process { ''') fragments.append('''process { ''')
......
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