Commit 98bc93d9 authored by Sander Bollen's avatar Sander Bollen
Browse files

Merge branch 'feature-FilterOnMappingQualityCarp' into 'develop'

Feature filter on mapping quality carp

Currently testing the pipeline with real samples. Dry run seem to look okay!

Pipeline tested, ready to merge!

See merge request !248
parents aca99bf8 9c71efa3
package nl.lumc.sasc.biopet.extensions.picard
import java.io.File
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
/**
* Created by sajvanderzeeuw on 6-10-15.
*/
class BuildBamIndex(val root: Configurable) extends Picard {
javaMainClass = new picard.sam.BuildBamIndex().getClass.getName
@Input(doc = "The input SAM or BAM files to analyze.", required = true)
var input: File = _
@Output(doc = "The output file to bam file to", required = true)
var output: File = _
override def cmdLine = super.cmdLine +
required("INPUT=", input, spaceSeparated = false) +
required("OUTPUT=", output, spaceSeparated = false)
}
......@@ -3,7 +3,7 @@ package nl.lumc.sasc.biopet.extensions.samtools
import java.io.File
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
/**
* Created by pjvanthof on 22/09/15.
......
......@@ -28,7 +28,7 @@ class SamtoolsView(val root: Configurable) extends Samtools {
@Output(doc = "output File")
var output: File = null
var quality: Option[Int] = config("quality")
var q: Option[Int] = config("q")
var b: Boolean = config("b", default = false)
var h: Boolean = config("h", default = false)
var f: List[String] = config("f", default = List.empty[String])
......@@ -36,7 +36,7 @@ class SamtoolsView(val root: Configurable) extends Samtools {
def cmdBase = required(executable) +
required("view") +
optional("-q", quality) +
optional("-q", q) +
repeat("-f", f) +
repeat("-F", F) +
conditional(b, "-b") +
......
......@@ -18,11 +18,12 @@ package nl.lumc.sasc.biopet.pipelines.carp
import java.io.File
import nl.lumc.sasc.biopet.core._
import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsView
import nl.lumc.sasc.biopet.utils.config._
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.Ln
import nl.lumc.sasc.biopet.extensions.macs2.Macs2CallPeak
import nl.lumc.sasc.biopet.extensions.picard.MergeSamFiles
import nl.lumc.sasc.biopet.extensions.picard.{ BuildBamIndex, MergeSamFiles }
import nl.lumc.sasc.biopet.pipelines.bammetrics.BamMetrics
import nl.lumc.sasc.biopet.pipelines.bamtobigwig.Bam2Wig
import nl.lumc.sasc.biopet.pipelines.mapping.Mapping
......@@ -40,8 +41,16 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript with
override def defaults = Map(
"mapping" -> Map(
"skip_markduplicates" -> true,
"skip_markduplicates" -> false,
"aligner" -> "bwa-mem"
),
"samtoolsview" -> Map("q" -> 10)
)
override def fixedValues = Map(
"samtoolsview" -> Map(
"h" -> true,
"b" -> true
)
)
......@@ -93,6 +102,7 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript with
}
val bamFile = createFile(".bam")
val bamFileFilter = createFile(".filter.bam")
val controls: List[String] = config("control", default = Nil)
def addJobs(): Unit = {
......@@ -114,10 +124,29 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript with
val bamMetrics = BamMetrics(qscript, bamFile, new File(sampleDir, "metrics"), sampleId = Some(sampleId))
addAll(bamMetrics.functions)
addSummaryQScript(bamMetrics)
val bamMetricsFilter = BamMetrics(qscript, bamFileFilter, new File(sampleDir, "metrics-filter"), sampleId = Some(sampleId))
addAll(bamMetricsFilter.functions)
bamMetricsFilter.summaryName = "bammetrics-filter"
addSummaryQScript(bamMetricsFilter)
addAll(Bam2Wig(qscript, bamFile).functions)
addAll(Bam2Wig(qscript, bamFileFilter).functions)
val samtoolsView = new SamtoolsView(qscript)
samtoolsView.input = bamFile
samtoolsView.output = bamFileFilter
samtoolsView.b = true
samtoolsView.h = true
add(samtoolsView)
val buildBamIndex = new BuildBamIndex(qscript)
buildBamIndex.input = bamFileFilter
buildBamIndex.output = swapExt(bamFileFilter.getParent, bamFileFilter, ".bam", ".bai")
add(buildBamIndex)
val macs2 = new Macs2CallPeak(qscript)
macs2.treatment = bamFile
macs2.treatment = bamFileFilter
macs2.name = Some(sampleId)
macs2.outputdir = sampleDir + File.separator + "macs2" + File.separator + sampleId + File.separator
add(macs2)
......@@ -155,8 +184,8 @@ class Carp(val root: Configurable) extends QScript with MultiSampleQScript with
if (!samples.contains(controlId))
throw new IllegalStateException("For sample: " + sampleId + " this control: " + controlId + " does not exist")
val macs2 = new Macs2CallPeak(this)
macs2.treatment = sample.bamFile
macs2.control = samples(controlId).bamFile
macs2.treatment = sample.bamFileFilter
macs2.control = samples(controlId).bamFileFilter
macs2.name = Some(sampleId + "_VS_" + controlId)
macs2.outputdir = sample.sampleDir + File.separator + "macs2" + File.separator + macs2.name.get + File.separator
add(macs2)
......
Supports Markdown
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