Sed.scala 1.01 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
4
package nl.lumc.sasc.biopet.extensions

import java.io.File

Peter van 't Hof's avatar
Peter van 't Hof committed
5
import nl.lumc.sasc.biopet.core.{ BiopetCommandLineFunction, Version }
Peter van 't Hof's avatar
Peter van 't Hof committed
6
import nl.lumc.sasc.biopet.utils.config.Configurable
Peter van 't Hof's avatar
Peter van 't Hof committed
7
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
Peter van 't Hof's avatar
Peter van 't Hof committed
8
9
10
11

import scala.util.matching.Regex

/**
Peter van 't Hof's avatar
Peter van 't Hof committed
12
13
 * Created by pjvanthof on 18/05/16.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Sed(val root: Configurable) extends BiopetCommandLineFunction with Version {
  executable = config("exe", default = "sed", freeVar = false)

  /** Command to get version of executable */
  override def versionCommand: String = executable + " --version"

  /** Regex to get version from version command output */
  override def versionRegex: Regex = """sed (GNU sed) \d+.\d+.\d+""".r

  @Input(required = false)
  var inputFile: File = _

  @Output
  var outputFile: File = _

  var expressions: List[String] = Nil

  def cmdLine = executable +
    repeat("-e", expressions) +
    (if (inputAsStdin) "" else required(inputFile)) +
    (if (outputAsStsout) "" else " > " + required(outputFile))

}