Sed.scala 1.68 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
/**
 * 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 16 17 18
package nl.lumc.sasc.biopet.extensions

import java.io.File

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

import scala.util.matching.Regex

/**
Peter van 't Hof's avatar
Peter van 't Hof committed
26 27
 * Created by pjvanthof on 18/05/16.
 */
Peter van 't Hof's avatar
Peter van 't Hof committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
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))

}