Reputation: 87
I am new to snakemake and would like to use the following rule :
input_path = config["PATH"]
samples = pd.read_csv(config["METAFILE"], sep = '\t', header = 0)['sample']
rule getPaired:
output:
fwd = temp(tmp_path + "/reads/{sample}_fwd.fastq.gz"),
rev = temp(tmp_path + "/reads/{sample}_rev.fastq.gz")
params:
input_path = input_path
run:
shell("scp -i {params.input_path}/{wildcards.sample}_*1*.f*q.gz {output.fwd}"),
shell("scp -i {params.input_path}/{wildcards.sample}_*2*.f*q.gz {output.rev}")
Input files have different patterns :
The getPaired rule works for input like {sample}_[1-2].fq.gz but not for the second pattern.
What am I doing wrong ?
Upvotes: 1
Views: 201
Reputation: 3691
You should make use of input functions. I made an example which isn't really what you need, but I think it should clearly show what you want to achieve:
paths = {'sample1': '/home/jankees/data',
'sample2': '/mnt/data',
'sample3': '/home/christina/fastq'}
extensions = {'sample1': '.fq.gz',
'sample2': '.fq.gz',
'sample3': '.fastq.gz'}
def get_input(wildcards):
input_file = paths[wildcards.sample] + "/read/" + wildcards.sample + extensions[wildcards.sample]
return input_file
rule all:
input:
["sample1_trimmed.fastq.gz",
"sample2_trimmed.fastq.gz",
"sample3_trimmed.fastq.gz"]
rule trim:
input:
get_input
output:
"{sample}_trimmed.fastq.gz"
shell:
"touch {output}"
Upvotes: 2