Schema.scala 7.17 KB
Newer Older
pjvan_thof's avatar
pjvan_thof committed
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.
  */
15
16
package nl.lumc.sasc.biopet.utils.summary.db

Peter van 't Hof's avatar
Peter van 't Hof committed
17
18
import java.sql.Date

19
20
21
import slick.driver.H2Driver.api._

/**
22
23
  * Created by pjvan_thof on 27-1-17.
  */
24
25
object Schema {

26
27
28
29
30
  case class Run(id: Int,
                 name: String,
                 outputDir: String,
                 version: String,
                 commitHash: String,
Peter van 't Hof's avatar
Peter van 't Hof committed
31
                 creationDate: Date)
32
  class Runs(tag: Tag) extends Table[Run](tag, "Runs") {
33
    def id = column[Int]("id", O.PrimaryKey)
Peter van 't Hof's avatar
Peter van 't Hof committed
34
    def runName = column[String]("runName")
35
    def outputDir = column[String]("outputDir")
Peter van 't Hof's avatar
Peter van 't Hof committed
36
37
38
    def version = column[String]("version")
    def commitHash = column[String]("commitHash")
    def creationDate = column[Date]("creationDate")
39

40
41
    def * =
      (id, runName, outputDir, version, commitHash, creationDate) <> (Run.tupled, Run.unapply)
42
43
44
  }
  val runs = TableQuery[Runs]

45
46
  case class Sample(id: Int, name: String, runId: Int, tags: Option[String])
  class Samples(tag: Tag) extends Table[Sample](tag, "Samples") {
47
48
    def id = column[Int]("id", O.PrimaryKey)
    def name = column[String]("name")
Peter van 't Hof's avatar
Peter van 't Hof committed
49
    def runId = column[Int]("runId")
50
    def tags = column[Option[String]]("tags")
51

52
    def * = (id, name, runId, tags) <> (Sample.tupled, Sample.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
53
54

    def idx = index("idx_samples", (runId, name), unique = true)
55
56
57
  }
  val samples = TableQuery[Samples]

58
59
  case class Library(id: Int, name: String, runId: Int, sampleId: Int, tags: Option[String])
  class Libraries(tag: Tag) extends Table[Library](tag, "Libraries") {
60
    def id = column[Int]("id", O.PrimaryKey)
Peter van 't Hof's avatar
Peter van 't Hof committed
61
    def name = column[String]("name")
Peter van 't Hof's avatar
Peter van 't Hof committed
62
    def runId = column[Int]("runId")
63
    def sampleId = column[Int]("sampleId")
64
    def tags = column[Option[String]]("tags")
65

66
    def * = (id, name, runId, sampleId, tags) <> (Library.tupled, Library.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
67
68

    def idx = index("idx_libraries", (runId, sampleId, name), unique = true)
69
70
71
  }
  val libraries = TableQuery[Libraries]

72
73
  case class Pipeline(id: Int, name: String, runId: Int)
  class Pipelines(tag: Tag) extends Table[Pipeline](tag, "PipelineNames") {
74
    def id = column[Int]("id", O.PrimaryKey)
Peter van 't Hof's avatar
Peter van 't Hof committed
75
    def name = column[String]("name")
Peter van 't Hof's avatar
Peter van 't Hof committed
76
    def runId = column[Int]("runId")
77

78
    def * = (id, name, runId) <> (Pipeline.tupled, Pipeline.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
79

Peter van 't Hof's avatar
Peter van 't Hof committed
80
    def idx = index("idx_pipeline_names", (name, runId), unique = true)
81
  }
82
  val pipelines = TableQuery[Pipelines]
Peter van 't Hof's avatar
Peter van 't Hof committed
83

84
85
  case class Module(id: Int, name: String, runId: Int, pipelineId: Int)
  class Modules(tag: Tag) extends Table[Module](tag, "ModuleNames") {
Peter van 't Hof's avatar
Peter van 't Hof committed
86
87
    def id = column[Int]("id", O.PrimaryKey)
    def name = column[String]("name")
Peter van 't Hof's avatar
Peter van 't Hof committed
88
89
    def runId = column[Int]("runId")
    def pipelineId = column[Int]("pipelineId")
Peter van 't Hof's avatar
Peter van 't Hof committed
90

91
    def * = (id, name, runId, pipelineId) <> (Module.tupled, Module.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
92

Peter van 't Hof's avatar
Peter van 't Hof committed
93
    def idx = index("idx_module_names", (name, runId, pipelineId), unique = true)
Peter van 't Hof's avatar
Peter van 't Hof committed
94
  }
95
  val modules = TableQuery[Modules]
Peter van 't Hof's avatar
Peter van 't Hof committed
96

97
98
99
100
101
102
  case class Stat(runId: Int,
                  pipelineId: Int,
                  moduleId: Option[Int],
                  sampleId: Option[Int],
                  library: Option[Int],
                  content: String)
103
  class Stats(tag: Tag) extends Table[Stat](tag, "Stats") {
Peter van 't Hof's avatar
Peter van 't Hof committed
104
    def runId = column[Int]("runId")
Peter van 't Hof's avatar
Peter van 't Hof committed
105
    def pipelineId = column[Int]("pipelineId")
Peter van 't Hof's avatar
Peter van 't Hof committed
106
107
108
    def moduleId = column[Option[Int]]("moduleId")
    def sampleId = column[Option[Int]]("sampleId")
    def libraryId = column[Option[Int]]("libraryId")
109
    def content = column[String]("content")
Peter van 't Hof's avatar
Peter van 't Hof committed
110

111
112
    def * =
      (runId, pipelineId, moduleId, sampleId, libraryId, content) <> (Stat.tupled, Stat.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
113
114
115
  }
  val stats = TableQuery[Stats]

116
117
118
119
120
121
  case class Setting(runId: Int,
                     pipelineId: Int,
                     moduleId: Option[Int],
                     sampleId: Option[Int],
                     library: Option[Int],
                     content: String)
122
  class Settings(tag: Tag) extends Table[Setting](tag, "Settings") {
Peter van 't Hof's avatar
Peter van 't Hof committed
123
    def runId = column[Int]("runId")
Peter van 't Hof's avatar
Peter van 't Hof committed
124
    def pipelineId = column[Int]("pipelineId")
Peter van 't Hof's avatar
Peter van 't Hof committed
125
126
127
    def moduleId = column[Option[Int]]("moduleId")
    def sampleId = column[Option[Int]]("sampleId")
    def libraryId = column[Option[Int]]("libraryId")
128
    def content = column[String]("content")
Peter van 't Hof's avatar
Peter van 't Hof committed
129

130
131
    def * =
      (runId, pipelineId, moduleId, sampleId, libraryId, content) <> (Setting.tupled, Setting.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
132
133
134
  }
  val settings = TableQuery[Settings]

135
136
137
138
139
140
141
142
143
144
  case class File(runId: Int,
                  pipelineId: Int,
                  moduleId: Option[Int],
                  sampleId: Option[Int],
                  libraryId: Option[Int],
                  key: String,
                  path: String,
                  md5: String,
                  link: Boolean,
                  size: Long)
145
  class Files(tag: Tag) extends Table[File](tag, "Files") {
Peter van 't Hof's avatar
Peter van 't Hof committed
146
    def runId = column[Int]("runId")
Peter van 't Hof's avatar
Peter van 't Hof committed
147
    def pipelineId = column[Int]("pipelineId")
Peter van 't Hof's avatar
Peter van 't Hof committed
148
149
150
    def moduleId = column[Option[Int]]("moduleId")
    def sampleId = column[Option[Int]]("sampleId")
    def libraryId = column[Option[Int]]("libraryId")
Peter van 't Hof's avatar
Peter van 't Hof committed
151
    def key = column[String]("key")
Peter van 't Hof's avatar
Peter van 't Hof committed
152
    def path = column[String]("path") // This should be relative to the outputDir
Peter van 't Hof's avatar
Peter van 't Hof committed
153
    def md5 = column[String]("md5")
154
155
    def link = column[Boolean]("link", O.Default(false))
    def size = column[Long]("size")
Peter van 't Hof's avatar
Peter van 't Hof committed
156

157
158
    def * =
      (runId, pipelineId, moduleId, sampleId, libraryId, key, path, md5, link, size) <> (File.tupled, File.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
159

160
    def idx =
pjvan_thof's avatar
pjvan_thof committed
161
      index("idx_files", (runId, pipelineId, moduleId, sampleId, libraryId, key))
Peter van 't Hof's avatar
Peter van 't Hof committed
162
163
164
  }
  val files = TableQuery[Files]

165
166
167
168
169
170
171
172
  case class Executable(runId: Int,
                        toolName: String,
                        version: Option[String] = None,
                        path: Option[String] = None,
                        javaVersion: Option[String] = None,
                        exeMd5: Option[String] = None,
                        javaMd5: Option[String] = None,
                        jarPath: Option[String] = None)
173
  class Executables(tag: Tag) extends Table[Executable](tag, "Executables") {
Peter van 't Hof's avatar
Peter van 't Hof committed
174
    def runId = column[Int]("runId")
Peter van 't Hof's avatar
Peter van 't Hof committed
175
176
    def toolName = column[String]("toolName")
    def version = column[Option[String]]("version")
Peter van 't Hof's avatar
Peter van 't Hof committed
177
    def path = column[Option[String]]("path")
Peter van 't Hof's avatar
Peter van 't Hof committed
178
179
180
    def javaVersion = column[Option[String]]("javaVersion")
    def exeMd5 = column[Option[String]]("exeMd5")
    def javaMd5 = column[Option[String]]("javaMd5")
Peter van 't Hof's avatar
Peter van 't Hof committed
181
    def jarPath = column[Option[String]]("jarPath")
Peter van 't Hof's avatar
Peter van 't Hof committed
182

183
184
    def * =
      (runId, toolName, version, path, javaVersion, exeMd5, javaMd5, jarPath) <> (Executable.tupled, Executable.unapply)
Peter van 't Hof's avatar
Peter van 't Hof committed
185

Peter van 't Hof's avatar
Peter van 't Hof committed
186
    def idx = index("idx_executables", (runId, toolName), unique = true)
Peter van 't Hof's avatar
Peter van 't Hof committed
187
188
  }
  val executables = TableQuery[Executables]
189

190
}