user3224522
user3224522

Reputation: 1151

Merge vcf files in snakemake

After running the variant calling, I would like to merge only specific outputs as shown in d. This is giving me an error of missing input files. How to solve this?

d = {"bob": ["bob:0-10.view.filtered.vcf", "bob:10-20.view.filtered.vcf"]
     "ann": ["ann:0-20.view.filtered.vcf", "ann:20-30.view.filtered.vcf"]}

rule varcall:
    input:
        ref="reference.fasta",
        bam="bam_list"
    output:
        outf ="var/{chr}.view.filtered.vcf"
    shell:
        """
        freebayes -r {wildcards.chr} -f {input.ref} --bam-list {input.bam} -v {output.outf}
        """

wildcard_constraints:
    chromosome = "|".join(chromosomes)

rule merge:
    input:
        lambda w: d[w.chromosome]
    output:
        outf = "merged/{chromosome}.vcf"
    params:
        lambda w: "I=" + " I=".join(d[w.chromosome])
    shell:
        "java -jar picard.jar GatherVcfs {params[0]} O={output.outf}"

Upvotes: 0

Views: 175

Answers (1)

dariober
dariober

Reputation: 9062

The output of varcall is

outf ="var/{chr}.view.filtered.vcf"

so probably dictionary d should include the directory var:

d = {"bob": ["var/bob:0-10.view.filtered.vcf", "var/bob:10-20.view.filtered.vcf"]
     "ann": ["var/ann:0-20.view.filtered.vcf", "var/ann:20-30.view.filtered.vcf"]}

Upvotes: 1

Related Questions