KrakenReportToJson.scala 1.58 KB
Newer Older
1
2
3
4
5
6
7
package nl.lumc.sasc.biopet.extensions.tools

/**
 * Created by waiyileung on 05-10-15.
 */
import java.io.File

Wai Yi Leung's avatar
Wai Yi Leung committed
8
import nl.lumc.sasc.biopet.core.ToolCommandFunction
9
10
11
import nl.lumc.sasc.biopet.core.summary.Summarizable
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
12
import org.broadinstitute.gatk.utils.commandline.{ Argument, Input, Output }
13
14
15
16
17
18

/**
 * KrakenReportToJson function class for usage in Biopet pipelines
 *
 * @param root Configuration object for the pipeline
 */
Wai Yi Leung's avatar
Wai Yi Leung committed
19
class KrakenReportToJson(val root: Configurable) extends ToolCommandFunction with Summarizable {
20
21
22
  def toolObject = nl.lumc.sasc.biopet.tools.KrakenReportToJson

  @Input(doc = "Input Kraken Full report", shortName = "inputReport", required = true)
Wai Yi Leung's avatar
Wai Yi Leung committed
23
  var inputReport: File = _
24
25

  @Argument(required = false)
26
  var skipNames: Boolean = false
27
28

  @Output(doc = "Output JSON", shortName = "output", required = true)
Wai Yi Leung's avatar
Wai Yi Leung committed
29
  var output: File = _
30
31
32

  override def defaultCoreMemory = 1.0

Wai Yi Leung's avatar
Wai Yi Leung committed
33
34
35
36
37
  override def cmdLine =
    super.cmdLine +
      required("-i", inputReport) +
      required("-o", output) +
      conditional(skipNames, "--skipnames")
38
39

  def summaryStats: Map[String, Any] = {
Wai Yi Leung's avatar
Wai Yi Leung committed
40
    ConfigUtils.fileToConfigMap(output)
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  }

  def summaryFiles: Map[String, File] = Map()

}

object KrakenReportToJson {
  def apply(root: Configurable, input: File, output: File): KrakenReportToJson = {
    val report = new KrakenReportToJson(root)
    report.inputReport = input
    report.output = new File(output, input.getName.substring(0, input.getName.lastIndexOf(".")) + ".kraken.json")
    report
  }
}