From 9e565c2f346f96305147634d55ff8f7f051bc71f Mon Sep 17 00:00:00 2001 From: Peter van 't Hof <p.j.van_t_hof@lumc.nl> Date: Mon, 17 Nov 2014 08:54:45 +0100 Subject: [PATCH] Added useIndelRealigner and useBaseRecalibration option --- .../pipelines/gatk/GatkVariantcalling.scala | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 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 b016e17dc..915371c72 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 @@ -41,12 +41,20 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr var useHaplotypecaller: Option[Boolean] = config("use_haplotypecaller", default = true) var useUnifiedGenotyper: Option[Boolean] = config("use_unifiedgenotyper", default = false) var useAllelesOption: Option[Boolean] = config("use_alleles_option", default = false) + var useIndelRealigner: Boolean = config("use_indel_realign", default = true) + var useBaseRecalibration: Boolean = config("use_base_recalibration", default = true) def init() { if (outputName == null && sampleID != null) outputName = sampleID else if (outputName == null) outputName = "noname" if (outputDir == null) throw new IllegalStateException("Missing Output directory on gatk module") else if (!outputDir.endsWith("/")) outputDir += "/" + + val baseRecalibrator = new BaseRecalibrator(this) + if (useBaseRecalibration && baseRecalibrator.knownSites.isEmpty) { + logger.warn("No Known site found, skipping base recalibration") + useBaseRecalibration = false + } } private def doublePreProces(files: List[File]): List[File] = { @@ -54,11 +62,10 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr if (files.isEmpty) throw new IllegalStateException("Files can't be empty") if (!doublePreProces.get) return files val markDub = MarkDuplicates(this, files, new File(outputDir + outputName + ".dedup.bam")) - if (dbsnp != null) { - add(markDub, isIntermediate = true) + add(markDub, isIntermediate = useIndelRealigner) + if (useIndelRealigner) { List(addIndelRealign(markDub.output, outputDir, isIntermediate = false)) } else { - add(markDub, isIntermediate = true) List(markDub.output) } } @@ -67,8 +74,14 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr scriptOutput.bamFiles = if (preProcesBams.get) { var bamFiles: List[File] = Nil for (inputBam <- inputBams) { - var bamFile = addIndelRealign(inputBam, outputDir) - bamFiles :+= addBaseRecalibrator(bamFile, outputDir, isIntermediate = bamFiles.size > 1) + var bamFile = inputBam + if (useIndelRealigner) { + bamFile = addIndelRealign(bamFile, outputDir, isIntermediate = useBaseRecalibration) + } + if (useBaseRecalibration) { + bamFile = addBaseRecalibrator(bamFile, outputDir, isIntermediate = bamFiles.size > 1) + } + bamFiles :+= bamFile } doublePreProces(bamFiles) } else if (inputBams.size > 1 && doublePreProces.get) { @@ -188,7 +201,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr } def addBaseRecalibrator(inputBam: File, dir: String, isIntermediate: Boolean = false): File = { - val baseRecalibrator = BaseRecalibrator(this, inputBam, swapExt(dir, inputBam, ".bam", ".baserecal")) //with gatkArguments { + val baseRecalibrator = BaseRecalibrator(this, inputBam, swapExt(dir, inputBam, ".bam", ".baserecal")) if (baseRecalibrator.knownSites.isEmpty) { logger.warn("No Known site found, skipping base recalibration, file: " + inputBam) @@ -196,7 +209,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr } add(baseRecalibrator) - val baseRecalibratorAfter = BaseRecalibrator(this, inputBam, swapExt(dir, inputBam, ".bam", ".baserecal.after")) //with gatkArguments { + val baseRecalibratorAfter = BaseRecalibrator(this, inputBam, swapExt(dir, inputBam, ".bam", ".baserecal.after")) baseRecalibratorAfter.BQSR = baseRecalibrator.o add(baseRecalibratorAfter) -- GitLab