Skip to content

Commit c5f181c

Browse files
committed
Adding step to check and enforce a maximum snakemake version
1 parent a1b8a4c commit c5f181c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

genome-seek

+23-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ from src.utils import (
5050
pairs,
5151
permissions,
5252
check_cache,
53-
require
53+
require,
54+
tool_version
5455
)
5556

5657

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

104126
if not sub_args.batch_id:
105127
# Set value of batch identifer by

src/utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ def tool_version(tool, cmd, strict = False):
239239
c = Colors
240240
version = ''
241241
try:
242-
version = subprocess.check_output(cmd).strip().decode('utf-8')
242+
# Merge standard error to standard output
243+
# some tools print version information to
244+
# stderr instead of stdout
245+
version = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip().decode('utf-8')
243246
except Exception as e:
244247
err("\n{0}{1}Warning: could not get version of {2} using: '{3}'{4}".format(
245248
c.bg_black, c.yellow, tool, ' '.join(cmd), c.end)

0 commit comments

Comments
 (0)