Skip to content
Snippets Groups Projects
Commit b8dc37ad authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added new summary to fastqsync

parent 0eed5996
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
package nl.lumc.sasc.biopet.tools package nl.lumc.sasc.biopet.tools
import java.io.File import java.io.File
import nl.lumc.sasc.biopet.core.summary.Summarizable
import scala.io.Source import scala.io.Source
import scala.util.matching.Regex import scala.util.matching.Regex
...@@ -29,7 +31,7 @@ import nl.lumc.sasc.biopet.core.config.Configurable ...@@ -29,7 +31,7 @@ import nl.lumc.sasc.biopet.core.config.Configurable
* *
* @param root Configuration object for the pipeline * @param root Configuration object for the pipeline
*/ */
class FastqSync(val root: Configurable) extends BiopetJavaCommandLineFunction { class FastqSync(val root: Configurable) extends BiopetJavaCommandLineFunction with Summarizable {
javaMainClass = getClass.getName javaMainClass = getClass.getName
...@@ -63,6 +65,47 @@ class FastqSync(val root: Configurable) extends BiopetJavaCommandLineFunction { ...@@ -63,6 +65,47 @@ class FastqSync(val root: Configurable) extends BiopetJavaCommandLineFunction {
required("-p", outputFastq2) + " > " + required("-p", outputFastq2) + " > " +
required(outputStats) required(outputStats)
def summaryFiles: Map[String, File] = {
Map("refFastq" -> refFastq,
"inputFastq1" -> inputFastq1,
"inputFastq2" -> inputFastq2,
"outputFastq1" -> outputFastq1,
"outputFastq2" -> outputFastq2
)
}
def summaryData: Map[String, Any] = {
val regex = new Regex("""Filtered (\d*) reads from first read file.
|Filtered (\d*) reads from second read file.
|Synced read files contain (\d*) reads.""".stripMargin,
"R1", "R2", "RL")
val (countFilteredR1, countFilteredR2, countRLeft) =
if (outputStats.exists) {
val text = Source
.fromFile(outputStats)
.getLines()
.mkString("\n")
regex.findFirstMatchIn(text) match {
case None => (0, 0, 0)
case Some(rmatch) => (rmatch.group("R1").toInt, rmatch.group("R2").toInt, rmatch.group("RL").toInt)
}
} else (0, 0, 0)
Map("version" -> getVersion,
"num_reads_discarded_R1" -> countFilteredR1,
"num_reads_discarded_R2" -> countFilteredR2,
"num_reads_kept" -> countRLeft
)
}
override def resolveSummaryConflict(v1: Any, v2: Any, key: String): Any = {
(v1, v2) match {
case (v1: Int, v2: Int) => v1 + v2
case _ => v1
}
}
// summary statistics // summary statistics
def summary: Json = { def summary: Json = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment