Commit 4a9e765c authored by bow's avatar bow
Browse files

Use Option[File] for optional files and fix bug with adapter sequence from fastqc capture

parent 1aca9cd6
......@@ -25,10 +25,10 @@ import nl.lumc.sasc.biopet.core.config.Configurable
class Fastqc(val root: Configurable) extends BiopetCommandLineFunction {
@Input(doc = "Contaminants", required = false)
var contaminants: File = _
var contaminants: Option[File] = None
@Input(doc = "Adapters", required = false)
var adapters: File = _
var adapters: Option[File] = None
@Input(doc = "Fastq file", shortName = "FQ")
var fastqfile: File = _
......@@ -50,17 +50,19 @@ class Fastqc(val root: Configurable) extends BiopetCommandLineFunction {
override def afterGraph {
this.checkExecutable
if (contaminants == null) {
val fastqcDir = executable.substring(0, executable.lastIndexOf("/"))
val defaultContams = getVersion match {
case "v0.11.2" => new File(fastqcDir + "/Configuration/contaminant_list.txt")
case _ => new File(fastqcDir + "/Contaminants/contaminant_list.txt")
}
val defaultAdapters = getVersion match {
case "v0.11.2" => new File(fastqcDir + "/Configuration/adapter_list.txt")
case _ => null
}
contaminants = config("contaminants", default = defaultContams)
contaminants = contaminants match {
case None =>
val fastqcDir = executable.substring(0, executable.lastIndexOf("/"))
val defaultContams = getVersion match {
case "v0.11.2" => Option(new File(fastqcDir + "/Configuration/contaminant_list.txt"))
case _ => Option(new File(fastqcDir + "/Contaminants/contaminant_list.txt"))
}
val defaultAdapters = getVersion match {
case "v0.11.2" => Option(new File(fastqcDir + "/Configuration/adapter_list.txt"))
case _ => None
}
config("contaminants", default = defaultContams)
case wrapped @ Some(_) => wrapped
}
}
......@@ -74,6 +76,6 @@ class Fastqc(val root: Configurable) extends BiopetCommandLineFunction {
conditional(noextract, "--noextract") +
conditional(extract, "--extract") +
conditional(quiet, "--quiet") +
required("-o", output.getParent()) +
required("-o", output.getParent) +
required(fastqfile)
}
......@@ -99,13 +99,16 @@ class Fastqc(root: Configurable) extends nl.lumc.sasc.biopet.extensions.Fastqc(r
def foundAdapters: Set[AdapterSequence] = {
/** Returns a list of adapter and/or contaminant sequences known to FastQC */
def getFastqcSeqs(file: File): Set[AdapterSequence] =
if (file != null) {
(for (
line <- Source.fromFile(file).getLines(); if line.startsWith("#");
values = line.split("\t*") if values.size >= 2
) yield AdapterSequence(values(0), values(1))).toSet
} else Set.empty[AdapterSequence]
def getFastqcSeqs(file: Option[File]): Set[AdapterSequence] = file match {
case None => Set.empty[AdapterSequence]
case Some(f) =>
(for {
line <- Source.fromFile(f).getLines()
if !line.startsWith("#")
values = line.split("\t*")
if values.size >= 2
} yield AdapterSequence(values(0), values(1))).toSet
}
val found = qcModules.get("Overrepresented sequences") match {
case None => Array.empty[String]
......@@ -137,7 +140,8 @@ class Fastqc(root: Configurable) extends nl.lumc.sasc.biopet.extensions.Fastqc(r
"plot_per_sequence_quality" -> "Images/per_sequence_quality.png",
"plot_sequence_length_distribution" -> "Images/sequence_length_distribution.png",
"fastqc_data" -> "fastqc_data.txt")
.map { case (name, relPath) =>
.map {
case (name, relPath) =>
name -> Map("path" -> (outputDir + relPath))
}
......
Supports Markdown
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