BiopetQScript.scala 2.16 KB
Newer Older
1
2
3
4
package nl.lumc.sasc.biopet.core

//import org.broadinstitute.sting.queue.QScript
import java.io.File
Peter van 't Hof's avatar
Peter van 't Hof committed
5
import nl.lumc.sasc.biopet.core.config._
6

Peter van 't Hof's avatar
Peter van 't Hof committed
7
8
abstract trait BiopetQScript extends Configurable {
  //var config: Config = _
9
  var outputFiles:Map[String,File] = Map()
Peter van 't Hof's avatar
Peter van 't Hof committed
10
  var samples:Map[String,Any] = Map()
11
  
Peter van 't Hof's avatar
Peter van 't Hof committed
12
  final def runSamplesJobs : Map[String,Map[String,File]] = {
13
    var output: Map[String,Map[String,File]] = Map()
Peter van 't Hof's avatar
Peter van 't Hof committed
14
15
16
17
18
    samples = config("samples")
    if (globalConfig.contains("samples")) for ((key,value) <- samples) {
      var sample = Configurable.any2map(value)
      if (!sample.contains("ID")) sample += ("ID" -> key)
      if (sample("ID") == key) {
19
20
21
22
23
24
25
        var files:Map[String,List[File]] = runSingleSampleJobs(sample)
      } else logger.warn("Key is not the same as ID on value for sample")
    } else logger.warn("No Samples found in config")
    return output
  }
  
  def runSingleSampleJobs(sample:String) : Map[String,List[File]] ={
Peter van 't Hof's avatar
Peter van 't Hof committed
26
    return runSingleSampleJobs(Configurable.any2map(samples(sample)))
27
  }
Peter van 't Hof's avatar
Peter van 't Hof committed
28
  def runSingleSampleJobs(sampleConfig:Map[String,Any]) : Map[String,List[File]] = {
29
30
31
32
33
34
35
    logger.debug("Default sample function, function 'runSingleSampleJobs' not defined in pipeline")
    
    runRunsJobs(sampleConfig)
    
    return Map()
  }
  
Peter van 't Hof's avatar
Peter van 't Hof committed
36
  final def runRunsJobs(sampleConfig:Map[String,Any]) : Map[String,Map[String,File]] = {
37
    var output: Map[String,Map[String,File]] = Map()
Peter van 't Hof's avatar
Peter van 't Hof committed
38
39
40
41
42
43
44
45
46
47
    val sampleID = sampleConfig("ID")
    if (sampleConfig.contains("runs")) {
      val runs = Configurable.any2map(sampleConfig("runs"))
      for ((key,value) <- runs) {
        var run = Configurable.any2map(value)
        if (!run.contains("ID")) run += ("ID" -> key)
        if (run("ID") == key) {
          output += key -> runSingleRunJobs(run, sampleConfig)
        } else logger.warn("Key is not the same as ID on value for run of sample: " + sampleID)
      }
48
49
50
    } else logger.warn("No runs found in config for sample: " + sampleID)
    return output
  }
Peter van 't Hof's avatar
Peter van 't Hof committed
51
  def runSingleRunJobs(runConfig:Map[String,Any], sampleConfig:Map[String,Any]) : Map[String,File] = {
52
53
54
55
56
    logger.debug("Default run function, function 'runSingleRunJobs' not defined in pipeline")
    
    return Map()
  }
}