Commit 08bdbb12 authored by Marc's avatar Marc
Browse files

include 'executor', 'clusterOptions' and 'beforeScript' properties in nextflow.config generation

parent e7854eff
......@@ -17,9 +17,7 @@ def flatten(d, parent_key='', sep='_'):
analysis_template = Template ('''
process ${id} {
executor '${executor}'
${clusterOptions}
${beforeScript}
input:
file fasta from for_${id}${chunks}
......@@ -51,7 +49,7 @@ process generate_${id}_live_results {
''')
convert_live_template = Template ('''
process convert_${id}_to_json {
${beforeScript}
input:
file result from ${id}_results
......@@ -66,7 +64,7 @@ process convert_${id}_to_json {
''')
convert_info_template = Template ('''
process convert_${id}_to_json {
${beforeScript}
input:
file result from ${id}_results
......@@ -81,7 +79,7 @@ process convert_${id}_to_json {
''')
convert_template = Template ('''
process convert_${id}_to_json {
${beforeScript}
input:
file result from ${id}_results
......@@ -96,7 +94,6 @@ process convert_${id}_to_json {
''')
retrieve_informations_template = Template('''
process retrieve_informations_for_${id} {
${beforeScript}
input:
file result from ${id}_json_info
......@@ -112,7 +109,6 @@ process retrieve_informations_for_${id} {
''')
retrieve_informations_live_template = Template('''
process retrieve_informations_for_${id} {
${beforeScript}
input:
file result from ${id}_json_info
......@@ -159,13 +155,21 @@ process split_documents {
"""
}
''')
process_config_template = Template('''
analysis_config_template = Template('''
withName:${id}{
executor = '${executor}'
${clusterOptions}
${beforeScript}
${container}
}
'''
)
beforeScript_config_template = Template('''
withName:${process_names}{
${beforeScript}
}
'''
)
def setup_execution_directory(execution):
directory = execution['directory']
......@@ -205,19 +209,11 @@ Channel.fromPath(params.fasta).set{fasta}''')
for m in modules:
config = flatten(m)
config['output'] = execution['output']
if 'venv' in execution:
config['beforeScript'] = "beforeScript 'export PS1=; source " + execution['venv'] + "/bin/activate'"
else:
config['beforeScript'] = ''
if execution['use_cluster']:
config['executor'] = 'sge'
config['chunks'] = ".splitFasta(by:300, file:'input')"
config['clusterOptions'] = "clusterOptions='-S /bin/bash'"
else:
config['executor'] = 'local'
config['chunks'] = ''
config['clusterOptions'] = ''
fragments.append(analysis_template.substitute(config))
if execution['mode'] == 'live' and not execution['fetch_informations']:
......@@ -250,15 +246,35 @@ def generate_nextflow_config(execution):
fragments = []
fragments.append('''docker.enabled = true''')
fragments.append('''process { ''')
for m in modules:
config = {}
config['id'] = m['id']
if m['analysis']['container']:
config['id'] = m['id']
config['container'] = "container = " + "'" + m['analysis']['container'] + "'"
else:
config['container'] = ''
fragments.append(process_config_template.substitute(config))
if 'venv' in execution:
config['beforeScript'] = "beforeScript = 'export PS1=; source " + execution['venv'] + "/bin/activate'"
else:
config['beforeScript'] = ''
if execution['use_cluster']:
config['executor'] = 'sge'
config['clusterOptions'] = "clusterOptions = '-S /bin/bash'"
else:
config['executor'] = 'local'
config['clusterOptions'] = ''
fragments.append(analysis_config_template.substitute(config))
if execution['fetch_informations']:
config['process_names'] = "'" + Template('convert_${id}_to_json|retrieve_informations_for_${id}').substitute(config) + "'"
else:
config['process_names'] = Template('convert_${id}_to_json').substitute(config)
fragments.append(beforeScript_config_template.substitute(config))
fragments.append('''}''')
nextflow_config = '\n'.join(fragments)
......
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