Commit 1e46be60 authored by rhpvorderman's avatar rhpvorderman

Added gcDistribution function.

parent 8c5573ad
......@@ -86,6 +86,15 @@ class Fastqc(root: Configurable) extends nl.lumc.sasc.biopet.extensions.Fastqc(r
else fqModules
}
def gcDistribution: Option[Map[Int, Double]] = {
qcModules.get("Per sequence GC content").map { module =>
module.lines.filter(!_.startsWith("#")).map { line =>
val tuple = line.split("\t")
tuple(0).toInt -> tuple(1).toDouble
}.toMap
}
}
/**
* Retrieves the FASTQ file encoding as computed by FastQC.
*
......@@ -242,7 +251,9 @@ class Fastqc(root: Configurable) extends nl.lumc.sasc.biopet.extensions.Fastqc(r
def summaryStats: Map[String, Any] = Map(
"per_base_sequence_quality" -> perBaseSequenceQuality,
"per_base_sequence_content" -> perBaseSequenceContent,
"adapters" -> foundAdapters.map(x => x.name -> x.seq).toMap)
"adapters" -> foundAdapters.map(x => x.name -> x.seq).toMap,
"gc_distribution" -> gcDistribution
)
}
object Fastqc {
......
......@@ -15,6 +15,7 @@
package nl.lumc.sasc.biopet.pipelines.flexiprep
import java.io.File
import java.nio.charset.CoderMalfunctionError
import java.nio.file.Paths
import org.scalatest.Matchers
......@@ -39,6 +40,19 @@ class FastqcV0101Test extends TestNGSuite with Matchers {
fqc.outputDir shouldBe new File(resourceDir, "v0101.fq_fastqc")
}
@Test
def testGcDistro: Unit = {
val fqc = new Fastqc(null)
fqc.output = outputv0101
val x = fqc.gcDistribution.get
x(0) shouldBe 0.0
x(35) shouldBe 6.0
x(51) shouldBe 29.5
x(74) shouldBe 5.5
x(100) shouldBe 0.0
}
@Test def testQcModules() = {
val fqc = new Fastqc(null)
fqc.output = outputv0101
......@@ -105,4 +119,18 @@ class FastqcV0101Test extends TestNGSuite with Matchers {
perBaseSequenceContent.keys should contain("1")
}
@Test def testSummaryStats() = {
val fqc = new Fastqc(null)
fqc.output = outputv0101
val summary = fqc.summaryStats
val testKeys = List(
"per_base_sequence_quality",
"per_base_sequence_content",
"adapters",
"gc_distribution"
)
summary.keys.toList.sorted shouldBe testKeys.sorted
}
}
\ No newline at end of file
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