MultiSampleQScript.scala 1.93 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
  var samples: Map[String, Any] = Map()
Peter van 't Hof's avatar
Peter van 't Hof committed
8
  def globalSampleDir: String = outputDir + "samples/"
bow's avatar
bow committed
9
10
11

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

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

Peter van 't Hof's avatar
Peter van 't Hof committed
30
  final def runLibraryJobs(sampleConfig: Map[String, Any]): Map[String, Map[String, File]] = {
bow's avatar
bow committed
31
    var output: Map[String, Map[String, File]] = Map()
32
    val sampleID = sampleConfig("ID")
Peter van 't Hof's avatar
Peter van 't Hof committed
33
34
    if (sampleConfig.contains("libraries")) {
      val runs = Configurable.any2map(sampleConfig("libraries"))
bow's avatar
bow committed
35
      for ((key, value) <- runs) {
Peter van 't Hof's avatar
Peter van 't Hof committed
36
37
38
39
        var library = Configurable.any2map(value)
        if (!library.contains("ID")) library += ("ID" -> key)
        if (library("ID") == key) {
          output += key -> runSingleLibraryJobs(library, sampleConfig)
40
41
42
43
44
        } 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
45
  def runSingleLibraryJobs(runConfig: Map[String, Any], sampleConfig: Map[String, Any]): Map[String, File]
46
}