I am trying desperately to have a rule downloading my fastq files before executing the following rules. I tried a lot of things including what is suggested here: http://ivory.idyll.org/blog/tag/snakemake.html
Below is a simplified version of my snakemake:
######### functions
def read_samplesTable(inputTable):
data = pandas.read_csv(inputTable)
# Verify column names
if not {'run', 'organism', 'name', 'experiment_title', 'cell_line', 'rep', 'study_name', 'library_strategy', 'library_layout', 'study_title'}.issubset(data.columns.values):
raise KeyError("The samples file must contain the following named columns: 'run', 'organism', 'name', 'experiment_title', 'cell_line', 'rep', 'study_name', 'library_strategy', 'library_layout', 'study_title'")
return data
def retrieveName(description):
result = []
for items in description.iteritems():
result.append(items[1].split(":")[0])
return result
######### Variables
input_table = config["samples"]["summaryFile"]
samplesData = read_samplesTable(input_table)
index_single = samplesData['library_layout'] == 'SINGLE - '
samplesData_single = samplesData[index_single]
gsm_single = retrieveName(samplesData_single["experiment_title"])
outputName_single = samplesData_single['name'] + "_" + samplesData_single['run'] + "_" + gsm_single + "_" + samplesData_single['study_name'] + "_" + samplesData_single['cell_line'] + "_" + samplesData_single['rep']
single_samples = outputName_single.tolist()
names_srrID_single = samplesData_single['run']
############ Rule
rule all:
input:
expand("data/single/{singleEndName}.fastq.gz", singleEndName = single_samples)
rule download_fastq_single:
output:
singleFastq = "data/single/{singleEndName}.fastq.gz"
params:
outputdirectory = config["rawdata"]["fastqrootfolder"]
ssridsingle = lambda wildcards: samplesData_single.loc[wildcards.names_srrID_single, "run"]
shell:
"fastq-dump --accession {params.srridsingle} --defline-seq '@$sn[_$rn]/$ri' --defline-qual \'+\' --gzip --outdir {params.outputdirectory}"
The rule is in a separate file 'download-fastq-snakefile' and I get the error SyntaxError in line 6 of download-fastq-snakefile
.
The problem, as I expected, is coming from the line ssridsingle = lambda wildcards: samplesData_single.loc[wildcards.names_srrID_single, "run"]
If you could help me that would be fantastic!
Thanks
My guess the problem is simply a missing comma:
params:
outputdirectory = config["rawdata"]["fastqrootfolder"], <-- add this comma
ssridsingle = lambda wildcards: samplesData_single.loc[wildcards.names_srrID_single, "run"]