SamtoolsSort.scala 1.05 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
4
5
package nl.lumc.sasc.biopet.extensions.samtools

import java.io.File

import nl.lumc.sasc.biopet.utils.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
6
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
Peter van 't Hof's avatar
Peter van 't Hof committed
7
8
9
10
11
12
13
14
15
16
17
18

/**
 * Created by pjvanthof on 22/09/15.
 */
class SamtoolsSort(val root: Configurable) extends Samtools {

  @Input(required = true)
  var input: File = _

  @Output
  var output: File = _

Peter van 't Hof's avatar
Peter van 't Hof committed
19
20
21
  var compresion: Option[Int] = config("l")
  var outputFormat: Option[String] = config("O")
  var sortByName: Boolean = config("sort_by_name", default = false)
Peter van 't Hof's avatar
Peter van 't Hof committed
22
  var prefix: String = _
Peter van 't Hof's avatar
Peter van 't Hof committed
23

Peter van 't Hof's avatar
Peter van 't Hof committed
24
25
  override def beforeGraph(): Unit = {
    super.beforeGraph()
Peter van 't Hof's avatar
Peter van 't Hof committed
26
    prefix = config("prefix", default = new File(System.getProperty("java.io.tmpdir"), output.getName))
Peter van 't Hof's avatar
Peter van 't Hof committed
27
28
  }

Peter van 't Hof's avatar
Peter van 't Hof committed
29
  def cmdLine = required(executable) + required("sort") +
Peter van 't Hof's avatar
Peter van 't Hof committed
30
    optional("-m", (coreMemeory + "G")) +
Peter van 't Hof's avatar
Peter van 't Hof committed
31
32
    optional("-@", threads) +
    optional("-O", outputFormat) +
Peter van 't Hof's avatar
Peter van 't Hof committed
33
    required("-T", prefix) +
Peter van 't Hof's avatar
Peter van 't Hof committed
34
    conditional(sortByName, "-n") +
Peter van 't Hof's avatar
Peter van 't Hof committed
35
    (if (outputAsStsout) "" else required("-o", output)) +
Peter van 't Hof's avatar
Peter van 't Hof committed
36
37
    (if (inputAsStdin) "" else required(input))
}