Sed.scala 1.01 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package nl.lumc.sasc.biopet.extensions

import java.io.File

import nl.lumc.sasc.biopet.core.{BiopetCommandLineFunction, Version}
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{Input, Output}

import scala.util.matching.Regex

/**
  * Created by pjvanthof on 18/05/16.
  */
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))

}