diff --git a/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala b/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala new file mode 100644 index 0000000000000000000000000000000000000000..7a4cf5bc79c74ba22bd31c8e17060da1ca8ff875 --- /dev/null +++ b/public/carp/src/test/scala/nl/lumc/sasc/biopet/pipelines/carp/CarpTest.scala @@ -0,0 +1,127 @@ +package nl.lumc.sasc.biopet.pipelines.carp + +import java.io.File + +import nl.lumc.sasc.biopet.core.config.{ConfigValueIndex, Config} +import nl.lumc.sasc.biopet.utils.ConfigUtils +import org.broadinstitute.gatk.queue.QSettings +import org.testng.annotations.{DataProvider, Test} +import org.testng.annotations.{Test, DataProvider} +import org.scalatest.Assertions._ + +/** + * Created by pjvan_thof on 2/13/15. + */ +class CarpTest { + def initPipeline(map: Map[String, Any]): Carp = { + new Carp() { + override def configName = "carp" + override def globalConfig = new Config(map) + qSettings = new QSettings + qSettings.runName = "test" + } + } + + @DataProvider(name = "carpOptions", parallel = true) + def carpOptions = { + val bool = Array(true, false) + + for (s1 <- bool; s2 <- bool; s3 <- bool; t <- bool; c <- bool) yield + Array("", s1, s2, s3, t, c) + } + + @Test(dataProvider = "carpOptions") + def testCarp(f:String, sample1:Boolean, sample2:Boolean, sample3:Boolean, threatment:Boolean, control:Boolean): Unit = { + val map = { + var m = ConfigUtils.mergeMaps(Map("output_dir" -> CarpTest.outputDir + ), CarpTest.excutables) + + if (sample1) m = ConfigUtils.mergeMaps(CarpTest.sample1, m.toMap) + if (sample2) m = ConfigUtils.mergeMaps(CarpTest.sample2, m.toMap) + if (sample3) m = ConfigUtils.mergeMaps(CarpTest.sample3, m.toMap) + if (threatment) m = ConfigUtils.mergeMaps(CarpTest.threatment1, m.toMap) + if (control) m = ConfigUtils.mergeMaps(CarpTest.control1, m.toMap) + m + } + + if (!sample1 && !sample2 && !sample3 && !threatment && !control) { // When no samples + intercept[IllegalArgumentException] { + initPipeline(map).script() + } + } else if (threatment && !control) { // If control of a samples does not exist in samples + intercept[IllegalStateException] { + initPipeline(map).script() + } + } else { // When samples are correct + val carp = initPipeline(map) + carp.script() + + + } + } +} + +object CarpTest { + val outputDir = System.getProperty("java.io.tmpdir") + File.separator + "flexiprep" + + val excutables = Map( + "reference" -> "test", + "seqstat" -> Map("exe" -> "test"), + "fastqc" -> Map("exe" -> "test"), + "seqtk" -> Map("exe" -> "test"), + "sickle" -> Map("exe" -> "test"), + "bwa" -> Map("exe" -> "test"), + "samtools" -> Map("exe" -> "test"), + "macs2" -> Map("exe" -> "test") + ) + + val sample1 = Map( + "samples" -> Map( "sample1" -> Map( "libraries" -> Map( + "lib1" -> Map( + "R1" -> "1_1_R1.fq", + "R2" -> "1_1_R2.fq" + ) + ) + ))) + + val sample2 = Map( + "samples" -> Map( "sample2" -> Map( "libraries" -> Map( + "lib1" -> Map( + "R1" -> "2_1_R1.fq", + "R2" -> "2_1_R2.fq" + ) + ) + ))) + + val sample3 = Map( + "samples" -> Map( "sample3" -> Map( "libraries" -> Map( + "lib1" -> Map( + "R1" -> "3_1_R1.fq", + "R2" -> "3_1_R2.fq" + ), + "lib2" -> Map( + "R1" -> "3_2_R1.fq", + "R2" -> "3_2_R2.fq" + ) + ) + ))) + + val threatment1 = Map( + "samples" -> Map( "threatment" -> Map( "control" -> "control1","libraries" -> Map( + "lib1" -> Map( + "R1" -> "threatment_1_R1.fq", + "R2" -> "threatment_1_R2.fq" + ) + ) + ))) + + val control1 = Map( + "samples" -> Map( "control1" -> Map( "libraries" -> Map( + "lib1" -> Map( + "R1" -> "control_1_R1.fq", + "R2" -> "control_1_R2.fq" + ) + ) + ))) + +} \ No newline at end of file