Commit 544b7b7d authored by Marc's avatar Marc
Browse files

nextflow.config is now generated with docker and singularity scopes in which...

nextflow.config is now generated with docker and singularity scopes in which the local database directory is mounted/bind in the containers to the /databases directory; config.py now concats the right database directory with the database property in regarding modules
parent 95fa5968
......@@ -4,15 +4,15 @@ import copy
import pkg_resources
class Repository:
def __init__(self, path):
self.path = path
def load_config(self):
'''return a dictionary with the whole configuration for this repository'''
config = self.load_config_file()
config['profiles'] = self.load_profiles()
config['modules'] = self.load_modules()
config['profiles'] = self.load_profiles(config)
config['modules'] = self.load_modules(config)
self.normalize_profiles(config['profiles'])
return config
......@@ -41,7 +41,7 @@ class Repository:
config = yaml.load(f)
return config
def load_profiles(self):
def load_profiles(self, config):
profiles = []
for manifest in self.get_profile_manifests():
with (open(manifest)) as f:
......@@ -50,7 +50,7 @@ class Repository:
return profiles
def load_modules(self):
def load_modules(self, config):
modules = {}
for manifest in self.get_module_manifests():
with (open(manifest)) as f:
......@@ -70,6 +70,13 @@ class Repository:
module['analysis']['container']['docker'] = None
elif not 'singularity' in module['analysis']['container']:
module['analysis']['container']['singularity'] = None
if 'database' in module['analysis']['parameters'] and module['analysis']['parameters']['database']:
if (container_run['docker?'] and module['analysis']['container']['docker']) \
or (container_run['singularity?'] and module['analysis']['container']['singularity']):
module['analysis']['parameters']['database'] = config['databases']['containerpath'] + module['analysis']['parameters']['database']
else:
module['analysis']['parameters']['database'] = config['databases']['localpath'] + module['analysis']['parameters']['database']
module['analysis']['script'] = os.path.abspath(os.path.join(self.get_scripts_location(), module['analysis']['script']))
module['converter']['script'] = os.path.abspath(os.path.join(self.get_scripts_location(), module['converter']['script']))
......@@ -140,7 +147,17 @@ class Config:
profile['modules'] = resolved_modules
def load_config(repositories=None):
def load_config(arguments=None, repositories=None):
global container_run
container_run = {}
if arguments:
container_run['docker?'] = arguments.docker
container_run['singularity?'] = arguments.singularity
else:
container_run['docker?'] = False
container_run['singularity?'] = False
# always use the installed repository as the first repo
all_repositories = [pkg_resources.resource_filename('psot', 'default_repo')]
......
databases:
localpath: '/usr/lib/dbs'
localpath: '/home/ubuntu/db'
containerpath: '/databases'
tools:
# Replace tool paths if they are located elsewhere
......
......@@ -11,7 +11,7 @@ info: 'blastp analysis against swissprot'
analysis:
script: 'run_blastp.py'
parameters:
database: '/home/ubuntu/db/blastp/uniprot_sprot.fasta'
database: '/blastp/uniprot_sprot.fasta'
evalue: 1e-10
use_accession:
container:
......
......@@ -11,8 +11,9 @@ info: 'ghostx analysis against swissprot'
analysis:
script: 'run_ghostx.py'
parameters:
database: '/home/ubuntu/db/ghostx/uniprot_sprot'
database: '/ghostx/uniprot_sprot'
container:
docker: 'ghostx'
# The name of the result to json converter script. Must take one parameter, the
# result file from the analysis_script
......
......@@ -11,12 +11,13 @@ info: 'hmmscan analysis against PFAM-A'
analysis:
script: 'run_hmmer.py'
parameters:
database: '/home/ubuntu/db/hmmer/Pfam-A.hmm'
database: '/hmmer/Pfam-A.hmm'
evalue: 1e-10
execution:
cluster:
chunksize: 200
container:
docker: 'hmmer'
# The name of the result to json converter script. Must take one parameter, the
# result file from the analysis_script
......
......@@ -5,5 +5,4 @@ modules:
organism: 'euk'
targetp:
organism_group: 'non-plant'
ghostx_swissprot:
hmmer_pfam_a:
\ No newline at end of file
......@@ -4,7 +4,6 @@ import sys
import json
import argparse
from os import path
from psot import config
import subprocess
parser = argparse.ArgumentParser(description='Convert ghostx results to json documents')
......@@ -60,6 +59,3 @@ output_filename = args.output
with open(output_filename, 'w') as o:
json.dump(documents, o)
# Replace sequences' enumerated ids with their original ids
restore_seq_ids_tool = config.load_config()['helpers_path'] + '/restore_seq_id_from_enumeration.py'
subprocess.run([restore_seq_ids_tool, '-j', output_filename, '-e', args.result + '/enum_headers.tsv'])
......@@ -4,7 +4,6 @@ import sys
import json
import argparse
from os import path
from psot import config
import subprocess
parser = argparse.ArgumentParser(description='Convert targetp results to json document')
......@@ -57,6 +56,3 @@ output_filename = args.output
with open(output_filename, 'w') as o:
json.dump(documents, o)
# Replace sequences' enumerated ids with their original ids
restore_seq_ids_tool = config.load_config()['helpers_path'] + '/restore_seq_id_from_enumeration.py'
subprocess.run([restore_seq_ids_tool, '-j', output_filename, '-e', args.result + '/enum_headers.tsv'])
......@@ -37,8 +37,8 @@ def main():
analyze_parser.set_defaults(func=analyze)
args = parser.parse_args()
config = load_config()
args.parser = parser
config = load_config(arguments=args)
args.func(args, config)
def help(args, config):
......
......@@ -333,9 +333,18 @@ def generate_nextflow_config(execution):
fragments = []
if execution['docker']:
fragments.append('''docker.enabled = true''')
fragments.append('''docker {
enabled = 'true'
fixOwnership = 'true'
runOptions = '--volume=/home/ubuntu/db:/databases'
}
''')
elif execution['singularity']:
fragments.append('''singularity.enabled = true''')
fragments.append('''singularity {
enabled = 'true'
runOptions = '--bind /home/ubuntu/db:/databases'
}
''')
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