GenerateIndexesTest.scala 2.93 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package nl.lumc.sasc.biopet.pipelines.generateindexes

import com.google.common.io.Files
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Config
import org.broadinstitute.gatk.queue.QSettings
import org.scalatest.Matchers
import org.scalatest.testng.TestNGSuite
import org.testng.annotations.Test

/**
 * Created by pjvan_thof on 13-5-16.
 */
class GenerateIndexesTest extends TestNGSuite with Matchers {
  def initPipeline(map: Map[String, Any]): GenerateIndexes = {
    new GenerateIndexes() {
      override def configNamespace = "generateindexes"
      override def globalConfig = new Config(ConfigUtils.mergeMaps(map, GenerateIndexesTest.config))
      qSettings = new QSettings
      qSettings.runName = "test"
    }
  }

  @Test
  def testNoFastaUri: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("" -> "")))
    intercept[IllegalArgumentException] {
      pipeline.script()
    }
  }

  @Test
  def testSingleFasta: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri")))
    pipeline.script()
  }

  @Test
  def testMultiFasta: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> List("uri", "uri2", "uri3.gz"))))
    pipeline.script()
  }

  @Test
  def testSingleDbsnp: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri", "dbsnp_vcf_uri" -> "uri.vcf.gz")))
    pipeline.script()
  }

  @Test
  def testMultiDbsnp: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri", "dbsnp_vcf_uri" -> List("uri.vcf.gz", "uri2.vcf.gz"))))
    pipeline.script()
  }

  @Test
  def testVep: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri", "vep_cache_uri" -> "something/human_vep_80_hg19.tar.gz")))
    pipeline.script()
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  @Test
  def testGtfZipped: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri", "gtf_uri" -> "bla.gf.gz")))
    pipeline.script()
  }

  @Test
  def testGtf: Unit = {
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri", "gtf_uri" -> "bla.gf")))
    pipeline.script()
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
}

object GenerateIndexesTest {
  val outputDir = Files.createTempDir()
  outputDir.deleteOnExit()

  val config = Map("output_dir" -> outputDir,
    "bwa" -> Map("exe" -> "test"),
    "star" -> Map("exe" -> "test"),
    "bowtiebuild" -> Map("exe" -> "test"),
    "bowtie2build" -> Map("exe" -> "test"),
    "gmapbuild" -> Map("exe" -> "test"),
    "samtools" -> Map("exe" -> "test"),
    "md5sum" -> Map("exe" -> "test"),
    "gatk_jar" -> "test",
    "tabix" -> Map("exe" -> "test")
  )
}