Commit fa86f834 authored by Sander Bollen's avatar Sander Bollen

add sorting jobs. Changes to pipes later.

parent d6c031ab
......@@ -171,7 +171,7 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
*/
def :<:(file: File): BiopetCommandLineFunction = {
this._inputAsStdin = true
this.stdinFile = Some(file)
this._stdinFile = Some(file)
this
}
......@@ -183,12 +183,13 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
*/
def >(file: File): BiopetCommandLineFunction = {
this._outputAsStdout = true
this.stdoutFile = Some(file)
this._stdoutFile = Some(file)
this
}
/**
* This method can handle args that have multiple args for 1 arg name
*
* @param argName Name of the arg like "-h" or "--help"
* @param values Values for this arg
* @param groupSize Values must come in groups of x number, default is 1
......@@ -209,10 +210,14 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
}
@Output(required = false)
private[core] var stdoutFile: Option[File] = None
private[core] var _stdoutFile: Option[File] = None
def stdoutFile: Option[File] = _stdoutFile
@Input(required = false)
private[core] var stdinFile: Option[File] = None
private[core] var _stdinFile: Option[File] = None
def stdinFile: Option[File] = _stdinFile
/**
* This function needs to be implemented to define the command that is executed
......@@ -231,8 +236,8 @@ trait BiopetCommandLineFunction extends CommandLineResources { biopetFunction =>
preCmdInternal()
val cmd = preCommands.mkString("\n", "\n", "\n") +
cmdLine +
stdinFile.map(file => " < " + required(file.getAbsoluteFile)).getOrElse("") +
stdoutFile.map(file => " > " + required(file.getAbsoluteFile)).getOrElse("")
_stdinFile.map(file => " < " + required(file.getAbsoluteFile)).getOrElse("") +
_stdoutFile.map(file => " > " + required(file.getAbsoluteFile)).getOrElse("")
cmd
}
......
......@@ -45,15 +45,15 @@ class BiopetPipe(val commands: List[BiopetCommandLineFunction]) extends BiopetCo
override def beforeGraph() {
super.beforeGraph()
stdoutFile = stdoutFile.map(_.getAbsoluteFile)
stdinFile = stdinFile.map(_.getAbsoluteFile)
_stdoutFile = _stdoutFile.map(_.getAbsoluteFile)
_stdinFile = _stdinFile.map(_.getAbsoluteFile)
if (stdoutFile.isDefined || _outputAsStdout) {
commands.last.stdoutFile = None
if (_stdoutFile.isDefined || _outputAsStdout) {
commands.last._stdoutFile = None
commands.last._outputAsStdout = true
}
if (commands.head.stdinFile.isDefined) commands.head._inputAsStdin = true
if (commands.head._stdinFile.isDefined) commands.head._inputAsStdin = true
val inputOutput = input.filter(x => output.contains(x))
require(inputOutput.isEmpty, "File found as input and output in the same job, files: " + inputOutput.mkString(", "))
......@@ -75,10 +75,10 @@ class BiopetPipe(val commands: List[BiopetCommandLineFunction]) extends BiopetCo
val parent: Configurable = commands.head.parent
override def configNamespace = commands.map(_.configNamespace).mkString("-")
def cmdLine: String = {
"(" + commands.head.cmdLine + (if (commands.head.stdinFile.isDefined) {
" < " + required(commands.head.stdinFile.map(_.getAbsoluteFile))
"(" + commands.head.cmdLine + (if (commands.head._stdinFile.isDefined) {
" < " + required(commands.head._stdinFile.map(_.getAbsoluteFile))
} else "") + " | " + commands.tail.map(_.cmdLine).mkString(" | ") +
(if (commands.last.stdoutFile.isDefined) " > " + required(commands.last.stdoutFile.map(_.getAbsoluteFile)) else "") + ")"
(if (commands.last._stdoutFile.isDefined) " > " + required(commands.last._stdoutFile.map(_.getAbsoluteFile)) else "") + ")"
}
override def freezeFieldValues(): Unit = {
......
......@@ -2,9 +2,10 @@ package nl.lumc.sasc.biopet.pipelines.tarmac
import java.io.File
import nl.lumc.sasc.biopet.core.{ PedigreeQscript, PipelineCommand, Reference }
import nl.lumc.sasc.biopet.core.{ BiopetCommandLineFunction, PedigreeQscript, PipelineCommand, Reference }
import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import nl.lumc.sasc.biopet.extensions.{ Gzip, Ln }
import nl.lumc.sasc.biopet.extensions.bedtools.BedtoolsSort
import nl.lumc.sasc.biopet.extensions.{ Bgzip, Gzip, Ln, Tabix }
import nl.lumc.sasc.biopet.extensions.gatk.DepthOfCoverage
import nl.lumc.sasc.biopet.extensions.wisecondor.{ WisecondorCount, WisecondorGcCorrect, WisecondorNewRef }
import nl.lumc.sasc.biopet.extensions.xhmm.XhmmMergeGatkDepths
......@@ -119,10 +120,16 @@ class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with
reference.inputBeds = gccs
reference.output = new File(outputDirectory, "reference.bed")
reference.isIntermediate = true
val gzipRef = new Gzip(this)
gzipRef.input = List(reference.output)
gzipRef.output = new File(outputDirectory, "reference.bed.gz")
reference :: gzipRef :: Nil
val sort = new BedtoolsSort(this)
sort.input = reference.output
sort.output = new File(outputDirectory, "reference.sorted.bed")
sort.isIntermediate = true
val refFile = new File(outputDirectory, "reference.bed.gz")
val gzipRef = new Bgzip(this) // FIXME change to pipe with sort
gzipRef.input = List(sort.output)
gzipRef.output = refFile
val tabix = Tabix(this, refFile)
reference :: sort :: gzipRef :: tabix :: Nil
}
class Sample(name: String) extends AbstractSample(name) {
......@@ -209,7 +216,7 @@ class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with
}
protected lazy val outputWisecondorGccJob: String \/ QFunction = {
val outFile = new File(sampleDir + File.separator + s"$name.wisecondor.gcc")
val outFile = new File(sampleDir + File.separator + s"$name.wisecondor.gcc.bed")
outputWisecondorCountFile map { bedFile =>
val gcc = new WisecondorGcCorrect(root)
gcc.inputBed = bedFile
......@@ -225,9 +232,58 @@ class Tarmac(val parent: Configurable) extends QScript with PedigreeQscript with
}
}
protected lazy val outputWisecondorSortJob: String \/ QFunction = {
val outFile = new File(sampleDir + File.separator + s"$name.wisecondor.sorted.gcc.bed")
outputWisecondorGccFile map { gccFile =>
val sort = new BedtoolsSort(root)
sort.input = gccFile
sort.output = outFile
sort.isIntermediate = true
sort
}
}
lazy val outputWisecondorSortFile: String \/ File = {
outputWisecondorSortJob match {
case -\/(error) => -\/(error)
case \/-(sort: BedtoolsSort) => \/-(sort.output)
}
}
// FIXME: change to pipe with sort
protected lazy val outputWisecondorGzJob: String \/ QFunction = {
val outFile = new File(sampleDir + File.separator + s"$name.wisecondor.sorted.gcc.bed.gz")
outputWisecondorSortFile map { bedFile =>
val gz = new Bgzip(root)
gz.input = List(bedFile)
gz.output = outFile
gz
}
}
lazy val outputWisecondorGzFile: String \/ File = {
outputWisecondorGzJob match {
case -\/(error) => -\/(error)
case \/-(gz: Bgzip) => \/-(gz.output)
}
}
protected lazy val outputWisecondorTbiJob: String \/ QFunction = {
outputWisecondorGzFile map { gz =>
Tabix(root, gz)
}
}
lazy val outputWisecondorTbiFile: String \/ File = {
outputWisecondorTbiJob match {
case -\/(error) => -\/(error)
case \/-(t: Tabix) => \/-(t.outputIndex)
}
}
/** Function to add sample jobs */
def addJobs(): Unit = {
(outputWisecondorGccJob :: outputWisecondorCountJob :: outputXhmmCountJob :: Nil).foreach {
(outputWisecondorTbiJob :: outputWisecondorGzJob :: outputWisecondorSortJob :: outputWisecondorGccJob :: outputWisecondorCountJob :: outputXhmmCountJob :: Nil).foreach {
case -\/(error) => Logging.addError(error)
case \/-(function) => add(function)
}
......
......@@ -2,7 +2,7 @@ package nl.lumc.sasc.biopet.pipelines.tarmac
import nl.lumc.sasc.biopet.extensions.Ln
import nl.lumc.sasc.biopet.extensions.gatk.DepthOfCoverage
import nl.lumc.sasc.biopet.extensions.wisecondor.{WisecondorCount, WisecondorGcCorrect, WisecondorNewRef}
import nl.lumc.sasc.biopet.extensions.wisecondor.{ WisecondorCount, WisecondorGcCorrect, WisecondorNewRef }
import nl.lumc.sasc.biopet.extensions.xhmm.XhmmMergeGatkDepths
import nl.lumc.sasc.biopet.utils.ConfigUtils
import nl.lumc.sasc.biopet.utils.config.Config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment