BedToolsTest.scala 909 Bytes
Newer Older
Sander Bollen's avatar
Sander Bollen committed
1 2 3 4 5 6
package nl.lumc.sasc.biopet.extensions

import java.io.File
import java.nio.file.Paths

import nl.lumc.sasc.biopet.extensions.bedtools.BedtoolsCoverage
Sander Bollen's avatar
Sander Bollen committed
7
import nl.lumc.sasc.biopet.utils.config.Config
Sander Bollen's avatar
Sander Bollen committed
8 9 10 11 12 13 14
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test

import scala.io.Source

/**
Sander Bollen's avatar
Sander Bollen committed
15 16
 * Created by Sander Bollen on 12-5-16.
 */
Sander Bollen's avatar
Sander Bollen committed
17 18 19 20 21 22 23
class BedToolsTest extends TestNGSuite with Matchers {

  @Test
  def testBedtoolsCoverageCreateGenomeFile() = {
    val file = new File(Paths.get(this.getClass.getResource("/ref.fa.fai").toURI).toString)
    val tmp = File.createTempFile("test", ".bed")
    tmp.deleteOnExit()
Sander Bollen's avatar
Sander Bollen committed
24 25 26
    val cov = new BedtoolsCoverage(null) {
      override def globalConfig = new Config(Map("output_dir" -> tmp.getParent))
    }
Sander Bollen's avatar
Sander Bollen committed
27 28 29 30 31
    val genome = cov.createGenomeFile(file)
    Source.fromFile(genome).getLines().mkString("\n") shouldBe "chr1\t9"
  }

}