MultiSampleQScript.scala 1.87 KB
Newer Older
1
2
3
4
5
6
package nl.lumc.sasc.biopet.core

import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable

trait MultiSampleQScript extends BiopetQScript {
bow's avatar
bow committed
7
8
9
10
  var samples: Map[String, Any] = Map()

  final def runSamplesJobs: Map[String, Map[String, File]] = {
    var output: Map[String, Map[String, File]] = Map()
11
    samples = config("samples")
Peter van 't Hof's avatar
Peter van 't Hof committed
12
    if (samples == null) samples = Map()
bow's avatar
bow committed
13
    if (globalConfig.contains("samples")) for ((key, value) <- samples) {
14
15
16
      var sample = Configurable.any2map(value)
      if (!sample.contains("ID")) sample += ("ID" -> key)
      if (sample("ID") == key) {
bow's avatar
bow committed
17
        var files: Map[String, List[File]] = runSingleSampleJobs(sample)
18
      } else logger.warn("Key is not the same as ID on value for sample")
bow's avatar
bow committed
19
20
    }
    else logger.warn("No Samples found in config")
21
22
    return output
  }
bow's avatar
bow committed
23
24
25

  def runSingleSampleJobs(sampleConfig: Map[String, Any]): Map[String, List[File]]
  def runSingleSampleJobs(sample: String): Map[String, List[File]] = {
26
27
    return runSingleSampleJobs(Configurable.any2map(samples(sample)))
  }
bow's avatar
bow committed
28

Peter van 't Hof's avatar
Peter van 't Hof committed
29
  final def runLibraryJobs(sampleConfig: Map[String, Any]): Map[String, Map[String, File]] = {
bow's avatar
bow committed
30
    var output: Map[String, Map[String, File]] = Map()
31
    val sampleID = sampleConfig("ID")
Peter van 't Hof's avatar
Peter van 't Hof committed
32
33
    if (sampleConfig.contains("librarys")) {
      val runs = Configurable.any2map(sampleConfig("librarys"))
bow's avatar
bow committed
34
      for ((key, value) <- runs) {
Peter van 't Hof's avatar
Peter van 't Hof committed
35
36
37
38
        var library = Configurable.any2map(value)
        if (!library.contains("ID")) library += ("ID" -> key)
        if (library("ID") == key) {
          output += key -> runSingleLibraryJobs(library, sampleConfig)
39
40
41
42
43
        } else logger.warn("Key is not the same as ID on value for run of sample: " + sampleID)
      }
    } else logger.warn("No runs found in config for sample: " + sampleID)
    return output
  }
Peter van 't Hof's avatar
Peter van 't Hof committed
44
  def runSingleLibraryJobs(runConfig: Map[String, Any], sampleConfig: Map[String, Any]): Map[String, File]
45
}