# Mix globbing and wildcards when specifying rule input

Consider the following scenario.

├── sample-alice
│   ├── sequence_1.fastq
│   ├── sequence_2.fastq
│   ├── ...
│   └── sequence_n.fastq
└── sample-bob
├── sequence_1.fastq
├── sequence_2.fastq
├── ...
└── sequence_m.fastq


I'm trying to write a single rule in my Snakefile that will preprocess each sample generically. The rule will execute a single command that takes all of Fastq files associated with the sample simultaneously. The samples do not have the same number of Fastq files.

If it was a single sample, I could do something like this.

rule preprocess:
input: glob('sample-alice/*.fastq')
output: 'alice-clean.fastq'
shell: 'mypreproccmd {input} > {output}'


On the other hand, if there was a single Fastq file for each sample, I could use a wildcard to write a generic rule like this.

rule preprocess:
input: 'sample-{samp}/sequence_1.fastq'
output: '{samp}-clean.fastq'
shell: 'mypreproccmd {input} > {output}'


Is it possible to combine these two approaches to write a rule for handling multi-file samples generically?

• I'm not sure if this exactly solves your question, but in one of my workflows I use the directory as input (as specified in the config.yaml). The shell command then uses {input}/*.fastq.gz See some examples here: github.com/wdecoster/nano-snakemake/blob/master/rules/align.smk Mar 5 '19 at 20:29

rule preprocess: