Skip to content

Commit

Permalink
Adding step to check and enforce a maximum snakemake version
Browse files Browse the repository at this point in the history
  • Loading branch information
skchronicles committed Jun 28, 2024
1 parent a1b8a4c commit c5f181c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
24 changes: 23 additions & 1 deletion genome-seek
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ from src.utils import (
pairs,
permissions,
check_cache,
require
require,
tool_version
)


Expand Down Expand Up @@ -100,6 +101,27 @@ def run(sub_args):
# The pipelines has only two requirements:
# snakemake and singularity
require(['snakemake', 'singularity'], ['snakemake', 'singularity'])
# Check the version of snakemake in the
# user's $PATH, the pipeline supports
# snakemake versions < 8.0.0.
snakemake_version = tool_version('snakemake', ['snakemake', '--version'], strict = True)
parsed_version = re.search(
'^(?P<prefix>v)?(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)',
snakemake_version.split()[-1]
)
# Check the parsed major version of snakemake
if int(parsed_version.group('major')) >= 8:
# Snakemake versions greater than or equal
# to 8.0.0 are not supported by genome-seek.
# This verison of snakemake introduced a set
# of breaking changes that are not compatible
# with the current pipeline. We will strictly
# enforce this until we move to profiles.
fatal(
'Error: Snakemake version "{}" is not supported! Please use a version less than "8.0.0".'.format(
snakemake_version
)
)

if not sub_args.batch_id:
# Set value of batch identifer by
Expand Down
5 changes: 4 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ def tool_version(tool, cmd, strict = False):
c = Colors
version = ''
try:
version = subprocess.check_output(cmd).strip().decode('utf-8')
# Merge standard error to standard output
# some tools print version information to
# stderr instead of stdout
version = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode('utf-8')
except Exception as e:
err("\n{0}{1}Warning: could not get version of {2} using: '{3}'{4}".format(
c.bg_black, c.yellow, tool, ' '.join(cmd), c.end)
Expand Down

0 comments on commit c5f181c

Please sign in to comment.