Commit a5ecd049 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Update breakdancer

parent 3c2f4a07
...@@ -18,38 +18,36 @@ package nl.lumc.sasc.biopet.extensions.breakdancer ...@@ -18,38 +18,36 @@ package nl.lumc.sasc.biopet.extensions.breakdancer
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand } import nl.lumc.sasc.biopet.core.{Reference, BiopetQScript, PipelineCommand}
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
/// Breakdancer is actually a mini pipeline executing binaries from the breakdancer package /// Breakdancer is actually a mini pipeline executing binaries from the breakdancer package
class Breakdancer(val root: Configurable) extends QScript with BiopetQScript { class Breakdancer(val root: Configurable) extends QScript with BiopetQScript with Reference {
def this() = this(null) def this() = this(null)
@Input(doc = "Input file (bam)") @Input(doc = "Input file (bam)")
var input: File = _ var input: File = _
@Input(doc = "Reference Fasta file")
var reference: File = _
@Argument(doc = "Work directory") @Argument(doc = "Work directory")
var workdir: String = _ var workDir: File = _
var deps: List[File] = Nil var deps: List[File] = Nil
@Output(doc = "Breakdancer config") @Output(doc = "Breakdancer config")
lazy val configfile: File = { lazy val configfile: File = {
new File(workdir + "/" + input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.cfg") new File(workDir, input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.cfg")
} }
@Output(doc = "Breakdancer raw output") @Output(doc = "Breakdancer raw output")
lazy val outputraw: File = { lazy val outputraw: File = {
new File(workdir + "/" + input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.tsv") new File(workDir, input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.tsv")
} }
@Output(doc = "Breakdancer VCF output") @Output(doc = "Breakdancer VCF output")
lazy val outputvcf: File = { lazy val outputvcf: File = {
new File(workdir + "/" + input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.vcf") new File(workDir, input.getName.substring(0, input.getName.lastIndexOf(".bam")) + ".breakdancer.vcf")
} }
override def init() { override def init(): Unit = {
} }
def biopetScript() { def biopetScript() {
...@@ -72,11 +70,10 @@ class Breakdancer(val root: Configurable) extends QScript with BiopetQScript { ...@@ -72,11 +70,10 @@ class Breakdancer(val root: Configurable) extends QScript with BiopetQScript {
} }
object Breakdancer extends PipelineCommand { object Breakdancer extends PipelineCommand {
def apply(root: Configurable, input: File, reference: File, runDir: String): Breakdancer = { def apply(root: Configurable, input: File, runDir: File): Breakdancer = {
val breakdancer = new Breakdancer(root) val breakdancer = new Breakdancer(root)
breakdancer.input = input breakdancer.input = input
breakdancer.reference = reference breakdancer.workDir = runDir
breakdancer.workdir = runDir
breakdancer.init() breakdancer.init()
breakdancer.biopetScript() breakdancer.biopetScript()
breakdancer breakdancer
......
...@@ -24,7 +24,7 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction { ...@@ -24,7 +24,7 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction {
var reference: File = _ var reference: File = _
@Argument(doc = "Work directory") @Argument(doc = "Work directory")
var workdir: String = _ var workDir: String = _
var cwd: String = _ var cwd: String = _
...@@ -35,7 +35,7 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction { ...@@ -35,7 +35,7 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction {
@Output(doc = "Clever raw output") @Output(doc = "Clever raw output")
lazy val outputraw: File = { lazy val outputraw: File = {
new File(workdir + "predictions.raw.txt") new File(workDir + "predictions.raw.txt")
} }
// var T: Option[Int] = config("T", default = defaultThreads) // var T: Option[Int] = config("T", default = defaultThreads)
...@@ -46,7 +46,7 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction { ...@@ -46,7 +46,7 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction {
var r: Boolean = config("r", default = false) // take read groups into account var r: Boolean = config("r", default = false) // take read groups into account
override def beforeCmd() { override def beforeCmd() {
if (workdir == null) throw new Exception("Clever :: Workdirectory is not defined") if (workDir == null) throw new Exception("Clever :: Workdirectory is not defined")
// if (input.getName.endsWith(".sort.bam")) sorted = true // if (input.getName.endsWith(".sort.bam")) sorted = true
} }
...@@ -58,9 +58,9 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction { ...@@ -58,9 +58,9 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction {
conditional(a, "-a") + conditional(a, "-a") +
conditional(k, "-k") + conditional(k, "-k") +
conditional(r, "-r") + conditional(r, "-r") +
required(this.input) + required(input) +
required(this.reference) + required(reference) +
required(this.workdir) required(workDir)
} }
object CleverCaller { object CleverCaller {
...@@ -69,7 +69,7 @@ object CleverCaller { ...@@ -69,7 +69,7 @@ object CleverCaller {
clever.input = input clever.input = input
clever.reference = reference clever.reference = reference
clever.cwd = svDir clever.cwd = svDir
clever.workdir = runDir clever.workDir = runDir
clever clever
} }
} }
\ No newline at end of file
...@@ -19,7 +19,7 @@ import java.io.File ...@@ -19,7 +19,7 @@ import java.io.File
import htsjdk.samtools.SamReaderFactory import htsjdk.samtools.SamReaderFactory
import nl.lumc.sasc.biopet.core.summary.SummaryQScript import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{PipelineCommand, BiopetQScript, Reference, SampleLibraryTag} import nl.lumc.sasc.biopet.core.{ PipelineCommand, BiopetQScript, Reference, SampleLibraryTag }
import nl.lumc.sasc.biopet.extensions.breakdancer.Breakdancer import nl.lumc.sasc.biopet.extensions.breakdancer.Breakdancer
import nl.lumc.sasc.biopet.extensions.clever.CleverCaller import nl.lumc.sasc.biopet.extensions.clever.CleverCaller
import nl.lumc.sasc.biopet.extensions.delly.Delly import nl.lumc.sasc.biopet.extensions.delly.Delly
...@@ -41,7 +41,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference ...@@ -41,7 +41,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference
protected def addBamFile(file: File, sampleId: Option[String] = None): Unit = { protected def addBamFile(file: File, sampleId: Option[String] = None): Unit = {
sampleId match { sampleId match {
case Some(sample) => inputBams += sample -> file case Some(sample) => inputBams += sample -> file
case _ if !file.exists() => throw new IllegalArgumentException("Bam file does not exits: " + file) case _ if !file.exists() => throw new IllegalArgumentException("Bam file does not exits: " + file)
case _ => { case _ => {
val inputSam = SamReaderFactory.makeDefault.open(file) val inputSam = SamReaderFactory.makeDefault.open(file)
...@@ -68,7 +68,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference ...@@ -68,7 +68,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference
BiopetQScript.addError("variantcaller '" + cal + "' does not exist, possible to use: " + callersList.map(_.name).mkString(", ")) BiopetQScript.addError("variantcaller '" + cal + "' does not exist, possible to use: " + callersList.map(_.name).mkString(", "))
} }
val callers = callersList.filter(x => configCallers.contains(x.name)).sortBy(_.prio) val callers = callersList.filter(x => configCallers.contains(x.name))
require(inputBams.nonEmpty, "No input bams found") require(inputBams.nonEmpty, "No input bams found")
require(callers.nonEmpty, "must select at least 1 SV caller, choices are: " + callersList.map(_.name).mkString(", ")) require(callers.nonEmpty, "must select at least 1 SV caller, choices are: " + callersList.map(_.name).mkString(", "))
...@@ -99,7 +99,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference ...@@ -99,7 +99,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference
//TODO: move minipipeline of breakdancer to here //TODO: move minipipeline of breakdancer to here
for ((sample, bamFile) <- inputBams) { for ((sample, bamFile) <- inputBams) {
val breakdancerDir = new File(outputDir, sample) val breakdancerDir = new File(outputDir, sample)
val breakdancer = Breakdancer(qscript, bamFile, qscript.reference, breakdancerDir) val breakdancer = Breakdancer(qscript, bamFile, breakdancerDir)
addAll(breakdancer.functions) addAll(breakdancer.functions)
} }
} }
...@@ -112,7 +112,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference ...@@ -112,7 +112,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference
def addJobs() { def addJobs() {
//TODO: check double directories //TODO: check double directories
for ((sample, bamFile) <- inputBams) { for ((sample, bamFile) <- inputBams) {
val cleverDir = new File(outputDir, sampleId) val cleverDir = new File(outputDir, sample)
val clever = CleverCaller(qscript, bamFile, qscript.reference, cleverDir, cleverDir) val clever = CleverCaller(qscript, bamFile, qscript.reference, cleverDir, cleverDir)
add(clever) add(clever)
} }
...@@ -126,7 +126,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference ...@@ -126,7 +126,7 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference
def addJobs() { def addJobs() {
//TODO: Move mini delly pipeline to here //TODO: Move mini delly pipeline to here
for ((sample, bamFile) <- inputBams) { for ((sample, bamFile) <- inputBams) {
val dellyDir = new File(outputDir, sampleId) val dellyDir = new File(outputDir, sample)
val delly = Delly(qscript, bamFile, dellyDir) val delly = Delly(qscript, bamFile, dellyDir)
addAll(delly.functions) addAll(delly.functions)
} }
...@@ -142,7 +142,8 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference ...@@ -142,7 +142,8 @@ class ShivaSvCalling extends SummaryQScript with SampleLibraryTag with Reference
/** Files for the summary */ /** Files for the summary */
def summaryFiles: Map[String, File] = { def summaryFiles: Map[String, File] = {
val callers: Set[String] = config("sv_callers") val callers: Set[String] = config("sv_callers")
callersList.filter(x => callers.contains(x.name)).map(x => x.name -> x.outputFile).toMap + ("final" -> finalFile) //callersList.filter(x => callers.contains(x.name)).map(x => x.name -> x.outputFile).toMap + ("final" -> finalFile)
Map()
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment