I have a function def get_ref_name and a rule called bioawk on my snakemake script.
def get_ref_name(ref_genome_path):
file_name = os.path.basename(ref_genome_path)
ref_name = file_name.split('.')[0]
return ref_name
rule all:
input:
bioawk_ref_size_file = expand("results/{prefix}/bioawk/{ref_name}.size", prefix=PREFIX, ref_name=get_ref_name(config["reference_genome"]))
rule bioawk:
input:
ref_name=get_ref_name(config["reference_genome"]),
ref_genome=config["reference_genome"]
output:
reference_size_file=f"results/{{prefix}}/bioawk/{{ref_name}}.size"
conda:
"envs/bioawk.yaml"
shell:
"bioawk -c fastx '{{ print $name, length($seq) }}' < {input.ref_genome} > {output.reference_size_file}"
I am trying to get the name of the reference genome from a path specified on my config file. So for example, if the path leads to a KPNIH1.fasta
file the output of the function is supposed to be KPNIH1
. I am trying to call the output from the get_ref_name
function in the input section as ref_name
and calling it again in the output section {{ref_name}}
. However, I am getting this error:
MissingInputException in line 320 of /.../snpkit-snakemake-test/snpkit_v3.smk:
Missing input files for rule bioawk:
KPNIH1
I assume there may be an issue with the way i am calling the function in the input section but not sure how to fix it. Thanks in advance for your help!
If both your "inputs" are from a config file, are they really inputs? You could place them in
params
, becauseinputs
are expected to be files.