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

More piping for target flagstat

parent 5421af11
......@@ -151,29 +151,21 @@ class BamMetrics(val root: Configurable) extends QScript with SummaryQScript wit
val targetDir = new File(outputDir, targetName)
val biStrict = BedtoolsIntersect(this, inputBam, intervals.bed,
output = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.strict.bam"),
output = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.strict.sam"),
minOverlap = config("strict_intersect_overlap", default = 1.0))
biStrict.isIntermediate = true
add(biStrict)
add(SamtoolsFlagstat(this, biStrict.output, targetDir))
val biopetFlagstatStrict = BiopetFlagstat(this, biStrict.output, targetDir)
add(biopetFlagstatStrict)
addSummarizable(biopetFlagstatStrict, targetName + "_biopet_flagstat_strict")
add(new BiopetFifoPipe(this, List(biStrict, biopetFlagstatStrict)))
val biLoose = BedtoolsIntersect(this, inputBam, intervals.bed,
output = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.loose.bam"),
output = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".overlap.loose.sam"),
minOverlap = config("loose_intersect_overlap", default = 0.01))
biLoose.isIntermediate = true
add(biLoose)
add(SamtoolsFlagstat(this, biLoose.output, targetDir))
val biopetFlagstatLoose = BiopetFlagstat(this, biLoose.output, targetDir)
add(biopetFlagstatLoose)
addSummarizable(biopetFlagstatLoose, targetName + "_biopet_flagstat_loose")
add(new BiopetFifoPipe(this, List(biLoose, biopetFlagstatLoose)))
val coverageFile = new File(targetDir, inputBam.getName.stripSuffix(".bam") + ".coverage")
val bedCov = BedtoolsCoverage(this, inputBam, intervals.bed, coverageFile, depth = true)
val covStats = CoverageStats(this, coverageFile, targetDir)
val bedCov = BedtoolsCoverage(this, inputBam, intervals.bed, depth = true)
val covStats = CoverageStats(this, targetDir, inputBam.getName.stripSuffix(".bam") + ".coverage")
covStats.title = Some("Coverage for " + targetName)
covStats.subTitle = Some(".")
add(bedCov | covStats)
......
......@@ -55,11 +55,10 @@ class CoverageStats(val root: Configurable) extends PythonCommandLineFunction wi
}
object CoverageStats {
def apply(root: Configurable, input: File, outputDir: File): CoverageStats = {
def apply(root: Configurable, outputDir: File, name: String): CoverageStats = {
val coverageStats = new CoverageStats(root)
coverageStats.input = input
coverageStats.output = new File(outputDir, input.getName + ".stats")
coverageStats.plot = new File(outputDir, input.getName + ".stats.png")
coverageStats.output = new File(outputDir, name + ".stats")
coverageStats.plot = new File(outputDir, name + ".stats.png")
coverageStats
}
}
......@@ -61,12 +61,12 @@ class BedtoolsCoverage(val root: Configurable) extends Bedtools {
object BedtoolsCoverage {
/** Returns defaul bedtools coverage */
def apply(root: Configurable, input: File, intersect: File, output: File,
def apply(root: Configurable, input: File, intersect: File, output: Option[File] = None,
depth: Boolean = true, sameStrand: Boolean = false, diffStrand: Boolean = false): BedtoolsCoverage = {
val bedtoolsCoverage = new BedtoolsCoverage(root)
bedtoolsCoverage.input = input
bedtoolsCoverage.intersectFile = intersect
bedtoolsCoverage.output = output
output.foreach(bedtoolsCoverage.output = _)
bedtoolsCoverage.depth = depth
bedtoolsCoverage.sameStrand = sameStrand
bedtoolsCoverage.diffStrand = diffStrand
......
......@@ -40,6 +40,8 @@ class BedtoolsIntersect(val root: Configurable) extends Bedtools {
var inputTag = "-a"
var ubam = false
override def beforeCmd() {
if (input.getName.endsWith(".bam")) inputTag = "-abam"
}
......@@ -50,6 +52,7 @@ class BedtoolsIntersect(val root: Configurable) extends Bedtools {
required("-b", intersectFile) +
optional("-f", minOverlap) +
conditional(count, "-c") +
conditional(ubam, "-ubam") +
" > " + required(output)
}
......@@ -61,6 +64,7 @@ object BedtoolsIntersect {
bedtoolsIntersect.input = input
bedtoolsIntersect.intersectFile = intersect
bedtoolsIntersect.output = output
if (output.getName.endsWith(".sam")) bedtoolsIntersect.ubam = true
bedtoolsIntersect.minOverlap = minOverlap
bedtoolsIntersect.count = count
bedtoolsIntersect
......
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