Commit f298fe2c authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added support to have a pipe as input file

parent 839b0c12
......@@ -17,7 +17,7 @@ package nl.lumc.sasc.biopet.extensions.tools
import java.io.File
import nl.lumc.sasc.biopet.core.ToolCommandFuntion
import nl.lumc.sasc.biopet.core.{BiopetCommandLineFunction, ToolCommandFuntion}
import nl.lumc.sasc.biopet.core.summary.Summarizable
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
......@@ -37,11 +37,9 @@ class FastqSync(val root: Configurable) extends ToolCommandFuntion with Summariz
@Input(doc = "Original FASTQ file (read 1 or 2)", shortName = "r", required = true)
var refFastq: File = null
@Input(doc = "Input read 1 FASTQ file", shortName = "i", required = true)
var inputFastq1: File = null
var inputFastq1: Either[File, BiopetCommandLineFunction] = null
@Input(doc = "Input read 2 FASTQ file", shortName = "j", required = true)
var inputFastq2: File = null
var inputFastq2: Either[File, BiopetCommandLineFunction] = null
@Output(doc = "Output read 1 FASTQ file", shortName = "o", required = true)
var outputFastq1: File = null
......@@ -54,12 +52,29 @@ class FastqSync(val root: Configurable) extends ToolCommandFuntion with Summariz
override def defaultCoreMemory = 4.0
override def beforeGraph(): Unit = {
inputFastq1 match {
case Left(file) => deps :+= file
case Right(cmd) => deps :::= cmd.deps
}
inputFastq2 match {
case Left(file) => deps :+= file
case _ =>
}
}
// executed command line
override def cmdLine =
super.cmdLine +
required("-r", refFastq) +
required("-i", inputFastq1) +
required("-j", inputFastq2) +
(inputFastq1 match {
case Left(file) => required("-i", file)
case Right(cmd) => " -i <( " + cmd.commandLine + " )"
}) +
(inputFastq2 match {
case Left(file) => required("-j", file)
case Right(cmd) => " -j <( " + cmd.commandLine + " )"
}) +
required("-o", outputFastq1) +
required("-p", outputFastq2) + " > " +
required(outputStats)
......
......@@ -180,31 +180,36 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
val qcCmdR1 = new QcCommand(this, fastqc_R1)
qcCmdR1.input = R1_in
qcCmdR1.output = new File(outDir, s"${sampleId}-${libId}.R1.qc.fq.gz")
qcCmdR1.output = if (paired)
new File("/dev/stdout")
else new File(outDir, s"${sampleId.getOrElse("x")}-${libId.getOrElse("x")}.R1.qc.fq.gz")
qcCmdR1.isIntermediate = paired || !keepQcFastqFiles
add(qcCmdR1)
//add(qcCmdR1)
if (paired) {
val qcCmdR2 = new QcCommand(this, fastqc_R2)
qcCmdR2.input = R2_in.get
qcCmdR2.output = new File(outDir, s"${sampleId}-${libId}.R2.qc.fq.gz")
qcCmdR2.isIntermediate = true
add(qcCmdR2)
qcCmdR2.output = new File("/dev/stdout")
//add(qcCmdR2)
val fqSync = new FastqSync(this)
fqSync.refFastq = R1_in
fqSync.inputFastq1 = qcCmdR1.output
fqSync.inputFastq2 = qcCmdR2.output
fqSync.inputFastq1 = Right(qcCmdR1)
fqSync.inputFastq2 = Right(qcCmdR2)
fqSync.outputFastq1 = fastqR1Qc
fqSync.outputFastq2 = fastqR2Qc.get
fqSync.outputStats = new File(outDir, s"${sampleId}-${libId}.sync.stats")
fqSync.threads = 6
fqSync.outputStats = new File(outDir, s"${sampleId.getOrElse("x")}-${libId.getOrElse("x")}.sync.stats")
fqSync.isIntermediate = !keepQcFastqFiles
add(fqSync)
addSummarizable(fqSync, "fastq_sync")
outputFiles += ("syncStats" -> fqSync.outputStats)
R1 = fqSync.outputFastq1
R2 = Some(fqSync.outputFastq2)
} else R1 = qcCmdR1.output
} else {
add(qcCmdR1)
R1 = qcCmdR1.output
}
val seqstat_R1_after = SeqStat(this, R1, outDir)
add(seqstat_R1_after)
......
......@@ -40,6 +40,9 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
deps :::= fastqc.outputFiles
}
override def defaultCoreMemory = 2.0
override def defaultThreads = 3
override def beforeCmd(): Unit = {
seqtk.Q = fastqc.encoding match {
case null => None
......
......@@ -293,8 +293,8 @@ class Gears(val root: Configurable) extends QScript with MultiSampleQScript { qs
// sync the fastq records
val fastqSync = new FastqSync(qscript)
fastqSync.refFastq = samToFastq.fastqR1
fastqSync.inputFastq1 = samToFastq.fastqR1
fastqSync.inputFastq2 = samToFastq.fastqR2
fastqSync.inputFastq1 = Left(samToFastq.fastqR1)
fastqSync.inputFastq2 = Left(samToFastq.fastqR2)
fastqSync.outputFastq1 = createFile(".unmapsynced.R1.fastq.gz")
fastqSync.outputFastq2 = createFile(".unmapsynced.R2.fastq.gz")
fastqSync.outputStats = createFile(".syncstats.json")
......
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