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

Adding a QC command

parent 2387d560
......@@ -63,8 +63,8 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
optional("-M", opt_maximum_length) +
// input / output
required(fastq_input) +
required("--output", fastq_output) +
" > " + required(stats_output)
(if (outputAsStsout) "" else required("--output", fastq_output) +
" > " + required(stats_output))
/** Output summary stats */
def summaryStats: Map[String, Any] = {
......
......@@ -48,8 +48,6 @@ class Sickle(val root: Configurable) extends BiopetCommandLineFunction with Summ
@Output(doc = "stats output")
var output_stats: File = _
var fastqc: Fastqc = _
executable = config("exe", default = "sickle", freeVar = false)
var qualityType: Option[String] = config("qualitytype")
var qualityThreshold: Option[Int] = config("qualityThreshold")
......@@ -76,15 +74,15 @@ class Sickle(val root: Configurable) extends BiopetCommandLineFunction with Summ
required("-s", output_singles)
} else cmd += required("se")
cmd +
required("-f", input_R1) +
(if (inputAsStdin) required("-f", new File("/dev/stdin")) else required("-f", input_R1)) +
required("-t", qualityType) +
required("-o", output_R1) +
(if (outputAsStsout) required("-o", new File("/dev/stdout")) else required("-o", output_R1)) +
optional("-q", qualityThreshold) +
optional("-l", lengthThreshold) +
conditional(noFiveprime, "-x") +
conditional(discardN, "-n") +
conditional(quiet, "--quiet") +
" > " + required(output_stats)
conditional(quiet || outputAsStsout, "--quiet") +
(if (outputAsStsout) "" else " > " + required(output_stats))
}
/** returns stats map for summary */
......
package nl.lumc.sasc.biopet.pipelines.flexiprep
import java.io.File
import nl.lumc.sasc.biopet.core.{ BiopetCommandLineFunction, BiopetPipe }
import nl.lumc.sasc.biopet.extensions.{ Gzip, Zcat, Sickle }
import nl.lumc.sasc.biopet.utils.config.Configurable
import org.broadinstitute.gatk.utils.commandline.{ Output, Input }
/**
* Created by pjvan_thof on 9/22/15.
*/
class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetCommandLineFunction {
val flexiprep = root match {
case f: Flexiprep => f
case _ => throw new IllegalArgumentException("This class may only be used inside Flexiprep")
}
@Input(required = true)
var input: File = _
@Output(required = true)
var output: File = _
val zcat = new Zcat(root)
val seqtk = new SeqtkSeq(root)
val cutadept = flexiprep.skipClip match {
case false => Some(new Cutadapt(root))
case true => None
}
val sickle = flexiprep.skipTrim match {
case false => Some(new Sickle(root))
case true => None
}
val gzip = Gzip(root)
override def beforeGraph(): Unit = {
super.beforeGraph()
deps :::= fastqc.outputFiles
}
override def beforeCmd(): Unit = {
seqtk.Q = fastqc.encoding match {
case null => None
case enc if enc.contains("Sanger / Illumina 1.9") => None
case enc if enc.contains("Illumina <1.3") => Option(64)
case enc if enc.contains("Illumina 1.3") => Option(64)
case enc if enc.contains("Illumina 1.5") => Option(64)
case _ => None
}
if (seqtk.Q.isDefined) seqtk.V = true
}
def cmdLine = {
val sanger = seqtk.Q match {
case Some(_) => Some(seqtk)
case _ => None
}
val clip = cutadept match {
case Some(cutadept) =>
val foundAdapters = fastqc.foundAdapters.map(_.seq)
if (cutadept.default_clip_mode == "3") cutadept.opt_adapter ++= foundAdapters
else if (cutadept.default_clip_mode == "5") cutadept.opt_front ++= foundAdapters
else if (cutadept.default_clip_mode == "both") cutadept.opt_anywhere ++= foundAdapters
if (foundAdapters.nonEmpty) Some(cutadept)
else None
case _ => None
}
val trim = sickle
val cmds = ((if (input.getName.endsWith(".gz") || input.getName.endsWith(".gzip")) Some(zcat) else None) ::
sanger :: clip :: trim :: Some(gzip) :: Nil).flatten
val cmd = input :<: cmds.tail.foldLeft(cmds.head)((a, b) => a | b) > output
cmd.beforeGraph()
cmd.commandLine
}
}
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