From d580c130c863c802adb20dce4c6b3930dfc2c8f8 Mon Sep 17 00:00:00 2001 From: Tobias Marschall <tobias.marschall@0ohm.net> Date: Wed, 10 Jan 2018 18:19:54 +0100 Subject: [PATCH] Add config option snv_calls to use existing SNV call sets --- Snake.config.json | 1 + Snakefile | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Snake.config.json b/Snake.config.json index 53cd157..eb71bc7 100644 --- a/Snake.config.json +++ b/Snake.config.json @@ -10,6 +10,7 @@ "samtools" : "samtools", "bcftools" : "bcftools", + "snv_calls" : "", "exclude_file" : "/g/korbel/meiers/tools/mosaicatcher/mosaicatcher/data/exclude/hg19.exclude", "variable_bins" : { diff --git a/Snakefile b/Snakefile index 4b8811b..9c82b17 100644 --- a/Snakefile +++ b/Snakefile @@ -289,13 +289,16 @@ rule prepare_strandphaser_config_per_chrom: print("bsGenome = '", config["R_reference"], "'", sep = "", file = f) - +def locate_snv_vcf(wildcards): + if config["snv_calls"] == "": + return "snv_calls/{}.{}.vcf".format(config["sample"], wildcards.chrom) + else: + return "external_snv_calls/{}.{}.vcf".format(config["sample"], wildcards.chrom) rule run_strandphaser_per_chrom: input: - mergedbam = "snv_calls/merged.bam", wcregions = "strand_states/" + config["sample"] + ".strandphaser_input.txt", - snppositions = "snv_calls/" + config["sample"] + ".{chrom}.vcf", + snppositions = locate_snv_vcf, configfile = "log/StrandPhaseR.{chrom}.config", strandphaser = "utils/R-packages/StrandPhaseR/R/StrandPhaseR", bamfolder = "bam" @@ -402,3 +405,15 @@ rule merge_SNV_calls: shell: config["bcftools"] + " concat -O v -o {output} {input}" +rule split_external_snv_calls: + input: + vcf = config["snv_calls"] + output: + vcf = "external_snv_calls/" + config["sample"] + ".{chrom}.vcf" + log: "external_snv_calls/" + config["sample"] + ".{chrom}.vcf.log" + params: + bcftools = config["bcftools"], + #sample = config["sample"] + shell: + "({params.bcftools} view --samples " + config["sample"] + " --types snps {input.vcf} {wildcards.chrom} | bcftools view --genotype het - > {output.vcf}) > {log} 2>&1" + -- GitLab