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

Adding separated outputDirs

parent 717a50df
......@@ -14,19 +14,20 @@
*/
package nl.lumc.sasc.biopet.pipelines.basty
import java.io.{ File, FileOutputStream }
import java.io.{File, FileOutputStream}
import com.google.common.io.Files
import nl.lumc.sasc.biopet.extensions.{ Raxml, RunGubbins }
import nl.lumc.sasc.biopet.extensions.gatk.{ BaseRecalibrator, IndelRealigner, PrintReads, RealignerTargetCreator }
import nl.lumc.sasc.biopet.extensions.{Raxml, RunGubbins}
import nl.lumc.sasc.biopet.extensions.gatk.{BaseRecalibrator, IndelRealigner, PrintReads, RealignerTargetCreator}
import nl.lumc.sasc.biopet.extensions.picard.MarkDuplicates
import nl.lumc.sasc.biopet.extensions.tools.{ BastyGenerateFasta, VcfStats }
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.extensions.tools.{BastyGenerateFasta, VcfStats}
import nl.lumc.sasc.biopet.utils.{ConfigUtils, 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.{ DataProvider, Test }
import org.testng.annotations.{AfterClass, DataProvider, Test}
/**
* Created by pjvanthof on 27/09/16.
......@@ -61,10 +62,14 @@ class BastyTest extends TestNGSuite with Matchers {
def annotation = false
def bootRuns: Option[Int] = None
private var dirs: List[File] = Nil
@Test(dataProvider = "bastyOptions")
def testBasty(f: String, sample1: Boolean, sample2: Boolean): Unit = {
val outputDir = BastyTest.outputDir
dirs :+= outputDir
val map = {
var m: Map[String, Any] = BastyTest.config
var m: Map[String, Any] = BastyTest.config(outputDir)
if (sample1) m = ConfigUtils.mergeMaps(BastyTest.sample1, m)
if (sample2) m = ConfigUtils.mergeMaps(BastyTest.sample2, m)
if (dbsnp) m = ConfigUtils.mergeMaps(Map("dbsnp_vcf" -> "test.vcf.gz"), m)
......@@ -133,21 +138,26 @@ class BastyTest extends TestNGSuite with Matchers {
pipeline.functions.count(_.isInstanceOf[RunGubbins]) shouldBe 2
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object BastyTest {
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
new File(outputDir, "input").mkdirs()
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
def inputTouch(name: String): String = {
val file = new File(outputDir, "input" + File.separator + name)
val file = new File(inputDir, name)
Files.touch(file)
file.getAbsolutePath
}
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()
}
......@@ -156,14 +166,14 @@ object BastyTest {
copyFile("ref.dict")
copyFile("ref.fa.fai")
val config = Map(
def config(outputDir: File) = Map(
"skip_write_dependencies" -> true,
"name_prefix" -> "test",
"cache" -> true,
"dir" -> "test",
"vep_script" -> "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"),
"bcftools" -> Map("exe" -> "test"),
......
......@@ -50,10 +50,14 @@ class CarpTest extends TestNGSuite with Matchers {
for (s1 <- bool; s2 <- bool; s3 <- bool; t <- bool; c <- bool) yield Array("", s1, s2, s3, t, c)
}
private var dirs: List[File] = Nil
@Test(dataProvider = "carpOptions")
def testCarp(f: String, sample1: Boolean, sample2: Boolean, sample3: Boolean, threatment: Boolean, control: Boolean): Unit = {
val outputDir = CarpTest.outputDir
dirs :+= outputDir
val map = {
var m = ConfigUtils.mergeMaps(Map("output_dir" -> CarpTest.outputDir
var m = ConfigUtils.mergeMaps(Map("output_dir" -> outputDir
), CarpTest.executables)
if (sample1) m = ConfigUtils.mergeMaps(CarpTest.sample1, m)
......@@ -92,22 +96,23 @@ class CarpTest extends TestNGSuite with Matchers {
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
FileUtils.deleteDirectory(CarpTest.outputDir)
dirs.foreach(FileUtils.deleteDirectory)
}
}
object CarpTest {
val outputDir = Files.createTempDir()
new File(outputDir, "input").mkdirs()
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
def inputTouch(name: String): String = {
val file = new File(outputDir, "input" + File.separator + name)
val file = new File(inputDir, name)
Files.touch(file)
file.getAbsolutePath
}
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()
}
......@@ -118,7 +123,7 @@ object CarpTest {
val executables = Map(
"skip_write_dependencies" -> true,
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (inputDir + File.separator + "ref.fa"),
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
"sickle" -> Map("exe" -> "test"),
......
......@@ -59,10 +59,14 @@ class FlexiprepTest extends TestNGSuite with Matchers {
) yield Array("", pair, skipTrim, skipClip, zip, abortOnCorruptFastq)
}
private var dirs: List[File] = Nil
@Test(dataProvider = "flexiprepOptions")
def testFlexiprep(f: String, paired: Boolean, skipTrim: Boolean, skipClip: Boolean,
zipped: Boolean, abortOnCorruptFastq: Boolean) = {
val map = ConfigUtils.mergeMaps(Map("output_dir" -> FlexiprepTest.outputDir,
val outputDir = FlexiprepTest.outputDir
dirs :+= outputDir
val map = ConfigUtils.mergeMaps(Map("output_dir" -> outputDir,
"skip_trim" -> skipTrim,
"skip_clip" -> skipClip,
"abort_on_corrupt_fastq" -> abortOnCorruptFastq
......@@ -85,8 +89,10 @@ class FlexiprepTest extends TestNGSuite with Matchers {
@Test
def testNoSample: Unit = {
val outputDir = FlexiprepTest.outputDir
dirs :+= outputDir
val map = ConfigUtils.mergeMaps(Map(
"output_dir" -> FlexiprepTest.outputDir
"output_dir" -> outputDir
), Map(FlexiprepTest.executables.toSeq: _*))
val flexiprep: Flexiprep = initPipeline(map)
......@@ -97,22 +103,27 @@ class FlexiprepTest extends TestNGSuite with Matchers {
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
FileUtils.deleteDirectory(FlexiprepTest.outputDir)
dirs.foreach(FileUtils.deleteDirectory)
}
}
object FlexiprepTest {
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")
val r1 = new File(inputDir, "R1.fq")
Files.touch(r1)
val r2 = new File(outputDir, "input" + File.separator + "R2.fq")
r1.deleteOnExit()
val r2 = new File(inputDir, "R2.fq")
Files.touch(r2)
val r1Zipped = new File(outputDir, "input" + File.separator + "R1.fq.gz")
r2.deleteOnExit()
val r1Zipped = new File(inputDir, "R1.fq.gz")
Files.touch(r1Zipped)
val r2Zipped = new File(outputDir, "input" + File.separator + "R2.fq.gz")
r1Zipped.deleteOnExit()
val r2Zipped = new File(inputDir, "R2.fq.gz")
Files.touch(r2Zipped)
r2Zipped.deleteOnExit()
val executables = Map(
"skip_write_dependencies" -> true,
......
......@@ -18,13 +18,14 @@ import java.io.File
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core.BiopetCommandLineFunction
import nl.lumc.sasc.biopet.extensions.centrifuge.{ Centrifuge, CentrifugeKreport }
import nl.lumc.sasc.biopet.extensions.kraken.{ Kraken, KrakenReport }
import nl.lumc.sasc.biopet.extensions.centrifuge.{Centrifuge, CentrifugeKreport}
import nl.lumc.sasc.biopet.extensions.kraken.{Kraken, KrakenReport}
import nl.lumc.sasc.biopet.extensions.picard.SamToFastq
import nl.lumc.sasc.biopet.extensions.samtools.SamtoolsView
import nl.lumc.sasc.biopet.extensions.tools.KrakenReportToJson
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.utils.{ConfigUtils, 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
......@@ -60,15 +61,19 @@ abstract class TestGearsSingle extends TestNGSuite with Matchers {
def inputMode: Option[String] = Some("fastq")
private var dirs: List[File] = Nil
@Test
def testGears(): Unit = {
val outputDir = TestGearsSingle.outputDir
dirs :+= outputDir
val map = ConfigUtils.mergeMaps(Map(
"gears_use_qiime_rtax" -> qiimeRtax,
"gears_use_centrifuge" -> centrifuge,
"gears_use_qiime_closed" -> qiimeClosed,
"gears_use_qiime_open" -> qiimeOpen,
"gears_use_seq_count" -> seqCount,
"output_dir" -> TestGearsSingle.outputDir
"output_dir" -> outputDir
) ++
kraken.map("gears_use_kraken" -> _) ++
downsample.map("downsample" -> _),
......@@ -134,6 +139,11 @@ abstract class TestGearsSingle extends TestNGSuite with Matchers {
pipesJobs.count(_.isInstanceOf[CentrifugeKreport]) shouldBe (if (centrifuge) 2 else 0)
}
}
@AfterClass
def removeDirs: Unit = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
class GearsSingleNoInputTest extends TestGearsSingle {
......@@ -219,17 +229,17 @@ class GearsSingleQiimeOpenDownsampleTest extends TestGearsSingle {
}
object TestGearsSingle {
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
new File(outputDir, "input").mkdirs()
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
val r1 = new File(outputDir, "input" + File.separator + "R1.fq")
val r1 = new File(inputDir, "R1.fq")
Files.touch(r1)
r1.deleteOnExit()
val r2 = new File(outputDir, "input" + File.separator + "R2.fq")
val r2 = new File(inputDir, "R2.fq")
Files.touch(r2)
r2.deleteOnExit()
val bam = new File(outputDir, "input" + File.separator + "bamfile.bam")
val bam = new File(inputDir, "bamfile.bam")
Files.touch(bam)
bam.deleteOnExit()
......
......@@ -17,12 +17,13 @@ package nl.lumc.sasc.biopet.pipelines.gears
import java.io.File
import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.utils.{ConfigUtils, 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.{ DataProvider, Test }
import org.testng.annotations.{AfterClass, DataProvider, Test}
/**
* Created by pjvanthof on 04/02/16.
......@@ -55,10 +56,14 @@ abstract class GearsTest extends TestNGSuite with Matchers {
) yield Array("", s1, s2)
}
private var dirs: List[File] = Nil
@Test(dataProvider = "gearsOptions")
def testGears(dummy: String, sample1: Boolean, sample2: Boolean): Unit = {
val outputDir = GearsTest.outputDir
dirs :+= outputDir
val map = {
var m: Map[String, Any] = GearsTest.config
var m: Map[String, Any] = GearsTest.config(outputDir)
if (sample1) m = ConfigUtils.mergeMaps(GearsTest.sample1, m)
if (sample2) m = ConfigUtils.mergeMaps(GearsTest.sample2, m)
ConfigUtils.mergeMaps(Map(
......@@ -82,6 +87,11 @@ abstract class GearsTest extends TestNGSuite with Matchers {
}
}
@AfterClass
def removeDirs: Unit = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
class GearsDefaultTest extends GearsTest
......@@ -101,18 +111,21 @@ class GearsLibraryTest extends GearsTest {
}
object GearsTest {
val outputDir = Files.createTempDir()
new File(outputDir, "input").mkdirs()
outputDir.deleteOnExit()
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
val r1 = new File(outputDir, "input" + File.separator + "R1.fq")
val r1 = new File(inputDir, "R1.fq")
Files.touch(r1)
val r2 = new File(outputDir, "input" + File.separator + "R2.fq")
r1.deleteOnExit()
val r2 = new File(inputDir, "R2.fq")
Files.touch(r2)
val bam = new File(outputDir, "input" + File.separator + "bamfile.bam")
r2.deleteOnExit()
val bam = new File(inputDir, "bamfile.bam")
Files.touch(bam)
bam.deleteOnExit()
val config = Map(
def config(outputDir: File) = Map(
"skip_write_dependencies" -> true,
"output_dir" -> outputDir,
"kraken" -> Map("exe" -> "test", "db" -> "test"),
......
......@@ -14,21 +14,22 @@
*/
package nl.lumc.sasc.biopet.pipelines.gentrap
import java.io.{ File, FileOutputStream }
import java.io.{File, FileOutputStream}
import com.google.common.io.Files
import nl.lumc.sasc.biopet.core.{ BiopetFifoPipe, BiopetPipe }
import nl.lumc.sasc.biopet.core.{BiopetFifoPipe, BiopetPipe}
import nl.lumc.sasc.biopet.extensions._
import nl.lumc.sasc.biopet.extensions.gmap.Gsnap
import nl.lumc.sasc.biopet.extensions.hisat.Hisat2
import nl.lumc.sasc.biopet.extensions.tools.{ BaseCounter, WipeReads }
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.extensions.tools.{BaseCounter, WipeReads}
import nl.lumc.sasc.biopet.utils.{ConfigUtils, Logging}
import nl.lumc.sasc.biopet.utils.config.Config
import nl.lumc.sasc.biopet.utils.camelize
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}
abstract class GentrapTestAbstract(val expressionMeasures: List[String]) extends TestNGSuite with Matchers {
......@@ -58,11 +59,14 @@ abstract class GentrapTestAbstract(val expressionMeasures: List[String]) extends
} yield Array(strandProtocol)
}
private var dirs: List[File] = Nil
@Test(dataProvider = "expMeasuresstrandProtocol")
def testGentrap(strandProtocol: String) = {
val outputDir = GentrapTest.outputDir
dirs :+= outputDir
val settings = Map(
"output_dir" -> GentrapTest.outputDir,
"output_dir" -> outputDir,
"gsnap" -> Map("db" -> "test", "dir" -> "test"),
"expression_measures" -> expressionMeasures,
"strand_protocol" -> strandProtocol
......@@ -145,6 +149,10 @@ abstract class GentrapTestAbstract(val expressionMeasures: List[String]) extends
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
class GentrapFragmentsPerGeneTest extends GentrapTestAbstract(List("fragments_per_gene"))
......@@ -166,18 +174,18 @@ class GentrapCallVariantsTest extends GentrapTestAbstract(List("fragments_per_ge
}
object GentrapTest {
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
new File(outputDir, "input").mkdirs()
def outputDir = Files.createTempDir()
val inputDir = Files.createTempDir()
def inputTouch(name: String): String = {
val file = new File(outputDir, "input" + File.separator + name)
val file = new File(inputDir, name)
Files.touch(file)
file.getAbsolutePath
}
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()
}
......@@ -188,12 +196,12 @@ object GentrapTest {
val executables: Map[String, Any] = Map(
"skip_write_dependencies" -> true,
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"refFlat" -> (outputDir + File.separator + "ref.fa"),
"annotation_gtf" -> (outputDir + File.separator + "ref.fa"),
"annotation_bed" -> (outputDir + File.separator + "ref.fa"),
"annotation_refflat" -> (outputDir + File.separator + "ref.fa"),
"ribosome_refflat" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (inputDir + File.separator + "ref.fa"),
"refFlat" -> (inputDir + File.separator + "ref.fa"),
"annotation_gtf" -> (inputDir + File.separator + "ref.fa"),
"annotation_bed" -> (inputDir + File.separator + "ref.fa"),
"annotation_refflat" -> (inputDir + File.separator + "ref.fa"),
"ribosome_refflat" -> (inputDir + File.separator + "ref.fa"),
"varscan_jar" -> "test",
"rscript" -> Map("exe" -> "test"),
"igvtools" -> Map("exe" -> "test", "igvtools_jar" -> "test"),
......
......@@ -14,15 +14,16 @@
*/
package nl.lumc.sasc.biopet.pipelines.sage
import java.io.{ File, FileOutputStream }
import java.io.{File, FileOutputStream}
import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.utils.{ConfigUtils, 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.{ DataProvider, Test }
import org.testng.annotations.{AfterClass, DataProvider, Test}
/**
* Created by pjvanthof on 28/09/16.
......@@ -53,10 +54,14 @@ class SageTest extends TestNGSuite with Matchers {
def tagsLibrary = false
def libraryCounts: Option[Boolean] = None
private var dirs: List[File] = Nil
@Test(dataProvider = "sageOptions")
def testSage(f: String, sample1: Boolean, sample2: Boolean): Unit = {
val outputDir = SageTest.outputDir
dirs :+= outputDir
val map = {
var m: Map[String, Any] = SageTest.config
var m: Map[String, Any] = SageTest.config(outputDir)
if (sample1) m = ConfigUtils.mergeMaps(SageTest.sample1, m)
if (sample2) m = ConfigUtils.mergeMaps(SageTest.sample2, m)
ConfigUtils.mergeMaps(
......@@ -99,6 +104,11 @@ class SageTest extends TestNGSuite with Matchers {
}
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
class SageNoBedTest extends SageTest {
......@@ -121,11 +131,11 @@ class SageLibraryCountsTest extends SageTest {
}
object SageTest {
val outputDir = Files.createTempDir()
outputDir.deleteOnExit()
new File(outputDir, "input").mkdirs()
def outputDir = Files.createTempDir()
val intputDir = Files.createTempDir()
def inputTouch(name: String): String = {
val file = new File(outputDir, "input" + File.separator + name)
val file = new File(intputDir, name)
Files.touch(file)
file.getAbsolutePath
}
......@@ -134,7 +144,7 @@ object SageTest {
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(intputDir, name))
org.apache.commons.io.IOUtils.copy(is, os)
os.close()
}
......@@ -143,9 +153,9 @@ object SageTest {
copyFile("ref.dict")
copyFile("ref.fa.fai")
val config: Map[String, Any] = Map(
def config(outputDir: File): Map[String, Any] = Map(
"skip_write_dependencies" -> true,
"reference_fasta" -> (outputDir + File.separator + "ref.fa"),
"reference_fasta" -> (intputDir + File.separator + "ref.fa"),
"output_dir" -> outputDir.getAbsolutePath,
"fastqc" -> Map("exe" -> "test"),
"seqtk" -> Map("exe" -> "test"),
......
......@@ -14,20 +14,21 @@
*/
package nl.lumc.sasc.biopet.pipelines.shiva
import java.io.{ File, FileOutputStream }
import java.io.{File, FileOutputStream}
import java.nio.file.Paths
import com.google.common.io.Files
import nl.lumc.sasc.biopet.extensions.breakdancer.{ BreakdancerCaller, BreakdancerConfig, BreakdancerVCF }
import nl.lumc.sasc.biopet.extensions.breakdancer.{BreakdancerCaller, BreakdancerConfig, BreakdancerVCF}
import nl.lumc.sasc.biopet.extensions.clever.CleverCaller
import nl.lumc.sasc.biopet.extensions.delly.DellyCaller
import nl.lumc.sasc.biopet.extensions.pindel.{ PindelCaller, PindelConfig, PindelVCF }
import nl.lumc.sasc.biopet.utils.{ ConfigUtils, Logging }
import nl.lumc.sasc.biopet.extensions.pindel.{PindelCaller, PindelConfig, PindelVCF}
import nl.lumc.sasc.biopet.utils.{ConfigUtils, 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.{ DataProvider, Test }
import org.testng.annotations.{AfterClass, DataProvider, Test}
import scala.collection.mutable.ListBuffer
......@@ -37,15 +38,17 @@ import scala.collection.mutable.ListBuffer
* Created by pjvan_thof on 3/2/15.
*/
class ShivaSvCallingTest extends TestNGSuite with Matchers {
def initPipeline(map: Map[String, Any]): ShivaSvCalling = {
def initPipeline(map: Map[String, Any], outputDir: File): ShivaSvCalling = {
new ShivaSvCalling {
override def configNamespace = "shivasvcalling"
override def globalConfig = new Config(ConfigUtils.mergeMaps(map, ShivaSvCallingTest.config))
override def globalConfig = new Config(ConfigUtils.mergeMaps(map, ShivaSvCallingTest.config(outputDir)))
qSettings = new QSettings
qSettings.runName = "test"
}
}
private var dirs: List[File] = Nil
@DataProvider(name = "shivaSvCallingOptions")
def shivaSvCallingOptions = {
val bool = Array(true, false)
......@@ -64,13 +67,15 @@ class ShivaSvCallingTest extends TestNGSuite with Matchers {
clever: Boolean,
breakdancer: Boolean,
pindel: Boolean) = {
val outputDir = ShivaSvCallingTest.outputDir
dirs :+= outputDir
val callers: ListBuffer[String] = ListBuffer()
if (delly) callers.append("delly")
if (clever) callers.append("clever")
if (breakdancer) callers.append("breakdancer")
if (pindel) callers.append("pindel")
val map = Map("sv_callers" -> callers.toList)
val pipeline = initPipeline(map)
val pipeline = initPipeline(map, outputDir)
pipeline.inputBams = (for (n <- 1 to bams) yield n.toString -> ShivaSvCallingTest.inputTouch("bam_" + n + ".bam")).toMap
......@@ -122,11 +127,13 @@ class ShivaSvCallingTest extends TestNGSuite with Matchers {
@Test(dataProvider = "dellyOptions")
def testShivaDelly(bams: Int, del: Boolean, dup: Boolean, inv: Boolean, tra: Boolean): Unit = {
val outputDir = ShivaSvCallingTest.outputDir
dirs :+= outputDir
val map = Map("sv_callers" -> List("delly"), "delly" ->
Map("DEL" -> del, "DUP" -> dup, "INV" -> inv, "TRA" -> tra)
)
val pipeline = initPipeline(map)
val pipeline = initPipeline(map, outputDir)
pipeline.inputBams = Map("bam" -> ShivaSvCallingTest.inputTouch("bam" + ".bam"))
......@@ -145,8 +152,11 @@ class ShivaSvCallingTest extends TestNGSuite with Matchers {
@Test
def testWrongCaller(): Unit = {
val outputDir = ShivaSvCallingTest.outputDir
dirs :+= outputDir
val map = Map("sv_callers" -> List("this is not a caller"))
val pipeline = initPipeline(map)
val pipeline = initPipeline(map, outputDir)
pipeline.inputBams = Map("bam" -> ShivaSvCallingTest.inputTouch("bam" + ".bam"))
......@@ -162,7 +172,10 @@ class ShivaSvCallingTest extends TestNGSuite with Matchers {
@Test
def testInputBamsArg(): Unit = {
val pipeline = initPipeline(Map())
val outputDir = ShivaSvCallingTest.outputDir
dirs :+= outputDir
val pipeline = initPipeline(Map(), outputDir)
pipeline.inputBamsArg :+= new File(resourcePath("/paired01.bam"))
......@@ -174,21 +187,26 @@ class ShivaSvCallingTest extends TestNGSuite with Matchers {
assert(summaryCallers.contains("clever"))
assert(summaryCallers.contains("breakdancer"))
}
// remove temporary run directory all tests in the class have been run
@AfterClass def removeTempOutputDir() = {
dirs.foreach(FileUtils.deleteDirectory)
}
}
object ShivaSvCallingTest {
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(outputDir, name).getAbsoluteFile
Files.touch(file)
file
}
private def copyFile(name: String): Unit = {
val is = getClass.getResourceAsStream("/" + name)
val os = new FileOutputStream(