diff --git a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/Tabix.scala b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/Tabix.scala index 4a80600c52cb602c579c5b09ba27931c09f2c338..d8f36a1944b22bb9635355e537b1143fc35bd0f3 100644 --- a/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/Tabix.scala +++ b/public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/Tabix.scala @@ -35,10 +35,9 @@ class Tabix(val root: Configurable) extends BiopetCommandLineFunction { @Output(doc = "Output (for region query)", required = false) var outputQuery: File = null - @Output(doc = "Output (for indexing)", required = false) // NOTE: it's a def since we can't change the index name ~ it's always input_name + .tbi - lazy val outputIndex: File = { - require(input != null, "Input must be defined") - new File(input.toString + ".tbi") + def outputIndex: File = { + require(input != null, "Input should be defined") + new File(input.getAbsolutePath + ".tbi") } @Argument(doc = "Regions to query", required = false) @@ -70,7 +69,8 @@ class Tabix(val root: Configurable) extends BiopetCommandLineFunction { p match { case Some(fmt) => require(validFormats.contains(fmt), "-p flag must be one of " + validFormats.mkString(", ")) - case None => ; + outputFiles :+= outputIndex + case None => } } @@ -96,3 +96,19 @@ class Tabix(val root: Configurable) extends BiopetCommandLineFunction { else baseCommand } } + +object Tabix { + def apply(root: Configurable, input: File) = { + val tabix = new Tabix(root) + tabix.input = input + tabix.p = tabix.input.getName match { + case s if s.endsWith(".vcf.gz") => Some("vcf") + case s if s.endsWith(".bed.gz") => Some("bed") + case s if s.endsWith(".sam.gz") => Some("sam") + case s if s.endsWith(".gff.gz") => Some("gff") + case s if s.endsWith(".psltbl.gz") => Some("psltbl") + case _ => throw new IllegalArgumentException("Unknown file type") + } + tabix + } +} \ No newline at end of file diff --git a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTrait.scala b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTrait.scala index 985d758791df536d10781f5b39c7ffe208f29bee..365d4e638524c1a2d10b320328134b50e8f2524d 100644 --- a/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTrait.scala +++ b/public/shiva/src/main/scala/nl/lumc/sasc/biopet/pipelines/shiva/ShivaVariantcallingTrait.scala @@ -163,7 +163,6 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag with val mp = new SamtoolsMpileup(qscript) mp.input = inputBams mp.u = true - //TODO: proper piping should be implemented mp.reference = referenceFasta() val bt = new BcftoolsCall(qscript) @@ -172,6 +171,7 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag with bt.c = true add(mp | bt > outputFile) + add(Tabix(qscript, outputFile)) } } @@ -197,6 +197,7 @@ trait ShivaVariantcallingTrait extends SummaryQScript with SampleLibraryTag with bt.output = new File(outputDir, inputBam.getName + ".vcf.gz") add(mp | bt) + add(Tabix(qscript, bt.output)) bt.output }