Question: No rule keywords allowed after run in snakefile
1
gravatar for Assa Yeroslaviz
3 days ago by
Assa Yeroslaviz1.3k
Munich
Assa Yeroslaviz1.3k wrote:

In my workflow I would like to have the option to choose which mapper to use. in my config file I have this statement

mapper: "bowtie2"

In the Snakefile I then have a mapping rule as such:

mapper = config['mapper']
...
rule Mapping:
    input:
        R1='{IDS}.conc.R1.fastq.gz',
        R2='{IDS}.conc.R2.fastq.gz',
    output:
        bam='{project}/{organism}/{mapper}/{IDS}.sorted.bam',
    params:
      mapper = {mapper}
    run:
    if params.mapper == "bowtie2":
        shell("bowtie2 --threads {config[threads]} --dovetail --very-sensitive-local --no-unal --no-mixed --no-discodant -X 2000 -x {params.index} -1 {input.R1} -2 {input.R2} 2> {log} | samtools view -Sbhu -q 7 -@8 - | samtools sort -@8 - -o {output.bam}")
    elif params.mapper == "bwa":
        shell("bwa -t {config[threads]} -M {params.index} {input.R1} {input.R2} | samtools view -Sbhu -q 7 -@8 - | samtools sort -@8 - -o {output.bam}")  
    elif params.mapper == "segemehl":
        shell("segemehl.x -i  {params.index} -d {params.ref} -S -t {config[threads]} -q {input.R1} -p {input.R2} | samtools view -Sbhu -q 7 -@8 - | samtools sort -@8 - -o {output.bam}")

But I keep getting an error message telling me I am not allow to use keywords within a run statement.

I don't understand this error. I have seen enough examples (here, or here) where this should work.

I would appreciate any corrections or suggestion.

thanks Assa

snakemake python run • 69 views
ADD COMMENTlink modified 3 days ago by Thibault D.690 • written 3 days ago by Assa Yeroslaviz1.3k
0
gravatar for Thibault D.
3 days ago by
Thibault D.690
European Union
Thibault D.690 wrote:

Hi,

Within the run section, you should use snakemake.input["R1"] instead of using wildcards. Or, use snakemake.wildcards[...].

If you do not mind, here are some unrelated advices:

  • Use the "threads" keyword to handle threading within Snakemake
  • input and output sections should have the same wildcards
ADD COMMENTlink modified 1 day ago • written 3 days ago by Thibault D.690

thanks for the advices. I have found it easier to handle the number of threads used, when I inout it once in the config file and not each time in every rule. Why is it better to set separately?

The input and output have the same wildcard- {IDS}. The rest of the path point to where the data should be saved.

ADD REPLYlink written 3 days ago by Assa Yeroslaviz1.3k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1289 users visited in the last hour