BiopetFlagstat.scala 2.18 KB
Newer Older
1
/**
2
3
4
5
6
7
8
9
10
11
12
13
14
  * Biopet is built on top of GATK Queue for building bioinformatic
  * pipelines. It is mainly intended to support LUMC SHARK cluster which is running
  * SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
  * should also be able to execute Biopet tools and pipelines.
  *
  * Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
  *
  * Contact us at: sasc@lumc.nl
  *
  * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
  * license; For commercial users or users who do not want to follow the AGPL
  * license, please contact us to obtain a separate license.
  */
Peter van 't Hof's avatar
Peter van 't Hof committed
15
package nl.lumc.sasc.biopet.extensions.tools
16

Peter van 't Hof's avatar
Peter van 't Hof committed
17
import java.io.File
18

19
import nl.lumc.sasc.biopet.core.ToolCommandFunction
20
import nl.lumc.sasc.biopet.core.summary.Summarizable
Peter van 't Hof's avatar
Peter van 't Hof committed
21
import nl.lumc.sasc.biopet.tools.flagstat
22
import nl.lumc.sasc.biopet.utils.ConfigUtils
Peter van 't Hof's avatar
Peter van 't Hof committed
23
import nl.lumc.sasc.biopet.utils.config.Configurable
24
import org.broadinstitute.gatk.utils.commandline.{Input, Output}
25

Peter van 't Hof's avatar
Peter van 't Hof committed
26
class BiopetFlagstat(val parent: Configurable) extends ToolCommandFunction with Summarizable {
Peter van 't Hof's avatar
Peter van 't Hof committed
27
  def toolObject = flagstat.BiopetFlagstat
28
29
30
31
32
33
34
35
36
37
38
39

  @Input(doc = "Input bam", shortName = "input", required = true)
  var input: File = _

  @Output(doc = "Output flagstat", shortName = "output", required = true)
  var output: File = _

  @Output(doc = "summary output file", shortName = "output", required = false)
  var summaryFile: File = _

  override def defaultCoreMemory = 6.0

40
  override def cmdLine: String =
41
    super.cmdLine + required("-I", input) + required("-s", summaryFile) + " > " + required(output)
42
43
44
45
46
47
48
49
50
51
52
53
54

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

  def summaryStats: Map[String, Any] = {
    ConfigUtils.fileToConfigMap(summaryFile)
  }
}

object BiopetFlagstat {
  def apply(root: Configurable, input: File, outputDir: File): BiopetFlagstat = {
    val flagstat = new BiopetFlagstat(root)
    flagstat.input = input
    flagstat.output = new File(outputDir, input.getName.stripSuffix(".bam") + ".biopetflagstat")
55
56
    flagstat.summaryFile =
      new File(outputDir, input.getName.stripSuffix(".bam") + ".biopetflagstat.json")
57
58
    flagstat
  }
59
}