SamtoolsFlagstat.scala 1.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/**
 * 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
 *
11
 * A dual licensing mode is applied. The source code within this project is freely available for non-commercial use under an AGPL
12
13
14
 * license; For commercial users or users who do not want to follow the AGPL
 * license, please contact us to obtain a separate license.
 */
15
package nl.lumc.sasc.biopet.extensions.samtools
Peter van 't Hof's avatar
Peter van 't Hof committed
16

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

Peter van 't Hof's avatar
Peter van 't Hof committed
19
import nl.lumc.sasc.biopet.utils.config.Configurable
bow's avatar
bow committed
20
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
Peter van 't Hof's avatar
Peter van 't Hof committed
21

Peter van 't Hof's avatar
Peter van 't Hof committed
22
/** Extension for samtools flagstat */
bow's avatar
bow committed
23
24
class SamtoolsFlagstat(val root: Configurable) extends Samtools {
  @Input(doc = "Bam File")
Peter van 't Hof's avatar
Peter van 't Hof committed
25
  var input: File = _
bow's avatar
bow committed
26
27

  @Output(doc = "output File")
Peter van 't Hof's avatar
Peter van 't Hof committed
28
  var output: File = _
bow's avatar
bow committed
29

Peter van 't Hof's avatar
Peter van 't Hof committed
30
  /** Returns command to execute */
31
32
33
  def cmdLine = required(executable) + required("flagstat") +
    (if (inputAsStdin) "-" else required(input)) +
    (if (outputAsStsout) "" else " > " + required(output))
Peter van 't Hof's avatar
Peter van 't Hof committed
34
35
36
}

object SamtoolsFlagstat {
37
  def apply(root: Configurable, input: File, outputDir: File): SamtoolsFlagstat = {
Peter van 't Hof's avatar
Peter van 't Hof committed
38
39
    val flagstat = new SamtoolsFlagstat(root)
    flagstat.input = input
40
    flagstat.output = new File(outputDir, input.getName.stripSuffix(".bam") + ".flagstat")
41
    flagstat
Peter van 't Hof's avatar
Peter van 't Hof committed
42
43
  }
}