GearsCentrifuge.scala 2.18 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
4
5
6
7
8
9
10
package nl.lumc.sasc.biopet.pipelines.gears

import nl.lumc.sasc.biopet.core.SampleLibraryTag
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.centrifuge.{ Centrifuge, CentrifugeKreport }
import nl.lumc.sasc.biopet.extensions.tools.KrakenReportToJson
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.queue.QScript

/**
11
12
 * Created by pjvanthof on 19/09/16.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class GearsCentrifuge(val root: Configurable) extends QScript with SummaryQScript with SampleLibraryTag {

  var fastqR1: File = _

  var fastqR2: Option[File] = None

  var outputName: String = _

  def init(): Unit = {
    require(fastqR1 != null)
    if (outputName == null) outputName = fastqR1.getName
      .stripSuffix(".gz")
      .stripSuffix(".fq")
      .stripSuffix(".fastq")
  }

  def biopetScript(): Unit = {
    val centrifuge = new Centrifuge(this)
    centrifuge.inputR1 = fastqR1
    centrifuge.inputR2 = fastqR2
    centrifuge.output = new File(outputDir, s"$outputName.centrifuge")
    centrifuge.report = Some(new File(outputDir, s"$outputName.centrifuge.report"))
    add(centrifuge)

    val centrifugeKreport = new CentrifugeKreport(this)
38
    centrifugeKreport.centrifugeOutputFiles :+= centrifuge.output
Peter van 't Hof's avatar
Peter van 't Hof committed
39
40
41
42
43
44
45
46
    centrifugeKreport.output = new File(outputDir, s"$outputName.centrifuge.kreport")
    add(centrifugeKreport)

    val krakenReportJSON = new KrakenReportToJson(this)
    krakenReportJSON.inputReport = centrifugeKreport.output
    krakenReportJSON.output = new File(outputDir, s"$outputName.krkn.json")
    krakenReportJSON.skipNames = config("skipNames", default = false)
    add(krakenReportJSON)
Peter van 't Hof's avatar
Peter van 't Hof committed
47
    addSummarizable(krakenReportJSON, "centrifuge_report")
Peter van 't Hof's avatar
Peter van 't Hof committed
48
49

    addSummaryJobs()
Peter van 't Hof's avatar
Peter van 't Hof committed
50
51
52
  }

  /** Location of summary file */
Peter van 't Hof's avatar
Peter van 't Hof committed
53
  def summaryFile = new File(outputDir, sampleId.getOrElse("sampleName_unknown") + ".centrifuge.summary.json")
Peter van 't Hof's avatar
Peter van 't Hof committed
54
55
56
57
58
59
60
61
62
63
64

  /** Pipeline settings shown in the summary file */
  def summarySettings: Map[String, Any] = Map()

  /** Statistics shown in the summary file */
  def summaryFiles: Map[String, File] = outputFiles + ("input_R1" -> fastqR1) ++ (fastqR2 match {
    case Some(file) => Map("input_R2" -> file)
    case _          => Map()
  })

}