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}
		"""

