I am getting started with Snakemake and I have a very basic question which I couldnt find the answer in snakemake tutorial. I want to creat a pipe that could accept multiple input files, for example, several samples with different lanes. I can create the pipe that deal with just one sample, Snakefile and config.yaml are as follows :
# Snakefile
configfile: "config.yaml"
SAMPLES = []
samp_lane = []
for samp,lane in config["samples"].items():
SAMPLES.append(samp)
samp_lane = lane
rawdir = config["raw_dir"]
Samples=config["samples"]
lanes=config["samples"]
rule all:
input:
expand("mapping/{sample}/{sample}_L{lane}.bam", sample=SAMPLES,lane=samp_lane)
rule bwa_map:
input:
R1 = config["raw_dir"]+"/{sample}_L{lane}_R1.fq.gz",
R2 = config["raw_dir"]+"/{sample}_L{lane}_R2.fq.gz"
output:
"mapping/{sample}/{sample}_L{lane}.bam"
log:
"log/bwa_map.log"
params:
ref = config["refgenome"]
threads: 8
shell:
"echo {input.R1} {input.R2} > {output} 2>{log}"
here is config file
samples:
KPGP-00001: [1,2,3,4,5,6]
# KPGP-00002: [1,2]
raw_dir: "/home/sxuan/WGS/rawdata"
refgenome: "hg19"
This could successfully deal with one sample input,but failed while add another sample "KPGP-0002". How to modify the code to process multi samples with consistent pattern? Sorry for my english and thanks in advance.
I'm guessing that should be samp_lane.append(samp) in the for loop?
Either way, the wildcards probably won't work as you expect them to. It might be considerably easier if you just merge your input files so you have a single file for each sample.