DownloadGenomesTest.scala 5.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * Biopet is built on top of GATK Queue for building bioinformatic
 * pipelines. It is mainly intended to support LUMC SHARK cluster which is running
 * SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
 * should also be able to execute Biopet tools and pipelines.
 *
 * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
 *
 * Contact us at: sasc@lumc.nl
 *
 * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
 * license; For commercial users or users who do not want to follow the AGPL
 * license, please contact us to obtain a separate license.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
15
16
17
18
19
20
21
22
23
24
25
26
27
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.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
28
29
30
class DownloadGenomesTest extends TestNGSuite with Matchers {
  def initPipeline(map: Map[String, Any]): DownloadGenomes = {
    new DownloadGenomes() {
Peter van 't Hof's avatar
Peter van 't Hof committed
31
      override def configNamespace = "generateindexes"
Peter van 't Hof's avatar
Peter van 't Hof committed
32
      override def globalConfig = new Config(ConfigUtils.mergeMaps(map, DownloadGenomesTest.config))
Peter van 't Hof's avatar
Peter van 't Hof committed
33
34
35
36
37
38
      qSettings = new QSettings
      qSettings.runName = "test"
    }
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
39
  def testNoFastaUri(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
40
41
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("" -> "")))
42
    an[IllegalArgumentException] should be thrownBy pipeline.script()
Peter van 't Hof's avatar
Peter van 't Hof committed
43
44
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
45
  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
46
  def testNcbiAssembly(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
47
48
49
50
51
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("ncbi_assembly_id" -> "id")))
    pipeline.script()
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
52
  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
53
  def testSingleFasta(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
54
55
56
57
58
59
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri")))
    pipeline.script()
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
60
  def testMultiFasta(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
61
62
63
64
65
66
    val pipeline = initPipeline(Map())
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> List("uri", "uri2", "uri3.gz"))))
    pipeline.script()
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
67
  def testSingleDbsnp(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
68
69
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
70
      "dbsnp" -> Map("version" -> Map("vcf_uri" -> "uri.vcf.gz")))))
Peter van 't Hof's avatar
Peter van 't Hof committed
71
72
73
    pipeline.script()
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
74
  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
75
  def testContigMapDbsnp(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
76
77
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
78
      "dbsnp" -> Map("version" -> Map("vcf_uri" -> "uri.vcf.gz", "contig_map" -> Map("1" -> "chr1"))))))
Peter van 't Hof's avatar
Peter van 't Hof committed
79
80
81
82
    pipeline.script()
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
83
  def testUnzippedContigMapDbsnp(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
84
85
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
86
      "dbsnp" -> Map("version" -> Map("vcf_uri" -> "uri.vcf", "contig_map" -> Map("1" -> "chr1"))))))
Peter van 't Hof's avatar
Peter van 't Hof committed
87
88
89
90
    pipeline.script()
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
91
  def testSingleUnzippedDbsnp(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
92
93
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
94
      "dbsnp" -> Map("version" -> Map(("vcf_uri" -> "uri.vcf"))))))
Peter van 't Hof's avatar
Peter van 't Hof committed
95
96
97
    pipeline.script()
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
98
  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
99
  def testMultiDbsnp(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
100
101
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
102
      "dbsnp" -> Map("version" -> Map("vcf_uri" -> List("uri.vcf.gz", "uri2.vcf.gz"))))))
Peter van 't Hof's avatar
Peter van 't Hof committed
103
104
105
106
    pipeline.script()
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
107
  def testVep(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
108
109
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
110
      "vep" -> Map("version" -> Map("cache_uri" -> "something/human_vep_80_hg19.tar.gz")))))
Peter van 't Hof's avatar
Peter van 't Hof committed
111
112
113
    pipeline.script()
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
114
  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
115
  def testGtfZipped(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
116
117
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
118
      "gene_annotation" -> Map("version" -> Map("gtf_uri" -> "bla.gf.gz")))))
Peter van 't Hof's avatar
Peter van 't Hof committed
119
120
121
122
    pipeline.script()
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
123
  def testGtf(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
124
125
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
126
      "gene_annotation" -> Map("version" -> Map("gtf_uri" -> "bla.gf")))))
Peter van 't Hof's avatar
Peter van 't Hof committed
127
128
129
130
    pipeline.script()
  }

  @Test
Peter van 't Hof's avatar
Peter van 't Hof committed
131
  def testGff(): Unit = {
Peter van 't Hof's avatar
Peter van 't Hof committed
132
133
    val pipeline = initPipeline(Map("download_annotations" -> true))
    pipeline.referenceConfig = Map("s1" -> Map("g1" -> Map("fasta_uri" -> "uri",
Peter van 't Hof's avatar
Peter van 't Hof committed
134
      "gene_annotation" -> Map("version" -> Map("gff_uri" -> "bla.gf")))))
Peter van 't Hof's avatar
Peter van 't Hof committed
135
136
137
    pipeline.script()
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
138
139
}

Peter van 't Hof's avatar
Peter van 't Hof committed
140
object DownloadGenomesTest {
Peter van 't Hof's avatar
Peter van 't Hof committed
141
142
143
144
145
146
  val outputDir = Files.createTempDir()
  outputDir.deleteOnExit()

  val config = Map("output_dir" -> outputDir,
    "bwa" -> Map("exe" -> "test"),
    "star" -> Map("exe" -> "test"),
Peter van 't Hof's avatar
Peter van 't Hof committed
147
    "hisat2build" -> Map("exe" -> "test"),
Peter van 't Hof's avatar
Peter van 't Hof committed
148
149
150
151
152
153
    "bowtiebuild" -> Map("exe" -> "test"),
    "bowtie2build" -> Map("exe" -> "test"),
    "gmapbuild" -> Map("exe" -> "test"),
    "samtools" -> Map("exe" -> "test"),
    "md5sum" -> Map("exe" -> "test"),
    "gatk_jar" -> "test",
Peter van 't Hof's avatar
Peter van 't Hof committed
154
155
    "tabix" -> Map("exe" -> "test"),
    "gffread" -> Map("exe" -> "test")
Peter van 't Hof's avatar
Peter van 't Hof committed
156
157
  )
}