Commit c4c62209 authored by Peter van 't Hof's avatar Peter van 't Hof

Added separated outputDirs

parent ee8d9af5
......@@ -56,9 +56,13 @@ class BamMetricsTest extends TestNGSuite with Matchers {
) yield Array(rois, amplicon, rna, wgs)
}
private var dirs: List[File] = Nil
@Test(dataProvider = "bammetricsOptions")
def testBamMetrics(rois: Int, amplicon: Boolean, rna: Boolean, wgs: Boolean) = {
val map = ConfigUtils.mergeMaps(Map("output_dir" -> BamMetricsTest.outputDir, "rna_metrics" -> rna, "wgs_metrics" -> wgs),
val outputDir = Files.createTempDir()
dirs :+= outputDir
val map = ConfigUtils.mergeMaps(Map("output_dir" -> outputDir, "rna_metrics" -> rna, "wgs_metrics" -> wgs),
Map(BamMetricsTest.executables.toSeq: _*)) ++
(if (amplicon) Map("amplicon_bed" -> BamMetricsTest.ampliconBed.getAbsolutePath) else Map()) ++
(if (rna) Map("annotation_refflat" -> "transcripts.refFlat") else Map()) ++
......@@ -81,30 +85,28 @@ class BamMetricsTest extends TestNGSuite with Matchers {
}
// remove temporary run directory all tests in the class have been run
@AfterClass
def removeTempOutputDir() = {
FileUtils.deleteDirectory(BamMetricsTest.outputDir)
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object BamMetricsTest {
val outputDir = Files.createTempDir()
new File(outputDir, "input").mkdirs()
val inputDir = Files.createTempDir()
val bam = new File(outputDir, "input" + File.separator + "bla.bam")
val bam = new File(inputDir, "input" + File.separator + "bla.bam")
Files.touch(bam)
val ampliconBed = new File(outputDir, "input" + File.separator + "amplicon_bed.bed")
val ampliconBed = new File(inputDir, "input" + File.separator + "amplicon_bed.bed")
Files.touch(ampliconBed)
def roi(i: Int): File = {
val roi = new File(outputDir, "input" + File.separator + s"roi${i}.bed")
val roi = new File(inputDir, "input" + File.separator + s"roi${i}.bed")
Files.touch(roi)
roi
}
private def copyFile(name: String): Unit = {
val is = getClass.getResourceAsStream("/" + name)
val os = new FileOutputStream(new File(outputDir, name))
val os = new FileOutputStream(new File(inputDir, name))
org.apache.commons.io.IOUtils.copy(is, os)
os.close()
}
......@@ -116,7 +118,7 @@ object BamMetricsTest {
val executables = Map(
"skip_write_dependencies" -> true,
"refFlat" -> "bla.refFlat",
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (inputDir + File.separator + "ref.fa"),
"samtools" -> Map("exe" -> "test"),
"bedtools" -> Map("exe" -> "test"),
"md5sum" -> Map("exe" -> "test")
......
......@@ -14,58 +14,73 @@
*/
package nl.lumc.sasc.biopet.pipelines.generateindexes
import java.io.File
import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Config
import org.apache.commons.io.FileUtils
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
import org.testng.annotations.{AfterClass, Test}
/**
* Created by pjvan_thof on 13-5-16.
*/
class DownloadGenomesTest extends TestNGSuite with Matchers {
def initPipeline(map: Map[String, Any]): DownloadGenomes = {
def initPipeline(map: Map[String, Any], outputDir: File): DownloadGenomes = {
new DownloadGenomes() {
override def configNamespace = "generateindexes"
override def globalConfig = new Config(ConfigUtils.mergeMaps(map, DownloadGenomesTest.config))
override def globalConfig = new Config(ConfigUtils.mergeMaps(map, DownloadGenomesTest.config(outputDir)))
qSettings = new QSettings
qSettings.runName = "test"
}
}
private var dirs: List[File] = Nil
@Test
def testNoFastaUri(): Unit = {
val pipeline = initPipeline(Map())
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map(), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("" -> "")))
an[IllegalArgumentException] should be thrownBy pipeline.script()
}
@Test
def testNcbiAssembly(): Unit = {
val pipeline = initPipeline(Map())
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map(), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("ncbi_assembly_report" -> "id")))
noException should be thrownBy pipeline.script()
}
@Test
def testSingleFasta(): Unit = {
val pipeline = initPipeline(Map())
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map(), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri")))
noException should be thrownBy pipeline.script()
}
@Test
def testMultiFasta(): Unit = {
val pipeline = initPipeline(Map())
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map(), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> List("uri", "uri2", "uri3.gz"))))
noException should be thrownBy pipeline.script()
}
@Test
def testSingleDbsnp(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"dbsnp" -> Map("version" -> Map("vcf_uri" -> "uri.vcf.gz")))))
noException should be thrownBy pipeline.script()
......@@ -73,7 +88,9 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testContigMapDbsnp(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"dbsnp" -> Map("version" -> Map("vcf_uri" -> "uri.vcf.gz", "contig_map" -> Map("1" -> "chr1"))))))
noException should be thrownBy pipeline.script()
......@@ -81,7 +98,9 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testUnzippedContigMapDbsnp(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"dbsnp" -> Map("version" -> Map("vcf_uri" -> "uri.vcf", "contig_map" -> Map("1" -> "chr1"))))))
noException should be thrownBy pipeline.script()
......@@ -89,7 +108,9 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testSingleUnzippedDbsnp(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"dbsnp" -> Map("version" -> Map(("vcf_uri" -> "uri.vcf"))))))
noException should be thrownBy pipeline.script()
......@@ -97,7 +118,9 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testMultiDbsnp(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"dbsnp" -> Map("version" -> Map("vcf_uri" -> List("uri.vcf.gz", "uri2.vcf.gz"))))))
noException should be thrownBy pipeline.script()
......@@ -105,7 +128,9 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testVep(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"vep" -> Map("version" -> Map("cache_uri" -> "something/human_vep_80_hg19.tar.gz")))))
noException should be thrownBy pipeline.script()
......@@ -113,7 +138,9 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testGtfZipped(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"gene_annotation" -> Map("version" -> Map("gtf_uri" -> "bla.gf.gz")))))
noException should be thrownBy pipeline.script()
......@@ -121,7 +148,9 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testGtf(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"gene_annotation" -> Map("version" -> Map("gtf_uri" -> "bla.gf")))))
noException should be thrownBy pipeline.script()
......@@ -129,19 +158,22 @@ class DownloadGenomesTest extends TestNGSuite with Matchers {
@Test
def testGff(): Unit = {
val pipeline = initPipeline(Map("download_annotations" -> true))
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Map("download_annotations" -> true), outputDir)
pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
"gene_annotation" -> Map("version" -> Map("gff_uri" -> "bla.gf")))))
noException should be thrownBy pipeline.script()
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object DownloadGenomesTest {
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
val config = Map(
def config(outputDir: File) = Map(
"skip_write_dependencies" -> true,
"output_dir" -> outputDir,
"bwa" -> Map("exe" -> "test"),
......
......@@ -20,10 +20,11 @@ import java.nio.file.Paths
import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.Logging
import nl.lumc.sasc.biopet.utils.config.Config
import org.apache.commons.io.FileUtils
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
import org.testng.annotations.{AfterClass, Test}
/**
* Created by pjvan_thof on 4/11/16.
......@@ -38,10 +39,14 @@ class GwasTestTest extends TestNGSuite with Matchers {
}
}
private var dirs: List[File] = Nil
@Test
def testFromVcf: Unit = {
val outputDir = Files.createTempDir()
dirs :+= outputDir
Logging.errors.clear()
val pipeline = initPipeline(GwasTestTest.config ++
val pipeline = initPipeline(GwasTestTest.config(outputDir) ++
Map("input_vcf" -> GwasTestTest.vcfFile.toString
)
)
......@@ -50,11 +55,18 @@ class GwasTestTest extends TestNGSuite with Matchers {
@Test
def testEmpty: Unit = {
val pipeline = initPipeline(GwasTestTest.config)
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(GwasTestTest.config(outputDir))
intercept[IllegalArgumentException] {
pipeline.script()
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object GwasTestTest {
......@@ -65,16 +77,13 @@ object GwasTestTest {
val phenotypeFile = File.createTempFile("gwas.", ".txt")
phenotypeFile.deleteOnExit()
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
val reference = new File(resourcePath("/fake_chrQ.fa"))
private def resourcePath(p: String): String = {
Paths.get(getClass.getResource(p).toURI).toString
}
val config = Map(
def config(outputDir: File) = Map(
"skip_write_dependencies" -> true,
"reference_fasta" -> reference.toString,
"phenotype_file" -> phenotypeFile.toString,
......
......@@ -19,10 +19,11 @@ import java.nio.file.Paths
import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.config.Config
import org.apache.commons.io.FileUtils
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
import org.testng.annotations.{AfterClass, Test}
/**
* Created by pjvan_thof on 31-5-16.
......@@ -37,9 +38,13 @@ class Impute2VcfTest extends TestNGSuite with Matchers {
}
}
private var dirs: List[File] = Nil
@Test
def testFromGens: Unit = {
val pipeline = initPipeline(Impute2VcfTest.config ++
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Impute2VcfTest.config(outputDir) ++
Map("input_gens" -> List(Map("genotypes" -> Impute2VcfTest.vcfFile, "contig" -> "chrQ"))
)
)
......@@ -48,7 +53,9 @@ class Impute2VcfTest extends TestNGSuite with Matchers {
@Test
def testWrongContig: Unit = {
val pipeline = initPipeline(Impute2VcfTest.config ++
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Impute2VcfTest.config(outputDir) ++
Map("input_gens" -> List(Map("genotypes" -> Impute2VcfTest.vcfFile, "contig" -> "chrBla"))
)
)
......@@ -59,7 +66,9 @@ class Impute2VcfTest extends TestNGSuite with Matchers {
@Test
def testFromSpecs: Unit = {
val pipeline = initPipeline(Impute2VcfTest.config ++
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Impute2VcfTest.config(outputDir) ++
Map("imute_specs_file" -> Impute2VcfTest.resourcePath("/specs/files.specs"))
)
pipeline.script()
......@@ -67,12 +76,18 @@ class Impute2VcfTest extends TestNGSuite with Matchers {
@Test
def testEmpty: Unit = {
val pipeline = initPipeline(Impute2VcfTest.config)
val outputDir = Files.createTempDir()
dirs :+= outputDir
val pipeline = initPipeline(Impute2VcfTest.config(outputDir))
intercept[IllegalArgumentException] {
pipeline.script()
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object Impute2VcfTest {
......@@ -83,16 +98,13 @@ object Impute2VcfTest {
val phenotypeFile = File.createTempFile("gwas.", ".txt")
phenotypeFile.deleteOnExit()
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
val reference = new File(resourcePath("/fake_chrQ.fa"))
private def resourcePath(p: String): String = {
Paths.get(getClass.getResource(p).toURI).toString
}
val config = Map(
def config(outputDir: File) = Map(
"skip_write_dependencies" -> true,
"reference_fasta" -> reference.toString,
"phenotype_file" -> phenotypeFile.toString,
......
......@@ -14,16 +14,17 @@
*/
package nl.lumc.sasc.biopet.pipelines.kopisu
import java.io.{ File, FileOutputStream }
import java.io.{File, FileOutputStream}
import com.google.common.io.Files
import nl.lumc.sasc.biopet.extensions.freec.{ FreeC, FreeCAssessSignificancePlot, FreeCCNVPlot }
import nl.lumc.sasc.biopet.extensions.freec.{FreeC, FreeCAssessSignificancePlot, FreeCCNVPlot}
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Config
import org.apache.commons.io.FileUtils
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.{ DataProvider, Test }
import org.testng.annotations.{AfterClass, DataProvider, Test}
import scala.collection.mutable.ListBuffer
......@@ -33,15 +34,17 @@ import scala.collection.mutable.ListBuffer
* Created by pjvan_thof on 3/2/15.
*/
class KopisuTest extends TestNGSuite with Matchers {
def initPipeline(map: Map[String, Any]): Kopisu = {
def initPipeline(map: Map[String, Any], outputDir: File): Kopisu = {
new Kopisu() {
override def configNamespace = "kopisu"
override def globalConfig = new Config(ConfigUtils.mergeMaps(map, KopisuTest.config))
override def globalConfig = new Config(ConfigUtils.mergeMaps(map, KopisuTest.config(outputDir)))
qSettings = new QSettings
qSettings.runName = "test"
}
}
private var dirs: List[File] = Nil
@DataProvider(name = "shivaSvCallingOptions")
def shivaSvCallingOptions = {
val bool = Array(true, false)
......@@ -56,12 +59,15 @@ class KopisuTest extends TestNGSuite with Matchers {
def testShivaSvCalling(bams: Int,
freec: Boolean,
conifer: Boolean) = {
val outputDir = Files.createTempDir()
dirs :+= outputDir
val callers: ListBuffer[String] = ListBuffer()
val map = Map("sv_callers" -> callers.toList)
val pipeline = initPipeline(map ++ Map(
"use_freec_method" -> freec,
"use_conifer_method" -> conifer
))
), outputDir)
pipeline.inputBams = (for (n <- 1 to bams) yield n.toString -> KopisuTest.inputTouch("bam_" + n + ".bam")).toMap
......@@ -84,21 +90,26 @@ class KopisuTest extends TestNGSuite with Matchers {
pipeline.functions.count(_.isInstanceOf[FreeCCNVPlot]) shouldBe (if (freec) bams else 0)
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object KopisuTest {
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
new File(outputDir, "input").mkdirs()
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
private def inputTouch(name: String): File = {
val file = new File(outputDir, "input" + File.separator + name).getAbsoluteFile
val file = new File(inputDir, name).getAbsoluteFile
Files.touch(file)
file
}
private def copyFile(name: String): Unit = {
val is = getClass.getResourceAsStream("/" + name)
val os = new FileOutputStream(new File(outputDir, name))
val os = new FileOutputStream(new File(inputDir, name))
org.apache.commons.io.IOUtils.copy(is, os)
os.close()
}
......@@ -108,14 +119,13 @@ object KopisuTest {
copyFile("ref.fa.fai")
val controlDir = Files.createTempDir()
controlDir.deleteOnExit()
Files.touch(new File(controlDir, "test.txt"))
val config = Map(
def config(outputDir: File) = Map(
"skip_write_dependencies" -> true,
"name_prefix" -> "test",
"output_dir" -> outputDir,
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (inputDir + File.separator + "ref.fa"),
"gatk_jar" -> "test",
"samtools" -> Map("exe" -> "test"),
"md5sum" -> Map("exe" -> "test"),
......
......@@ -47,6 +47,8 @@ import org.testng.annotations.{ AfterClass, DataProvider, Test }
class TinyCapTest extends TestNGSuite with Matchers {
private var dirs: List[File] = Nil
def initPipeline(map: Map[String, Any]): TinyCap = {
new TinyCap() {
override def configNamespace = "tinycap"
......@@ -69,8 +71,10 @@ class TinyCapTest extends TestNGSuite with Matchers {
@Test(dataProvider = "tinyCapOptions")
def testTinyCap(dummy: String, sample1: Boolean): Unit = {
val outputDir = TinyCapTest.outputDir
dirs :+= outputDir
val map = {
var m: Map[String, Any] = TinyCapTest.config
var m: Map[String, Any] = TinyCapTest.config(outputDir)
if (sample1) m = ConfigUtils.mergeMaps(TinyCapTest.sample1, m)
m
}
......@@ -90,35 +94,34 @@ class TinyCapTest extends TestNGSuite with Matchers {
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
FileUtils.deleteDirectory(TinyCapTest.outputDir)
dirs.foreach(FileUtils.deleteDirectory)
}
}
object TinyCapTest {
val outputDir = Files.createTempDir()
new File(outputDir, "input").mkdirs()
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
val r1 = new File(outputDir, "input" + File.separator + "R1.fq.gz")
val r1 = new File(inputDir, "input" + File.separator + "R1.fq.gz")
Files.touch(r1)
val bam = new File(outputDir, "input" + File.separator + "bamfile.bam")
val bam = new File(inputDir, "input" + File.separator + "bamfile.bam")
Files.touch(bam)
val referenceFasta = new File(outputDir, "ref.fa")
val referenceFasta = new File(inputDir, "ref.fa")
Files.touch(referenceFasta)
val referenceFastaDict = new File(outputDir, "ref.dict")
val referenceFastaDict = new File(inputDir, "ref.dict")
Files.touch(referenceFastaDict)
val bowtieIndex = new File(outputDir, "ref.1.ebwt")
val bowtieIndex = new File(inputDir, "ref.1.ebwt")
Files.touch(bowtieIndex)
val annotationGFF = new File(outputDir, "annot.gff")
val annotationGTF = new File(outputDir, "annot.gtf")
val annotationRefflat = new File(outputDir, "annot.refflat")
val annotationGFF = new File(inputDir, "annot.gff")
val annotationGTF = new File(inputDir, "annot.gtf")
val annotationRefflat = new File(inputDir, "annot.refflat")
Files.touch(annotationGFF)
Files.touch(annotationGTF)
Files.touch(annotationRefflat)
val config = Map(
def config(outputDir: File) = Map(
"skip_write_dependencies" -> true,
"output_dir" -> outputDir,
"reference_fasta" -> (referenceFasta.getAbsolutePath),
......
......@@ -21,10 +21,11 @@ import com.google.common.io.Files
import nl.lumc.sasc.biopet.extensions.VariantEffectPredictor
import nl.lumc.sasc.biopet.extensions.tools.VcfWithVcf
import nl.lumc.sasc.biopet.utils.config.Config
import org.apache.commons.io.FileUtils
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test
import org.testng.annotations.{AfterClass, Test}
/**
* Created by pjvan_thof on 4/11/16.
......@@ -39,9 +40,13 @@ class ToucanTest extends TestNGSuite with Matchers {
}
}
private var dirs: List[File] = Nil
@Test
def testDefault(): Unit = {
val pipeline = initPipeline(ToucanTest.config)
val outputDir = ToucanTest.outputDir
dirs :+= outputDir
val pipeline = initPipeline(ToucanTest.config(outputDir))
pipeline.inputVcf = new File(ToucanTest.resourcePath("/chrQ2.vcf.gz"))
pipeline.script()
......@@ -51,7 +56,10 @@ class ToucanTest extends TestNGSuite with Matchers {
@Test
def testBinning(): Unit = {
val pipeline = initPipeline(ToucanTest.config ++ Map("bin_size" -> 4000, "min_scatter_genome_size" -> 1000))
val outputDir = ToucanTest.outputDir
dirs :+= outputDir
val pipeline = initPipeline(ToucanTest.config(outputDir) ++ Map("bin_size" -> 4000, "min_scatter_genome_size" -> 1000))
pipeline.inputVcf = new File(ToucanTest.resourcePath("/chrQ2.vcf.gz"))
pipeline.script()
......@@ -61,7 +69,10 @@ class ToucanTest extends TestNGSuite with Matchers {
@Test
def testGonl(): Unit = {
val pipeline = initPipeline(ToucanTest.config ++ Map("gonl_vcf" -> ToucanTest.gonlVcfFile))
val outputDir = ToucanTest.outputDir
dirs :+= outputDir
val pipeline = initPipeline(ToucanTest.config(outputDir) ++ Map("gonl_vcf" -> ToucanTest.gonlVcfFile))
pipeline.inputVcf = new File(ToucanTest.resourcePath("/chrQ2.vcf.gz"))
pipeline.script()
......@@ -71,7 +82,10 @@ class ToucanTest extends TestNGSuite with Matchers {
@Test
def testExac(): Unit = {
val pipeline = initPipeline(ToucanTest.config ++ Map("exac_vcf" -> ToucanTest.exacVcfFile))
val outputDir = ToucanTest.outputDir
dirs :+= outputDir
val pipeline = initPipeline(ToucanTest.config(outputDir) ++ Map("exac_vcf" -> ToucanTest.exacVcfFile))
pipeline.inputVcf = new File(ToucanTest.resourcePath("/chrQ2.vcf.gz"))
pipeline.script()
......@@ -81,7 +95,10 @@ class ToucanTest extends TestNGSuite with Matchers {
@Test
def testVarda(): Unit = {
val pipeline = initPipeline(ToucanTest.config ++ Map("use_varda" -> true))
val outputDir = ToucanTest.outputDir
dirs :+= outputDir
val pipeline = initPipeline(ToucanTest.config(outputDir) ++ Map("use_varda" -> true))
val gvcfFile = File.createTempFile("bla.", ".g.vcf")
pipeline.inputVcf = new File(ToucanTest.resourcePath("/chrQ2.vcf.gz"))
pipeline.inputGvcf = Some(gvcfFile)
......@@ -91,6 +108,10 @@ class ToucanTest extends TestNGSuite with Matchers {
pipeline.functions.count(_.isInstanceOf[VcfWithVcf]) shouldBe 0
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object ToucanTest {
......@@ -98,15 +119,14 @@ object ToucanTest {
Paths.get(getClass.getResource(p).toURI).toString
}
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
def outputDir = Files.createTempDir()
val gonlVcfFile: File = File.createTempFile("gonl.", ".vcf.gz")
gonlVcfFile.deleteOnExit()