Search code examples
snakemakerna-seq

always report errors: 'str' object is not callable in my snakemake for RNA-seq workflow


I want to use snakemake to write my RNA-seq pipeline,but it always report same errors.It annoys me !

The following shows whole file at present folder.

|-- 01_raw
|   |-- epcr1_1.fastq
|   |-- epcr1_2.fastq
|   |-- epcr2_1.fastq
|   |-- epcr2_2.fastq
|   |-- wt1_1.fastq
|   |-- wt1_2.fastq
|   |-- wt2_1.fastq
|   `-- wt2_2.fastq
|-- 02_clean
|   `-- id.txt
|-- Snakefile
`-- Snakemake2.py

there is my whole content in Snakefile

SBT=["wt1","wt2","epcr1","epcr2"]


rule all:
    input:
        expand("02_clean/{nico}_1.paired.fq.gz","02_clean/{nico}_2.paired.fq.gz",nico=SBT)

rule trim_galore:
    input:
        "01_raw/{nico}_1.fastq",
        "01_raw/{nico}_2.fastq"
    output:
        "02_clean/{nico}_1.paired.fq.gz",
        "02_clean/{nico}_1.unpaired.fq.gz",
        "02_clean/{nico}_2.paired.fq.gz",
        "02_clean/{nico}_2.unpaired.fq.gz",
    log:
        "02_clean/{nico}_qc.log"
    shell:
        "Trimmomatic PE -threads 16 {input[0]} {input[1]} {output[0]} {output[1]} {output[2]} {output[3]} ILLUMINACLIP:/software/Trimmomatic-0.36/adapters/TruSeq3-PE-2.fa:2:30:10 LEADING:3 TRAILING:3 SLIDINGWINDOW:4:15 MINLEN:36 &"

when I use command "snakemake -np" to dry_run it, I hope it can run smoothly,but It always report same errors:

TypeError in line 6 of /root/s/r/snakemake/my_rnaseq_data/Snakefile:
'str' object is not callable
  File "/root/s/r/snakemake/my_rnaseq_data/Snakefile", line 6, in <module>

and the line6 is

expand("02_clean/{nico}_1.paired.fq.gz","02_clean/{nico}_2.paired.fq.gz",nico=SBT)

I dont't know what's wrong with it. It annoys me whole day! Hope somebody can help me.Thanks advance!


Solution

  • Problem is with how you are using expand function in rule all. expand acts on one string, but you were supplying two. This would work:

    rule all:
        input:
            expand("02_clean/{nico}_1.paired.fq.gz", nico=SBT),
            expand("02_clean/{nico}_2.paired.fq.gz", nico=SBT)
    

    Or, you could further simplify:

    rule all:
        input:
            expand("02_clean/{nico}_{n}.paired.fq.gz", nico=SBT, n=[1,2])