1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
from pathlib import Path
# Untested:
# ancient
# subworkflows
# directory
OUTDIR = Path("outdir")
existing_file = Path("existing_file.txt")
rule all:
input:
OUTDIR / "output_existing",
OUTDIR / "output_temp",
OUTDIR / "output_protected",
OUTDIR / "output_other_rule_output_existing",
OUTDIR / "function_unpacking/output_function_unpacking",
rule input_Path:
input: Path("{sample}_file.txt")
output: OUTDIR / "output_{sample}"
log: OUTDIR / "log_{sample}"
shell:
"""
cat {input} > {output}
echo log {wildcards.sample} > {log}
"""
rule input_Path_output_temp:
input: existing_file
output: temp(OUTDIR / "output_temp")
log: OUTDIR / "log_temp"
shell:
"""
cat {input} > {output}
echo log temp > {log}
"""
rule input_Path_output_protected:
input: existing_file
output: protected(OUTDIR / "output_protected")
log: OUTDIR / "log_protected"
shell:
"""
cat {input} > {output}
echo log protected > {log}
"""
rule input_other_rule_output:
input: rules.input_Path.output
output: OUTDIR / "output_other_rule_output_{sample}"
log: OUTDIR / "log_other_rule_output_{sample}"
shell:
"""
cat {input} > {output}
echo log protected > {log}
"""
def myfunc1():
return [existing_file]
def myfunc2():
return {'existing_file2': existing_file}
rule input_function_unpacking:
input:
*myfunc1(),
**myfunc2(),
output: OUTDIR / "function_unpacking/output_function_unpacking"
log: OUTDIR / "log_function_unpacking"
shell:
"""
echo {input[0]} > {output}
echo {input.existing_file2} >> {output}
echo log function unpacking > {log}
"""
|