Skip to content
Snippets Groups Projects
Commit eec279c5 authored by Blaise Li's avatar Blaise Li
Browse files

Source decorator to apply wildcards to outputs.

This is used to circumvent the change in behaviour in snakemake.
https://bitbucket.org/snakemake/snakemake/issues/956/placeholders-not-properly-matched-with
parent 1438776f
No related branches found
No related tags found
No related merge requests found
......@@ -7,4 +7,4 @@ from .libworkflows import (
sum_feature_counts, sum_htseq_counts, sum_intersect_counts,
test_na_file,
texscape,
warn_context)
warn_context, wc_applied)
......@@ -10,6 +10,7 @@ import matplotlib as mpl
import matplotlib.pyplot as plt
from re import compile, sub
from snakemake import shell
from snakemake.io import apply_wildcards
# To parse genome size information
from bs4 import BeautifulSoup
......@@ -108,6 +109,25 @@ def ensure_relative(path, basedir):
else:
return path
def wc_applied(source_function):
"""
This can be used as a decorator for rule input sourcing functions.
This ensures that results returned in the form of explicit output from a
rule has the wildcard substitution applied.
See <https://bitbucket.org/snakemake/snakemake/issues/956/placeholders-not-properly-matched-with>.
"""
def wc_applied_source_func(wildcards):
filename_templates = source_function(wildcards)
if not isinstance(filename_templates, (str, bytes)):
return [apply_wildcards(filename_template, wildcards) for filename_template in filename_templates]
else:
return apply_wildcards(filename_templates, wildcards)
return wc_applied_source_func
def cleanup_and_backup(output_dir, config):
"""Performs cleanup and backup according to the information present in the
*config* dictionary."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment