From 137ecdb3976a68cf0db6dc9212c4e256cf944f63 Mon Sep 17 00:00:00 2001
From: Peter van 't Hof <p.j.van_t_hof@lumc.nl>
Date: Tue, 4 Nov 2014 11:42:30 +0100
Subject: [PATCH] Added genotypemergeoption option, needed since Gatk 3.3
 Allele mode now also on discovery alleles

---
 .../biopet/pipelines/gatk/GatkVariantcalling.scala | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/pipelines/gatk/GatkVariantcalling.scala b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/pipelines/gatk/GatkVariantcalling.scala
index 465a946ee..e4899798f 100644
--- a/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/pipelines/gatk/GatkVariantcalling.scala
+++ b/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/pipelines/gatk/GatkVariantcalling.scala
@@ -84,6 +84,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
 
     if (variantcalling) {
       var mergBuffer: SortedMap[String, File] = SortedMap()
+      def mergeList = mergBuffer map { case (key, file) => TaggedFile(removeNoneVariants(file), "name=" + key) }
 
       if (sampleID != null && (useHaplotypecaller.get || config("joint_genotyping", default = false).getBoolean)) {
         val hcGvcf = new HaplotypeCaller(this)
@@ -141,10 +142,17 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
       mergBuffer += ("9.raw" -> scriptOutput.rawFilterVcfFile)
 
       if (useAllelesOption.get) {
+        val tempFile = if (mergeList.toList.size > 1) {
+          val allelesTemp = CombineVariants(this, mergeList.toList, outputDir + outputName + ".alleles_temp.vcf.gz")
+          allelesTemp.genotypemergeoption = org.broadinstitute.gatk.utils.variant.GATKVariantContextUtils.GenotypeMergeType.UNSORTED
+          add(allelesTemp, isIntermediate = true)
+          allelesTemp.out
+        } else mergeList.toList.head
+
         val alleleOnly = new CommandLineFunction {
-          @Input val input: File = scriptOutput.rawFilterVcfFile
+          @Input val input: File = tempFile
           @Output val output: File = outputDir + "raw.allele_only.vcf.gz"
-          @Output val outputindex: File = outputDir + "raw.allele_only.vcf.gz.tbi"
+          @Output val outputindex: File = outputDir + "raw.allele__temp_only.vcf.gz.tbi"
           def commandLine = "zcat " + input + " | cut -f1,2,3,4,5,6,7,8 | bgzip -c > " + output + " && tabix -pvcf " + output
         }
         add(alleleOnly, isIntermediate = true)
@@ -181,8 +189,8 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
         sv.out
       }
 
-      def mergeList = mergBuffer map { case (key, file) => TaggedFile(removeNoneVariants(file), "name=" + key) }
       val cvFinal = CombineVariants(this, mergeList.toList, outputDir + outputName + ".final.vcf.gz")
+      cvFinal.genotypemergeoption = org.broadinstitute.gatk.utils.variant.GATKVariantContextUtils.GenotypeMergeType.UNSORTED
       add(cvFinal)
       scriptOutput.finalVcfFile = cvFinal.out
     }
-- 
GitLab