Commit e5d7f321 authored by Peter van 't Hof's avatar Peter van 't Hof

Added sambamba to multisamplemapping

parent ca7bf0d9
......@@ -41,7 +41,7 @@ class SambambaMarkdup(val parent: Configurable) extends Sambamba {
override def defaultCoreMemory = 4.0
/** Returns command to execute */
def cmdLine = required(executable) +
def cmdLine: String = required(executable) +
required("markdup") +
conditional(removeDuplicates, "--remove-duplicates") +
optional("-t", nCoresRequest) +
......@@ -55,10 +55,11 @@ class SambambaMarkdup(val parent: Configurable) extends Sambamba {
}
object SambambaMarkdup {
def apply(root: Configurable, input: File, output: File): SambambaMarkdup = {
def apply(root: Configurable, input: File, output: File, isIntermediate: Boolean = false): SambambaMarkdup = {
val markdup = new SambambaMarkdup(root)
markdup.input = input
markdup.output = output
markdup.isIntermediate = isIntermediate
markdup
}
......
......@@ -21,7 +21,6 @@ import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
/** Extension for sambemba merge */
class SambambaMerge(val parent: Configurable) extends Sambamba {
override def defaultThreads = 4
@Input(doc = "Bam File[s]")
var input: List[File] = Nil
......@@ -39,7 +38,7 @@ class SambambaMerge(val parent: Configurable) extends Sambamba {
override def defaultCoreMemory = 4.0
/** Returns command to execute */
def cmdLine = required(executable) +
def cmdLine: String = required(executable) +
required("merge") +
optional("-t", nCoresRequest) +
optional("-l", compressionLevel) +
......@@ -47,5 +46,5 @@ class SambambaMerge(val parent: Configurable) extends Sambamba {
conditional(header, "--header") +
conditional(showProgress, "--show-progress") +
required(output) +
repeat("", input)
repeat(input)
}
......@@ -19,7 +19,7 @@ import java.io.File
import htsjdk.samtools.SamReaderFactory
import htsjdk.samtools.reference.FastaSequenceFile
import nl.lumc.sasc.biopet.core.report.ReportBuilderExtension
import nl.lumc.sasc.biopet.core.{ PipelineCommand, Reference, MultiSampleQScript }
import nl.lumc.sasc.biopet.core.{ MultiSampleQScript, PipelineCommand, Reference }
import nl.lumc.sasc.biopet.extensions.Ln
import nl.lumc.sasc.biopet.extensions.picard._
import nl.lumc.sasc.biopet.pipelines.bammetrics.BamMetrics
......@@ -28,8 +28,8 @@ import nl.lumc.sasc.biopet.pipelines.gears.GearsSingle
import nl.lumc.sasc.biopet.utils.Logging
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript
import MultisampleMapping.MergeStrategy
import nl.lumc.sasc.biopet.extensions.sambamba.{ SambambaMarkdup, SambambaMerge }
import scala.collection.JavaConversions._
......@@ -247,7 +247,7 @@ trait MultisampleMappingTrait extends MultiSampleQScript
mergeStrategy match {
case MergeStrategy.None =>
case (MergeStrategy.MergeSam | MergeStrategy.MarkDuplicates) if libraries.flatMap(_._2.bamFile).size == 1 =>
case (MergeStrategy.MergeSam) if libraries.flatMap(_._2.bamFile).size == 1 =>
add(Ln.linkBamFile(qscript, libraries.flatMap(_._2.bamFile).head, bamFile.get): _*)
case (MergeStrategy.PreProcessMergeSam | MergeStrategy.PreProcessMarkDuplicates) if libraries.flatMap(_._2.preProcessBam).size == 1 =>
add(Ln.linkBamFile(qscript, libraries.flatMap(_._2.preProcessBam).head, bamFile.get): _*)
......@@ -259,6 +259,17 @@ trait MultisampleMappingTrait extends MultiSampleQScript
add(MarkDuplicates(qscript, libraries.flatMap(_._2.bamFile).toList, bamFile.get, isIntermediate = !keepMergedFiles))
case MergeStrategy.PreProcessMarkDuplicates =>
add(MarkDuplicates(qscript, libraries.flatMap(_._2.preProcessBam).toList, bamFile.get, isIntermediate = !keepMergedFiles))
case MergeStrategy.PreProcessSambambaMarkdup =>
val mergedBam = new File(sampleDir, "merged.bam")
if (libraries.flatMap(_._2.bamFile).size == 1) {
add(Ln.linkBamFile(qscript, libraries.flatMap(_._2.preProcessBam).head, mergedBam): _*)
} else {
val merge = new SambambaMerge(qscript)
merge.input = libraries.flatMap(_._2.preProcessBam).toList
merge.output = mergedBam
add(merge)
}
add(SambambaMarkdup(qscript, mergedBam, bamFile.get, isIntermediate = !keepMergedFiles))
case _ => throw new IllegalStateException("This should not be possible, unimplemented MergeStrategy?")
}
......@@ -301,7 +312,7 @@ class MultisampleMapping(val parent: Configurable) extends QScript with Multisam
object MultisampleMapping extends PipelineCommand {
object MergeStrategy extends Enumeration {
val None, MergeSam, MarkDuplicates, PreProcessMergeSam, PreProcessMarkDuplicates = Value
val None, MergeSam, MarkDuplicates, PreProcessMergeSam, PreProcessMarkDuplicates, PreProcessSambambaMarkdup = Value
}
/** When file is not absolute an error is raise att the end of the script of a pipeline */
......
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