I want to create a list of BAM files in the folder using this command line:
ls *.bam > bam_list
But, I would like to integrate this in snakemake. How to do this? This is what I tried, but is not working:
rule bam_list:
input:
inlist ="dup/{sample}.bam"
output:
outlist = "dup/bam_list"
shell:
"""
ls {input.inlist} > {output.outlist}
"""
The output bam_list looks like this:
bob.bam
anne.bam
john.bam
You could completely skip the input:
rule bam_list:
output:
outlist = "dup/bam_list"
shell:
"""
ls *.bam > {output.outlist}
"""
edit
rule bam_list:
input:
rules.previous.output
output:
outlist = "dup/bam_list"
params:
indir = lambda wildcards, input: os.path.dirname(input[0])
shell:
"""
ls {params.indir}*.bam > {output.outlist}
"""
for more complex logic you will probably have to use input functions.