Skip to content

Commit

Permalink
Didn't need rule order, just a carefully written branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Guest committed Oct 7, 2024
1 parent b5ba520 commit c91b45a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions workflow/playpen.smk
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ rule a2b:
output: "{path}.b"
shell: "sed -e 's/a/b/g' {wildcards.path}.a >{wildcards.path}.b"

def wildcard_path_endswith_gz(wildcards):
return wildcards["path"].endswith(".gz")

rule gunzip:
input:
branch(wildcard_path_endswith_gz,
then=[],
otherwise="{path}.gz")
branch(lambda wildcards: not wildcards["path"].endswith(".gz"),
then="{path}.gz",
otherwise="/N/A")
output: "{path}"
shell: "gunzip -k {wildcards.path}.gz"

rule gzip:
input: "{path}"
input:
branch(lambda wildcards: not wildcards["path"].endswith(".gz"),
then="{path}",
otherwise="/N/A")
output: "{path}.gz"
shell: "gzip -k {wildcards.path}"

ruleorder: a2b > gzip > gunzip

0 comments on commit c91b45a

Please sign in to comment.