Skip to content
Snippets Groups Projects
Commit 1144a30e authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added link to final file when only 1 lib

parent 1442d071
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri ...@@ -50,6 +50,7 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
/** Library variantcalling */ /** Library variantcalling */
val gatkVariantcalling = new GatkVariantcalling(qscript) val gatkVariantcalling = new GatkVariantcalling(qscript)
gatkVariantcalling.doublePreProces = false
gatkVariantcalling.sampleID = sampleId gatkVariantcalling.sampleID = sampleId
gatkVariantcalling.outputDir = libDir gatkVariantcalling.outputDir = libDir
...@@ -112,7 +113,6 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri ...@@ -112,7 +113,6 @@ class GatkPipeline(val root: Configurable) extends QScript with MultiSampleQScri
if (bamFile.isDefined) { if (bamFile.isDefined) {
gatkVariantcalling.inputBams = List(bamFile.get) gatkVariantcalling.inputBams = List(bamFile.get)
gatkVariantcalling.variantcalling = config("library_variantcalling", default = false) gatkVariantcalling.variantcalling = config("library_variantcalling", default = false)
gatkVariantcalling.preProcesBams = true
gatkVariantcalling.init gatkVariantcalling.init
gatkVariantcalling.biopetScript gatkVariantcalling.biopetScript
addAll(gatkVariantcalling.functions) addAll(gatkVariantcalling.functions)
......
...@@ -7,6 +7,7 @@ package nl.lumc.sasc.biopet.pipelines.gatk ...@@ -7,6 +7,7 @@ package nl.lumc.sasc.biopet.pipelines.gatk
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand } import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand }
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.extensions.Ln
import nl.lumc.sasc.biopet.tools.{ VcfStats, MpileupToVcf, VcfFilter, MergeAlleles } import nl.lumc.sasc.biopet.tools.{ VcfStats, MpileupToVcf, VcfFilter, MergeAlleles }
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.extensions.gatk.{ AnalyzeCovariates, BaseRecalibrator, GenotypeGVCFs, HaplotypeCaller, IndelRealigner, PrintReads, RealignerTargetCreator, SelectVariants, CombineVariants, UnifiedGenotyper } import nl.lumc.sasc.biopet.extensions.gatk.{ AnalyzeCovariates, BaseRecalibrator, GenotypeGVCFs, HaplotypeCaller, IndelRealigner, PrintReads, RealignerTargetCreator, SelectVariants, CombineVariants, UnifiedGenotyper }
...@@ -38,12 +39,12 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr ...@@ -38,12 +39,12 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
@Argument(doc = "Sample name", required = false) @Argument(doc = "Sample name", required = false)
var sampleID: String = _ var sampleID: String = _
var preProcesBams: Option[Boolean] = config("pre_proces_bams", default = true) var preProcesBams: Boolean = config("pre_proces_bams", default = true)
var variantcalling: Boolean = true var variantcalling: Boolean = true
var doublePreProces: Option[Boolean] = config("double_pre_proces", default = true) var doublePreProces: Boolean = config("double_pre_proces", default = true)
var useHaplotypecaller: Option[Boolean] = config("use_haplotypecaller", default = true) var useHaplotypecaller: Boolean = config("use_haplotypecaller", default = true)
var useUnifiedGenotyper: Option[Boolean] = config("use_unifiedgenotyper", default = false) var useUnifiedGenotyper: Boolean = config("use_unifiedgenotyper", default = false)
var useAllelesOption: Option[Boolean] = config("use_alleles_option", default = false) var useAllelesOption: Boolean = config("use_alleles_option", default = false)
var useMpileup: Boolean = config("use_mpileup", default = true) var useMpileup: Boolean = config("use_mpileup", default = true)
var useIndelRealigner: Boolean = config("use_indel_realign", default = true) var useIndelRealigner: Boolean = config("use_indel_realign", default = true)
var useBaseRecalibration: Boolean = config("use_base_recalibration", default = true) var useBaseRecalibration: Boolean = config("use_base_recalibration", default = true)
...@@ -62,42 +63,55 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr ...@@ -62,42 +63,55 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
} }
private def doublePreProces(files: List[File]): List[File] = { private def doublePreProces(files: List[File]): List[File] = {
if (files.size == 1) return files
if (files.isEmpty) throw new IllegalStateException("Files can't be empty") if (files.isEmpty) throw new IllegalStateException("Files can't be empty")
if (!doublePreProces.get) return files else if (!doublePreProces) files
val markDup = MarkDuplicates(this, files, new File(outputDir + outputName + ".dedup.bam")) else if (files.size == 1) {
markDup.isIntermediate = useIndelRealigner val bamFile: File = outputDir + files.head.getName
add(markDup) if (bamFile != files.head) {
if (useIndelRealigner) { val oldIndex: File = files.head.getAbsolutePath.stripSuffix(".bam") + ".bai"
List(addIndelRealign(markDup.output, outputDir, isIntermediate = false)) val newIndex: File = bamFile.getAbsolutePath.stripSuffix(".bam") + ".bai"
add(Ln(this, oldIndex, newIndex))
val bamLn = Ln(this, files.head, bamFile)
bamLn.deps :+= newIndex
add(bamLn)
}
List(bamFile)
} else { } else {
List(markDup.output) val markDup = MarkDuplicates(this, files, new File(outputDir + outputName + ".dedup.bam"))
markDup.isIntermediate = useIndelRealigner
add(markDup)
if (useIndelRealigner) {
List(addIndelRealign(markDup.output, outputDir, isIntermediate = false))
} else {
List(markDup.output)
}
} }
} }
def biopetScript() { def biopetScript() {
scriptOutput.bamFiles = if (preProcesBams.get) { scriptOutput.bamFiles = {
var bamFiles: List[File] = Nil doublePreProces(if (preProcesBams) {
for (inputBam <- inputBams) { //var bamFiles: List[File] = Nil
var bamFile = inputBam for (inputBam <- inputBams) yield {
if (useIndelRealigner) { var bamFile = inputBam
bamFile = addIndelRealign(bamFile, outputDir, isIntermediate = useBaseRecalibration) if (useIndelRealigner)
} bamFile = addIndelRealign(bamFile, outputDir, isIntermediate = useBaseRecalibration)
if (useBaseRecalibration) { if (useBaseRecalibration)
bamFile = addBaseRecalibrator(bamFile, outputDir, isIntermediate = bamFiles.size > 1) bamFile = addBaseRecalibrator(bamFile, outputDir, isIntermediate = inputBams.size > 1)
bamFile
} }
bamFiles :+= bamFile //bamFiles
} } else {
doublePreProces(bamFiles) inputBams
} else if (inputBams.size > 1 && doublePreProces.get) { })
doublePreProces(inputBams) }
} else inputBams
if (variantcalling) { if (variantcalling) {
var mergBuffer: SortedMap[String, File] = SortedMap() var mergBuffer: SortedMap[String, File] = SortedMap()
def mergeList = mergBuffer map { case (key, file) => TaggedFile(removeNoneVariants(file), "name=" + key) } def mergeList = mergBuffer map { case (key, file) => TaggedFile(removeNoneVariants(file), "name=" + key) }
if (sampleID != null && (useHaplotypecaller.get || config("joint_genotyping", default = false).asBoolean)) { if (sampleID != null && (useHaplotypecaller || config("joint_genotyping", default = false).asBoolean)) {
val hcGvcf = new HaplotypeCaller(this) val hcGvcf = new HaplotypeCaller(this)
hcGvcf.useGvcf hcGvcf.useGvcf
hcGvcf.input_file = scriptOutput.bamFiles hcGvcf.input_file = scriptOutput.bamFiles
...@@ -106,7 +120,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr ...@@ -106,7 +120,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
scriptOutput.gvcfFile = hcGvcf.out scriptOutput.gvcfFile = hcGvcf.out
} }
if (useHaplotypecaller.get) { if (useHaplotypecaller) {
if (sampleID != null) { if (sampleID != null) {
val genotypeGVCFs = GenotypeGVCFs(this, List(scriptOutput.gvcfFile), outputDir + outputName + ".hc.discovery.vcf.gz") val genotypeGVCFs = GenotypeGVCFs(this, List(scriptOutput.gvcfFile), outputDir + outputName + ".hc.discovery.vcf.gz")
add(genotypeGVCFs) add(genotypeGVCFs)
...@@ -121,7 +135,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr ...@@ -121,7 +135,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
mergBuffer += ("1.HC-Discovery" -> scriptOutput.hcVcfFile) mergBuffer += ("1.HC-Discovery" -> scriptOutput.hcVcfFile)
} }
if (useUnifiedGenotyper.get) { if (useUnifiedGenotyper) {
val ugVcf = new UnifiedGenotyper(this) val ugVcf = new UnifiedGenotyper(this)
ugVcf.input_file = scriptOutput.bamFiles ugVcf.input_file = scriptOutput.bamFiles
ugVcf.out = outputDir + outputName + ".ug.discovery.vcf.gz" ugVcf.out = outputDir + outputName + ".ug.discovery.vcf.gz"
...@@ -156,12 +170,12 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr ...@@ -156,12 +170,12 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
} }
// Allele mode // Allele mode
if (useAllelesOption.get) { if (useAllelesOption) {
val mergeAlleles = MergeAlleles(this, mergeList.toList, outputDir + "raw.allele__temp_only.vcf.gz") val mergeAlleles = MergeAlleles(this, mergeList.toList, outputDir + "raw.allele__temp_only.vcf.gz")
mergeAlleles.isIntermediate = true mergeAlleles.isIntermediate = true
add(mergeAlleles) add(mergeAlleles)
if (useHaplotypecaller.get) { if (useHaplotypecaller) {
val hcAlleles = new HaplotypeCaller(this) val hcAlleles = new HaplotypeCaller(this)
hcAlleles.input_file = scriptOutput.bamFiles hcAlleles.input_file = scriptOutput.bamFiles
hcAlleles.out = outputDir + outputName + ".hc.allele.vcf.gz" hcAlleles.out = outputDir + outputName + ".hc.allele.vcf.gz"
...@@ -172,7 +186,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr ...@@ -172,7 +186,7 @@ class GatkVariantcalling(val root: Configurable) extends QScript with BiopetQScr
mergBuffer += ("3.HC-alleles" -> hcAlleles.out) mergBuffer += ("3.HC-alleles" -> hcAlleles.out)
} }
if (useUnifiedGenotyper.get) { if (useUnifiedGenotyper) {
val ugAlleles = new UnifiedGenotyper(this) val ugAlleles = new UnifiedGenotyper(this)
ugAlleles.input_file = scriptOutput.bamFiles ugAlleles.input_file = scriptOutput.bamFiles
ugAlleles.out = outputDir + outputName + ".ug.allele.vcf.gz" ugAlleles.out = outputDir + outputName + ".ug.allele.vcf.gz"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment