Title: Missing input files error for expanded input in Snakemake
Tags: python;snakemake
Question: I have been having a strange error that I cannot fix. I am using snakemake 7.8.2 in a conda environment on an Ubuntu 20.04 machine (have also tried running this on our cluster and the same error occurred). For some odd reason one of my rules that has wildcards cannot be used as an expanded input for the following rule and continuously gives me an error that the input files are missing when they are very clearly created in the previous rule.
Here are my 2 rules:
### Use R to generate figures of each run's sequencing summary
rule rejected_seq_figures:
input:
seq_summary = &quot;resources/{RUNS}/guppy_outputs/sequencing_summary.txt&quot;,
rejected_ids = &quot;resources/{RUNS}/raw_reads/unblocked_read_ids.txt&quot;
output:
rejected_pie = report(&quot;results/rejected/seq_summary/{RUNS}_pie_chart.pdf&quot;, caption=&quot;report/rejected_pie.rst&quot;, category=&quot;Rejected Reads Sequence Summary&quot;, subcategory=&quot;{RUNS}&quot;),
histo_read_len = report(&quot;results/rejected/seq_summary/{RUNS}_histogram.pdf&quot;, caption=&quot;report/histo_read_len.rst&quot;, category=&quot;Rejected Reads Sequence Summary&quot;, subcategory=&quot;{RUNS}&quot;),
barcode_boxplot = report(&quot;results/rejected/seq_summary/{RUNS}_boxplot.pdf&quot;, caption=&quot;report/barcode_boxplot.rst&quot;, category=&quot;Rejected Reads Sequence Summary&quot;, subcategory=&quot;{RUNS}&quot;)
script:
&quot;scripts/rejected_seq_summary_figures.R&quot;
### Use R to create a summary table of all runs sequencing summaries
rule rejected_seq_table:
input:
sum_file_list = &quot;results/rejected/sum_file_list.tsv&quot;,
ids_file_list = &quot;results/rejected/ids_file_list.tsv&quot;,
rejected_pie = expand(&quot;results/rejected/seq_summary/{run}_pie_chart.pdf&quot;, run=RUNS)
output:
report(&quot;results/rejected/seq_summary/rejected_seq_summary_table.tsv&quot;, caption=&quot;report/rejected_seq_summary_table.rst&quot;, category=&quot;Rejected Reads Sequence Summary&quot;, subcategory=&quot;All Runs&quot;)
script:
&quot;scripts/rejected_seq_summary_table.R&quot;
The error snakemake produces as it tries to build the DAG:
MissingInputException in line 39 of /home/639893/Adaptive_Sequencing_Analysis_Workflow/workflow/rules/rejected_seq_summary.smk:
Missing input files for rule rejected_seq_table:
output: results/rejected/seq_summary/rejected_seq_summary_table.tsv
affected files:
results/rejected/seq_summary/ONT_skin1_adap2_pie_chart.pdf
results/rejected/seq_summary/ONT_skin1_adap_pie_chart.pdf
Those are exactly the expected outputs for the rule so the wildcard is working, there are not any typos or path mistakes either. The R script has been tested and the snakemake inputs and outputs work well, but when I add the rule to my workflow it continuously produces this error.
I have already tried: taking all three outputs for the figure rule as expanded inputs, changing the orders of the inputs for the following rule, putting the expanded input into the rule all rather than the following rule (I am just trying to get this rule to run), creating a temporary and touched text file rather than a pdf, making the path shorter and longer, changing the snakemake version to 7 different versions, just having one output for the first rule, and removing the report code from the outputs. All resulted in the same error and the rest of my workflow works well.
Additionally, I have another rule where I perform the same action (expanded output from a previous rule with wildcards as the input for the next) and that works perfectly fine. The only difference between the rules is that the one causing an error (above) uses an R script and the working rule just uses shell commands.
I would really appreciate any help because I need to be able to create figures like this and add them to the snakemake report. Thank you in advance.
Comment: If you execute: `snakemake [your opts] results/rejected/seq_summary/ONT_skin1_adap2_pie_chart.pdf results/rejected/seq_summary/ONT_skin1_adap_pie_chart.pdf` do you actually see rule `rejected_seq_figures` being executed and these files created?


Here is another answer: The issue turned out to be the constraint I used for the wildcard in my rules, &quot;RUNS&quot;.
The constraint that caused this problem was:
wildcard_constraints:
RUNS=&quot;^[^\/]+$&quot;
The characters &quot;^&quot; and &quot;$&quot; for the start and end of the string, respectively, cannot be used in wildcard constraints.
The correct format is:
wildcard_constraints:
RUNS=&quot;[^\/]+&quot;
Thank you to the Snakemake team for their quick responses and all the help!

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:06/21/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><snakemake>', 'Title': 'Missing input files error for expanded input in Snakemake', 'ViewCount': 71, 'id': 72701330, 'user_AboutMe': None, 'user_AccountId': 25609347.0, 'user_DisplayName': 'merfre', 'user_Reputation': 1.0, 'user_Views': 0.0, 'user_id': 19383014.0}}