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

fix nullpointer

parent 8197a29d
......@@ -15,11 +15,11 @@
*/
package nl.lumc.sasc.biopet.extensions.bedtools
import java.io.{File, PrintWriter}
import java.io.{ File, PrintWriter }
import nl.lumc.sasc.biopet.core.Reference
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Argument, Input, Output}
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
import scala.io.Source
......@@ -44,7 +44,7 @@ class BedtoolsCoverage(val root: Configurable) extends Bedtools with Reference {
@Argument(doc = "diffStrand", required = false)
var diffStrand: Boolean = false
@Argument(doc = "sorted", required= false)
@Argument(doc = "sorted", required = false)
var sorted: Boolean = config("sorted", default = false, freeVar = false)
override def defaultCoreMemory = 4.0
......@@ -61,11 +61,11 @@ class BedtoolsCoverage(val root: Configurable) extends Bedtools with Reference {
(if (outputAsStsout) "" else " > " + required(output))
/**
* Creates the genome file. i.e. the first two columns of the fasta index
* @return
*/
* Creates the genome file. i.e. the first two columns of the fasta index
* @return
*/
def createGenomeFile(fai: File): File = {
val tmp = File.createTempFile(fai.getName, ".genome", output.getParentFile)
val tmp = File.createTempFile(fai.getName, ".genome", config("output_dir"))
tmp.deleteOnExit()
val writer = new PrintWriter(tmp)
Source.fromFile(fai).
......
......@@ -4,6 +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 org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
......@@ -11,19 +12,19 @@ import org.testng.annotations.Test
import scala.io.Source
/**
* Created by Sander Bollen on 12-5-16.
*/
* Created by Sander Bollen on 12-5-16.
*/
class BedToolsTest extends TestNGSuite with Matchers {
@Test
def testBedtoolsCoverageCreateGenomeFile() = {
val file = new File(Paths.get(this.getClass.getResource("/ref.fa.fai").toURI).toString)
val cov = new BedtoolsCoverage(null)
val tmp = File.createTempFile("test", ".bed")
tmp.deleteOnExit()
cov.output = tmp
val cov = new BedtoolsCoverage(null) {
override def globalConfig = new Config(Map("output_dir" -> tmp.getParent))
}
val genome = cov.createGenomeFile(file)
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