0

I have Snakefile as following:

SAMPLES, = glob_wildcards("data/{sample}_R1.fq.gz")
rule all: 
    input:
        expand("samtools_sorted_out/{sample}.raw.snps.indels.g.vcf", sample=SAMPLES), 
        expand("samtools_sorted_out/combined_gvcf")
rule combine_gvcf:
    input: "samtools_sorted_out/{sample}.raw.snps.indels.g.vcf"
    output:directory("samtools_sorted_out/combined_gvcf")
    params: gvcf_file_list="gvcf_files.list",
            gatk4="/storage/anaconda3/envs/exome/share/gatk4-4.1.0.0-0/gatk-package-4.1.0.0-local.jar"
    shell:"""
        java -DGATK_STACKTRACE_ON_USER_EXCEPTION=true \
            -jar {params.gatk4} GenomicsDBImport \
            -V {params.gvcf_file_list} \
            --genomicsdb-workspace-path {output}
       """

When I test it with dry run, I got error:

RuleException in line 335 of /data/yifangt/exomecapture/Snakefile:
Wildcards in input, params, log or benchmark file of rule combine_gvcf cannot be determined from output files:
'sample'

There are two places that I need some help:

  1. The {output} is a folder that will be created by the shell part;
  2. The {output} folder was hard-coded manually required by the command line (and the contents are unknown ahead of time).

The problem seems to be with the {output} without expansion as compared with the {input} which does. How should I handle with this situation? Thanks a lot!

Yifangt
  • 151
  • 1
  • 10
  • 1
    Wildcards are determined based on `output`, which means that you can't use a wildcard in `input` that's not part of `output`. In rule `combine_gvcf`, wildcard `sample` is not used in `output`, which leads to your error. – Manavalan Gajapathy Mar 22 '19 at 01:34
  • 1
    Looks like you need to `expand` in your input to `combine_gvcf`. See my recent answer to this: https://stackoverflow.com/questions/55300845/snakemake-wildcards-in-input-files-cannot-be-determined-from-output-files – Russ Hyde Mar 22 '19 at 14:16
  • Thanks @JeeYem and @Russ. It seems I need digest more on both the `expand()` and `directory() `directives – Yifangt Mar 27 '19 at 22:38

0 Answers0