Commit c708df45 authored by Sander Bollen's avatar Sander Bollen
Browse files

sort input bed and fix test

parent 15d13bb6
......@@ -17,11 +17,11 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import java.io.File
import nl.lumc.sasc.biopet.core.annotations.{ RibosomalRefFlat, AnnotationRefFlat }
import nl.lumc.sasc.biopet.core.annotations.{AnnotationRefFlat, RibosomalRefFlat}
import nl.lumc.sasc.biopet.utils.config.Configurable
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.core.{ Reference, BiopetFifoPipe, PipelineCommand, SampleLibraryTag }
import nl.lumc.sasc.biopet.extensions.bedtools.{ BedtoolsCoverage, BedtoolsIntersect }
import nl.lumc.sasc.biopet.core.{BiopetFifoPipe, PipelineCommand, Reference, SampleLibraryTag}
import nl.lumc.sasc.biopet.extensions.bedtools.{BedtoolsCoverage, BedtoolsIntersect, BedtoolsSort}
import nl.lumc.sasc.biopet.extensions.picard._
import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsFlagstat
import nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats
......@@ -164,7 +164,11 @@ class BamMetrics(val root: Configurable) extends QScript
addSummarizable(biopetFlagstatLoose, targetName + "_biopet_flagstat_loose")
add(new BiopetFifoPipe(this, List(biLoose, biopetFlagstatLoose)))
val bedCov = BedtoolsCoverage(this, intervals.bed, inputBam, depth = true)
val sorter = new BedtoolsSort(this)
sorter.input = intervals.bed
sorter.output = swapExt(targetDir, intervals.bed, ".bed", ".sorted.bed")
add(sorter)
val bedCov = BedtoolsCoverage(this, sorter.output, inputBam, depth = true)
val covStats = CoverageStats(this, targetDir, inputBam.getName.stripSuffix(".bam") + ".coverage")
covStats.title = Some("Coverage Plot")
covStats.subTitle = Some(s"for file '$targetName.bed'")
......
package nl.lumc.sasc.biopet.extensions.bedtools
import java.io.File
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Argument, Input, Output}
/**
* Created by Sander Bollen on 26-5-16.
*/
class BedtoolsSort(val root: Configurable) extends Bedtools with Reference {
@Input
var input: File = null
@Output
var output: File = null
@Argument(required = false)
var faidx: File = referenceFai
def cmdLine = required(executable) + required("sort") + required("-i", input) +
optional("-faidx", faidx) +
(if(outputAsStsout) "" else " > " + required(output))
}
......@@ -4,7 +4,7 @@ import java.io.File
import java.nio.file.Paths
import nl.lumc.sasc.biopet.extensions.bedtools.BedtoolsCoverage
import nl.lumc.sasc.biopet.utils.config.Config
import nl.lumc.sasc.biopet.utils.config.{Config, Configurable}
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
......@@ -21,10 +21,14 @@ class BedToolsTest extends TestNGSuite with Matchers {
val file = new File(Paths.get(this.getClass.getResource("/ref.fa.fai").toURI).toString)
val tmp = File.createTempFile("test", ".bed")
tmp.deleteOnExit()
val cov = new BedtoolsCoverage(null) {
override def globalConfig = new Config(Map("output_dir" -> tmp.getParent))
class TestCov(override val root: Configurable) extends BedtoolsCoverage(root) {
jobTempDir = tmp
override def referenceFai = file
def genome = BedtoolsCoverage.createGenomeFile(file, file.getParentFile)
}
val genome = cov.createGenomeFile(file)
val cov = new TestCov(null)
val genome = cov.genome
Source.fromFile(genome).getLines().mkString("\n") shouldBe "chr1\t9"
}
......
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