Commit 9b41313c authored by bow's avatar bow
Browse files

Merge branch 'feature-yamsvp' into 'develop'

Feature yamsvp

Convert yamsvp to also work from a bam file and be included in Shiva

See merge request !201
parents 7a2b2219 05a50457
...@@ -179,7 +179,7 @@ trait BastyTrait extends MultiSampleQScript { ...@@ -179,7 +179,7 @@ trait BastyTrait extends MultiSampleQScript {
snpsOnly: Boolean = false): FastaOutput = { snpsOnly: Boolean = false): FastaOutput = {
val bastyGenerateFasta = new BastyGenerateFasta(this) val bastyGenerateFasta = new BastyGenerateFasta(this)
bastyGenerateFasta.outputName = if (outputName != null) outputName else sampleName bastyGenerateFasta.outputName = if (outputName != null) outputName else sampleName
bastyGenerateFasta.inputVcf = shiva.variantcalling.get.finalFile bastyGenerateFasta.inputVcf = shiva.variantCalling.get.finalFile
if (shiva.samples.contains(sampleName)) { if (shiva.samples.contains(sampleName)) {
bastyGenerateFasta.bamFile = shiva.samples(sampleName).preProcessBam.get bastyGenerateFasta.bamFile = shiva.samples(sampleName).preProcessBam.get
} }
......
...@@ -18,38 +18,35 @@ package nl.lumc.sasc.biopet.extensions.breakdancer ...@@ -18,38 +18,35 @@ 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 +69,10 @@ class Breakdancer(val root: Configurable) extends QScript with BiopetQScript { ...@@ -72,11 +69,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
......
...@@ -51,8 +51,8 @@ class BreakdancerCaller(val root: Configurable) extends BiopetCommandLineFunctio ...@@ -51,8 +51,8 @@ class BreakdancerCaller(val root: Configurable) extends BiopetCommandLineFunctio
var x: Option[Int] = config("x", default = 1000) var x: Option[Int] = config("x", default = 1000)
var b: Option[Int] = config("b", default = 100) var b: Option[Int] = config("b", default = 100)
var t: Boolean = config("t", default = false) var t: Boolean = config("t", default = false)
var d: String = config("d") var d: Option[String] = config("d")
var g: String = config("g") var g: Option[String] = config("g")
var l: Boolean = config("l", default = false) var l: Boolean = config("l", default = false)
var a: Boolean = config("a", default = false) var a: Boolean = config("a", default = false)
var h: Boolean = config("h", default = false) var h: Boolean = config("h", default = false)
......
/**
* Biopet is built on top of GATK Queue for building bioinformatic
* pipelines. It is mainly intended to support LUMC SHARK cluster which is running
* SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
* should also be able to execute Biopet tools and pipelines.
*
* Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
*
* Contact us at: sasc@lumc.nl
*
* A dual licensing mode is applied. The source code within this project that are
* not part of GATK Queue is freely available for non-commercial use under an AGPL
* license; For commercial users or users who do not want to follow the AGPL
* license, please contact us to obtain a separate license.
*/
package nl.lumc.sasc.biopet.extensions.clever
import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand }
import org.broadinstitute.gatk.queue.QScript
class Clever(val root: Configurable) extends QScript with BiopetQScript {
def this() = this(null)
@Input(doc = "Input file (bam)")
var input: File = _
@Input(doc = "Reference")
var reference: File = _
@Argument(doc = "Work directory")
var workdir: String = _
@Argument(doc = "Current working directory")
var cwd: String = _
override def init() {
}
def biopetScript() {
// write the pipeline here
logger.info("Starting Clever Pipeline")
/// start clever and then copy the vcf into the root directory "<sample>.clever/"
val clever = CleverCaller(this, input, reference, cwd, workdir)
outputFiles += ("clever_vcf" -> clever.outputvcf)
add(clever)
}
}
object Clever extends PipelineCommand {
override val pipeline = "/nl/lumc/sasc/biopet/extensions/svcallers/Clever/Clever.class"
def apply(root: Configurable, input: File, runDir: String): Clever = {
val cleverpipeline = new Clever(root)
cleverpipeline.input = input
cleverpipeline.workdir = runDir
cleverpipeline.init()
cleverpipeline.biopetScript()
cleverpipeline
}
}
\ No newline at end of file
...@@ -2,18 +2,19 @@ package nl.lumc.sasc.biopet.extensions.clever ...@@ -2,18 +2,19 @@ package nl.lumc.sasc.biopet.extensions.clever
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction import nl.lumc.sasc.biopet.core.{ Reference, BiopetCommandLineFunction }
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output } import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction { class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction with Reference {
executable = config("exe", default = "clever") executable = config("exe", default = "clever")
private lazy val versionexecutable: File = config("version_exe", default = new File(executable).getParent + "/ctk-version") private lazy val versionExecutable: File = config("version_exe", default = new File(executable).getParent + "/ctk-version")
override def defaultThreads = 8 override def defaultThreads = 8
override def defaultCoreMemory = 3.0
override def versionCommand = versionexecutable.getAbsolutePath override def versionCommand = versionExecutable.getAbsolutePath
override def versionRegex = """(.*)""".r override def versionRegex = """(.*)""".r
override def versionExitcode = List(0, 1) override def versionExitcode = List(0, 1)
...@@ -23,19 +24,17 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction { ...@@ -23,19 +24,17 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction {
@Input(doc = "Reference") @Input(doc = "Reference")
var reference: File = _ var reference: File = _
@Argument(doc = "Work directory") protected def workDir: File = new File(cwd, "work")
var workdir: String = _ var cwd: File = _
var cwd: String = _
@Output(doc = "Clever VCF output") @Output(doc = "Clever VCF output")
lazy val outputvcf: File = { lazy val outputvcf: File = {
new File(cwd + "predictions.vcf") new File(cwd, "predictions.vcf")
} }
@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)
...@@ -45,31 +44,30 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction { ...@@ -45,31 +44,30 @@ class CleverCaller(val root: Configurable) extends BiopetCommandLineFunction {
var k: Boolean = config("k", default = false) // keep working directory var k: Boolean = config("k", default = false) // keep working directory
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 beforeGraph() {
if (workdir == null) throw new Exception("Clever :: Workdirectory is not defined") super.beforeGraph()
// if (input.getName.endsWith(".sort.bam")) sorted = true if (workDir == null) throw new Exception("Clever :: Workdirectory is not defined")
if (reference == null) reference = referenceFasta()
} }
def cmdLine = required(executable) + def cmdLine = required(executable) +
" --sorted " + " --sorted " +
" --use_xa " + " --use_xa " +
optional("-T", nCoresRequest) + optional("-T", threads) +
conditional(f, "-f") + conditional(f, "-f") +
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 {
def apply(root: Configurable, input: File, reference: File, svDir: String, runDir: String): CleverCaller = { def apply(root: Configurable, input: File, svDir: File): CleverCaller = {
val clever = new CleverCaller(root) val clever = new CleverCaller(root)
clever.input = input clever.input = input
clever.reference = reference
clever.cwd = svDir clever.cwd = svDir
clever.workdir = runDir
clever clever
} }
} }
\ No newline at end of file
...@@ -2,33 +2,34 @@ package nl.lumc.sasc.biopet.extensions.delly ...@@ -2,33 +2,34 @@ package nl.lumc.sasc.biopet.extensions.delly
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.{ BiopetQScript, PipelineCommand } import nl.lumc.sasc.biopet.core.{ Reference, BiopetQScript, PipelineCommand }
import nl.lumc.sasc.biopet.core.config.Configurable import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.extensions.Ln import nl.lumc.sasc.biopet.extensions.Ln
import org.broadinstitute.gatk.queue.QScript import org.broadinstitute.gatk.queue.QScript
import org.broadinstitute.gatk.queue.extensions.gatk.CatVariants import org.broadinstitute.gatk.queue.extensions.gatk.CatVariants
class Delly(val root: Configurable) extends QScript with BiopetQScript { class Delly(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 = _
@Argument(doc = "Work directory") var workDir: File = _
var workdir: String = _
@Output(doc = "Delly result VCF") @Output(doc = "Delly result VCF")
var outputvcf: File = _ var outputVcf: File = _
var outputBaseName: String = _ var outputName: String = _
// select the analysis types DEL,DUP,INV,TRA // select the analysis types DEL,DUP,INV,TRA
var del: Boolean = config("DEL", default = false) var del: Boolean = config("DEL", default = true)
var dup: Boolean = config("DUP", default = false) var dup: Boolean = config("DUP", default = true)
var inv: Boolean = config("INV", default = false) var inv: Boolean = config("INV", default = true)
var tra: Boolean = config("TRA", default = false) var tra: Boolean = config("TRA", default = true)
override def init() { override def init(): Unit = {
if (outputName == null) outputName = input.getName.stripSuffix(".bam")
if (outputVcf == null) outputVcf = new File(workDir, outputName + ".delly.vcf")
} }
def biopetScript() { def biopetScript() {
...@@ -37,15 +38,12 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript { ...@@ -37,15 +38,12 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript {
var outputFiles: Map[String, File] = Map() var outputFiles: Map[String, File] = Map()
var vcfFiles: Map[String, File] = Map() var vcfFiles: Map[String, File] = Map()
this.outputBaseName = workdir + input.getName.substring(0, input.getName.lastIndexOf(".bam"))
this.outputvcf = outputBaseName + ".delly.vcf"
/// start delly and then copy the vcf into the root directory "<sample>.delly/" /// start delly and then copy the vcf into the root directory "<sample>.delly/"
if (del) { if (del) {
val delly = new DellyCaller(this) val delly = new DellyCaller(this)
delly.input = input delly.input = input
delly.analysistype = "DEL" delly.analysistype = "DEL"
delly.outputvcf = outputBaseName + ".delly.del.vcf" delly.outputvcf = new File(workDir, outputName + ".delly.del.vcf")
add(delly) add(delly)
vcfFiles += ("DEL" -> delly.outputvcf) vcfFiles += ("DEL" -> delly.outputvcf)
} }
...@@ -53,7 +51,7 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript { ...@@ -53,7 +51,7 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript {
val delly = new DellyCaller(this) val delly = new DellyCaller(this)
delly.input = input delly.input = input
delly.analysistype = "DUP" delly.analysistype = "DUP"
delly.outputvcf = outputBaseName + ".delly.dup.vcf" delly.outputvcf = new File(workDir, outputName + ".delly.dup.vcf")
add(delly) add(delly)
vcfFiles += ("DUP" -> delly.outputvcf) vcfFiles += ("DUP" -> delly.outputvcf)
} }
...@@ -61,7 +59,7 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript { ...@@ -61,7 +59,7 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript {
val delly = new DellyCaller(this) val delly = new DellyCaller(this)
delly.input = input delly.input = input
delly.analysistype = "INV" delly.analysistype = "INV"
delly.outputvcf = outputBaseName + ".delly.inv.vcf" delly.outputvcf = new File(workDir, outputName + ".delly.inv.vcf")
add(delly) add(delly)
vcfFiles += ("INV" -> delly.outputvcf) vcfFiles += ("INV" -> delly.outputvcf)
} }
...@@ -69,47 +67,43 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript { ...@@ -69,47 +67,43 @@ class Delly(val root: Configurable) extends QScript with BiopetQScript {
val delly = new DellyCaller(this) val delly = new DellyCaller(this)
delly.input = input delly.input = input
delly.analysistype = "TRA" delly.analysistype = "TRA"
delly.outputvcf = outputBaseName + ".delly.tra.vcf" delly.outputvcf = new File(workDir, outputName + ".delly.tra.vcf")
// vcfFiles += ("TRA" -> delly.outputvcf) // vcfFiles += ("TRA" -> delly.outputvcf)
add(delly) add(delly)
} }
// we need to merge the vcf's // we need to merge the vcf's
var finalVCF = if (vcfFiles.size > 1) { val finalVCF = if (vcfFiles.size > 1) {
// do merging // do merging
// CatVariants is a $org.broadinstitute.gatk.utils.commandline.CommandLineProgram$; // CatVariants is a $org.broadinstitute.gatk.utils.commandline.CommandLineProgram$;
//TODO: convert to biopet extension
val variants = new CatVariants() val variants = new CatVariants()
variants.jobResourceRequests :+= "h_vmem=4G"
variants.nCoresRequest = 1
variants.memoryLimit = Option(2.0)
variants.variant = vcfFiles.values.toList variants.variant = vcfFiles.values.toList
variants.reference = config("reference") variants.outputFile = this.outputVcf
variants.outputFile = this.outputvcf variants.reference = referenceFasta()
// add the job // add the job
add(variants) //add(variants)
this.outputvcf Some(outputVcf)
} else { } else if (vcfFiles.size == 1) {
// TODO: pretify this // TODO: pretify this
val ln = Ln(this, vcfFiles.head._2, this.outputvcf, relative = true) val ln = Ln(this, vcfFiles.head._2, this.outputVcf, relative = true)
add(ln) //add(ln)
ln.output Some(ln.output)
} } else None
outputFiles += ("vcf" -> this.outputvcf) finalVCF.foreach(file => outputFiles += ("vcf" -> file))
} }
private def swapExtension(inputFile: String) = inputFile.substring(0, inputFile.lastIndexOf(".bam")) + ".delly.vcf"
} }
object Delly extends PipelineCommand { object Delly extends PipelineCommand {
override val pipeline = "/nl/lumc/sasc/biopet/extensions/svcallers/Delly/Delly.class" override val pipeline = "/nl/lumc/sasc/biopet/extensions/svcallers/Delly/Delly.class"
def apply(root: Configurable, input: File, runDir: String): Delly = { def apply(root: Configurable, input: File, workDir: File): Delly = {
val dellypipeline = new Delly(root) val dellyPipeline = new Delly(root)
dellypipeline.input = input dellyPipeline.input = input
dellypipeline.workdir = runDir dellyPipeline.workDir = workDir
dellypipeline.init() dellyPipeline.init()
dellypipeline.biopetScript() dellyPipeline.biopetScript()
dellypipeline dellyPipeline
} }
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ class DellyCaller(val root: Configurable) extends BiopetCommandLineFunction { ...@@ -12,6 +12,7 @@ class DellyCaller(val root: Configurable) extends BiopetCommandLineFunction {
private lazy val versionexecutable: File = new File(executable) private lazy val versionexecutable: File = new File(executable)
override def defaultThreads = 1 override def defaultThreads = 1
override def defaultCoreMemory = 4.0
override def versionCommand = versionexecutable.getAbsolutePath override def versionCommand = versionexecutable.getAbsolutePath
override def versionRegex = """DELLY \(Version: (.*)\)""".r override def versionRegex = """DELLY \(Version: (.*)\)""".r
......
...@@ -42,7 +42,7 @@ class VcfFilter(val root: Configurable) extends ToolCommandFuntion { ...@@ -42,7 +42,7 @@ class VcfFilter(val root: Configurable) extends ToolCommandFuntion {
var minSamplesPass: Option[Int] = config("min_samples_pass") var minSamplesPass: Option[Int] = config("min_samples_pass")
var filterRefCalls: Boolean = config("filter_ref_calls", default = false) var filterRefCalls: Boolean = config("filter_ref_calls", default = false)
override def defaultCoreMemory = 1.0 override def defaultCoreMemory = 3.0
override def commandLine = super.commandLine + override def commandLine = super.commandLine +
required("-I", inputVcf) + required("-I", inputVcf) +
......
...@@ -267,6 +267,22 @@ object ConfigUtils extends Logging { ...@@ -267,6 +267,22 @@ object ConfigUtils extends Logging {
any2list(any).map(_.toString) any2list(any).map(_.toString)
} }
/** Convert Any to List[Any], fallback on list with 1 value */
def any2set(any: Any): Set[Any] = {
if (any == null) return null
any match {
case s: Set[_] => s.toSet
case l: List[_] => l.toSet
case _ => Set(any)
}