I am looking for advice on testing input functions in Snakemake. Input functions are commonly defined in the common.smk
file, e.g.:
import pandas as pd
from snakemake.io import glob_wildcards
def find_fastq_files(wildcards) -> list[str]:
"""
Return a list of fastq files given sample name and processing stage.
"""
# Find the fastq file names for the sample
sample_dir = f"data/{wildcards.sample}/fastq"
file_names = glob_wildcards(f"{sample_dir}/{{file_name}}.fastq.gz").file_name
# return the file paths
return [f"{sample_dir}/{f}.fastq.gz" for f in file_names]
My current approach involves parsing the output of a snakemake dry run, followed by assertion using pytest
. It would be cleaner to circumvent the dry run and test the input function directly, however I have not found an easy way to import a function that is defined within common.smk
.
What would be the recommended way to test such an input function? Thanks!