Skip to content
Snippets Groups Projects
Commit 7b72d74e authored by Yohan Jarosz's avatar Yohan Jarosz
Browse files

Mount the current IMP codebase via --current option

parent 2b4417ae
No related branches found
No related tags found
No related merge requests found
......@@ -21,8 +21,8 @@ __doc__ = """Integrated Metaomic Pipeline.
(____)(_/\/\_)(__)
Usage:
IMP [-m MG1 -m MG2] [-t MT1 -t MT2] -o OUTPUT [--enter] [--norm] [-r REPO] [-n CONTAINER] [-v VERSION] [-c CONFIGFILE] [-d DBPATH] [-a ASSEMBLER] [-e ENV] ... [COMMANDS ...]
IMP --init [-d DBPATH] [-n CONTAINER] [-v VERSION] [-r REPO]
IMP [-m MG1 -m MG2] [-t MT1 -t MT2] -o OUTPUT [--enter] [--norm] [--current] [-r REPO] [-n CONTAINER] [-v VERSION] [-c CONFIGFILE] [-d DBPATH] [-a ASSEMBLER] [-e ENV] ... [COMMANDS ...]
IMP --init [--current] [-d DBPATH] [-n CONTAINER] [-v VERSION] [-r REPO]
IMP (-h | --help)
IMP --version
......@@ -32,6 +32,7 @@ Options:
--init Initialize IMP databases (Take a while).
--norm Don't delete the container after use. Useful for debugging.
--ask Ask to create directory if it doesn't exist.
--current Use the current version of the IMP codebase (what you have pulled).
-c CONFIG Pass a user defined config file. Default: conf/userconfig.imp.json
-h --help Show this help and exit
-m MG Path to the metagenomics paired files (must be 2 files).
......@@ -54,6 +55,8 @@ Typical use:
./IMP --init -d /path/to/databases_directory
./IMP -m input/mg.r1.fq -m input/mg.r2.fq -t input/mt.r1.fq -t input/mt.r2.fq -o output_directory -d /path/to/databases_directory
# use the IMP code you have pulled instead of the one shipped inside the container.
./IMP -m input/mg.r1.fq -m input/mg.r2.fq -t input/mt.r1.fq -t input/mt.r2.fq -o output_directory --current
""".format(
name=IMP_IMAGE_NAME,
......@@ -140,16 +143,22 @@ def init(args):
Must be run at least once.
"""
CURRENT_PATH = Path(__file__).parent.abspath()
version = args['-v']
container_name = args['-n']
database_path = Path(args['-d']).abspath()
docker_cmd = 'docker run --rm -v {p}:/code -v {d}:/databases {n}:{v}'.format(
p=CURRENT_PATH,
d=database_path,
n=args['-n'],
v=args['-v']
)
# prepare docker command
docker_cmd = 'docker run --rm -v {d}:/databases {n}:{v}'
formatting_args = {
'd': database_path,
'n': args['-n'],
'v': args['-v']
}
# override docker command if the user want to mount a specific version of IMP codebase.
if args[--'current']:
formatting_args['p'] = CURRENT_PATH
docker_cmd = 'docker run --rm -v {p}:/code -v {d}:/databases {n}:{v}'
# format docker command
docker_cmd.format(**formatting_args)
# IMP command + user mapping (see https://github.com/docker/docker/pull/12648)
cmd = docker_cmd + map_user('snakemake -s /code/rules/init', '/databases')
print("Executing", '"', cmd, '"')
subprocess.call(cmd, shell=True)
......@@ -183,12 +192,14 @@ def run(args):
# configure IMP mount point to the docker container
mount_points = [
'-v %s:/data' % common_path,
'-v %s:/code' % CURRENT_PATH,
'-v %s:/output' % output,
'-v %s:/databases' % database_path,
]
# add code mount point if the user want to mount a specific version of IMP codebase.
if args[--'current']:
mount_points.append('-v %s:/code' % CURRENT_PATH)
# environement variables: add MG and MT data and config if specified
# environment variables: add MG and MT data and config if specified
envs = ['-e {}="{}"'.format(*e.split('=')) for e in args['-e']]
# prepare MG and MT data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment